🧠 How the Creature Brain Works
The full story behind the demo: a 26-neuron spiking brain, evolved over weeks, that eats food and dodges hazards — and every experiment that tried to beat it.
The creature
The creature lives in a 340×340 arena with 5 foods and 4 hazards. It moves at 34 units per second, eats anything within 14 units, and gets stung — frozen for 1 second — if it touches a hazard (each hazard then needs 3 seconds to recharge). A life lasts 600 seconds. The score is simple: foods eaten, stings taken, combined as fitness = foods − 6 × stings.
It sees the world through 12 eyes: 7 food eyes spread across −72°…+72°, and 5 hazard eyes across −60°…+60°. Each eye has a narrow cos⁴ lobe, so it responds strongly only to things roughly straight ahead in its direction, and its signal falls off with the square of distance (range 260). The eyes feed a hidden layer of 12 neurons, and everything drives two motor neurons — left and right — whose spike-rate difference steers the creature. A winner-take-all connection makes the two motors inhibit each other, so it commits to turning one way instead of dithering.
Two reflexes are baked into the body, not learned. The looming channel measures how fast each hazard is approaching and multiplies the hazard signal by up to ×3 when something rushes at the creature. The flinch reflex fires when any hazard eye exceeds 0.35: turning sharpens ×1.8 and speed jumps ×1.25 for a beat, a startled swerve.
The brain, precisely
Every neuron is a Hodgkin–Huxley neuron — the classic squid-axon equations, with sodium, potassium, and leak currents, integrated at 0.05 ms steps. The wiring has two parts:
- Fixed substrate (never evolved): dense sensory→hidden weights (0.35–0.65) and a sparse hidden→hidden recurrent network (25% connected, 0.2–0.5), both drawn once from seed 777. This is the creature's innate brainstem.
- The genome (49 numbers, the part evolution tunes): 24 sensory→motor weights, 24 hidden→motor weights, and 1 winner-take-all inhibition weight. That's all evolution ever touches in the champion.
The demo on this site runs this exact brain: the same equations, the same substrate, the same genome. Only the world seed is new.
How the champion was evolved
The road to the champion took several rounds, and most of them failed in instructive ways:
- v1, STDP learning: online spike-timing plasticity from scratch. Poor homing — it never learned to steer reliably. Abandoned.
- Genetic algorithm: populations of genomes, selected on food and stings. The v2 champion reached 116.0 foods / 13.3 stings and shipped.
- Safety evolution (sting penalty −10): found only corner solutions. Failed its bar.
- Crossbreeding (penalty −6): ~106 / 10.2. Shipped as an improvement, then superseded.
- Structural probes: longer sensor range hurt, hazard persistence hurt, a distance-squared hazard curve helped a little, and the flinch reflex helped a lot (127.0 / 11.7 in testing). Flinch + distance curve became the body.
- Flinch evolution: a new population inside the flinch body produced a champion at 123.7 / 9.9 (flinch-only) — shipped, then carried into the looming body.
- Looming channel: adding the approach-rate multiplier helped the existing champion (126.7 / 8.7 vs 122.7 / 9.0 on the OLD world set), but brains evolved inside the looming body got more aggressive, not safer (129.3 / 11.6). The shipped call was "the looming body, same brain."
- CMA-ES: a smarter evolutionary strategy (covariance-matrix adaptation, population 16, penalty −6) run from the flinch champion. After 24 generations the mean scored 109.3 / 5.9 — fewer foods, far fewer stings, best on the penalized fitness. Run 24 generations longer, the generation-49 mean validated at 122.3 foods / 5.5 stings — and that became the champion.
Validation protocol. Every number here comes from the same test: 15 lives of 600 seconds each — 5 OLD worlds (seeds 9101–9105), 5 FRESH (9201–9205), 5 NEW (9401–9405) — in the looming flinch body. Short trials lie: at ~10 stings per life, counting noise alone is ±3, and a 70-second snapshot best is usually a mirage. Nothing ships without the 15-life test.
The dominance hunt
With a champion at 122.3 / 5.5, the bar became strict: a candidate counts only if it beats the champion on both axes — more foods and fewer stings. A trade is a trade, never a win. Ten ideas were built and tested against that bar. All ten lost:
| Idea | Foods | Stings | Verdict |
|---|---|---|---|
| Sting-written hazard memory (phantom hazards) | 112.9 | 8.2 | Evolution inside the memory body did worse than the warm start; the phantom scared the creature off good approaches. |
| Sector veto (gate food eyes by hazard direction) | 103.5 | 4.0 | Best veto food after tuning, still ~19 foods short. A powerful sting lever the weights can't afford. |
| Startle upgrades (directional suppression, caution window) | 79.0 / 83.8 | 5.6 / 4.2 | Anything that weakens the food pathway, even briefly, costs far more food than it saves in stings. |
| Sharper hazard lobes (cos⁶) | 121.5 | 6.5 | Looked good on OLD worlds, evaporated on NEW ones. |
| Optic-flow discounting (ignore receding hazards) | 112.0 | 4.4 | Best bolt-on sting cut, cost 12.4 foods. Still a trade. |
| Constrained evolution (foods-first, stings capped) | 109.1 | 7.1 | The cap was stricter than the champion's own short-trial sting rate, so selection chased sting-luck. Stings went up. |
| Expanded brain (12 → 16 hidden neurons) | 140.3* | 9.9* | *Best checkpoint; biggest food jump ever — but stings nearly doubled. Capacity moved along the trade-off, not past it. |
| Substrate evolution (evolve the recurrent wiring) | 115.9 | 5.3 | The first candidate ever to beat the champion on stings — but 6.4 foods short. Closest call of the hunt. |
| Denser hazard eyes (9 eyes at 15° spacing) | 60.0 | 3.0 | Stings fell to 3.0, but foods collapsed monotonically as evolution ran. More hazard signal swamps food approach. |
| R-STDP with homeostasis (learn within a life) | 111.9 | 7.5 | Best of four learning-rate variants. Less learning approaches the champion from below, never above — the reward signal holds nothing evolution didn't already extract. |
| Champion (CMA-ES gen-49 mean) | 122.3 | 5.5 | Still unbeaten. |
What the hunt taught us
- Foraging and sting exposure are coupled. Most stings happen while approaching food near hazards (median nearest-food distance at sting time: 43 units). A better forager meets more hazards. That's why nearly every "improvement" slid along the same trade-off curve instead of breaking it.
- Weights expect the body they were tuned for. Bolting a new sense or reflex onto frozen weights always trades; only retuning weights inside the new body has a chance, and even then the champion's body keeps winning.
- Short trials lie. The same mirage recurred in every round: a snapshot best on 70-second trials evaporated over 15 long lives. Finalists are only ever judged long.
- The champion is a strong local optimum for this body and genome — not necessarily the global best, but everything tried so far moves along the curve rather than past it.
Try it yourself
On the demo page, press 🎲 New world for a fresh arena, or ⏸ Pause to freeze the action and watch the neuron dots: food eyes flare green as food swings past, hazard eyes flare red near danger, and the two gold motor dots set the steering. Speed 5× is the default; 1× lets you watch individual turns. A life here uses the same physics as the validation runs — your world just hasn't been scored yet.
Built October 2026. Champion genome: CMA-ES generation-49 mean, validated 122.3 foods / 5.5 stings (fitness 89.1) over 15 × 600-second lives. Demo runs the same Hodgkin–Huxley equations, substrate, and genome as the validation sim.