a slime mold has no brain and no plan. put oat flakes where the cities are and it grows a railway between them anyway. tap to put out food or take it away.
Tens of thousands of tiny agents wander a grid. Each one does the same three things, over and over: sniff the trail on its left, ahead and right; turn toward the strongest; step forward and leave a bit of trail. Between steps the trail spreads out a little and fades. Each food dot just keeps its own patch of trail topped up, so agents are drawn to it.
Trails that get walked get stronger, trails that don't, fade. Out of that, thick veins appear between the food. Tero, Nakagaki and colleagues in 2010 put oat flakes on a wet map where the cities around Tokyo are and let the real Physarum polycephalum grow for a day. The network it made was close to the one the railway engineers drew, and about as efficient and as resilient to breaking one link.
This is the agent model from Jeff Jones (2010), not the tube-flow model from the paper, so the veins here are where agents pile up, not tubes that thicken with flow. The status line counts how many food dots the strong trail connects, by flood fill over cells above a cutoff. It is a rough measure, and the cutoff is my pick.
Try: wipe slime and watch it start over; switch the tool to wall and drag to draw a barrier it has to go around; shorten how far they see and the veins turn into a tangle, lengthen it and they go straight lines between far-apart foods.