Ants, Part 1

February 17, 2011

I recently read a book called Turtles, Termites, and Traffic Jams for school. Through this book, I discovered a very cool computer program called StarLogo. Personally, I’m fascinated by the program, but I’m hoping that if the program has teaching value, it will somewhat justify the time I’ve wasted watching it run. The program is intended to allow exploration of “massively parallel systems.” What that means in this specific case is that the program creates tiny entities (which it calls “turtles”) and places them on a screen where they can interact with each other.

The turtles don’t have to behave like turtles. They can be programmed to do pretty much whatever you want them to do, including, in one particular program, act like ants. A program that comes included in the StarLogo package, called “ants,” is a representation of how ants might go about collecting food.

Here’s the basics of how this program works. First, it sets up a “nest,” indicated in purple, and some “food sources,” indicated in blue. All of the ants start out in the nest when the program begins. When you tell the program to start running, the ants (red) start moving around the map at random, one step at a time. Things start to change when ants land on a blue space (i.e. a space with food on it). As soon as they find some food, the ants start to “sniff” around looking for their nest. The nest emits a special scent, and the ants carrying food take a step to where the “nest scent” is highest. This will lead them home to drop the food and start again.

So far, so basic. Ant wander around randomly looking for food, they find some food, pick up a piece, and go back to their nest. There’s another aspect, though, which makes the program a lot more interesting. While ants are carrying food, they release a certain chemical (indicated in green) to the surrounding squares. When an ant in “random” mode detects the presence of this chemical, it stops moving randomly and starts moving in the direction where this scent is the most intense. So we have three basic “ant modes” 1. Move about randomly 2. If carrying food, move towards “nest scent” 3. If not carrying food but in the presence of “food chemical,” move in the direction where this food chemical is strongest.
The green patches indicate places where ants are emitting the food chemical. Other ants who detect the chemical will follow these trails. The “food scent” is most strongly concentrated near the food source closest to the nest. More ants are led to this food source. The first source is exhausted. The scent has evaporated from the first source, but is becoming quite strong near the second-closest source. Second source is (practically) exhausted. Ants search in vain for more food.

Okay, so that’s how the program typically runs. Here is a video of the program in action:

Cool, no? In future parts, we’ll chat about why I think this program matters.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: