Methods

Technical reference for the simulation architecture and algorithms.

▸ Architecture Overview

The simulation runs as a pure Python process with no ML framework dependencies. The world is a Watts-Strogatz small-world graph — 800 nodes with an average degree of 4 and a rewiring probability of 0.15. There is no grid, no Cartesian coordinate system. Connectivity is the spatial structure.

Each node holds energy (regenerated per tick, modulated by seasons) and pheromone (deposited by visiting agents, decaying over time). Agents live on nodes and can traverse edges to reach neighboring nodes.

The core loop processes one tick per iteration. For every alive agent, the tick executes:

  1. Upkeep: Deduct tick_cost + brain metabolic cost from energy; accumulate entropy
  2. Perceive: BFS within sense_range hops → 64-channel sensory vector
  3. Decide: NEAT brain forward pass → 23 continuous effector outputs
  4. Act: Physics engine interprets effectors into world effects
  5. Learn: Cortex reinforcement, episodic memory, motor pattern tracking

Persistence uses SQLite for time-series data and gzipped JSON checkpoints for full simulation snapshots. Milestone checkpoints are saved permanently every 10,000 ticks.

▸ Brain: NEAT Neural Networks

Agent brains use NEAT (NeuroEvolution of Augmenting Topologies). Unlike fixed-topology networks, NEAT evolves both the structure and weights of the neural network simultaneously.

Structural mutations:

  • Add connection (15%): Create a new weighted connection between two nodes
  • Add node (3%): Split an existing connection, inserting a new hidden neuron
  • Mutate weight (80%): Gaussian perturbation of an existing connection weight
  • Toggle connection (5%): Enable or disable an existing connection
  • Mutate activation (2%): Change activation function (tanh, relu, sigmoid, identity, sin, abs, step)

Metabolic cost creates selection pressure against unnecessary complexity. Each tick, the brain costs: neurons × 0.005 + connections × 0.002 + sensory_excess × 0.001 + broadcast_width × 0.003

There is no reward function. The brain evolves via natural selection: agents with brains that produce better survival behaviour reproduce more.

▸ Sensory System (64 Channels)

Each agent perceives the world through a 64-dimensional sensory vector. Channels 0–44 carry core information; channels 45–63 are latent (gain≈0.01, effectively dormant until evolution upregulates them).

  • 0–12 Proprioceptive: Energy/entropy levels, age, brain complexity, energy/entropy deltas
  • 13–22 Exteroceptive: Local energy, neighbor energy, node degree, agent counts
  • 23–32 Social: Signal count, 4 signal channel averages, kin presence
  • 33–35 Pheromone: Local, best neighbor, average neighbor pheromone levels
  • 36–40 Environmental: Season phase (sin/cos), season regen, circadian clock
  • 41–44 Stochastic: Constant bias, uniform noise, gaussian noise, age-modulated pulse
  • 45–63 Latent: Effector echo, broadcast echo, derivatives, cross-products, memory readouts

Every channel has heritable gain and offset. Evolution "turns on" a latent channel by evolving its gain upward — without changing brain I/O dimensionality.

▸ Motor System (23 Effectors)

The brain produces 23 continuous output values each tick — 7 motor effectors plus up to 16 broadcast channels. Multiple effectors can fire simultaneously.

  • 0: Locomotion direction — continuous value mapped to neighbor index
  • 1: Locomotion intensity — 0–1 movement commitment
  • 2: Harvest — 0–1 energy extraction from current node
  • 3: Social interaction — signed: negative = attack, positive = energy transfer
  • 4: Maintenance — 0–1 self-repair (reduces entropy)
  • 5: Reproduction — above threshold (0.7) triggers fork attempt
  • 6: Signal — above threshold triggers broadcast
  • 7–22: Broadcast channels — up to 16 evolved signal content channels
▸ Genome and Inheritance (29 Traits)

Each agent's genome is a three-part heritable blueprint: (1) 29 numeric traits, (2) NEAT node/connection genes, (3) per-channel sensory gains and offsets.

TraitRangeDescription
tick_cost 0.3–2.0 Energy cost per tick to exist
max_energy 100–250 Maximum energy capacity
entropy_resistance 0.5–2.0 Resistance to entropy accumulation
sense_range 1–4 Perception range in graph hops
signal_range 1–5 Signal broadcast range in hops
learning_rate 0.01–0.5 Cortex weight update speed
exploration_factor 0.05–0.5 Random action probability
mutation_rate 0.01–0.3 Offspring genome mutation magnitude
fork_threshold 40–80 Energy needed to reproduce
cortex_capacity 50–500 Max entries in cortex weight table
memory_capacity 10–100 Episodic memory buffer size
harvest_drive 0.0–1.0 Bias toward energy extraction when hungry
maintain_drive 0.0–1.0 Bias toward self-repair when entropic
explore_drive 0.0–1.0 Bias toward movement
social_drive -1.0–1.0 Negative = aggression, positive = cooperation
reproduce_drive 0.0–1.0 Bias toward forking when energy surplus
signal_drive 0.0–1.0 Bias toward broadcasting
broadcast_width 1–16 Active broadcast channels
cortex_reliance 0.0–1.0 Probability cortex fires when brain active
memory_decay 0.80–0.99 Memory importance decay rate per tick
macro_capacity 5–50 Max compound actions per agent
▸ Natural Selection (No Reward Function)

The simulation uses pure natural selection as the sole optimisation mechanism. There is no reward function, no fitness function, no gradient descent, no reinforcement learning signal.

Agents that accumulate enough energy and survive long enough can reproduce. Those that die before reproducing leave no offspring. Children receive mixed traits from both parents, mixed brain topology, mixed sensory genes, and a subset of motor patterns.

Metabolic cost acts as counter-pressure to complexity. Bigger brains, more sensory channels, and wider broadcast bandwidth all cost energy per tick. Evolution must find the sweet spot.

An extinction safeguard auto-spawns mutant agents if population drops to 1, preventing total extinction from terminating the simulation.


For the complete implementation reference including database schema and checkpoint format, see the project's claude.md file.