~/work/primordial/README.md
Primordial
An evolution sandbox where behaviour is never programmed, only selected.
Problem
Can interesting strategies emerge with no fitness function at all, only energy, mutation and survival?
Approach
- Brains are never trained. Each creature has a two-layer network (11 inputs, 8 hidden, 4 outputs). Children inherit their parent’s weights with small random mutations.
- Species emerge on their own. A newborn whose genome drifts far enough from its founder starts a new species (NEAT-style compatibility distance), and established species get generated Latin names.
- Energy is conserved. It only enters the world through plants, so predators can’t farm energy by eating each other. A test checks that the books balance on every birth.
- No per-creature Python loop. State lives in NumPy arrays, every brain is evaluated in a single
einsum, and neighbour search uses periodic KD-trees. - A renderer written from scratch. Every creature is a signed distance field built from its genes and drawn in one instanced WebGL2 call, with HDR bloom.
What I learned
The first thing evolution found was a bug: when bodies were free, predators farmed energy by eating each other and filled the world. Conserving energy, and testing that it stays conserved, fixed it.
~/architecture
- World: NumPy struct-of-arrays
- all brains in one einsum
- binary frames, 32 B per creature
- WebSocket with per-client flow control
- WebGL2 renderer
~/results
2×
predators evolved independently; only one line survived
+51%
prey top speed during the arms race
50
worlds swept in parallel: food supply, not bite strength, decides whether predators evolve
66
tests, CI on Python 3.11–3.13, plus a real-browser Playwright test
~/figures



~/what's-next
Distributed simulation across worker processes, sexual reproduction with crossover, recurrent brains and exact replays.