Skip to content

brain_widget.py

Vicious Squid edited this page Apr 3, 2026 · 12 revisions

View source file: brain_widget.py (version 2.6.2.0)

Main neural network visualization and coordination hub. It serves as the central controller that owns the authoritative brain state, coordinates background worker threads, and integrates all the subsystems that make the neural network function. Everything flows through this widget—stat updates from the game, rendering requests, learning signals, and neurogenesis events all converge here before being dispatched to the appropriate handlers.

Core State Management:

  • Maintains the authoritative state dictionary with all neuron activations (hunger, happiness, anxiety, etc.)
  • Manages weights dictionary for connection strengths between neurons
  • Tracks neuron_positions for visualization layout

Worker Coordination:

  • Receives an external BrainWorker via set_brain_worker() (avoids duplicate thread creation)
  • Owns a BrainRenderWorker for offscreen rendering
  • Coordinates signal/slot connections between workers and UI

Subsystems Integrated:

  • EnhancedNeurogenesis for dynamic neuron creation
  • ExperienceBuffer for tracking learning experiences
  • EnhancedBrainTooltips for hover information
  • Theming with animation styles (Vibrant, Subtle, etc.)
  • Brain state bridge for designer synchronization

Key Methods:

  • update_brain_state(stats_dict) — main entry point for stat updates from the game
  • set_brain_worker() — accepts external worker instance
  • export_brain_state_for_designer() — syncs state with the Brain Designer tool

Clone this wiki locally