Starting an ant colony


Sept. 21, 2009

I have started to remake a simulation of an ant colony that I once made in QBASIC. The idea (and I am by no means, the first to think of it) is to create an ant colony that can harvest surrounding food (seeds or leaves – the green ovals in the picture) in an intelligent manner, despite the individual ants having very limited intelligence or information to work with.

Simulated ant colony

The ants (black circles in the picture above – I could replace them with more realistic images, but it’s probably not worth it) can be considered simple information processors (Hofstadter made the analogy between ants in a colony and neurons in a brain). In the simulation they are blind, and can only sense food and pheromones. They are capable of a limited repertoire of actions, such as moving forward, turning, picking up food and releasing a pheromone (the blue squares in the picture below).

So far in my simulation, the ants leave the nest (the odd looking black circle with a halo, and the reason I got sidetracked into evolving images of Darwin – I know it looks rubbish), in a random direction. At each unit of time, there is a 10% chance of an ant altering its direction (somewhere between -45 and 45 degrees), otherwise it moves releases a pheromone and moves forwards; over time the pheromone degrades.

Pheromones

The next step will be to allow the ants to change their behaviour when they detect a pheromone. For example, if I want ants to explore new areas, I could make them avoid areas of high pheromone, since those areas will have been covered by ants before. If I want the ant to return to its nest (e.g. if it is holding a seed), then I could make it prefer areas of high pheromone. By introducing a second pheromone, released when ants are carrying food, information about where food is can be passed to other ants, perhaps allowing the colony to efficiently direct its efforts to collecting food. Later, I would like to add movable and immovable obstacles to get in the ants way.

This simulation is the first time I’ve really made use of Pygame’s sprite objects. I’m not sure whether made full use of the object's functionality, but I have found that it make detecting collisions between ants and seeds much simpler than it would otherwise have been. I would like to work out how to use SVG images for the sprites, because at the moment, the seeds look quite rubbish. But I should focus on the ants behaviour before getting bogged down in making things look pretty.

Leave a comment

cancel reply