Student work
Artificial life
Ant foraging

Please note

The simulation needs a Java-Plugin (1.3.x) installed for your internet browser. If you do not already have one installed, the browser will prompt you to download the Plugin from “Sun”, who is the inventor of Java. Please download the JRE (=Java runtime environment) into a directory on your computer (e.g. “c:\temp”), execute the downloaded file for installation on your system (double-click on the file). Afterwards you will be able to reload the simulation page. Maybe you will have to restart your browser to succeed.

Run the simulation

Please click here.

Description of the simulation

This simulation shows how ants decide between different food sources. The ants are released into the environment one by one. Basically they run around randomly (“random walk”). If they hit a feeding site, they change their state to “carrying” and immediately turn around and transport a piece of the food to the nest.

On the way home, they store an amount of pheromone on their current location in the environment (“patches”), thereby building up a pheromone trail. The amount of pheromone dropped per location decreases with longer duration of the journey, but at least one unit of pheromone is dropped. This way the pheromone trail gets graduated with higher concentrations pointing towards the feeding place. Unloaded ants that hit a pheromone trail do not walk randomly anymore, instead, they follow the pheromone uphill. The pheromone is diffused in the environmental patches, what causes the trail to become broader. Pheromones also evaporate, so they have to be restored by following ants, otherwise the pheromone trail will cease.

After a loaded ant reaches the nest, it changes its state to "unloaded" again and starts to wander around randomly.

To allow the ants to find the nest directly after they encountered some food, a second pheromone is placed in high amounts at the nest center and diffused massively, therefore establishing a homing-signal gradient over the whole “world”. This mechanism is chosen for simplicity, it resembles the mechanisms ants have developed in nature to find home like:

  • Navigation using the direction of the polisarisation of the sunlight
  • Remembering the surrounding (landmarks)
  • Counting and calculating steps and turn angles

The system of diffusion and evaporation leads of a competition among food sources for available ants, because the number of ants is limited and the trails need a steady walking of ants along them to stay stable. The shorter the distance of a feeding place to the nest, the shorter is the trail, the more often ants walk from nest to feeder and back per time unit. This leads to a positive feedback loop and race conditions among the feeders, selecting for the nearest one.

As the number of ants is limited, this leads to saturation at one point when almost all ants are bound to the strongest trail. The remaining trails can not be kept stable by the remaining ants. But as soon as the closest feeding place is empty, all ants are freed from this trail and the race starts again for the second closest source. This way the feeding places are exploited in an effective order.

In nature, too much pheromone on a trail decreases the following abilities of ants, therefore ensuring after a certain amount of already recruited ants to one source, that the remaining ants are available to the next profitable source. This effect is omitted in this simulation.


  • Change the number of ants and see what happens.
  • Test for the effect of the evaporation rate and of the diffusion rate.



The simulation was first written by Mitchel Resnick and described in his book Turtles, termites and traffic jams. It is also described in Swarm intelligence by Bonabeau, Dorigo and Theraulaz. The version I show here is based on an updated version of the StarLogo team for StarLogo 1.2.2. Based on this distributed version, I did some small changes and placed it here.

  • Resnick M. (2000) Turtles, termites and traffic jams. MIT Press.
  • Bonabeau E., Dorigo M. and Theraulaz G. (1999) Swarm intelligence. From natural to artificial systems. Santa Fee Institute studies in the sciences of complexity. Oxford University Press.

[Home] [Self-organization] [Ecology] [Populations] [Artificial life] [Student work] [Software] [Links] [Contact]