axiom-ai

Evolution

Creatures with tiny neural brains evolve to find food and avoid danger.

Build log

Status

Not started. This log is written by Claude Code during the cloud session that builds the demo, then lightly edited.

The brief

The prompt the session received, verbatim, and a link to the cloud session and PR.

Approach

What was chosen and why. Alternatives considered. Anything reused from open source, with license and link.

Timeline

Short dated entries as the work progressed: what was tried, what broke, what fixed it.

Numbers

Rough wall-clock time, number of turns, tokens or cost if known, bundle size, frames per second on a laptop and a phone.

What I would do next

Known gaps, stretch goals, ideas.

Original spec

Evolution

Build a neuroevolution simulation in projects/evolution/demo/index.ts following the demo contract in CLAUDE.md.

Goal

Creatures that visibly get better at surviving over generations, with the mechanism (tiny neural nets, mutation, selection) exposed clearly enough that a visitor understands what is happening.

World

  • 2D toroidal world rendered on Canvas 2D, HiDPI aware, resizes with the container.
  • Food particles spawn at a configurable rate. Optional hazards (poison or a predator type) toggled by the visitor.
  • Creatures have position, heading, speed, energy, age and a colour derived from their genome.

Brain

  • A small feed-forward neural network per creature, implemented in plain TypeScript with Float32Arrays. Inputs: a few ray-cast or sector sensors for nearest food (distance and angle), nearest hazard, own energy, and a bias. Outputs: turn and thrust.
  • Genome is the flat weight array. Reproduction copies the parent genome with Gaussian mutation at a configurable rate and strength. Optional crossover when two creatures reproduce.

Life cycle

  • Moving costs energy proportional to speed; eating restores it. Creatures die at zero energy or max age. A creature above an energy threshold reproduces, paying energy to the child.
  • Population floor: if the population drops below a minimum, spawn new creatures from the best genomes of the current or previous generation so the sim never dies out.

UI

  • Controls: population cap, food rate, mutation rate and strength, sim speed (1x to 20x with frame-skipping), pause, reset, hazards toggle.
  • Live charts drawn on a second small canvas: average and best fitness per generation, population over time. Keep a rolling window.
  • Click a creature to inspect it: draws its sensors, shows its network as a small diagram with weights coloured by sign, and its stats.
  • “Hall of fame”: the best genome so far; a button to seed the population from it.

Should have

  • Save and load the current best genome as JSON via download and file picker.
  • Colour creatures by lineage so you can see a successful family spread.

Reference

  • The Nature of Code, chapters on evolutionary computing and neural networks. Reuse ideas, write your own code.

Acceptance

  • npm run check and npm run build pass.
  • 300 creatures at 60 fps on a laptop at 1x; clearly visible improvement in average fitness within two minutes at 10x.
  • Works on a phone with a reduced default population.
  • project.json status set to live, BUILD-LOG.md complete per CLAUDE.md.