Author Topic: Mutation Sims  (Read 35463 times)

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« on: April 12, 2005, 01:53:02 PM »
Following Nums' advice I decided to share some of my experience in running evolution sims that actually get some positive results.  It does not imply that this is the only way to do it, just one of them.  Besides, the approach will be different depending on your starting bot, your goals and other stuff.

I wanted to evolve a bot that can live on variable-in-abundance food source in large, high-friction environment.

My veggie was Alga Grexa, which runs around and follows any bot that it meets.  As a result they tend to accumulate in groups of 2-5 and run in circles.  This also means that they will survive well in places with low number of predators, multiply and then spread through the field.

My starting bot was Dominator Invincibalis.  Simply because it already had two essential features that a bot needs to survive in environment I wanted to create: it waited until food came to it and it was very good at killing the food.  It also did some other things, but that was not important.

Important things to consider before you start (run sample sims to figure these out):

1. Sim size.  It should be fairly large, because you need a lot of bots for evolution and that means you need a lot of space.  But very large sims result in pretty large variation in your population (until bots are adapted).  I started with size 5.

2. Energy input.  This is very important!  It should be barely enough for bots to survive, but it should not be too low to result in random "dying out".  Run several sims until you get reliable "predator-prey cycles" - your predator population should go up and down in more or less evenly spaced cycles.  The lowest number of predators in these cycles should not get below 25-30, or you'll get "dying outs".  Cycling between 50 and 150 is good.  Try to set "repopulate veggies" value as low as possible, and not to reseed too many veggies (and not to give your veggies too much energy).  If your "predator-prey" cycles are following the "reseeding" cycles, then you are doing something wrong!

3. Mutation rates.  These will depend greatly on DNA size of your bot.  For bots with short genomes mutation rates should be higher, with long genomes - lower.  If you are not sure, always go for lower rate!  My starting bot, DI, had ~ 400 DNA commands and I set all mutation rates to 25000 and that worked fairly well.  Mutation rate of mutation rate..  I don't think this is important.  I had it disabled completely.

4. Friction.  I wanted to adapt bots to friction.  You may go for something else.  Advice here is: Be patient. Don't start with very harsh conditions right away.  I set my initial friction to .3, because from sample sims I could see that DI still survived at that friction.  Then later I adjusted the slider higher and higher but very slowly, by about .01 every 2 million cycles.  Simultaneously I raised the energy input, because moving in higher friction would require more energy.

OK, now you are ready to start the sim!  Start it and open "Population" and "Average mutation" graphs.  Turn off the visual output and let simulation run.  Keep an eye on the graphs.  You should see cycles in population and slow, very slow rise in "average mutation".

Interpreting "Average mutation" graph: It is not as easy as it may seem.  Your average mutations will always go up over long periods of time.  It does not indicate that your bots are actually adapting, it may simply mean accumulation of neutral mutations.  One good way to distinguish "neutral" from "good" mutations is to look at the graph: "neutral" mutations will result in "Average" going up and down erratically, while "good" mutation results in slow but steady increase.  

Tracking the adaptations: Every now and then (1-2 million cycles) stop the sim and make a snapshot of your population (or just pick a random bot).  Choose the DNA that is the most frequent and compare it to the parent (I do that in Excel).  Highlight somehow the places where changes have occured.  Save.  Repeat.  After some time you'll see that some mutations persist - these are likely to be "good" mutations.  Don't start a new sim with only the new mutant bots!  Your best chance to get adaptations is to keep the whole population!  Just let the program run for as long as your patience allows you (and then a bit longer).  You can always go back to your saved sequences if you have to.  If your program crashed, or you had to reboot then it is fair game to take the latest mutant and start new simulation only with it.  BUT BEFORE YOU DO THAT:

Make sure your evolution is going the way you want: Before you start a new sim, take you parental bot (the one you started with) and put it in competition with your latest mutant.  If your mutant wins (or at least stays even) then all is well, keep mutating.  If your mutant bot is losing, then something is wrong, and you need to start over. :(  The easiest way to remedy that is to reduce you mutation rates even further.

Well, that is about all.  Ask me question if you have them!
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Mutation Sims
« Reply #1 on: April 12, 2005, 02:01:05 PM »
Could you please post "Alga Grexa" to the beastiary. A lot of members may not have it.
Put it in the "Veggies" sub forum and if you like also post it to the "Interesting behaviour bots" sub forum
« Last Edit: April 12, 2005, 02:01:34 PM by PurpleYouko »
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Light

  • Bot Destroyer
  • ***
  • Posts: 245
    • View Profile
Mutation Sims
« Reply #2 on: April 12, 2005, 03:14:03 PM »
I allways thought mutating highly tuned bots would result in them getting weaker, what sort of results did you get mutating Dom inv?

Offline Shen

  • Bot Destroyer
  • ***
  • Posts: 111
    • View Profile
Mutation Sims
« Reply #3 on: April 12, 2005, 03:25:26 PM »
Agreed Light. I always mutate simple bots and change the enviroment to see how it affects them.

Also shvarz do you actually have a working database and snapshot feature? I can never get it working. 'File Error 52' :(
« Last Edit: April 12, 2005, 03:26:00 PM by Shen »

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« Reply #4 on: April 12, 2005, 03:41:47 PM »
Well, "highly tuned" is a relative thing.  What is good in one environment will suck in another environment.  Dom.Inv. was not perfect in sim with a high friction, so there was room for improvement.  And it improved.  In addition, it had several genes that were designed for F1 conditions - to fight attacking bots.  These genes became useless in my sim (there was no one to fight), so they served as "junk DNA", something that bot can mutate and maybe make use of.

Snapshot feature does not work right now.  I just use "find best bot" feature, take their DNA.  This is not a big problem when mutation rate is low.

One interesting thing I noticed that DomInv never turned cannibalistic (a huge problem with evosims, as we all know).  I have some ideas why that might be, but I'll try to test them first, then post them.  I think it has something to do with environment, not with bot.
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« Reply #5 on: April 12, 2005, 03:50:44 PM »
Look in the attached file for the example of "predator-prey" cycles.
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Shen

  • Bot Destroyer
  • ***
  • Posts: 111
    • View Profile
Mutation Sims
« Reply #6 on: April 12, 2005, 03:56:24 PM »
Recently Ive had a new approach to the cannibal problem of evosims. Just accept that your bots will probably at some point start eating each other and look at it another way.

Really we dont care if bots eat each other, we care if parents eat there kids. So instead of a conspec avoid gene I just set a timer of 50 cycles that ran when a bot was born and when a bot gave birth. The timer made them flee other bots but only for that short period the timer was running. The interesting thing was that, unlike conspec genes, the kid protection genes never devolve. In fact having such a hostile sim where its a Bot Eat Bot world they tended to evolve the genes to flee from any bot all the time and just eat alga.

Edit: an example of cyclic growth just to backup shvarz :P
« Last Edit: April 12, 2005, 03:59:52 PM by Shen »

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« Reply #7 on: April 12, 2005, 04:38:42 PM »
Actually, I noticed that our two graphs are quite different - you have more veggies than bots, me - more bots than veggies.  Probably due to the fact that I started with a very efficient bot and you are evolving from scratch.  My only concern is that your bot's population may drop so much that it results in Mueller's ratchet...
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Shen

  • Bot Destroyer
  • ***
  • Posts: 111
    • View Profile
Mutation Sims
« Reply #8 on: April 12, 2005, 05:53:43 PM »
What do you think the lower limit for number of bots is? I try to get a range of 25-100 in size 4 fields and never really goes lower than that.

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« Reply #9 on: April 12, 2005, 06:02:45 PM »
That is good.  I think if it starts to go below 25, then it is not too good.  But then again if your mutation rates are low enough so that bots simply cruise through this tight spot without losing much fitness, then that works too.
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Mutation Sims
« Reply #10 on: April 13, 2005, 03:07:17 AM »
Schvarz, alot of what you do seems alot of work.  Are there any kinds of macros or anything like that that you'd like to be included in the program to speed up the process?

Maybe some kind of statistical check on the snapshot DNA.  Some way to highlight modified DNA between a distant offspring and the parent?

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« Reply #11 on: April 13, 2005, 11:02:56 AM »
It would be nice.  Actually most of the work is to figure out the correct starting conditions.  After that PY's snapshot analyzer (excel sheet) works very nicely in figuring out the most common genotype.  And once database recording and scripts are working, this will be even easier.

One thing that may help though is some way to get a sense of frequency of mutations for a given bot expressed in a form of: "One in N offsprings will be mutated, out of those mutations x% will be insertions, y% deletions and z% substitutions."  Some kind of routine that uses the current mutation values, compares them to DNA of your bot and calculates those frequencies.  Alternatively, we can have N, x, y, z to be set up by user and those would automatically adjust the (somewhat criptic) mutation rates values.
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Mutation Sims
« Reply #12 on: April 17, 2005, 12:14:04 AM »
I think evolution tends to conserve the stuff we add when it is vital to the current sim. I added code that checks that refage and robage are greater than 0, prior to firing. The bots, even Canni's, never stoped using it, providing mutation rates/nrg levels were bearable. Evolution "wants" at least some children to survive, but has to make do until a better method evolves.

Most Canni's seem to occcur whenever food is scarce, caused by either over population or actual lack of food. The continual shooting variety are interesting, since as population drops, the bot's fitness decreases allowing normal bots to increase in numbers.

What is so bad about Mueller's Rachet? It seems to speed evolution more than hurt it, since only the best normally survive the harsh periods.

Endy B)
« Last Edit: April 17, 2005, 12:15:58 AM by Endy »

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Mutation Sims
« Reply #13 on: April 17, 2005, 12:37:10 AM »
Mueller's ratchet is bad because any small number of bots is likely to have some bad mutations.  Without competition from good mutants these bad mutations will be passed to future generations.  If you repeat the situation several times in fast succession, it is bound to reduce the overall fitness of population.

Just google it if it is still not clear...
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Mutation Sims
« Reply #14 on: April 17, 2005, 03:30:09 AM »
What about if we post the type of behaviors the bots evolve with the different settings? This way we can make bots already evolved to that type of sim. Since the Dna just defines a type of behavior, making a similar species should be possible.

Endy B)