Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Ant colony simulator

Watch ants find food with scent trails: searching, carrying and following pheromone on a grid, plus the classic double-bridge shortest-path experiment.

Orange: nest · brown: food · navy dots: searching ants · red dots: ants carrying food · green: food trail · blue-grey: home trail.

How to use

  1. Foraging trails: the ants leave the nest (orange) in random directions. Searching ants leave a home scent behind them; ants that find food turn round, follow the home scent back and leave a food scent on the way. Other ants follow the food scent out.
  2. Press Play and watch: after some wandering, green trails join the nest to the food. Click or tap the field to drop more food anywhere.
  3. Change how fast the scent fades and how often ants wander at random, then press New colony to compare. Run 500 steps jumps ahead and draws the food count over time.
  4. Double bridge: the nest and the food are joined by a short and a long bridge. Each ant picks a bridge, preferring the one with more marks at its end. Press Run to see one colony and 20 more with other seeds.

Keyboard and touch

TabMove between tabs, boxes and buttons
Enter in a boxStart a new colony or run the bridge experiment
Click or tap the fieldDrop food (with a keyboard, use the two food piles already there)

Tips

  • With no fading at all, old trails never go away and ants keep visiting empty food spots. A little fading lets the colony forget and move on.
  • Set wandering to 0 and the ants become strict trail followers: they exploit known food well but are slow to find new piles. A few wanderers (scouts) help.
  • When one pile runs out, its green trail fades and the ants switch to the other pile.
  • On the double bridge, make the bridges equal: the colony still usually picks one of them, at random. That is the crowd effect of n = 2.
  • A large k makes early choices count for less, so the colony takes longer to settle on one bridge.

About this simulator

Many ants find food together without a plan: each one follows simple rules about scent, called pheromone. This page models that on a grid of 100 by 60 cells. Each step an ant looks at the three cells ahead of it (left, straight, right) and picks one with a weight of (0.02 + scent) squared, doubled for going straight; with the wandering chance it picks at random instead. The scent an ant lays starts at 1 at the nest or the food and weakens by 1.5 % with every step it walks, so trails get stronger near their source and point the way. Scents fade by the set percentage every step. It is a teaching model, not a copy of any real species.

The double bridge follows the experiments of Jean-Louis Deneubourg, Simon Goss and colleagues with Argentine ants (1989-1990) and their choice formula with k = 20 and n = 2: the chance of the short bridge is (k + A)2 / ((k + A)2 + (k + B)2), where A and B count the marks ants have left at that end of each bridge (an ant marks the end it enters and the end it leaves). Ants on the short bridge reach the food first, so the food end of the short bridge gets marked first and returning ants pick it; with a bridge twice as long, the short one wins in about three colonies out of four here. The same idea inspired "ant colony optimisation" algorithms for routing problems. Runs are seeded, so the same settings and seed always give the same result. Everything runs in your browser.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product