Darwinbots Forum

Bots and Simulations => Simulation Emporium => Topic started by: ikke on June 05, 2008, 08:39:10 AM

Title: my first evo sim
Post by: ikke on June 05, 2008, 08:39:10 AM
Just wanted to share some of my first experiences with the community, so here it goes.

My intention was to get an evo sim going with predator and prey coevolving in a predator prey cycle without external interference like constant energy (day night) or polulation caps (max veggies, costX). I started with just a veggie (runaways) and set the physics and cost. I adjusted the nrg influx so that the veggie population barely survived the first reproduction cycle, figuring that if the veggies would get more than that they swould have conquered the world already. Next I added the predator(animalis minimalis) in a 1:10 ratio. The sim busted for several repeatedly for several reasons:
1) no variance in population:  predators and all prey each started all having the same parameter values: age, energy and body of each individual in the population were the same. This meant that every so much cycles the prey would reproduce all at once, peaking its population. I tried to solve this by adding some randomness to the prey reproductive gene, but that wouldn't help me at start up. Secondly the predator would reproduce sucessfully but its offspring would not survive food competition. The original predator population grew old and died without leaving sustainable offspring. A decent age build up would have prevented that
2) predator and prey were both dumped with in an environment. They hadn't coevolved with each other in this environment. Basically I dumped an alligator and a penguin in the desert and was waiting for predator prey cycle. What are the chances of that happening?

So I gave up and added caps: CostX for the predator, constant system energy for the prey. A minimum veggie population above the starting population increasing by 1 every cycle, to get a more even prey population build up, adding predators manually for the same reason. CostX screwed up my minimal energy balance of prey, so I upped the nrg/turn. This resulted in the working sim attached

The first muation to catch on was collision avoidance: dont up the speed for distance <6, which makes sense in the elastic collision sim. At first I thought the gene was degrading, so I reran with both the original and the mutation. The mutation would replace the original every time. Another was conditional rotation: rotate small angles with targets in sight, otherwise large. A third was to travel if no food was available as opposed to waiting and starving. All clear energy aquiring or saving mechanisms. I have to admit after that the genes have become too obscure for me to identify improvements beyond that.
One mutation I was expecting but which did not appear for considerable amount of time was higher survival of offspring. Amimalis give 10% to offspring, which leads to high infant mortality (8-9 average offspring) in the environment. A mutation on this point could take over quick.

I have observed a number of things in the sim:
1) Since animalis genes are all functional neutral or positive mutations usually start within randomness or at the end of a gene. A future experiment of mine is to duplicate all genes and re-run. Is the species with all genes double stronger (better resiliance when mutating) or weaker (killer breakdowns occur more often)?
2) once on a while the number of subspecies collapses. Population of predators noramally ranges beteen 180 and 220, so I don't see mass extinction as the cause. I think it is a more adapted subspecies taking over at the expense of population diversity. I wonder what impact sexual reproduction would have on stability of species diversity.
3) best mutations don't occur first. Open door of course, since mutations are random, but I was waiting for infant mortality to come down by an improvement in the reproduction gene, and all kinds of things happened, but not that.
Title: my first evo sim
Post by: EricL on June 05, 2008, 11:05:55 AM
Quote from: ikke
2) once on a while the number of subspecies collapses. Population of predators noramally ranges beteen 180 and 220, so I don't see mass extinction as the cause. I think it is a more adapted subspecies taking over at the expense of population diversity. I wonder what impact sexual reproduction would have on stability of species diversity.
Cool sim.  The above is especially interesting to me.  As you describe, one would expect to see a reduction in diversity following fixation of a new adaptation.  Fixation perhaps isn't the right word for an asexually reproducing species, but the diversity dropping is key.  Would love to see the graph.   I'll try to get the genetic distance graph working right soon so we can see that as well.

FYI, I'm not sure how the subspecies graph handles sexual reproduction.  It may become meaningless for a sexually reproducing species.
Title: my first evo sim
Post by: ikke on June 05, 2008, 12:07:34 PM
Quote from: EricL
Cool sim.  The above is especially interesting to me.  As you describe, one would expect to see a reduction in diversity following fixation of a new adaptation.  Fixation perhaps isn't the right word for an asexually reproducing species, but the diversity dropping is key.  Would love to see the graph.   I'll try to get the genetic distance graph working right soon so we can see that as well.
here you are
Quote from: EricL
FYI, I'm not sure how the subspecies graph handles sexual reproduction.  It may become meaningless for a sexually reproducing species.
Ultimately, with enough gene combinations possible, it should show each individual is unique. You'd have to track gene diversity (how much variants are there of a given gene) within the species.[attachment=953:diversity.bmp]
Title: my first evo sim
Post by: EricL on June 05, 2008, 12:35:40 PM
Took a look at the code.  Offspring of sexual reproduction inherit their mother's subspecies number and crossover alone does not modify it.  Thus, baring a reproduction time mutation, the act of sexual reproduction will not create a new subspecies even though the genome may differ from both the parents due to crossover.  This means that (ignoring viruses) a non-mutating sexually reproducing population will all be of the same subspecies.  Note that there can still be diversity within the population due to sequence alleles.  One would need to bootstrap this, say with different genomes for the starting male and female bots at sim startup time, but after all the original males pass away, all the extant bots should have the same subspecies number in a non-mutating sim even though they may differ in genome.

This is good news to me at least in that it means the subspecieis graph has meaning for sexually reproducing sims.  It won't show diversity due to sequence alleles, but it will give you some idea as it does with asexual sims on the diversity within a species due to mutations and the extent to which such mutations have/are fixating.
Title: my first evo sim
Post by: Numsgil on June 05, 2008, 02:24:14 PM
Cool sim!  It's sometimes hard to find a mutation that can out compete the original, so I applaud you
Title: my first evo sim
Post by: ikke on June 06, 2008, 02:27:45 AM
A major shift occurred last night: average costX increased from 6 to 12. What happened? Purple shots, not red? Predator genome:
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']'''''''''''''''''''''''  Gene:  1 Begins at position  1  '''''''''''''''''''''''
 cond
 *.eye5 6 !~=
 *181 -565 sgn 9 dist *.refeye *.myeye !=
 start
 *.refveldx 4 54 *.refvelup pow floor store
 .up inc
 stop
''''''''''''''''''''''''  Gene:  1 Ends at position  23  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  2 Begins at position  24  '''''''''''''''''''''''
 cond
 *.refypos *.eye5 44 >
 pyth *.refeye *.myeye !=
 start
 %=
 dup inc
 pow dist xor
 312 -6 .shoot store
 *.shflav 385 -52 !=
 *.refvelup .up store
 dec
 pow -206 * or

''''''''''''''''''''''''  Gene:  2 Ends at position  55  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  3 Begins at position  56  '''''''''''''''''''''''
 cond
 *.eye5 0 =
 start
 *.myeye div 1099 .aimright store

''''''''''''''''''''''''  Gene:  3 Ends at position  65  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  4 Begins at position  66  '''''''''''''''''''''''
 cond
 *.nrg 25075 >
 start
 .repro store
 xor
''''''''''''''''''''''''  Gene:  4 Ends at position  73  '''''''''''''''''''''''
Title: my first evo sim
Post by: Numsgil on June 06, 2008, 02:29:46 AM
Oh, that's really, really cool.  They learned how to body feed instead of nrg feed.
Title: my first evo sim
Post by: ikke on June 06, 2008, 02:50:35 AM
Quote from: Numsgil
Oh, that's really, really cool.  They learned how to body feed instead of nrg feed.
What is the advantage there?
Title: my first evo sim
Post by: Numsgil on June 06, 2008, 01:53:09 PM
The bot is feeding from its preys' body instead of nrg.  Body holds 10 times as much nrg as raw nrg does, so as long as its preys' nrg is less than ten times its body, it's a more efficient way to feed (they can extract more nrg).
Title: my first evo sim
Post by: ikke on June 08, 2008, 03:51:35 AM
Quote from: ikke
2) once on a while the number of subspecies collapses. Population of predators noramally ranges beteen 180 and 220, so I don't see mass extinction as the cause. I think it is a more adapted subspecies taking over at the expense of population diversity.
Now I think the driver here can also be local extinction. In one area food prey is no longer available so the subspecies living there go extinct while other areas with abundance keep the total population relatively constant
Title: my first evo sim
Post by: ikke on June 10, 2008, 10:27:24 AM
Update @ 5.8M cycles: so far algae genome length has grown form 22 to 29. To me this means the algae genome is more or less stable, with little or no founctionality added. On the other hand animalis genome has increased from 56 to 132. The longer genes must have some function, since they have been selected. No idea what though. Bonus points for the one who explains them to me...
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']'''''''''''''''''''''''  Gene:  1 Begins at position  1  '''''''''''''''''''''''
 cond
 *.eye5 -5 !~=
 =
 1 ceil *883 mult drop *181 *.refeye *.myeye <
 start
 dec
 swap store
 pyth store
 -553 *.refveldx .dx store
 .up inc
 angle dec
 angle true
 add abs not
 store
 dropbool
 angle *-626 rnd inc
 - floor -795 | *877 * inc
 *1304 dupbool
 or
 ^ store

''''''''''''''''''''''''  Gene:  1 Ends at position  51  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  2 Begins at position  52  '''''''''''''''''''''''
 cond
 drop pyth 1062 *.shflav *-92 *-106 true
 inc
 >> mod *.eye5 50 >
 dec
 store
 mod *294 pow *.refeye *.myeye !%=
 store
 start
 %=
 xor
 -6 .shoot store
 ceil 1332 *.shflav 385 -62 !=
 *.refvelup .up store
 dec
 *102
''''''''''''''''''''''''  Gene:  2 Ends at position  91  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  3 Begins at position  92  '''''''''''''''''''''''
 else
 sgn abs -- ceil xor
 *28 !~=
 ^
''''''''''''''''''''''''  Gene:  3 Ends at position  100  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  4 Begins at position  101  '''''''''''''''''''''''
 start
 .eye6width inc
 *.eye5 =

''''''''''''''''''''''''  Gene:  4 Ends at position  105  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  5 Begins at position  106  '''''''''''''''''''''''
 start
 *.myeye 1169 .aimright store

''''''''''''''''''''''''  Gene:  5 Ends at position  110  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  6 Begins at position  111  '''''''''''''''''''''''
 start

''''''''''''''''''''''''  Gene:  6 Ends at position  111  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  7 Begins at position  112  '''''''''''''''''''''''
 start
 61 *.nrg 25075 >

''''''''''''''''''''''''  Gene:  7 Ends at position  116  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  8 Begins at position  117  '''''''''''''''''''''''
 start
 .repro store
 dec
 mod sqr swapbool

''''''''''''''''''''''''  Gene:  8 Ends at position  123  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  9 Begins at position  124  '''''''''''''''''''''''
 else
 dec
 *-543 inc
 dist sqr *404 xor
 stop
''''''''''''''''''''''''  Gene:  9 Ends at position  132  '''''''''''''''''''''''
 inc
Title: my first evo sim
Post by: Numsgil on June 10, 2008, 02:10:28 PM
That genome is officially at the point where it is difficult to decipher by hand.

BTW, what sort of mutation are causing the genome to increase in length?
Title: my first evo sim
Post by: ikke on June 10, 2008, 02:52:20 PM
I changed the numbers for the insertion to 1 3 5, standard deviation 1 (same as major deletion). Odds still favour genome length going down. This is due to the probability of a minor deletion, where no minor insertion exists.
Title: my first evo sim
Post by: ikke on June 23, 2008, 09:00:44 AM
Passed 10 M cycles (~60.000 generations). No new major changes observed, so I stopped the sim. It's like watching grass grow. No new huntig tactics, no improved eyesight nothing of the sort. Probably more improvements in the existing genes than I identified, but nothing new. Now I now why it 3 billion years befor the cambrian explosion took place, and why so many genes can be traced back to the explosion: truely new genes take a looong time to develop.

I programmed some of the evolved characteristics in the original bots and restarted. One thing I hadn't noticed: the reproductive genes have become less fragile. The original cond statements are barely recognisable after 10 M cycles. The new code is definitely functional. The original code breaks quite often, resulting in an explosion of bots dividing and dividing. In the evolved versions this is gone, mutations don't result in the same breakdown. No idea how. Another point is that not every mutation is an improvement. Somewhere along the line animais stopped rotating when seeing his own species. You can often see pairs of animalis endlessly looking in each others deep blue eyes. Not an optimal hunting strategy, but either coincidence or the development of some other improvement made this strain dominant.

Next step: a death match between evolution and ID: will the evolved strains outcompete the GM versions?
Title: my first evo sim
Post by: Peksa on June 23, 2008, 01:23:15 PM
Quote from: ikke
Passed 10 M cycles (~60.000 generations). No new major changes observed, so I stopped the sim. It's like watching grass grow. No new huntig tactics, no improved eyesight nothing of the sort. Probably more improvements in the existing genes than I identified, but nothing new. Now I now why it 3 billion years befor the cambrian explosion took place, and why so many genes can be traced back to the explosion: truely new genes take a looong time to develop.

I programmed some of the evolved characteristics in the original bots and restarted. One thing I hadn't noticed: the reproductive genes have become less fragile. The original cond statements are barely recognisable after 10 M cycles. The new code is definitely functional. The original code breaks quite often, resulting in an explosion of bots dividing and dividing. In the evolved versions this is gone, mutations don't result in the same breakdown. No idea how. Another point is that not every mutation is an improvement. Somewhere along the line animais stopped rotating when seeing his own species. You can often see pairs of animalis endlessly looking in each others deep blue eyes. Not an optimal hunting strategy, but either coincidence or the development of some other improvement made this strain dominant.

In every sim I've run or read about (except internet mode), eventually de-evolution has overcome evolution as has happened with your animal minimalis. Solutions to this could be increasing population size to thousands, decreasing mutation probabilities (to something like 1/8 or less of default settings, probably) or provide strong enough evolutionary pressure by competition or shepherd bots or some other way. Sexual reproduction also helps, but in my sims it has been replaced by faster asexual reproduction. It has taken some time though.

Quote from: ikke
Next step: a death match between evolution and ID: will the evolved strains outcompete the GM versions?

I'd like to know the results of this. It's quite usual for the evolved strain to be less fit, but more resistant to mutations. See survival of the flattest (http://www.spacedaily.com/news/life-01z.html).
Title: my first evo sim
Post by: Numsgil on June 23, 2008, 05:37:28 PM
Did they ever learn to eat each other?

Evolution is really lazy.  Once it gets to a point where quick and easy adaptations have all been done, you'll usually plateau.  I'm sure there's some neat word for this idea, but I don't know what it is.  The only way to get runaway adaptation, where there's that slow and steady fitness increase, is to have a Red Queen's Race (http://en.wikipedia.org/wiki/Red_Queen) sort of situation.  Not sure how to set one up, though.
Title: my first evo sim
Post by: Numsgil on June 23, 2008, 06:53:21 PM
Another thought occurs to me as well.  They might be evolving all sorts of neat things, but if we can't figure out their genome, we can only look for changes in phenotype.  It's very hard to see a difference in speed between 20 and 15, for instance.
Title: my first evo sim
Post by: ikke on June 24, 2008, 03:47:30 AM
Quote from: Peksa
In every sim I've run or read about (except internet mode), eventually de-evolution has overcome evolution as has happened with your animal minimalis.
I'm not so sure if this is a proper way of phrasing what happened. Evolution is not survival of the fittest, it is survival of the least unfit. A strain can survive negative mutations if they are offset by positive ones. A strain doesn't have to be optimal, better is enough.
De-evolution  would imply that the 7M cycle strain would outcompete the 10 m cycle strain in a death match. I haven't tried
Quote from: Peksa
Solutions to this could be increasing population size to thousands, decreasing mutation probabilities (to something like 1/8 or less of default settings, probably) or provide strong enough evolutionary pressure by competition or shepherd bots or some other way.
The animalis population was set at 200 by costX and varied between 150 and 250 max. Mutation settings were at 1. The major random factor hindering ''optimal selection'' was food availability. Algae distribution was not uniform. A strain in a rich part can replace a strain in the poor part. C' est la vie.. On the other hand I have a suspicion (anecdotal observations, not  traced back into the code) that at least sometimes reproduction was postponed untill food was available. This would imply adaptation (or selective observation on my part of course  )

Quote from: Peksa
Sexual reproduction also helps, but in my sims it has been replaced by faster asexual reproduction. It has taken some time though.
This is on my original to do list: death matches between otherwise equal sexual and a-sexual strains. The main problem is they only differ in the way they handle mutations, and a large number of replications is probably needed. I need to figure out how to set up my own little evo league and have a lot of patience..

Quote from: Peksa
I'd like to know the results of this.
Will do..
Quote from: Peksa
It's quite usual for the evolved strain to be less fit, but more resistant to mutations. See survival of the flattest (http://www.spacedaily.com/news/life-01z.html).
To me fitness is defined as the ability to create offspring that survives, not fast reproduction. Allthough I haden't recognised it as a selection criterion, resiliance in the face of mutations is a part of what I would consider fit.
Title: my first evo sim
Post by: ikke on June 24, 2008, 04:09:34 AM
Quote from: Numsgil
Did they ever learn to eat each other?
No. My problem: I can't distinguish between it ever evolving and being selected against, or never being tried. There is a big difference...
Quote from: Numsgil
Evolution is really lazy.  Once it gets to a point where quick and easy adaptations have all been done, you'll usually plateau. The only way to get runaway adaptation, where there's that slow and steady fitness increase, is to have a Red Queen's Race (http://en.wikipedia.org/wiki/Red_Queen) sort of situation.  Not sure how to set one up, though.

This probably the difference between optimising / fine tuning current genes as opposed to developing truely new ones. I think that within my current genepool animalis and runaways have co-evolved most improvements. Runaways have to evolve new things (shell, poison, eyesight&evade, whatever) before animalis can react. As said I am starting to see why it took 3 billion years before the cambrian...
Quote from: Numsgil
Another thought occurs to me as well. They might be evolving all sorts of neat things, but if we can't figure out their genome, we can only look for changes in phenotype. It's very hard to see a difference in speed between 20 and 15, for instance.
My do they sometimes delay reproducing untill they are feeding definitely falls in this category. I know they delayed reproducing, the > nrg condition had been met. Was it a coincicence they were feeding when finally reproducing? No idea.
This is as far as I am concerned the major challenge in the develop conditional bots form zerobots contest. Not the development itself, but recognising them when they have occurred.
Title: my first evo sim
Post by: ikke on July 16, 2008, 07:11:29 AM
As promised feedback on the death matches. That did not turn out the way I thought it would. Basically a fair evaluation is not possible. Startup conditions are nothing like the steady state, due to differing body sizes. The GM version outcompetes the evolved strain, but since the environment is not what the evolved strain is used to this means nothing. Inversely and equally invalid is dumping the GM version in the steady state environment in which the evolved version grew. With default body sizes competing against the large, mature evolved strain in not possible.

As a spin off I have investigated death matches between equal strains. With the rules I have one strain outcompeting the other in 30k-60 k cycles @ 200 individuals per strain. This seems to scale to the root of the population sizes, and proportionally to ageing cost. I had intended to evaluate genome evolutionary strength and adaptability between strains, but this does not seem feasable as one strain dies out before any meaningfull number of mutations occur.

One last comment on the sim: both the evolved and the GM versions of predator and prey are capable of coexisting without using dynamic costX. My penguin and my alligator have evolved to form an ecosystem in my desert.
Title: my first evo sim
Post by: Endy on July 17, 2008, 12:42:46 AM
I normally just use evolution to look for "improved" dna I can make use of in a standard bot. You can't take this too far though, since alot of the improvements evolution comes up with won't be useful in a normal F1 match.
Title: my first evo sim
Post by: Numsgil on July 17, 2008, 01:18:47 PM
I don't think it's easy or maybe even possible to evolve a strain to do well in F1.  At least not with present methods.  F1 is an extremely artificial starting point, with robots evenly distributed and all with the same amount of nrg.  The only way to do it would be through something like a genetic algorithm: have the program take a zero bot, run it against a successful F1 bot, create some mutated children, run those against the successful F1 bot.  Mate the bots that live the longest (or kill the enemy in the shortest time once you get that far), and repeat until you get a bot that is good against that F1 species.  To program something like that DB would need to be automatable, so you could set it up and let it run over a few weeks.  But you're almost guaranteed results.