Monday, February 18, 2008

Simulating Evolution

Am reading 'The Blind watchmaker' by Richard Dawkins. In one of the chapters he explains evolutions as cumulative selection. I wrote a simple java program which finally evolves a readable sentence in the end.

As you can see, it started as a random collection of alphabets. In each iteration only the sentence resembling the most to the desired sentence is selected and it breeds further.

Here the 'desired sentence' can be compared to the most fit characteristics for the environment and only the most fit candidate will be successful in passing his/her genes!

0 : iyrqqqouhwmmqksoqwzfgzercqnwbp v
1 : azxzcoyhawkhldielwjvwvnivhfpokz
2 : ualrpeov sdqvxficjy bxbni htrqwz
3 : calviso usiuoafic kflfnimhtxfbv
4 : waspi owgpwjgpfic oyfitniyhtnkrh
5 : manarvozeotgarfic fsuycnightcorc
6 : hanwojomeutoahfic ls yrnightvurh
7 : yanielogektfadfic fs psnightuurv
8 : ranpmlodeht aafic ns xwnightaqrn
9 : aanntlolebtsapfic hs vjnightwcrq
10 : ganeoloreutoaffic hs ainightvxrv
11 : wanfrloreltoaffic xs aqnightdurk
12 : eanq lorewtmaffic is aqnightbarn
13 : uanlllorevtfaffic is aonightgarp
14 : panahlore tzaffic is arnightuarc
15 : banadlore tcaffic is acnightbarg
16 : bannolore tsaffic is acnightjarc
17 : banptlore traffic is afnightearz
18 : banxplore traffic is arnighteark
19 : ban slore traffic is ajnightzarb
20 : banphlore traffic is aqnightaara
21 : banyalore traffic is alnightaare
22 : banlalore traffic is acnightaare
23 : banralore traffic is asnighteare
24 : banvalore traffic is aqnightmare
25 : banxalore traffic is abnightmare
26 : bancalore traffic is annightmare
27 : bangalore traffic is a nightmare
28 : bangalore traffic is a nightmare

No comments:

Google