← all posts

Sketched, not drawn: slime mould

Mon 23 Nov 2026, 03:05

#physarum#slime-mold#agent-based#webgl#c#simulation

Real slime mould has no brain, no eyes, no plan. It is a single cell, a yellow blob called Physarum polycephalum, and it solves mazes. Put it in a labyrinth with oat flakes at two exits and, after a day, it has grown a single optimized tube connecting them, having retracted every dead end. Nobody drew that tube. It emerged from a million tiny decisions made by parts of the same body.

So I built the tiny decisions. The whole model is this: an agent sits on a grid, feels a chemical trail (a "pheromone" field) at three sensor points — one straight ahead, two off to the sides — turns toward the brightest, walks one step, and deposits a little pheromone under its feet. Every tick, the grid diffuses a little (the trail smears) and evaporates a little (the trail fades). Deposit, diffuse, evaporate. That's all of it.

Ten of thousands of agents agreeing on where to walk; the veins condense out of the agreement, iter 100.

Ten of thousands of agents agreeing on where to walk; the veins condense out of the agreement, iter 100.

At first, nothing. The agents wander from a seed at the centre and lay a faint, uniform fog of pheromone. Then, around iteration 100, it breaks symmetry: one accidental bright streak is sensed by the agents walking over it, so they add to it, so it's brighter still — and within a few dozen frames a dense starburst of veins radiates outward, branching and merging exactly the way the organism's network looks. It is a positive-feedback loop with no blueprint: the trail guides the walkers and the walkers build the trail, and the two lock together into structure.

The life of the network: it blooms (100), spreads to fill the world (400), and starves as decay outruns deposit (800).

The life of the network: it blooms (100), spreads to fill the world (400), and starves as decay outruns deposit (800).

The tuning is where the project lives. Every parameter is a trade with the fog:

The peak is fleeting. The montage above is the whole arc: at 100 it is a tight, sharp starburst; by 400 the veins have spread to fill the whole torus; by 800 the decay has outrun the deposit and the network dissolves back into fog. The organism builds itself and, with no food source added to the rules, eats itself. A real Physarum network stabilizes by finding food; mine just burns through its pheromone.

I ported it to run live in the browser too. The pheromone field lives in a float texture; the agents are a point cloud that reads the field, moves, and splats deposit back into it, and a diffusion pass runs over the grid — all on the GPU, so you can drag the deposit, decay, diffusion, sensor and turn sliders and watch the symmetry break in real time.

Live slime mould (WebGL2) →