← Serhii Leniv

Evolution without a training loop

I wanted to see selection happen rather than read about it, so I built a closed petri dish with three trophic levels: vegetation, herbivores, predators. Nothing in it is trained and nothing is scripted.

Every animal carries its own small neural network: 23 inputs, 8 hidden, 4 outputs. There is no loss function and no backward pass. The only optimiser is dying, or living, without offspring.

What that changes

A training loop tells you what the right answer was. Selection does not. It only removes the networks that stopped existing, which means the population drifts toward behaviour that survives without anything ever computing a gradient.

Reproduction is sexual, with mate choice and genetic recombination, plus a fallback for when nobody is around.

How it runs

All state lives in typed arrays in a struct-of-arrays layout. It is single threaded, has zero runtime dependencies, draws to one Canvas2D surface, and is deterministic from a seed. The same seed gives the same run every time, which is the only reason any of it is debuggable.