Home▸Animals & Their World▸Ant Colony Pheromone Trails (2D)

Ant Colony Pheromone Trails (2D)

Watch a colony converge on the shorter of two barrier gaps between nest and food through nothing but pheromone deposit and evaporation — no ant ever measures a distance.

Animals & Their World2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-ant-colony-3d-simulation ↗ Open standalone

This 2D companion turns the ant colony into a real stigmergy simulation: ants leave the nest, wander with a pheromone-biased random walk, and once they reach the food they head straight home while laying a strong trail behind them. A wall with two gaps of different length separates nest and food, so the colony faces the classic "double bridge" choice — and because trips through the shorter gap complete faster, that gap's trail builds up before it can evaporate, pulling more ants onto it in a self-reinforcing loop.

⚙ Under the hood

Pheromone deposit and exponential evaporation on a grid, with ants steering probabilistically toward the strongest nearby trail — the same stigmergic feedback loop real ant colonies use to find efficient foraging routes.

ant colonypheromone trailstigmergyswarm intelligencedouble bridge experiment

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

Why do the ants converge on one gap instead of splitting evenly?

Because ants that use the shorter gap return to the nest sooner, they lay pheromone there more often per unit time than ants using the longer gap. Since pheromone also evaporates, the shorter route's trail strength pulls ahead and keeps attracting more foragers — a positive feedback loop with no central coordination.

What happens if I raise the evaporation rate?

A faster decay prunes weak trails quickly, so only the most frequently reinforced path survives — the colony converges faster but is more likely to abandon a route if traffic on it briefly drops.

Is this the same algorithm used in Ant Colony Optimization?

Yes — the deposit/evaporate/probabilistic-steering loop here is the core mechanism behind Ant Colony Optimization, a real metaheuristic used for routing and scheduling problems, simplified here to a 2D foraging field you can watch converge in real time.

What did you find?

Add reproduction steps (optional)