Author Topic: First Evosim  (Read 6893 times)

Offline The_Duck

  • Bot Neophyte
  • *
  • Posts: 29
    • View Profile
First Evosim
« on: April 01, 2008, 12:34:30 AM »
Hi all,

I've started up my first real attempt at a long-term evosim. I'd appreciate any suggestions about parameters and such to encourage evolution.

Details:

-I am trying to evolve Animal Minimalis. Any other suggestions for a simple bot to evolve?

-The food chain is Alga Minimalis -> Animal Minimalis -> Shepherd bot.

-Sim size = 4

-The shepherd is handcoded, virus/mutation immune, omnivorous, and much better than Animal Minimalis; a cond for all genes is "*.totalbots *.totalmyspecies div 4 >" so that it hibernates when it is too large a percentage of the total population.

Shepherd code:
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']'all genes (except for birth-tie breaking) predicated on .totalbots / .totalmyspecies

cond
  *.robage 0 =
start
  .tie inc
  314 628 rnd add .aimdx store
stop

cond
  *.robage 1 =
  *.numties 0 > or
start
  *.tiepres .deltie store
stop

cond
  *.nrg 4000 >
  *.totalbots *.totalmyspecies div 4 >
start
  50 .repro store
stop

cond
  *.totalbots *.totalmyspecies div 4 >
start
  5 .up store
  *.nrg 4 div .strbody store
  *.body 2 div .fdbody store

  .shoot .vloc store
  0 .venval store

  *.velscalar 40 >
    314 rnd .aimdx store
stop

cond
  *.totalbots *.totalmyspecies div 4 >
  *.nrg 500 >
  *.venom 100 <
start  
  10 .strvenom store
stop

cond
  *.totalbots *.totalmyspecies div 4 >
  *.eye5 0 >
  *.refeye *.myeye !=
start
  *.refveldx .dx store
  *.refvelup 80 add .up store
  *.eye6 *.eye4 sub *.eye4 *.eye6 sub abs div 5 mult .aimdx store
stop  

cond
  *.totalbots *.totalmyspecies div 4 >
  *.eye5 50 >
  *.refeye *.myeye !=
start
  *.refveldx .dx store
  *.refvelup .up store
  *.eye6 *.eye4 sub *.eye4 *.eye6 sub abs div 5 mult .aimdx store
  .shoot dec

  'sometimes shoot venom
  10 rnd 1 =
    -3 .shoot store
    *.venom .shootval store
stop


cond
  *.totalbots *.totalmyspecies div 4 >
  *.eye5 0 =
  *.refeye *.myeye = or
  *.shflav 0 !=
  *.shflav -2 !=
start
  *.shang 314 add .aimdx store
stop

end


------------
I am trying to get smooth, regular predator-prey cycles going between Animal Minimalis and Alga Minimalis. I have veg population capped at 100; Currently the Animals will slowly overpopulate the sim while the Alga population stays stuck to the ceiling; then suddenly the Alga population crashes and the Animal population declines slowly, until suddenly Alga populations surge again, and so on. I want a smoother cycle; I guess the problem is that the delay between Animal and Alga populations is too long. I was thinking a well-tuned constant tax on nrg for Animals might help; it would make the Animals die off more quickly when their food source disappears. Also I might uncap the veg population. Any thoughts?

Actually it looks like the population stabilized with the algae at the population cap and Animal Minimalis at the shepherd in equilibrium. I don't like the veggie population sitting at the cap, so I uncapped it; veggie population is now 1000 and rising. I guess I'll play around with the energy fed to veggies to stabilize them.

A problem with the shepherd is that .totalbots includes veggies, so that it starts playing rough with Animal Minimalis when veggie populations spike. I think this delays the restoring force that would otherwise be applied to spiking veggie populations. Also the shepherd's venom disarms its target for a while, making it harder for Animal Minimalis to control the veggies.

I'd appreciate any help, and I'll report any interesting results here.
« Last Edit: April 01, 2008, 12:37:02 AM by The_Duck »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
First Evosim
« Reply #1 on: April 01, 2008, 12:53:36 AM »
Sounds interesting.  I prefer starting from zerobots personally since msot hand authorred DNA usueally must devolve before it can evolve.  It will be interesting to see whether Animal_Min maintains it's functionality or not.  Preditors may force it to.

Some suggestions:

1) Post the sim.  That would be very helpful fin understanding all the settings, whether your alga's are allowed to mutate, etc.
2) You could code your shepards to target only the Animals if you wanted by having them ignore bots with that exact dnalen or fixed bots (if they are fixed) or similar.
3) Adding some randomness to when your shepards wake up witllsmooth things out.   See this topic.
4) Consider having your shepards commit suicide when too large a percentage of the population.  Again, add some randomness here so they don't all wink out in the same cycle.

Keep us posted...
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
First Evosim
« Reply #2 on: April 01, 2008, 01:16:39 AM »
Partly the issue you have is that your population sizes are small.  Or at least your veggy pop is too small.  I'm thinking if you want to maintain a small population for speed reasons, make veggies more like trees:

1.  Give them some minor defensive ability when they're being fed on.  Maybe switch animal minimalis to -6 shots, and have veggy pain trigger shell production.
2.  Fix veggies that are above a certain size.
3.  Feed veggies based on kilobody, instead of just per instance.
4.  Have you veggies wander a bit before settling down.
5.  Have stable shelled veggies produce lots of little babies.  Something like 2 or 3 percent.  These are the seeds that go off and produce new "trees".

This way, each stable veggy is huge, more like a cluster of veggies, and you get the large nrg reserve of a group of traditional veggies.

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
First Evosim
« Reply #3 on: April 01, 2008, 10:46:03 AM »
Good advice above, I'll just throw in my two cents:
Keep the population well-mixed (low friction), this will smooth out any stochastic spikes in populations.
Don't use caps on veggie population. This creates an uneven flow of energy, veggies reach that cap and then they grow well above the size they would grow otherwise. This gives hunters that find them too much energy and hunters population spikes. Key to good smooth curves is self-control of the sim energy.
Track average energy and total energy of each species, this will help you figure out what causes unbalances.

You also need to pick veggie-predator pair that matches each other. Alga minimalis and Animal minimalis are a good start. Don't pick any predators that are too good.

Having the third species to hunt the Alga minimalis is a real pain. I spent quite a lot of time trying to work this out and had to give up eventually. It's possible to keep them all together for some time, but don't expect nice curves. Also, population sizes (and fields) for 3-way sims have to be pretty large. At smaller sizes stochastic effects are too great and one of the species eventually dies out.
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline The_Duck

  • Bot Neophyte
  • *
  • Posts: 29
    • View Profile
First Evosim
« Reply #4 on: April 02, 2008, 02:16:47 AM »
Thanks for the advice, guys. I've discovered, as shvarz noted, that it's hard to keep 3 species in a sim in balance for a long time. One of them usually dies out; maybe my predator-shepherd just isn't good enough. I decided to leave out the shepherd and just try to get a basic stable sim going, with just Alga Minimalis and Animal Minimalis. I still found it hard to keep things stable, so I decided to use the day/night feature: I give the veggies lots of energy but cut it off when total sim nrg rises is above certain threshold. Essentially this enforces conservation of nrg: any nrg lost to the sim is immediately returned as sunlight. This was inspired by my experiences with Gene Pool, which conserves energy and consistently produces stable predator-prey cycles. I also have a significant nrg tax on the bots just for being alive, which increases with age; this kills off bots that just sit around and provides selection pressure towards better hunters. I have mutations at 16x for 1 cycle out of 10 and 1/16x for the rest. I'll let it run for a while and might try to introduce a predator if things look stable enough.

The sim is attached; if you run it you'll note that in the absence of any friction the whole sim has developed a net momentum in the southwestwards direction. I'll be interested to see if this changes over time. Also, I noticed a few bots at one point with a broken conspec-avoidance gene, but it was the long-distance closing gene, not the shooting gene. I can see though how easy it is to break conspec-recognition with just a single point-mutation. I expect it will happen soon.
« Last Edit: April 02, 2008, 02:20:03 AM by The_Duck »

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
First Evosim
« Reply #5 on: April 02, 2008, 08:44:47 PM »
What you can do is to start a sim with just one Animal Minimalis and then tweak the costs to make it die within a certain number of cycles. Then you get an idea how long a bot can survive without feeding when it's constantly spinning. Then you can add other costs too and balance it for day/night cycles if you want.
The sim I'm running right now is balanced for the magic number 32 in DB. You can check it out if you want to see how I have set the costs. This sim hasn't been running long enough for anything interesting to appear. Note that you have to go and change the CostX to 1 every time you load it. Day/night cycles are set to 32000.  
The internet is corrupt and controlled by criminally minded people.

Offline The_Duck

  • Bot Neophyte
  • *
  • Posts: 29
    • View Profile
First Evosim
« Reply #6 on: April 05, 2008, 04:57:06 PM »
The sim has reached 72 hours and almost 5 million cycles. Maintaining the total energy of the sim at a constant level makes the sim extremely stable, with bot populations in the range of 150-250 and veggie populations in the range 50-100 (I abandoned having a shepherd).

I'm running at an 8x mutation rate, which is perhaps not good for the bots' fitness but makes things go more quickly. Average # of mutations has reached 54, which is about the length of the original Animal Minimalis genome. I wrote a little program to parse .sim files and produce a phylogenetic tree based on mutation histories. Here's the relevant bit of the tree:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']4415480 (177)
  4427017 (177)
    4470413 (177)
      4571230 (142)           ----------4
         4790644 (138)
           4793476 (138)      ---------87
           4912239 (1)        ----------1
             4871477 (36)     ---------29
             4908262 (3)      ----------3
             4898672 (3)      ----------3
             4914695 (1)      ----------1
           4909370 (5)        ----------5
           4913445 (3)        ----------3
           4913047 (1)        ----------1
           4915105 (1)        ----------1
           4914439 (1)        ----------1
           4914017 (1)        ----------1
           4912645 (1)        ----------1
           4913465 (1)        ----------1
      4636330 (35)
        4776084 (35)          ---------33
          4908424 (1)         ----------1
          4903758 (1)
            4905239 (1)       ----------1

The big numbers are cycles in which mutations occurred. The numbers in parentheses are the number of living bots with that mutation. Numbers after the dashes on the right indicate the number of living bots for whom that mutation was their last mutation. The indentation indicates the "family tree" of the mutations.

As you can see, the most successful genome has 87 living bots. Here's its DNA:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']''''''''''''''''''''''''  Gene:  1 Begins at position  1  '''''''''''''''''''''''
 start
 *.eye7 *.refeye *.myeye and
 <

''''''''''''''''''''''''  Gene:  1 Ends at position  6  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  2 Begins at position  7  '''''''''''''''''''''''
 start
 *.refveldx .dx store
 *554 70 .up store

''''''''''''''''''''''''  Gene:  2 Ends at position  14  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  3 Begins at position  15  '''''''''''''''''''''''
 cond
 *.eye5
''''''''''''''''''''''''  Gene:  3 Ends at position  16  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  4 Begins at position  17  '''''''''''''''''''''''
 cond
 77 >
 *683 *.myeye !=
 start
 -1 .shoot dec
 *.refvelup .up store

''''''''''''''''''''''''  Gene:  4 Ends at position  29  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  5 Begins at position  30  '''''''''''''''''''''''
 start

''''''''''''''''''''''''  Gene:  5 Ends at position  30  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  6 Begins at position  31  '''''''''''''''''''''''
 cond
 *.eye5 =
 *.refeye and
 *.myeye %=
 or
 start
 371 .aimright store

''''''''''''''''''''''''  Gene:  6 Ends at position  42  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  7 Begins at position  43  '''''''''''''''''''''''
 cond
 >=
 start
 *.nrg 22880 >

''''''''''''''''''''''''  Gene:  7 Ends at position  48  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  8 Begins at position  49  '''''''''''''''''''''''
 start
 dec
 <
 .repro store
 stop
''''''''''''''''''''''''  Gene:  8 Ends at position  54  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  9 Begins at position  55  '''''''''''''''''''''''
 start
''''''''''''''''''''''''  Gene:  9 Ends at position  55  '''''''''''''''''''''''


As far as I can tell it cleans up to

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']start
 *.refeye *.myeye <       'conspec recognition

   *.refveldx .dx store   'match velocities

   70 .up store           'close for the kill

cond
 *.eye5 77 >              'proximity sensor
 *683 *.myeye !=          'broken conspec recognition. why don't they shoot each other?
start
 .shoot dec               'fire away!
 *.refvelup .up store     'match velocities


cond
 -1 *.eye5 = and          'always false, but the "or" saves the day
 *.refeye *.myeye %= or   'conspec recognition; %= essentially functions as =
start
 371 .aimright store      'avoid conspecs

cond
 *.eye7 *554 >=           'apparently, only reproduce when something is in eye7...
start
 *.nrg 22880 >            'keeps bot from going cancerous

 dec <                    'I don't see how anything survives here on the integer stack
 .repro store             'to get stored in .repro but apparently it happens.

stop


It seems to me that conspec recognition for the shooting gene is broken, but I don't observe any cannibalism. Indeed the number of .eye commands has remained constant at 3 since the beginning of the sim. If the bots were cannibals there would be no incentive to maintain matching .refeye's. Perhaps I don't quite understand how cond, start, and stop function in DNA. My though was that "cond" clears the boolean stack except for an implicit "true" value, "start" ANDs up the boolean stack and skips to the next "cond" if it evaluates to "false", and "stop" skips to the next "cond". Also stores only execute when the top value of the boolean stack is "true". Is this correct?
« Last Edit: April 05, 2008, 05:01:39 PM by The_Duck »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
First Evosim
« Reply #7 on: April 05, 2008, 05:09:18 PM »
Animal minimalis has several redundant conspec recognition conditions.  It looks like the code that approaches enemies and turns away from friends are both causing it not to eat friends, even though the middle gene that actually eats stuff would let it.

What's your #mutations / #generation ratio?

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
First Evosim
« Reply #8 on: April 05, 2008, 07:27:06 PM »
Hello. I don't know if anybody cares, but because I got the numbers wrong I need to correct it.

Putting the number 0.635 into the Rotation field will cause Animal Minimalis to die after 64000 cycles.

Putting the number 0.495 into the Voluntary Movement field will cause R Fisannis to die after 32000 cycles.

...if none of the bots find food before then.

Ok, so what's the point? Well, if you have day/night cycles set to 32000 this means that a veggie that happens to evolve constant swimming will make it just barely through the night, probably it will die before the next morning. It should have a selective pressure on bots to not evolve to swim around like crazy. Of course it's a matter of taste how aggressively you want to tax such behavior. I just think these numbers are fun, to have costs based on 32000.  

I also discovered that despite that R Fisannis is both turning and swimming at the same time it appears that only costs for swimming are applied, like movement costs override rotation costs. Could be a bug or design, I don't know.
« Last Edit: April 05, 2008, 07:29:07 PM by Testlund »
The internet is corrupt and controlled by criminally minded people.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
First Evosim
« Reply #9 on: April 05, 2008, 07:38:56 PM »
I'd say that might be a bug.  Rotation costs should work independantly of movement costs.

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
First Evosim
« Reply #10 on: April 05, 2008, 08:10:01 PM »
I suspected as much. Heading over to the bug reports section....
The internet is corrupt and controlled by criminally minded people.

Offline The_Duck

  • Bot Neophyte
  • *
  • Posts: 29
    • View Profile
First Evosim
« Reply #11 on: April 05, 2008, 08:29:49 PM »
Quote from: Numsgil
Animal minimalis has several redundant conspec recognition conditions.  It looks like the code that approaches enemies and turns away from friends are both causing it not to eat friends, even though the middle gene that actually eats stuff would let it.

Ah, that would explain it. Occasionally they do shoot a shot or two at each other before they can turn away.


Quote from: Numsgil
What's your #mutations / #generation ratio?

The generation number on the bot info panel seems not to be working properly; a bot I selected claims to be of generation 9, which is clearly impossible. However average age is currently around 2000, so that gives 2500 generations over 5 million cycles. 50 mutations / 2500 generations = 1/50. I saw something recommending a ratio of 1/2, so I guess I should up the mutation rate?
« Last Edit: April 05, 2008, 08:30:47 PM by The_Duck »

Offline The_Duck

  • Bot Neophyte
  • *
  • Posts: 29
    • View Profile
First Evosim
« Reply #12 on: April 07, 2008, 01:06:51 PM »
The sim has hit 100 hours and 8 million cycles. Over 3.7 million bots have lived and died. For the last 4 million cycles or so I haven't touched the settings. With mutation rate at 32x we're up to 90 mutations. I think this DNA is representative:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
''''''''''''''''''''''''  Gene:  1 Begins at position  1  '''''''''''''''''''''''
 start
 abs *.eye7 *.refeye *.myeye
''''''''''''''''''''''''  Gene:  1 Ends at position  5  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  2 Begins at position  6  '''''''''''''''''''''''
 start
 <
 swapbool
 -- *.refveldx << .dx store
 *432 86 .up store

''''''''''''''''''''''''  Gene:  2 Ends at position  17  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  3 Begins at position  18  '''''''''''''''''''''''
 cond
 store
 *.eye5 91 >
 *630 *.myeye !%=
 start
 4 .shoot dec
 *.refvelup .up store

''''''''''''''''''''''''  Gene:  3 Ends at position  32  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  4 Begins at position  33  '''''''''''''''''''''''
 start
 *.eye5 =
 *.refeye *.myeye %=
 or
 371 .aimleft store
 >=

''''''''''''''''''''''''  Gene:  4 Ends at position  43  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  5 Begins at position  44  '''''''''''''''''''''''
 cond
 ~ *.nrg 27008 >
 start
 dec
 <
 .repro store
 *-167''''''''''''''''''''''''  Gene:  5 Ends at position  54  '''''''''''''''''''''''


Major changes since the start of the sim include:
-Bots now constantly move instead of sitting still, spinning, and waiting for food. I expected that this would occur; sitting still is not a very effective hunting technique. Since they are spinning and accelerating at the same time they execute a kind of Brownian motion.
-Bot speed has increased several times, now at 86
-Feeding distance has decreased several times, now at *.eye5 > 91. So they are zooming around and ramming the veggies, hopefully stopping and matching velocities when they do.

Edit:
-Reproduction energy threshold has been increasing. It seems like this must be advantageous somehow; I can't see why.
« Last Edit: April 07, 2008, 01:46:43 PM by The_Duck »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
First Evosim
« Reply #13 on: April 07, 2008, 01:29:29 PM »
Quote from: The_Duck
The generation number on the bot info panel seems not to be working properly; a bot I selected claims to be of generation 9, which is clearly impossible. However average age is currently around 2000, so that gives 2500 generations over 5 million cycles. 50 mutations / 2500 generations = 1/50. I saw something recommending a ratio of 1/2, so I guess I should up the mutation rate?

Don't up it if you're happy with the results.  The lower the mutation rates the fewer negative mutations are going to fixate.  But if you're getting impatient, yes, you could probably up the rates a little.

Offline The_Duck

  • Bot Neophyte
  • *
  • Posts: 29
    • View Profile
First Evosim
« Reply #14 on: April 08, 2008, 02:04:59 AM »
Update: 9.2 million cycles, 100 mutations, 4.4 million born. With the performance improvements in 2.43.1h I've increased sim size and thus population by 60%.

Here is the most common genome at the moment:
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
''''''''''''''''''''''''  Gene:  1 Begins at position  1  '''''''''''''''''''''''
 start
 and
 *.eye7 *.refeye *.myeye
''''''''''''''''''''''''  Gene:  1 Ends at position  5  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  2 Begins at position  6  '''''''''''''''''''''''
 start
 <
 -- *.refveldx << .dx store
 *432 86 .up store

''''''''''''''''''''''''  Gene:  2 Ends at position  16  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  3 Begins at position  17  '''''''''''''''''''''''
 cond
 store
 *.eye5 91 >
 *630 *.myeye !%=
 start
 4 .shoot dec
 *.refvelup .up store

''''''''''''''''''''''''  Gene:  3 Ends at position  31  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  4 Begins at position  32  '''''''''''''''''''''''
 start
 *.eye5 %=
 store
 *.refeye *.myeye %=
 or
 371 .aimleft store
 >=

''''''''''''''''''''''''  Gene:  4 Ends at position  43  '''''''''''''''''''''''
''''''''''''''''''''''''  Gene:  5 Begins at position  44  '''''''''''''''''''''''
 cond
 *.nrg .shootval store
 >
 start
 dec
 ~ not
 <
 .repro store
 *-167 inc
''''''''''''''''''''''''  Gene:  5 Ends at position  57  '''''''''''''''''''''''


Not much of importance has changed, but there is the intriguing line "*.nrg .shootval store" which has been around for a while but, as far as I can tell, never executes (wouldn't it kill the bot if it did?). Do stores in cond sections execute?