Visualizations
379 / 500

379 · Emergence

Neural Ecosystem

Herbivores and predators with tiny neural brains evolve in a pastel petri dish.

Every creature is steered by its own neural network. Seven vision rays fan across its field of view and report how close the nearest plant, herbivore, predator and dish wall are; those 28 numbers, its energy and two memory values pass through 10 tanh neurons to outputs for turning, speed and the memory it keeps for the next step. Nothing is trained: moving costs energy, eating restores it, and a creature with enough energy splits in two, passing on its weights with small mutations and a slight shift of hue, so lineages show up as color families. Brains that happen to steer toward food leave more copies, the populations swing through predator and prey cycles in the chart, and over minutes you can catch predators loitering around the fertile patches where herbivores graze. The first seconds run in fast-forward, so you join after a couple of simulated minutes of evolution.

Try it. Click any creature to watch its brain: the rays light up by what each eye sees, and every connection glows with the signal flowing through it. Drag to sprinkle food. Click the view, then press F to fast-forward, Space to pause, Escape to deselect and R to restart with new random brains.

  • Neuroevolution
  • Ray-binned vision with a spatial hash
  • Live network activation diagram

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a tiny evolving ecosystem of creatures with neural network brains, using JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Draw a large circular dish in the middle of a canvas that fills the window. Scatter about 150 green plant dots inside it, and keep regrowing them at random spots up to that number.
- Add about 40 creatures with a position, heading, speed and energy. Give each one a brain: a small neural network with random weights, written by hand as arrays (no libraries), with one hidden layer of 8 tanh neurons and 2 outputs, turn and speed.
- For inputs, give each creature 5 eyes spread across a 180 degree field of view. For every plant within 100 pixels, work out its angle relative to the heading, find the eye whose slice it falls in, and set that eye's input to how close it is (1 when touching, 0 at the edge of sight). Add the creature's energy and a constant 1 as extra inputs.
- Every frame, run the network, turn and move the creature, keep it inside the dish and subtract energy for moving. Eating a plant adds energy. When energy runs out it dies. When energy passes a threshold it splits: the child copies the brain with a few weights nudged by small random amounts.
- Draw creatures as little rounded bodies with eyes, pointing along their heading.

Once that works, make it beautiful:
- Add predators that eat the plant eaters, give every eye separate inputs for plants, prey and predators, and plot both populations over time.
- Click a creature to draw its vision rays and a diagram of its network, with neurons and connections colored by their live activity.
- Use a soft pastel palette, a glassy rim on the dish and a gentle shadow under each creature.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a fast-forward button, recurrent memory neurons, or letting body size and eye range evolve too.
PreviousWood Wide WebRoots and fungal hyphae weave a soil network that shuttles carbon to shaded seedlings. NextPerceptual CodecWatch a psychoacoustic model decide which parts of the music you will never miss.

Related visualizations

  • CPPN GardenMachine learning Breed images grown by tiny neural networks by picking the ones you like.
  • Growing Neural CellsMachine learning Cells running one tiny learned rule grow a gecko from a single seed and heal its wounds.
  • Ghost RacersMachine learning Sixty neural-net cars evolve to race a track, then face one you draw.
  • NEAT SpeciesMachine learning Networks grow their own topology to balance two poles, while species rise and fall.
  • Slime MoldEmergence Simple agents leave trails that self-organize into living networks.
  • Neural NetworkMachine learning A tiny neural network learns to classify points, live, in your browser.
  • Particle LifeEmergence Colored particles with simple attractions that assemble into living cells.
  • BiomorphsAlgorithms Dawkins' Blind Watchmaker: breed recursive ink creatures by choosing a child.
  • Evolution Strategy LandersMachine learning Fifty ghost landers learn soft touchdowns by natural evolution strategies.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs