The Slime Mold — Physarum Rediscovers the Tokyo Subway Map
100,000 particles depositing trails on a chemoattractant field. Within 30 seconds an optimal transport network emerges — recreating the famous 2010 Physarum experiment that found the Tokyo subway from scratch.
What this is
100,000 particles on a 2D field, updated entirely on the GPU via WebGL2 transform feedback. Each particle samples three sensor points ahead of it on a trail-pheromone field, steers toward the strongest sensor, moves forward, and deposits trail. The trail diffuses and decays each frame via a fragment shader. Food sources (placed by clicking, or pre-loaded with the Tokyo region preset) emit strong trail. Within 30 seconds the mold organizes into an efficient transport network connecting the food sources — branching, then refining to dominant paths. The aesthetic is bioluminescent gold trails on dark background.
Why this is mind-blowing
Physarum polycephalum is a single-celled organism with no nervous system that solves shortest-path problems in mazes. In 2010, Tero and Nakagaki placed oat flakes at the locations of Tokyo's outlying cities and the slime mold grew a network nearly identical to the actual Tokyo subway. This demo recreates that experiment in your browser from one paragraph of prompt. The model knows the literature.
Build a single-file simulation of Physarum slime mold growth using the
agent-based reinforcement model: 100,000+ particles walk along a
chemoattractant field, depositing trail behind them, biased toward
existing trails and food sources. Trails diffuse and decay each frame.
Drop food sources by clicking. Within 60 seconds the mold should
self-organize into an efficient transport network — recreating the
famous 2010 Tero/Nakagaki experiment where Physarum rediscovered the
Tokyo subway map. WebGL2 ping-pong textures for the trail field,
instanced rendering for the particles.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- WebGL2 transform feedback lets you update 100K particle states entirely on the GPU. No CPU/GPU roundtrip, no readPixels stall — the simulation never leaves VRAM.
- Jeff Jones' 2010 paper specified parameters that produce optimal networks: sensor distance ~12, sensor angle ~22°, turn angle ~28°, decay ~0.955. The model knows them.
- The Tero/Nakagaki Tokyo experiment is a great preset — it gives the demo a story. 'This is the slime mold that rediscovered the Tokyo subway' is sticky in a way 'this is a swarm simulation' is not.