Sunday, June 1, 2008

MicroPond v2


In MicroPond v1, there's food and then there's critters. The evolution of the critters is simply driven by competition between the critters for food, and the food does not evolve.

For the second version, I wanted the critters to eat each other in the hopes that this would drive critter evolution naturally. My thought was that the evolution of predators should drive the evolution of natural defenses, which should in turn drive smarter predators.

Additionally, I planned for the "critters" in MicroPond V2 to develop a richer instruction set. While one goal I had for MicroPond V1 was to create an evolving ALife simulation that could be understood by a non-programmer, I hoped for more interesting instruction sets to evolve in V2. In V2, some instructions map to segments, while others do not. For example, while there's a Photosynthesize instruction that maps to a green pixel, an Eat instruction that maps to a red pixel, there are other instructions that don't map to segments at all.

One problem I faced was coming up with an "attack" instruction that allowed for intelligent strategies to develop. If you can't defend yourself from attack, there's no need for much intelligence on the part of the attacker or prey. My solution was this: a critter gains energy each turn for every exposed Photosynthesize instruction (a green pixel), but the Photosynthesize instruction leaves a critter open to attack. Normally one critter cannot move on top of another, but if a critter attempts to move over another critter's green/photosynthesize segment, it will eat the critter.

One defensive strategy is for a critter to curl up around its photosynthesize instruction, so no part is exposed. Colonies also form, which provides lesser protection.

There are three territories in MicroPond V2: a shaded center square in which photosynthesis operates at reduced efficiency (every time a Photosynthesis instruction executes inside the center square it produces a third of the energy compared to elsewhere), a small square in the lower left that contains randomly placed gray obstacles, with a solid wall on its right side, and the remaining area which is unobstructed and photosynthesis runs at full efficiency.

Also, MicroPond v2 is multithreaded, and so two separate "worlds" run simultaneously. There's no synchronization between the worlds, but it uses my dual-core process to good effect, and it's interesting to see how differently they can develop. I'm curious if this could be a useful metric for the "interestingness" of a particular simulation - let it run several times for a set number of turns and see how different the end result is between runs. Also, in a future version I'd like critters to migrate from one "world" to another.

Finally, there's a pretty nice close-up view in MicroPond v2 that shows the individual "critters", along with their head, orientation, and a bar of their energy level on the tail.

The program can be downloaded here:
http://www.badongo.com/file/9705866