-
Notifications
You must be signed in to change notification settings - Fork 13
brain_worker.py
Rufus Pearce edited this page Jan 6, 2026
·
8 revisions
Not to be confused with brain_render_worker.py
A background QThread dedicated to handling computationally expensive brain logic that would otherwise block the UI. It operates on cached snapshots of brain state, processes tasks from a thread-safe queue, and emits results back to the main thread via signals. This separation keeps the simulation responsive even during complex Hebbian learning calculations or neurogenesis evaluations.
- Uses thread-safe
Queuefor task dispatch - Processes three task types:
neurogenesis,hebbian,state_update - Supports pause/resume for game state changes
- Evaluates stress/novelty/reward triggers against configurable thresholds
- Emits
neurogenesis_resultsignal with creation recommendations - Handles emergency stress neuron creation when anxiety exceeds 90
- Selects top-k neuron pairs based on co-activation scores
- Includes anti-loop mechanisms (randomization, cooldown penalties on recently-used pairs)
- Can create new connections between previously unconnected co-active neurons
- Emits weight updates back to main thread for application
- Applies temporal decay toward baseline for non-input neurons
- Adds small random noise for organic feel
- Propagates connection effects through the network
🦑 Raise digital squids whose brains grow & rewire themselves through Hebbian learning and Neurogenesis