← cd ~/work

~/work/primordial/README.md

Primordial

An evolution sandbox where behaviour is never programmed, only selected.

role
Solo
year
2026
stack
Python · NumPy · SciPy · FastAPI · WebSockets · WebGL2
status
active · v0.4
Primordial running: creatures swimming, hunting and reproducing

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

  1. World: NumPy struct-of-arrays
  2. all brains in one einsum
  3. binary frames, 32 B per creature
  4. WebSocket with per-client flow control
  5. 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

Bodies are drawn from genes: rows vary diet, columns vary speed
Bodies are drawn from genes: rows vary diet, columns vary speed
Tree of life for seed 7: 22 species over 40,000 ticks
Tree of life for seed 7: 22 species over 40,000 ticks
Phase diagram: predator share by plant growth and bite strength
Phase diagram: predator share by plant growth and bite strength

~/what's-next

Distributed simulation across worker processes, sexual reproduction with crossover, recurrent brains and exact replays.

Ask Leah

an assistant that only answers from what's on this site · it can be wrong