Posts Tagged ‘c’

Ants Intro

Friday, October 10th, 2008

Inspired by the brave explorers that found their way into my kitchen via means unknown, I’ve been working on a simulation of ants with their actions being based on the pheremone trails they leave behind. Given that I could represent their decision making process with a simple table of values, I decided to use a genetic algorithm to refine the values over successive generations and attempt to breed better and better ants. I wrote up an initial design before I began coding, although I found some issues with it and have strayed somewhat as time has gone by.

As of writing this, I have covered most of the basic functionality necessary to prove the function of the simulator to myself. I have ants that run around and bring food back home, I use a version of a genetic algorithm to make future generations better than prior ones, and I have a visualizer that lets me see how the ants move and how the pheremones are distributed.

Speed is an issue, and it is a limiting factor in running larger simulations and having multiple teams of ants fight one another. In the name of making things run faster, I’m probably going to have to greatly simplify or entirely remove the code for diffusing pheremones across the map. More on this once I come up with a solution, but my initial method required touching every cell on the map 9 times, which just won’t do when I’m trying to run hundreds of thousands of iterations in a timely manner.

So as to provide historical context, I will link to the current revision of the repository. Several aspects of the code have grown beyond my original plans for them and everything needs a bit of a cleanup. As I address the deficiencies of various features I plan to write up the changes I made here.