Validation (9) XML (9) Geeky (3) Java (3) Android (2) Business IT (1) Chromecast (1) Devfest (1) Web (1)

Sunday, May 23, 2010

Evolution, fun with genetic algorithms

Try Evolution...  download or run directly the Evolution's executable JAR

When I was young and I got my first computer one of the thinks what fascinated me was the Convey's game of Life. I could stare at the screen for hours watching the swarming pixels/cells. I spent hours and days programming the game with different initial conditions to see how do they afect cells ability to survive. I also challenged different cells' races to compete. And finally a have created a "Gods" user interface (GUI) to allow me to iterfere into the runnig games using several tools e.g. antibiotics, heat, nutrific dilusion etc...
Once in a while there is a time in developers every day life when he needs to return into the childish dreams and write somethink what has just one sence: pleasing the developers sole. Evolution is exactly this kind of think. It uses simple genetic algorithms to simulate evolution of a bug race in an artificial world with few simple physical laws.
Bugs can turn around and move forward and backward. They can also eat, sleep a mate. What a Life! Their behaviour in differnt situations is determined by their genome which basically maps bugs sensations to different action. A bug can see objects located in his current direction up to a certain distance. They know the distance from the particular object and they recognize certain objects as food, other bugs, empty field and world edges. Apart from simple vizion bags have also a another sence, the hunger. They can dramatically change their behaviour in case they are hungry.
Bugs can eat flowers. There are to kinds of flowers in current evolution's implementation. One of them uses vegetative reproduction and the other uses seats which can be transported across far distances before rooting. The second flower type is especially useful in the case when bugs are over-populated. The ability to colonize far distances gives them a better chance to survive and therefor it keeps the system better balanced as flower are harder to be eat up. This is especially important as bugs don't have any natural enemies (they'll come in the next version :)).
In the begining a certain number of bugs with rundom genoms is generated. Most of them die very soon. They don't have abilities to survive even in an environment full of flower to eat. Most of them don't know that flower should be eaten and other bugs mated. Such errornous genom disappears quickly. But the few survivals aren't much better off. Their strategies are mostly very wiered. Some of them move mostly backward, some are trying to copulate all the time no matter there is no-one around, some are sleeping unless they are neerly starving to dead etc...
Thanks to the evolution principal the inefficient strategies are gradually replaced by the more efficient onese. In the beginning the system is quite unstable. Some characteristics can quickly became dominant as reproduction which leads to lack of food which causes mass die outs and dramatic population shocks. After few hours you can watch a new quality emerging. The strategy of those late bugs' generations is analogical with farming. Bugs govers their small pieces of land by harvesting flowers in there neighbourhood. The flower as well as the bug population stays relatively stable in a long-term period.
But of course every Evolution's run is unique. As mutation occure rarely the random genom generation in the begining can determine the population's characteristic behaviour for many generations in advance. So the previously described emerged strategies are based just on a small number of my personal observations.
I have run Evolution for several days and did not experience any bugs' attempt to communicate with me. I was expecting shapes or even whole messages eaten out in the flower fields but unfortunatly nothing happened. Everyone can try out Evolution by downloading and running this jar file. If anyone is interested in the source code, please send me an emails.

1 comment:

  1. A Scale Free Evolution Strategy I devised:!topic/