CS 420/594 — Biologically Inspired Computation
NetLogo Simulation

Resnick Ants

This page was automatically generated by NetLogo 3.1.4. Questions, problems? Contact feedback@ccl.northwestern.edu.

The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun’s Java site.  General information on the models, including instructions for running them on your own computer, is available from the NetLogo Simulation Information Page.

created with NetLogo

view/download model file: Ants.nlogo


In this project, a colony of ants forages for food. Each ant follows a set of simple rules, but the colony as a whole acts in a sophisticated way.

When an ant finds a piece of food, it carries the food back to the nest, dropping a chemical as it moves. When other ants "sniff" the chemical, they follow the chemical toward the food. As more ants carry food to the nest, they reinforce the chemical trail.


Click the SETUP button to set up the ant nest (in violet, at center) and three piles of food. Click the GO button to start the simulation. The chemical is shown in a green-to-white gradient, the nest-scent in a red-to-white gradient.

The EVAPORATION-RATE slider controls the evaporation rate of the chemical. The DIFFUSION-RATE slider controls the diffusion rate of the chemical and nest scent. There is an on-off PLOT? switch. Turning off the plotting lets the model run faster.

The DISPLAY-FIELD chooser determines whether to display the chemical concentration or the nest-scent concentration.

The MAKE BARRIER button allows barriers to be drawn, which block the ants and diffusion of the chemical and nest scent. The REMOVE BARRIER allows some or all of the barriers to be erased. Click or hold the mouse button to draw or erase barriers.

The DEPOSIT FOOD button allows more food to be deposited. The kind of food to be deposited ("cyan," "sky," or "blue") is determined by the FOOD-KIND chooser. Click or hold the mouse button to add food in particular places.


The ant colony generally exploits the food source in order, starting with the food closest to the nest, and finishing with the food most distant from the nest. It is more difficult for the ants to form a stable trail to the more distant food, since the chemical trail has more time to evaporate and diffuse before being reinforced.

Once the colony finishes collecting the closest food, the chemical trail to that food naturally disappears, freeing up ants to help collect the other food sources. The more distant food sources require a larger "critical number" of ants to form a stable trail.

The consumption of the food source is shown in a plot. In CYAN you see food1 which is on the right side of the world. In BLUE you see food2 which is on the lower left of the world. In MAGENTA you see food3 which is on the upper left of the world.

Try creating a barrier between a food source and the nest. How long does it take the ants to create a path around it? If you make a hole through the barrier (with REMOVE BARRIER), how long does it take the ants to discover it?


Try different placements for the food sources. What happens if two food sources are equidistant from the nest? When that happens in the real world, ant colonies typically exploit one source then the other (not at the same time).

In this project, the ants use a "trick" to find their way back to the nest: they follow the "nest scent." Real ants use a variety of different approaches to find their way back to the nest. Try to implement some alternative strategies.


In the UPHILL-CHEMICAL procedure, the ant "follows the gradient" of the chemical. That is, it "sniffs" in three directions, then turns in the direction where the chemical is strongest. You might want to try variants of the UPHILL-CHEMICAL procedure, changing the number and placement of "ant sniffs."

RETURN-TO-NEST uses a similar gradient.


Modified 2007-10-08 by B.J. MacLennan to simulate diffusion of nest-scent, to allow display of nest-scent, to allow insertion and removal of barriers, and to allow introduction of more food.

This model was developed at the MIT Media Lab. See Resnick, M. (1994) "Turtles, Termites and Traffic Jams: Explorations in Massively Parallel Microworlds." Cambridge, MA: MIT Press. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project. Adapted to NetLogo, 2001, as part of the Participatory Simulations Project.

To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Ants model. http://ccl.northwestern.edu/netlogo/models/Ants. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 1998 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Ants for terms of use.

Return to CS 420/594 home page

Return to MacLennan's home page

Send mail to Bruce MacLennan / MacLennan@utk.edu

Valid HTML 4.01! This page is www.cs.utk.edu/~mclennan/Classes/420/NetLogo/Ants.html
Last updated: 2007-10-09.