Author Topic: Randombot evolution sim  (Read 15065 times)

Offline Beanspoon

  • Bot Neophyte
  • *
  • Posts: 26
    • View Profile
Randombot evolution sim
« on: March 28, 2012, 11:10:29 AM »
The original post from this topic was modified by a moderator (not naming any names! ;) ), and I can't be bothered to re-write the whole essay so here's the gist.

I set up an evo sim with 100 1024bit randombots (1024 random integers between 1 and 1000), set as autotroph and left to mutate the ability to reproduce.

I used random integers instead of zeros because I noticed that point mutation only mutates numbers by small amounts, meaning that 1) even if luck was on our side and the number mutated only in the right direction, it would take a long time to reach 300, and 2) behaviour evolved would most likely only use the low array areas, as it becomes exponentally less likely for the higher array areas to be reached.  Using random integers means that the chances of any array location being used are equal.

After a surprisingly short number of cycles, the command .repro inc appeared, causing a cancerous reproduction pattern.  Please see further on for the next step.
« Last Edit: April 05, 2012, 09:06:53 AM by Beanspoon »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Randombot evolution sim
« Reply #1 on: March 28, 2012, 03:07:20 PM »
Yes, please post the bot.



I am doing something similar evolving robots for F1 mode. I completely changed the mutation engine, see attachment. I don't like point mutations so I replaced them with a custom "copy error"; Although they evolve zero bots they also screw with robots that are already functional so I decided to remove them. I also attached my A1 trough A9 generations.



I would like to see your point mutation code as well, It might just convince me to change my mind.  :P
Maybe have that one activate if the robot did not reproduce ever after like 8000 cycles...
« Last Edit: March 28, 2012, 03:17:22 PM by Botsareus »

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Re: Randombot evolution sim
« Reply #2 on: March 29, 2012, 01:12:33 PM »
I used a random bot for the same reason. Generate 1000 random numbers in excel and use them. Point of concern: mutation rates need to be much lower, is my experience. You need to strike a balance between the time a mutation needs to settle  (or disappear, if bad) and new mutations appearing.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Randombot evolution sim
« Reply #3 on: March 29, 2012, 02:06:39 PM »
I used a random bot for the same reason. Generate 1000 random numbers in excel and use them. Point of concern: mutation rates need to be much lower, is my experience. You need to strike a balance between the time a mutation needs to settle  (or disappear, if bad) and new mutations appearing.
Yeah, this is right. It's usually even better to drop them after they're less than 1/32 using the bot's settings. It just gives time for bots who have good mutations to survive and bots with bad mutations to die.

However, I never really thought of using random-bots over zero-bots and it seems like such a good idea. I must try this at some point. It will probably be summer before I get around to it, though.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Randombot evolution sim
« Reply #4 on: March 29, 2012, 05:56:09 PM »
oh, he never moded the code, it simply not a true zero bot...

I have to look into doing this kind of stuff internally...



That problem seems to come from this line:

        Do
         ' Dim a As Integer
          .DNA(t).value = Gauss(IIf(Abs(old) < 100, IIf(Sgn(old) = 0, Random(0, 1) * 2 - 1, Sgn(old)) * 10, old / 10), .DNA(t).value)
        Loop While .DNA(t).value = old

I am going to try a mod...



el fixo:

Code: [Select]
If Mtype = PointUP Then
      Dim randomsysvar As Integer
        Do
                randomsysvar = Int(Rnd * 1000)
            Loop Until sysvar(randomsysvar).Name <> ""
        .DNA(t).value = sysvar(randomsysvar).value
      Else
        Do
         ' Dim a As Integer
          .DNA(t).value = Gauss(IIf(Abs(old) < 100, IIf(Sgn(old) = 0, Random(0, 1) * 2 - 1, Sgn(old)) * 10, old / 10), .DNA(t).value)
        Loop While .DNA(t).value = old
      End If

I feel better about using point mutations now
« Last Edit: March 29, 2012, 06:50:55 PM by Botsareus »

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Re: Randombot evolution sim
« Reply #5 on: March 30, 2012, 12:49:51 PM »
oh, he never moded the code, it simply not a true zero bot...

I have to look into doing this kind of stuff internally...



That problem seems to come from this line:

        Do
         ' Dim a As Integer
          .DNA(t).value = Gauss(IIf(Abs(old) < 100, IIf(Sgn(old) = 0, Random(0, 1) * 2 - 1, Sgn(old)) * 10, old / 10), .DNA(t).value)
        Loop While .DNA(t).value = old

I am going to try a mod...



el fixo:

Code: [Select]
If Mtype = PointUP Then
      Dim randomsysvar As Integer
        Do
                randomsysvar = Int(Rnd * 1000)
            Loop Until sysvar(randomsysvar).Name <> ""
        .DNA(t).value = sysvar(randomsysvar).value
      Else
        Do
         ' Dim a As Integer
          .DNA(t).value = Gauss(IIf(Abs(old) < 100, IIf(Sgn(old) = 0, Random(0, 1) * 2 - 1, Sgn(old)) * 10, old / 10), .DNA(t).value)
        Loop While .DNA(t).value = old
      End If

I feel better about using point mutations now
Looks good. Can I ask for another one: decrease mutation rate defaults by a factor of 10?

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Randombot evolution sim
« Reply #6 on: April 02, 2012, 03:51:47 PM »
I have load/save mutation rates from file, but it's alpha... (I never added code to select the file location, it defaults to a specific file)
If you want, I'll post that too.
« Last Edit: April 03, 2012, 02:42:45 PM by Botsareus »

Offline Beanspoon

  • Bot Neophyte
  • *
  • Posts: 26
    • View Profile
Re: Randombot evolution sim
« Reply #7 on: April 04, 2012, 06:24:00 AM »
Hey, so far nothing interesting to report, the sim has restarted a couple of times due to all bots dying out, but otherwise all quiet.

In the current version of the sim, all animal reproducers have died out due to cancerous growth and no incoming energy, two veggies have survived due to mutation which has rendered the reproduction gene dormant, and the randombots are just sitting there slowly mutating and running out of energy.

As suggested I am using nrg per kilobody point to discourage cancerous veg, and I have costs on in order to make finding food a priority.  I know that it would probably be in my better interest to try to keep the bots alive, however I see no good way of doing that save forcing them to evolve the necessary code.  If I set them as autotroph or create a feederbot to feed them, they will become lazy and just let that happen.  Sometimes you have to be cruel to be kind...

I am going to adjust the sim to repopulate veggies if the population falls below 20.  That should give them plenty of chances to evolve into something a little more sensible, while keeping a decent supply of food around in case anything else felt like evolving...

I'll post the A1 code next time I get the chance, there's really not very much to see though, just a random string of numbers and commands with 58 .repro inc stuck in there somewhere.

Watch this space...

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Randombot evolution sim
« Reply #8 on: April 04, 2012, 02:03:53 PM »
Ah!  I just realized I modified your first post instead of replying like I meant to.  I'm really really sorry; I've never done that before.  That was a lot of text to lose, and it was entirely my fault.  :redface:

I'll put my post here.  If you want to modify your original post to explain what you're doing again, that would be good (even if it's just a brief outline).

Quote
You're the patient sort, aren't you :P

I usually aim for no more than 1000 bots.  That keeps the cycles/sec at something slightly more reasonable (1-3 cycles/sec or so).  With cancerous reproduction, where they always try to reproduce every frame, once they get small enough the system won't let them reproduce anymore and they'll need to produce body (assuming you're only feeding them nrg from the autotroph system).  If your veggy feeding method is set to nrg per kilobody, you'll also discourage (or at least, not actively encourage) cancerous veggies.

A single cancerous starter bot, at 1000 body, will produce about 1000 bots before each bot's body gets so low that it can't reproduce anymore.
« Last Edit: April 04, 2012, 02:11:31 PM by Numsgil »

Offline Beanspoon

  • Bot Neophyte
  • *
  • Posts: 26
    • View Profile
Re: Randombot evolution sim
« Reply #9 on: April 05, 2012, 08:54:31 AM »
Haha I was a little confused - I assumed it was just a server error.  Yeah, I can't really remember what it was I wrote now...when I feel up to the task of re-writing my essay I will do ;)

In the meantime, I've decided to work on one thing at a time.  Currently, I'm setting up the sim to instead focus on stabilising the veggy version of my evobot, i.e. evolving out the current cancerous nature.  I will make a new topic with what I've achieved so far and where I'm going with it next.  Incidentally, I want to evolve interesting veggy behaviour so I need an interesting environment - does anyone know how to provide good settings for pondmode?  All the permutations I've tried dont seem to make any difference.  I want to have the veggies get enough energy if they remain in the upper part of the pond, but if they sink to the bottom they die.  I've tried light intensity 1 and sediment level 20 but even that doesn't seem to stop the ones at the bottom getting more than enough energy.  Also I set nrg per cycle to 0 so they were only getting energy from the pondmode source.

Offline Beanspoon

  • Bot Neophyte
  • *
  • Posts: 26
    • View Profile
Re: Randombot evolution sim
« Reply #10 on: April 05, 2012, 09:41:59 AM »
Milestone 1

Right, here is where I draw the line for the first milestone of this project.  Using randombots, I have successfully "evolved" a bot capable of reproduction.  This is being done by a .repro inc command buried in the random integers. This causes a cancerous reproduction pattern, where the bots attempt to reproduce every single cycle.

My next step will be to attempt to breed out this cancerous growth, giving something a little more controlled.  To do this, I will set energy to be distributed per kilobody point, which favours sensible veggies.  Costs will be set to F1 default, but with age cost set to 0.1, which will also discourage cancerous growth, and veggies repopulation threshold will be set to 100.  From previous dabblings with these settings, I have seen that the veggies that survive are the ones that evolve to turn off the area of code which allows them to reproduce.  Therefore after a while of cancerous growth, I will end up with 100 non-reproducing veggies, however most, if not all, will still posess the genetic code enabling them to do so.  Then, it's a simple matter of waiting for the point mutations to evolve a sensible control for the reproduction.

The F1 default costs will provide an evolutionary drive towards a sensible reproduction pattern for another reason as well.  Eventually, the Age cost will outstrip the amount of energy being collected by the bot, and it will begin to lose energy.  Therefore, each bot has a lifespan, and if it does not develop a sensible method of evolution in that time (and with age cost at 0.1, that's still 10 gigacycles per 1 energy) then both it and its genetic code dies.  Sort of a brute-force method, but I'm pretty sure it should yield results eventually.  If a veggie dies, it is replaced by a brand new cancerous veg, which will eventually simmer down into something useful again.  And so the cycle continues...

If you have any suggestions, please let me know and I will give them due consideration.  Most of my methods are hypothesis and a little trial and error, so if you have any useful experience, I'd love to hear it.  Also, as I mentioned above, does anyone know how to work pondmode, because I've had no luck so far.  I'd like to use it later.

I get the feeling I need a successful veg before I can start evolving something that can feed on veg...

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Re: Randombot evolution sim
« Reply #11 on: April 05, 2012, 01:19:15 PM »
I used the dynamic cost settings to provide evolutionary pressure. A target setting of say 400 bots is used. Below 400 bots the cost will decrease and above it will increase. Later on I did it manually to avoid see saw behaviour.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Randombot evolution sim
« Reply #12 on: April 05, 2012, 01:27:22 PM »
Common wisdom in the past has been to treat it a bit like gardening.  Start off with 0 costs.  That way no behavior is discouraged (well, bots can still find ways to kill themselves, but it's rather hard).  Make all the bots vegs, and keep the nrg/cycle to something very small (since you have no costs there shouldn't be need for much nrg).  And keep population controls so that the sim doesn't balloon to thousands of bots and wreck your cycles/sec.  Probably keep the field size small since you want a certain bot spatial density.

Eventually, you'll probably get a bot that can move in one direction, fire -1 shots constantly (and therefore feed), and reproduce (probably cancerously).  It just does everything constantly, but it's the beginnings of a rudimentary bot.  From that base, you then crank up costs (slowly) to provide additional pressures.  Maybe add in shapes to keep things interesting.  The main point is that the complexity of the environment has to keep up with the complexity of the bot.  Eventually you might be able to get a bot that can survive without being a veggy.  Then you switch the species off of being a veggy and introduce a feeder veggy.  Maybe just the original zero bots.  Alternatively, if you're aiming for a veggy species, you could drop in, say, animal minimalis, and have them cap their own population to some (very low number).  As the veggies get better at surviving you can crank up the population cap that the bots self impose.  Eventually replace the animal minimalis with a more aggressive hunter.

And while cancerous, constant reproduction isn't very sexy (:P), the most successful evo sim I ever ran actually did pretty well with a cancerous veggy being fed nrg per bot instead of per kilobody point.  If it learns to rotate and reproduce it can produce a sort of "foam" of bots with 1 nrg.  Animals can only really kill 1 bot per cycle, and they won't get that much nrg back from it, so they will have a hard time entirely killing a veggy field.  Maybe 10% of the veggy population survives to reproduce some more.  So you have this very narrow evolutionary window for success, and an insane number of generations, so you do get some actual evolution going on.  (If you turn on fixed bot radii, it makes this easier.  They'll form a regular lattice structure.).

Offline Beanspoon

  • Bot Neophyte
  • *
  • Posts: 26
    • View Profile
Re: Randombot evolution sim
« Reply #13 on: April 05, 2012, 01:45:24 PM »
There are so many different ways to induce evolution in the bots... I think I'm going to have to start a charity where people donate their old computers to me so that I can use them for extra processing power.  Try a different sim setup on each one and see how things develop.

That does sound like an interesting use of cancerous growth, and I can see how that would stay stable - you end up with a sort of grass effect, fields of veg grow, bots feeding from it gain only a little energy per veg, so must eat a lot of them.  I rather like that idea actually, seems a little more reminiscent of real veg and herbivores.

I'm not sure I follow your approach to creating an animal bot though - if you make all the bots veg, won't that promote veg behaviour? If a bot can get enough energy just by sitting around and (for want of a better word) vegitating, what evolutionary advantage does moving around and shooting give?

Took a peek at my sim just now, I noticed that the constant reproduction was causing bots to propel themselves along, creating a 1% bot each cycle which immediately died from lack of energy.  The poiffs of exploding bots make it look like a smoke trail for the one that's reproducing  :P
« Last Edit: April 05, 2012, 03:51:13 PM by Beanspoon »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Randombot evolution sim
« Reply #14 on: April 05, 2012, 04:29:19 PM »
There are so many different ways to induce evolution in the bots... I think I'm going to have to start a charity where people donate their old computers to me so that I can use them for extra processing power.  Try a different sim setup on each one and see how things develop.

If you plan on leaving them on for a while, it's sometimes better to just buy a new stripped down computer with a core i7, in terms of the energy consumption.  Each DB instance is single threaded, but you can run multiple instances simultaneously.  So one of the new 6 core processors can run 12 instances (6 cores with hyperthreading = 12 hardware threads) pretty effectively.

Quote
I'm not sure I follow your approach to creating an animal bot though - if you make all the bots veg, won't that promote veg behaviour? If a bot can get enough energy just by sitting around and (for want of a better word) vegitating, what evolutionary advantage does moving around and shooting give?

If they don't get a lot of nrg from being a veggy, they should learn to feed as well, to supplement their meager nrg income.  Pretty soon after that all the non feeding vegs should get eaten.  Then you lower the veggy feeding some more, and introduce dumb bots to feed the animals by getting eaten.  You keep lowering the veg nrg until you can turn it off entirely.  Then start the sim with that species not marked as vegs, and you can introduce in smarter and smarter vegs.

Quote
Took a peek at my sim just now, I noticed that the constant reproduction was causing bots to propel themselves along, creating a 1% bot each cycle which immediately died from lack of energy.  The poiffs of exploding bots make it look like a smoke trail for the one that's reproducing  :P

Heh, that's a funny way to evolve locomotion. :)