Author Topic: my first evo sim  (Read 8751 times)

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« 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.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
my first evo sim
« Reply #1 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.
Many beers....

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #2 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]
« Last Edit: June 05, 2008, 12:08:52 PM by ikke »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
my first evo sim
« Reply #3 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.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
my first evo sim
« Reply #4 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

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #5 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  '''''''''''''''''''''''

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
my first evo sim
« Reply #6 on: June 06, 2008, 02:29:46 AM »
Oh, that's really, really cool.  They learned how to body feed instead of nrg feed.

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #7 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?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
my first evo sim
« Reply #8 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).

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #9 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

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #10 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

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
my first evo sim
« Reply #11 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?

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #12 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.

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
my first evo sim
« Reply #13 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?

Offline Peksa

  • Bot Destroyer
  • ***
  • Posts: 118
    • View Profile
my first evo sim
« Reply #14 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.