RunTheSim
← simulations Playable v1 DE

swarm intelligence

Ant Colony
Stigmergy

Each ant is stupid. Together they are precise. Trails deepen where ants repeat them. Trails fade where ants forget. A week later the forest floor is a decision you can read, one nobody wrote.

Food trail Home trail Ants
What's happening Each ant reacts to local signals only. No map, no leader, no central plan. The route emerges from feedback.
What to try Swap the preset, raise evaporation, or push jitter up. Stable paths dissolve or reform in seconds.
Why it matters The same logic drives routing, optimization, and distributed coordination far beyond biology.

source notes

Model level and refs

  • Dual-field pheromone model, tuned for fast visual convergence, not a full biological replica.
  • Inspired by stigmergy and ant colony optimization as algorithmic metaphors, not exact species behavior.
  • Diffusion and evaporation run as discrete grid updates for in-browser speed.

deeper dive

How a colony writes a map nobody drew

Watching real ants find food looks like planning. It isn't. There's no scout that returns with directions, no forager that sets the route. Every ant follows two simple rules about chemical signals on the ground, and the whole colony converges on efficient paths anyway. The word for this is stigmergy: indirect coordination through a shared environment. The simulation above is a stripped-down model of it.

The two signals above are doing all the work

Ants moving away from the nest lay one kind of scent: a home trail. Ants carrying food back lay another: a food trail. Every ant sniffs the cells ahead of it and steers toward whichever signal matters for its current task: the home trail if it's searching, the food trail if it's delivering. Both signals fade over time. Routes that aren't reinforced disappear. Routes that many ants repeat get stronger. That's the whole rulebook. No map, no memory, no authority.

What emerges looks like a decision. Given an obstacle and two possible paths, the colony usually ends up walking the shorter one. Not because any individual can compare them, but because shorter paths complete round trips faster and therefore get reinforced more often per unit time. The system picks the better route by measuring it with its own traffic.

Why this model is deliberately simpler than a real ant

Real ants have vision, pheromone blends, task-switching, colony-level feedback, and physical trail geometry. The simulation collapses all of that into two scalar fields and a heading angle. That's on purpose. The goal isn't to replicate biology. It's to make the coordination mechanism visible. A faithful ant model would be slower to run and harder to read. What you see here matches the shape of the behavior, not the biology. The source notes above list the specific simplifications.

Where the same logic shows up outside biology

Ant colony optimization (ACO) was formalized as a routing algorithm in the early 1990s because the rules scale. They work anywhere agents need to find good paths without a central planner. The same pheromone-gradient idea shows up in:

  • Network routing. Packets reinforce paths that deliver fast, abandon ones that don't.
  • Vehicle logistics. Simulated ants find low-cost tours across hundreds of cities in the travelling salesman problem.
  • Swarm robotics. Drone fleets coordinate sweeps without radio contact by depositing and reading environmental signals.
  • Distributed optimization. Anywhere you have many agents, no leader, and only local signals.

The common pattern: simple rules plus shared environment plus positive feedback produces emergent coordination. The ant on your screen and the packet in a data center are running the same algorithm. The bird flocking simulation on this site runs on the same shape of rule with a different medium: air currents instead of pheromones.

Things to try

Push evaporation up. Trails dissolve before ants can return, and the colony loses its memory and searches from scratch. Push it down. Trails become permanent scars; the colony keeps walking the first random path it happened to find, even if better ones exist. Try the maze preset. The colony eventually threads it, but you can watch the early confusion. Raise turn jitter. Too much randomness breaks coordination. Too little and the colony locks onto one path prematurely. The interesting parameter region is narrow, which is part of the point. Browse the full simulation library for other systems built on local rules and global shape.