Translations available (email me to add your translation to this list):
Language/LinkContributor (thank you!)
RomanianAlexander Ovsov
PolishAndrey Fomin
Serbo-CroatianJovana Milutinovich
PortugueseArtur Weber

Simulation of Ant's Emergent Behavior Using StarLogo

This page is about a short personal project of mine to investigate emergent behavior.  To this end, I created a virtual ant colony using a piece of software called StarLogo made by some people at MIT.  The idea is that each ant alone is next to useless for gathering food efficiently, but a bunch of ants each acting on its own simple set of rules together are able to gather food much more efficiently.  This phenomenon where the group ability is greater than the sum of each individual acting alone, can be a form of emergent behavior.  An excellent book on emergent behavior is "EMERGENCE The connected lives of ants, brains, cities, and software" by Steven Johnson.  This book was recommended by a friend and inspired me to do this project.  I'll quote his definition of emergence here, from the inside flap of the book cover:

Emergence is what happens when an interconnected system of relatively simple elements self-organizes to form more intelligent, more adaptive higher-level behavior.  It's a bottom-up model; rather than being engineered by a general or a master planner, emergence begins at the ground level.  Systems that at first glance seem vastly different--ant colonies, human brains, cities, immune systems--all turn out to follow the rules of emergence.  In each of these systems, agents residing on one scale start producing behavior that lies a scale above them: ants create colonies, urbanites create neighborhoods.

Following is a screenshot of my virtual ants gathering food and bringing it back to the nest:

This may look complicated at first, but it's actually pretty simple.  If you want to see this running on your own computer, just follow these easy steps:

  1. download and install the StarLogo software from MIT.  NOTE: My software was written in version 1.2.2 of StarLogo and the current version is 2.0.  My original source was not compatible and a couple kind folks told me they were getting an error message, so I upgraded the source link below to provide a 2.0 compatible version.  I'm not sure if it will work with the 1.2.2 version anymore, so if you have that version and have trouble, I apologize, please try version 2.0.
  2. download my source code.  If this file opens in your browser, just Back up to this page, right-click and "Save Target As..." to save it on your hard disk as "ant_simulation.slogo"
  3. run StarLogo and open the my source code file that you just downloaded.  
  4. For the simplest demonstration, click the "setup" button once, and then click the "execute turn" button.  Then ants will now start running around and soon form a trail to the food.
  5. In exchange for using my source code, I simply ask a few things.  First, feel free to have fun with and make changes to the software.  Second, if you make any improvements you think I might find interesting, email me!

So, back to what's going on in the picture: 

With this understanding, I'll try to explain what rules the ants follow, then how these simple rules lead to this beautiful example of emergent behavior (the nice straight food trail allowing the ants to more efficiently collect food).  If you haven't already, let me recommend that you install and run the software before continuing.  Although it is a nice screenshot if I do say so myself, it's no substitute for seeing the ants running around and building the trail- it's absolutely fascinating to watch (maybe just for me?) and it will make this coming explanation that much easier to understand.

Since I don't know where to start explaining this, what I'll do is start at the top of the application window and explain what the different buttons, sliders, and info boxes mean.  By the time I get to the bottom, it should be fairly clear what is going on (also, keep in mind the above descriptions of what the graphical display means).

At this point, you should have a good idea of how this program works.  If you got this far, hopefully you are interested in playing with it some on your own.  I highly recommend running it and playing with the sliders to see how it affects the ants, note that many setting combinations will completely cripple their ability to gather food in a reasonably efficient manner so if you want to save your changes, you should do so with a new file name so that you can always restart with my settings if you can't get the ants working properly again.

Things I'd Like to Improve

Mostly, I'd like to improve the evolution of the ants from the silly little hack method I used above to evolve the "FollowProbability".  I was hoping that I could somehow have a C (or any programming language with good ability to manipulate data)  program interface with StarLogo.  This would allow the C program to do things like creating genetic trees of the slider settings since I suspect that branching the genetic paths would be necessary to find optimal combinations of settings, since the settings are related and thus there might be local minimums and maximums for a given setting in relation to another.  What I mean by this is that if you just move one setting at a time, you will find a point at which that setting is best, but if you change some other settings then the first setting may no longer be optimal.  This is why I suspect that having various branches on the chain of evolution might help discover the most efficient settings.  A C program could manage this data and make the evolutionary changes and the call the StarLogo program to run a given ant population a few times to measure its ability to gather food, the C program then can read the results and determine if the new population was an improvement or a step in the wrong direction.  

I contacted the people who wrote StarLogo to ask if they had written any hidden interface like this, but they said they had not but that they had thought about it.  This was back in October or so, and I was hoping that they'd come out with a new version including this feature by now, but so far they have not released any new updates to StarLogo since the 1.2.2 version that I got back then.  I suspect the main authors (if not everyone involved) are working on other things now.

Update: maybe StarLogo 2.0 has some provision for communicating with a language more suitable to handling the data sets to run a good evolution algorithm.  I haven't had time to look into this yet, but if anyone knows the answer I'd sure appreciate a tip. :-)