Home▸Life & Biology▸Physarum Slime Mold: Agent-Based Network Optimization (2D)

Physarum Slime Mold: Agent-Based Network Optimization (2D)

Thousands of trail-sensing agents self-organize into an efficient transport network between food sources — a live BFS-measured network-efficiency readout and an optional maze-solving mode make the real slime-mold-network-optimization algorithm directly visible.

Life & Biology2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-s34-slime-mold-growth ↗ Open standalone

About this Physarum agent-network simulator

The 3D companion draws slime mold as a branching organism: a handful of tendril tips crawl toward the nearest food node, occasionally forking, with each tip's own local steering. This 2D companion instead runs the actual algorithm real slime-mold-computing research is built on — Jeff Jones' agent-based Physarum model. Thousands of independent, identical agents each sense a single shared pheromone field at three points ahead (left, center, right sensors offset by the sensor angle, at the sensor distance), turn toward whichever sensor reads strongest, move forward, and deposit their own trail into that same field. No agent has any notion of "food" or "branch" — the field is all they see.

What turns that into a network is the field's own dynamics: every step it diffuses to neighboring cells and decays, so a trail only survives if enough agent traffic keeps reinforcing it. Paths used by many agents strengthen and pull in more agents (positive feedback); paths used by few fade back to nothing. Food sources are modeled as constant pheromone beacons that never decay, so agents are drawn toward them the same way they are drawn toward each other's trails — and the network that survives between them approximates a low-cost connecting graph, the same emergent behaviour used to model real Physarum solving maze and transport-network problems (famously, Nakagaki's 2000 experiment where slime mold found the shortest route through a maze).

The live readout treats the trail field as a graph: every second, breadth-first search finds the shortest path between food sources through cells whose pheromone exceeds a threshold, and compares that path length against the straight-line distance — the efficiency percentage shown is exactly the metric used in the research literature to show how close an emergent Physarum network gets to optimal. Turning on maze mode adds a wall with two gaps between the food sources, and the network can be watched finding its way around it in real time.

Frequently Asked Questions

How is this different from the 3D "S34 Slime Mold Growth" simulation?

The 3D version models growth as a small number of tendril tips, each independently steering toward the nearest food node with some added noise — a "branching organism" view. This 2D companion instead runs the population-scale, sensor-based Physarum algorithm: thousands of agents that only ever see a shared pheromone field, with the network pattern emerging purely from diffusion, decay and positive feedback rather than any per-tip food-seeking rule.

What does the network-efficiency percentage actually measure?

Every second the simulation runs breadth-first search over the pheromone field (treating any cell above a trail-strength threshold as traversable) to find the shortest connecting path between each pair of food sources, then divides the straight-line distance by that path length. A value near 100% means the emergent network has found something close to the most direct possible route; lower values mean the network is still consolidating or is being forced around an obstacle.

Why do the agents turn instead of moving randomly toward food?

That is the defining feature of the real Physarum algorithm: an agent never "knows" where food is. It only compares the pheromone level at three local sensor points and turns toward the strongest one. Because food sources continuously emit pheromone and busy trails reinforce themselves, food-seeking and path-optimizing behaviour both emerge from that single local rule — nothing in the agent code references distance-to-food directly.

⚙ Under the hood

Jeff Jones' agent-based Physarum model: thousands of sensor-steering agents deposit a shared pheromone field that diffuses and decays, self-organizing into an efficient network between food sources, with a live BFS network-efficiency readout and an optional maze-routing mode.

physarumslime moldagent-based modelemergent networkpheromone trailnetwork optimization

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)