One of my better alife programs. Cambrium shows creatures crawling around the screen in search for food. The creatures are controled by a neural network and assembled out of parts.

This is the second version of Cambrium, an evolutionary simulation. The Cambrium world is a two-D world filled with little green plants that contain energy. Normally, gravity keeps the plants towards the centre of the world where there is most light and the grow best.

The interesting part starts with the animals that crawl around in the cambrium world. They are all circles with on the edges different body parts: eyes, moving tails, mouths and brain cells. The eyes peer in a direction and see colors, red, green and blue. The tails can move the animals forward. Mouths eat if they get into touch with food or even other animals. Body parts have inputs and outputs. How fast a tail moves depends on the input, while the three output of eyes depend on what colors they see. Body parts can be connected by simple formula's. Let's have a look at a typical animal in Cambrium world.

Here we see Adam (and his brother). Adam has two eyes on front, one to the left, one to the right and in between his eyes, two mouths. Adam also has three tails, middle, left and right. Now, the formula of Adams middle tail is:
RightEye.1*8 + LeftEye.1*8
Meaning, input 1 of RightEye (the green channel) times 8 plus input 1 of the LeftEye (also green) times 8. In other words, if Adam sees green, i.e. food, his middle tails starts to move, propulsing Adam in the direction of the food. His left tail and right tail are similarly configured, but depend only respectively on his Right Eye and Left Eye. So, if Adam sees more green in his Left Eye than in his Right Eye, his Right Tail will start to move faster than his Left Tail and Adam turns in the direction of the food. This also works of course the other way around.

What if Adam doesn't see any food? Here the Brain Cell comes in. Brain Cells can be added to animals to make intermediate calculations. With a couple of Brain Cells, it is possible to construct complete neural networks. Adams doesn't need that. Brain Cells calculate their output based on a formula containing inputs of other Body Parts (Eyes, Mouths or other Brain Cells), but also have a random component and a constant component. Adams brain cell has a constant output value of 1. Since his Right Tail is hooked to the green channel of his Left Eye and also to his brain cell, Adam will turn left just a little bit if he doesn't see any food, thus avoiding starvation while there is food in the other direction

Animals in Cambrium are saved in simple XML format. Let's have a look at Adam:

Simple enough, right? Maxenergy defines how big Adam is before he splits. The large integer for color is a three bytes integer defining the RGB value. Then there is a list of body parts. The type of tails is "engine". The phi factor defines where in radials this body part is placed on the body edge, while engines also have an angle, defining the angle the engine makes with the body. This determines whether the engines just pushes or also rolls the animal. Formula's are not as flexible as you'd maybe think. They have to be of the format BodyPart.Channel * Factor + X.

Some mutations take place when the animals split, but so far I haven't implemented mutations in the formula's and t hat is where it really gets interesting. I will though. But you can start now. The .exe and source are included in the archive below.

downloadable files: Source code and windows executable. Requires Delphi if you want to mess around with code.