Draw My Canvas / studio

Slime Mould Network

Eleven thousand specks that can only smell where the others have been. Follow the strongest trail, leave a little more, let the map forget the rest — and a branching web builds itself.

Plate 22physarum

Waiting for the animation above to load…

What lands in the file, and what the width does

One click writes whatever the animation is drawing at that moment to a PNG, with the drawmycanvas.com mark drawn into the picture rather than laid over it. Leave the width box empty and you get the stage exactly as your browser rasterised it — your window’s width times its device pixel ratio, which is about 1,600 px across from a 1280‑px window on a HiDPI laptop and about 353 px from a 390‑px phone.

Type a width instead, or take a preset, and the frame is redrawn into a canvas that wide: the height follows the stage’s own shape and the mark scales with it. The stage is 16:9 on a wide window and 4:3 below 560 px, so a width of 1200 saves 1200×675 on a laptop and 1200×900 on a phone. 1200 px is the width Open Graph and X link cards are cut from — the canonical card is 1200×630, and a card crops the extra height rather than letterboxing it.

Honest limits. Asking for more pixels than the stage was drawn at resamples pixels that were never drawn: a 1920‑px file exported from a 353‑px phone stage is bigger, not sharper. A very large width is a real memory allocation and a browser is allowed to refuse it; when that happens the line above says so plainly and nothing else on the page changes. PNG only — no JPEG, no WebP, no animated export. And nothing is uploaded: the picture is assembled in your own browser, so no frame of this plate ever reaches us.

Live on an HTML canvas · vanilla JavaScript · no dependencies Open fullscreen

About this piece

Nothing on this plate draws a network. What the frame holds is a trail map — a grid of plain numbers, one per cell, 303 × 170 of them at the size this page renders it — and a crowd of 11,332 agents wandering over it. An agent is four numbers wide: where it stands, which way it faces, and one word of its own random stream. It has no goal, no plan, no memory of where it has been, and no way of knowing that any other agent exists.

Once a frame, each agent does four things and then stops. It samples the map three cells ahead of itself — straight on, and at 25.8° to either side. It turns 34.4° toward whichever of those three readings is the largest. It walks one cell forward. And it drops 0.9 of trail onto the cell it lands on. Then, once every agent has moved, the whole map is blurred 70% of the way toward its own 3 × 3 average and multiplied by 0.87.

That is the entire program, and the branching web is nowhere in it. The web is what those four lines do to each other. A path that happens to carry a little more trail than its surroundings can be sensed from further away, so it recruits the agents near it; those agents deposit on it, which strengthens it, which widens the catchment it recruits from. Meanwhile the ×0.87 is quietly deleting everything: a trail nobody walks loses half its value in five frames, about a twelfth of a second. Only a path that keeps earning traffic survives being forgotten.

Reinforcement and forgetting, and nothing else. Biologists call this stigmergy — coordination through marks left in a shared environment rather than through messages — and it is the same bookkeeping an ant colony does with pheromone. Every junction, loop and dead end you can see on the frame is a consequence, not an instruction.

Four lines, and why they make a web rather than a smear

Each of the four steps is load-bearing, and the quickest way to see it is to break one and measure what happens. The measurement used here is the spread of the trail map — its standard deviation divided by its mean. A map of uniform fog has a spread near zero however bright it is; a map of bright filaments through dark medium has one well above 1. On this page’s stage the real model reaches 1.70 by the frame it opens on and climbs to 2.78 by frame 7,000.

  • Take away the steering — set the turn to zero so the agents still walk and still deposit, but never react to what they sense — and the spread collapses to 0.26. The map becomes exactly what a few thousand random walks look like: even grey. Nothing about the deposit or the decay builds a network; the sensing does.
  • Reverse the steering, so agents flee their own trail instead of following it, and the spread is 0.30 — no better. The sign of that one turn is the difference between a picture and a fog.
  • Take away the blur and the trail becomes a set of one-cell scratches. An agent looking three cells ahead cannot see a one-cell scratch reliably, so nothing is ever reinforced. The blur is not a prettifying filter: it is the sensing range of the medium.
  • Take away the decay and every path ever walked stays lit. Within about twenty seconds the frame saturates to a solid slab, which is the same picture as no structure at all.

There is a fifth ingredient that is easy to miss and is the reason this plate is still worth looking at after a minute: a cell can hold at most 6 of trail, and a deposit onto a saturated cell is simply lost. Without that ceiling the reinforcement loop has no brake. Measured on the same stage map with the limit removed, the spread runs 2.4 at frame 160, 3.0 at 400, 4.6 at 1,200 and 6.9 at 3,000; the peak trail climbs past 148; and by frame 3,000 a whole edge of the map is empty, because the picture has collapsed into five fat ropes and cannot recover. With the ceiling in, the same run reads 1.70, 2.04, 2.51, 2.68 and 2.78, and the quietest edge of the frame never falls below 4.2. A saturated trunk stops out-competing its neighbours, so a side branch is always still worth walking, and the web keeps re-cutting itself instead of settling. Real tubes have a maximum diameter for much the same reason.

Where this actually happens

Physarum polycephalum is a slime mould: in its plasmodial stage it is a single cell containing many nuclei, sometimes spreading over a square metre of forest floor. It has no neurons, no brain and no central anything. What it does have is a body of tubes that thicken where cytoplasm flows through them and wither where it does not — the same reinforce-and-forget accounting this plate runs, done with protoplasm instead of arithmetic.

In 2000, Toshiyuki Nakagaki and colleagues published a one-page paper in Nature reporting that a plasmodium spread over an agar maze, given food at the entrance and the exit, withdrew from every dead end and left a single tube along the shortest of the four possible routes. The organism did not search the maze; it filled it and then abandoned everything that was not paying for itself.

The result that made the model famous came ten years later. Atsushi Tero and co-authors, writing in Science in 2010, laid oat flakes on a wet surface in the pattern of the 36 stations around Tokyo, put a plasmodium on the flake standing in for Tokyo itself, and let it grow for 26 hours. The tube network it produced was comparable to the real Tokyo rail network on total length, on transport efficiency, and on how gracefully it degraded when a link was cut. Slime mould does not design a rail network better than engineers do; the interesting claim is the cheaper one, that a mechanism this simple lands in the same neighbourhood as deliberate design.

The agent-and-trail-map version this plate runs is Jeff Jones’ 2010 model, published in Artificial Life: he showed that a crowd of sensor-driven particles on a diffusing, decaying field reproduces the same transport-network behaviour without simulating any biology at all. The same three-sensor pattern is used to model ant foraging, where the shared medium is a pheromone that evaporates; the term for coordination through an environment rather than through messages, stigmergy, was coined by the entomologist Pierre-Paul Grassé in 1959 while studying termite mound construction.

Reading the plate: what to watch for

The picture is never finished, and the things worth watching are the changes rather than the shape at any one moment.

  • Coral marks the traffic, not a random quarter. A cell turns from cobalt toward coral only in the top sixth of the trail scale, which works out at 3.3% to 3.8% of the frame at every size this plate is drawn. Look at where it lands: mostly on junctions, because a junction carries the traffic of every branch that meets there and saturates first.
  • Branches competing, and one of them losing. Pick a spot where two routes leave the same node and rejoin further on. Over ten or twenty seconds one of them will usually thicken while the other thins, breaks and disappears — not because anything decided, but because the shorter of two parallel routes returns its agents to the junction sooner, so it gets marginally more deposits per second and the decay finishes the argument.
  • Filaments that go nowhere. The faint hairs drifting through the empty regions are agents that lost their trail and have not yet found another. They are the exploration budget: a network with none of them can never discover a better route, and this one is always re-testing.
  • Nothing ever touches an edge. The map is a torus — a trail running off the right-hand side reappears on the left, and a filament that leaves the top comes back at the bottom. That is why the web fills the frame evenly instead of thinning toward a border, and it is worth knowing that the two ends of a rope crossing the frame are frequently the same rope.
  • Click the animation and the colony restarts. The map is wiped and every agent is scattered to a fresh position and heading, so the whole formation runs again in front of you: an even grain for the first fraction of a second, filaments by about one second, the mature web by three. It comes back a different web — the overlap between the network before a click and the network three seconds after it measures 0.27 out of a possible 1 — which is the one thing worth knowing about this model: the structure lives in the map, not in the agents.

Two shipped plates look like relatives from a distance and are not. Plate 14, Frost Dendrites, also grows a branching shape out of wandering particles — but there a particle that touches the crystal freezes onto it permanently, so the figure only ever grows and no branch can be un-drawn. Here every filament on the frame is provisional. Plate 08, Fractal Dreams, branches because an L-system rule tells it to branch; this one has no rule that mentions branching at all.

Colour, and how the picture is put together

The trail map is not something the drawing code renders — it is the picture. Every frame, each cell’s value is looked up in a 512-entry colour ramp and written straight into a single ImageData buffer, which goes to the canvas in one putImageData call. There are no paths, no gradients, no second canvas and no blend mode; that one blit is the whole draw. There is also no wipe, because every pixel of the frame is overwritten unconditionally — the decay that keeps the picture alive happens on the map, not on the canvas.

The canvas’s own backing store is the map: one canvas pixel per trail cell, stretched to the frame by CSS. That is why a fullscreen embed on a 2560 × 1440 screen colours 147,456 cells a frame instead of 3.69 million pixels, and it is also the right look — a diffusing medium has no hard pixel edges, so the browser’s own smoothing is doing something honest rather than hiding a shortcut.

Both inks and the paper come from this site’s shared palette rather than being invented here, so the plate follows the light/dark setting of whatever page it sits on. The ramp is indexed by the square root of the trail value rather than the value itself, which is a small thing with a visible effect: a quarter of the map sits below 0.008 and half of it below 0.09, while the trunks sit at the ceiling of 6. A linear table would spend most of its entries on values almost no cell ever holds and quantise the faint medium — where most of the texture is — into a handful of steps you could see.

The cell size does not scale in proportion to the frame. Sensor range, step and deposit are all measured in cells, so the width of a filament is fixed in cells and the cell size decides both how coarse the web looks and what a frame costs. In proportion, the 3‑pixel cell of this page’s stage would be 1.3 pixels on a gallery thumbnail — five times the cells and five times the cost, for a thumbnail — and 8.5 pixels on a 1440-tall screen, a web of visible blocks. It follows a square root with a floor of 2.2 and a ceiling of 5 instead. The honest cost is that the thumbnail is not a miniature of this view: it runs a 163 × 101 map with 3,622 agents against the stage’s 303 × 170 and 11,332, and a smaller map grows a coarser web with fewer branch points.

Honest limits

Several, and none of them are hidden.

This is a picture of a mechanism, not a simulation of an organism. There is no food, no cytoplasm, no tube diameter, no mass conservation and no cell. The agents are a sampling device for the trail field, and calling them “the slime mould” would be a category error — the map is the closest thing here to the organism.

The trail ceiling is a device, not biology. It is the single most consequential number on the plate and it exists because the unbounded model degrades into ropes, as the figures above show. A real plasmodium is limited by how much protoplasm it has; capping each cell at 6 is a crude stand-in for that, and it is the place where this plate is least faithful to the paper it comes from.

The torus is a convenience. Wrapping the map means every cell has the same neighbourhood, so no part of the frame is structurally privileged and no edge can be left bare — but it also means the network has no boundary to break on, and boundary effects are a real part of how the organism behaves in a dish.

A different frame size is a different picture. The map is sized from the frame, so this page’s stage, a phone and a gallery thumbnail are running 51,510, 19,200 and 16,463 cells respectively, with different agent counts and different networks. Each is deterministic and repeatable — the same seed gives the same colony every time — but they are not one run at three magnifications.

It is not free. Timed in Node on this machine, one frame costs about 3.7 ms of arithmetic at this page’s stage size and about 9 ms at 2560 × 1440 — comfortably inside sixty frames a second on a laptop, and enough that a several-year-old phone will not always hold sixty. The opening frame also costs a one-off 160-frame warm-up, roughly 600 ms, because frame zero of the model is a uniform scatter of agents on an empty map: honest, and not worth looking at.

Finally, motion. Under prefers-reduced-motion nothing animates — the colony is warmed to its opening frame and drawn once as a still, which is a formed web rather than the noise the model actually starts from, and the click that would restart it is inert rather than leaving an empty frame.

Curious how the loop and canvas fit together? Read how it works →

More from the gallery

All 22 animations in the gallery →