This processing applet is my first attempt to create a Cellular Automata. The CA, called Blubbs, are each represented by an ever growing and fading colored ellipse. A Blubb contains 'genetic material', which is stored as a color value. A Blubb's genetic color value is used as its display color, and the color inverse as its outline. As the Blubb ages, it gets larger and moves faster (a random walk) until it either dies of old age or encounters another Blubb. When two Blubbs encounter they examine one another's genetic material to find if the other would be a suitable mate. If so, they move towards each other. Otherwise, they repel. Blubbs' attractiveness to one another is based on an overall difference in color values. The formula is as follows:
Attractiveness(Blubb a, Blubb b) = | a's red - b's red | + | a's green - b's green | + | a's blue - b's blue |
The current threshold is Attractiveness > 200 attracts. If two Blubbs' centers collide, they mate by producing four offspring containing random compositions of the parents' genes. (e.g. if a pure red Blubb (with genetics of 255, 0, 0) encounters a pure green Blubb (0, 255, 0), each offspring has a 50% chance of having either 255 or 0 for it's red value, 50% of having 0 or 255 for its green value, and because both parents have 0 for their blue value, a 100% chance of having 0 for its blue value. The two parents die after mating and are removed from the simulation. By 'selective breeding', genetic diversity is rewarded by multiplicity of offspring with diverse color values. Genetic similarity is discouraged. Also, for each of the offspring's color values, there is a .5% chance that it will mutate to a random color. This may or may not benefit the organism, depending on the potential mates it encounters, but allows for randomness in the system. There are also a limited number of Blubb souls, and if two Blubb's mate while there are no souls left to give, the offspring are not introduced to the system, preventing overpopulation. The world that the Blubb's live in is an initial gradient containing all shades of gray (and therefor the potential for 2^24 or 16 million different Blubbs). Initially, 25 Blubbs are spawned by incarnating 25 random pixels into Blubb's with the pixel colors as the genetic material. If at any point all Blubb's die, the simulation is reset.
The source code is available here.