Skip to content

brain_tool.py

Rufus Pearce edited this page Jan 22, 2026 · 3 revisions

Responsibilities

  • Builds the multi-tab window (Network, Learning, Memory, Decisions, Statistics, …).
  • Hosts the BrainWidget in the “Network” tab.
  • Exposes buttons, sliders, tables to stimulate neurons, export data, change learning rate, force a learning cycle, etc.
  • Persists / loads the whole brain state (weights, positions, neurogenesis history) to JSON.
  • Owns the BrainWorker thread instance (wraps the one inside BrainWidget) and restarts it if it crashes.
  • Bridges between the squid logic (tamagotchi_logic) and the brain widget:

– every few seconds it copies the squid’s current hunger, happiness, anxiety… into the widget’s state so the network mirrors the squid.

– when the network learns new weights, the squid can query them for decision-making.

Key internal objects

  • self.brain_widget – canvas widget (brain_widget.py)
  • self.tabs – QTabWidget with all the inspector tabs
  • self.config_manager – central place for thresholds, intervals, colours, etc.
  • self.tamagotchi_logic – reference to the actual pet simulation (runs in the main game loop)

Clone this wiki locally