Antswarm: An Agent-Based Simulation of Ants

Antswarm is an agent-based simulation of an ant colony using the Gordon model of ant task-allocation (Pacala, Gordon, & Godfray, 1996). An agent-based simulation is one that does not rely on an underlying equation. In agent-based simulations, the individual actors (in this case, ants) in the model are represented directly and possess a state and set of behaviors that govern their interactions with each other and the environment. The Gordon model states that ants choose a task based on the number of ants they encounter that are successful at that task. Ants also give up on a task if they spend more than a set amount of time unsuccessfully attempting it.

What Antswarm Does:

The program allows users to experiment with the parameters of the Gordon model. This permits users to better understand the Gordon model and how changing the parameters affects ant behavior. For each task, there are two parameters, startup and timeout. Startup is the number of ants that an ant must meet before switching to the task. Timeout is the amount of time that ants spend unsuccessfully attempting a task before giving up.

Antswarm features five ant tasks directly specified in the Gordon model:

  • Nest Repair: ants repair and expand the nest by digging up dirt.
  • Brood Care: ants care for eggs, larva, and pupa.
  • Foraging: ants follow trails and bring food back to the nest.
  • Patrolling: ants find food and lay trails back to the nest.
  • Inactive: ants mill around and decide on a new task by counting the number of ants succeeding at other tasks.

Users can also set parameters to control the simulation environment using the map editor. These include:

  • The number and location of nests.
  • The number and types (queens and workers) of ants in the nest at start.
  • The amount and location of food items.
  • Terrain color and barriers.

Ants navigate using a simple wall-following algorithm that allows them to avoid obstacles and nest walls. The algorithm also permits foragers to follow "pheromone trials" laid down by patrollers. The patrollers get the XY coordinates of the food, return to the nest, and transmit those coordinates to all ants in the nest. The foragers then use the wall-following algorithm to travel to the food at the XY coordinates and take that food back to the nest.

Download Link:

Here is an installer for windows. Right click and press "Save As" in the menu, choose my documents and press save. Then open My Documents (on the desktop) and double click on the file you just saved ("antswarm.msi" unless you changed it).
Here is a zip of the simulation. Once you've downloaded it, unzip it and double click antswarm.exe (antswarm_linux on linux) to start. Full source code is included.
If you've got any problems, a help forum is here.

Using Antswarm:

  • Starting the Simulation:
    • Click "Simulation" and then "start" to start the simulation.
    • After clicking simulation, you may chose a map from the list.
    • Click "Options" and then chose a resolution to change the size of the screen.
    • Click "Quit" to exit the simulation.
  • About the default map:
    • The default map features 2 nests with 42 workers and one queen each.
    • Statistics appear in the upper-right hand corner of the screen.
      • Each line indicates a nest.
      • The icons show how many ants are doing each task.
      • "Ants" indicates the total number of ants in the nest.
      • "Food Collected" indicates the total amount of food in the nest.
      • "Food Scouted" indicates the number of food items found.
      • "Dirt" is the amount of dirt that ants have taken out of the nest.
  • About the ants:
    • Ants move around in the simulation world.
    • The ants have icons above them indicating task.
      • A group of dots indicates that the ant is a brood worker.
      • An apple indicates that the ant is forager.
      • A triangle indicates that the ant is a nest repair worker.
      • A picture of an eye indicates that the ant is a patroller.
      • The /. icon indicates inactivity.
  • Inside the nest:
    • White objects are brood items (larva and pupa that grow into ants).
    • Dark areas are blocked and the grey areas are open spaces that has been dug by the ants.
  • Controlling the view and moving around:
    • Use the arrow keys to scroll around the map.
    • Click on a nest icon (a triangle in a circle) to view inside the ant hill.
    • Click on the minimap in the upper-left hand corner of the screen to move to that location.
      • The box outline represents the area of the map currently on the screen.
      • The bright dots on the minimap represent ants.
      • The triangles on the minimap are nest entrances.
  • To Adjust Gorden Model Parameters:
    • Click on a nest in the statistics panel at the upper-right corner of the screen.
    • Click on a task icon at the top of the panel at the lower-left corner of the screen.
    • Move the left slider to adjust the number of ants required to start going the task.
    • Move the right slider to adjust the amount of time to spend unsuccessfully doing the task.
  • Using the Map Editor:
    • To open the map editor, choose "editor" at the main menu. Choose a map to open, and then click "start."
    • To save the map file, click the save button. Then type the save map name. A prompt will appear if you save over an pre-existing map.
    • Changing food and tiles:
      • To add food items, click one of the food pictures at the bottom left of the screen.
      • To delete food, click the red X button, and then click on the food.
      • To change the color of the terrian, click on the terrian pictures at the bottom left of the screen, and then drag the mouse on the map.
      • To stop placing anything, click the green X button.
    • Changing nests:
      • To select a nest, click on it in the statistics panel at the upper-right corner of the screen.
      • To change the number of ants in a nest, select it, and click the "ants" button at the bottom-left of the screen.
      • To place a nest, select it and click on the "<>Nest" button. Then, click on tilemap map to place it.
      • To remove a nest, select it, and press the at the bottom-left of the screen.
  • Press the X in the upper-right corner of the screen (the Windows close button) to quit the simulation. Upon exiting, nest statistics will be printed to the cygwin console.
  • If you've made changes to the program's source code and would like to recompile it:
    • On Windows with Cygwin: Navigate the Cygwin console to the unziped files and type make.
    • In Linux: Navigate the shell to the unziped files and type make -f Makefile.lin. You will need SDL and SDL-devel.