There are two species of bots who graze on patchy plants. The red species eats less; the blue eats more -- indeed it destroys the plant and the patch's ability to grow plants. To make the contrast dramatic, the two species are separated into East and West halves of their world (which is a torus). The plants' growth rate is fudged by a random sampling of 1% of the patches per tick. A better implementation would make the patches a cellular automaton. The simulation re-uses the code from Matthew Caryl's Bugs applet, which is "Based on Simulated Evolution: wherein bugs learn to hunt bacteria by A. K. Dewdney in Scientific American, May 1989. This article discusses a program called Simulated Evolution by Michael Palmiter which shows the same behaviour as the applet above." On the muddy bottom of a pond a number of protozoa cruise around eating dead bacteria which rain down from above. Their endless search for food takes energy and those who do not find enough nourishment will die. Java capable browsers will show a microscopic segment of the pond which receives enough food to support about 40 protozoa.
The behaviour of the protozoa is controlled by 6 genes which determine the probability of turning by a particular amount.
When old enough and bolstered with lots of energy a protozoa will reproduce by splitting into two new individuals. Small mutations mean that these offspring are not exact copies of their parents but share most characteristics. In the competition to find food only those with good genes can eat enough to reproduce. Natural selection encourages the development of particular sorts of protozoa.
In the beginning gene values are assigned at random which causes most bugs to jitter about making little progress but expending a lot of energy. Jitterbugs have a high death rate. After exhausting the locale food supply their energy gradually diminishes unless they chance across a fresh patch. Some survive, most often those who jitter less. Next to develop are tumblers who move round in circles before cruisers take over. A cruiser moves forward most of the time but turns every now and then, forever bring the protozoa into new food areas.
If you want a closer look at the process in action there are two things to do. First click on bit of the banner without any bugs on and a control panel will appear with which you can adjust the speed to something more suitable. Second click on a bit of the banner with bugs on and another control panel will appear, this time displaying information the selected bugs age, energy, and genome. The bug you have selected will now appear yellow on the screen.
Source code for this simple demonstration is available:
Based on Simulated Evolution: wherein bugs learn to hunt bacteria by A. K. Dewdney in Scientific American, May 1989. This article discusses a program called Simulated Evolution by Michael Palmiter which shows the same behaviour as the applet above.