Author Topic: Newbie starting a complex simulation  (Read 8100 times)

Offline pieflavor

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Newbie starting a complex simulation
« on: April 18, 2014, 09:36:19 AM »
So basically, I'm new to Darwinbots and want to start a simulation for a project in my biology class (high school).

My goal is to run a coevolution simulation, with a predator and prey species evolving over time in different ways. Ideally, this would actually take quite a long time, and would be as a result of certain random mutations resulting and being selected for, therefore allowing the organisms with those mutations to survive and reproduce.

Also, it would be nice if there was a way to alter variables like size, speed, etc. manually for the starting population so that I would be able to show selection towards a specific trait, though from what I have seen of the program it relies on genes and not specific traits.

Anyway, my question is: do you have any advice for me in terms of what bots to use (I'm using a slightly altered Algae Minimalis bot that runs away and is still an "autotroph" as my prey species, and just the Animal Minimalis) and what type of general settings I should have? Thanks so much, any advice is greatly appreciated.

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Newbie starting a complex simulation
« Reply #1 on: April 18, 2014, 11:11:48 AM »
bad idea for the vegi being able to move with an animal minimal because they have such a basic targeting system moving vegis would through it off and the population crashes and dies out or at least that's happen to me. if you can get it to work then thums up to you. if not then i suggest using a different bot than animal minimal. if you want i could give you 3 bots (vegi prey predator) this week end i will be pulling an allnighter any way making a bot.

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Newbie starting a complex simulation
« Reply #2 on: April 18, 2014, 07:14:48 PM »
If you want to evolve both predator and prey. I would pick a alge that produces chloroplasts. If not it would likely just continually die out and repop.

What do you mean with alter size, speed?
If you put a huge bot in a sim, but with dna belonging to a small bot, it'll reproduce till it gets to smaller bots. Traits are what follows from the genes. So to alter how big or fast a bot will become before a sim starts, you have to alter the genes manually.

As for bots you're picking, you should pick one that's simple enough to be understood without too much trouble. So you understand beforehand how the bot behaves. (And it may help to look at the dna afterwards and determine what has changed, but far evolved dna can be a pain to understand)
Oh my god, who the hell cares.

Offline pieflavor

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Re: Newbie starting a complex simulation
« Reply #3 on: April 19, 2014, 09:07:56 AM »
Thanks for the advice Shadowgod! (Sorry I feel a little stupid but I'm not sure how to reply to you specifically, hopefully you'll see this). Those three bots sound awesome! And you're right, that is what has happened to me. But yes, it would be a huge help to me if you were to send me those bots, as I really have only just started and have only been able to slightly alter animal minimalis as of yet.

Thanks!
« Last Edit: April 19, 2014, 09:15:15 AM by pieflavor »

Offline pieflavor

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Re: Newbie starting a complex simulation
« Reply #4 on: April 19, 2014, 09:13:22 AM »
Peter: Thanks for the advice, and you are absolutely right I see the error in what I was saying now; unless they were all different species they would eventually just revert to what is outlined for them in their DNA. The idea I was trying to accomplish was somehow simulating the natural genetic variation in populations that exists in the real world, and how that can result in selecting for certain robots to survive. Having looked into it further, though, this might be impossible or far too difficult with Darwinbots, but that is ok because of Darwinbots' potential for interesting coevolution simulations that just rely on the DNA.

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Re: Newbie starting a complex simulation
« Reply #5 on: April 19, 2014, 01:16:33 PM »
One of the big issues you're facing is the very small environment. This tends to cause one specie to exterminate the others rather fast.
Another issue is that any specie can produce chloroplast in the latest version of DB, so anyone could become a vegy.

There's another topic where some people where putting together a "wiki bot" where each person adds one line of code at the time.
(I should mention some of the lines are taken from other evolved bots, making the code very hard to read.)
This is what it looked like:
Code: [Select]
start
.tie inc
*.focuseye .eye5 add * 0 >
*.nrg 1000 sub sgn 0 floor 49 *.venom sub sgn 0 floor mult 5 mult .strvenom store
7 .venloc store
-2 .venval store
59 << *.robage 192 ceil >> rnd << << ++ store
*.eyef 0 sub sgn abs -- abs .focuseye mult inc
clearbool
*.refbody << *.timer rnd 3 ceil mult ++ .up store
59 << *.robage 192 ceil >> rnd << << ++ store
*.refeye 4 sub .sx store
.shoot dec
5 .sharenrg store
*.body *.trefbody sub 10 div 65 floor .sharenrg store
stop


I tried running a sim with the wikibot and an alge, it had a hard time surviving but eventually mutated to a point where it was stable (after about 1600 cycles), the code looked like this:
Code: [Select]
start
 .tie inc
 *.focuseye 505 add * 0 >
 *.nrg 1000 sub sgn 0 floor 49 *.venom sub sgn 0 floor mult 5 mult .strvenom store
 7 0 store
 -2 .venval store
 59 << *.robage 192 ceil >> rnd << << ++ store
 *.eyef 0 sub sgn abs -- abs 511 mult inc
 clearbool
 *.refbody << *.timer *323 rnd 3 ceil mult ++ .up store
 59 << *.robage 192 ceil >> rnd << << ++ store
 *.refeye 4 sub .sx store
 .shoot dec
 5 .sharenrg store
 *.body *.trefbody sub 10 div 65 floor .sharenrg store
 stop


It would eventually kill the alge it was feeding off, but the sim would repopulate the alge so it didn't die out.
However after 24K cycles it reached a point where it stopped shooting. It would still feed off the alge through ties, but wouldn't kill it.
It would also produce chloroplast though. So it had in a way evolved into a parasitic alge.
This was the end result:
Code: [Select]
start
 .tie inc
 *.focuseye 505 add 0 xor
 * *.nrg 1000 sub *.venom 49 floor 0 sgn sgn 0 floor mult 5 mult .strvenom store
 store
 0 7 -2 .venval floorstore
 59 clearbool
 *.robage 192 ceil >> rnd << << ++ store
 *.eyef 0 sub abs -- abs 511 clearbool
 inc
 mult << *.timer store
 div rnd 3 logx mult ++ .up store
 59 *.robage 176 ceil >> rnd << << ++ store
 store
 7 830 10 div 65 floor 830 overbool
 store
 stop


The problem with all of this is that the code is unreadable and very hard to follow. I'm assuming you want to somehow document what has changed in each bot.
It also sounds like you want to be able to modify a specie during the sim. But if you simply have 2 species in a sim, then they will evolve in each their way and it will be out of your control. (You can only control the environment they're in)

One option could be to take a descent bot from the F3 or maybe F2 league and run the sim with a basic alge which repopulates. Then at some point switch out the alge with a slightly stronger bot, something from the bottom of the F3 league. And then basically slowly increase the strength of the repopulated bot as the bot in the sim evolves to be able to kill the repopulated bot easily.
At least that would be a way to show visible improvement in one bot. But if your goal is to show 2 bots coexisting that will be harder.
I have only seen this happen once in a sim, where a bot branched out into 2 species, where one fixed it's position and reproduced in small clusters while the other moved around but had a hard time feeding off an alge as it kept pushing it out of the way. The only reason both species managed to coexist was because they depended on each other. The bots that moved could not survive without something to block the alge it was pushing and holding it in place, and the fixed bot could not survive without something pushing alge over to it.
But over time one of them (Don't know which one) evolved into something else, and wiped out the other bot.

The best chances you have of 2 species coexisting is for them to depend on each other somehow. Or at least for the stronger one to depend on the weaker one. In a very large sim with very few alge, bots will tend to feed off the alge without killing them, since once the alge is dead it may take them a long time to find a new food source. But this is rarely completely stable.

The last of the 3 code samples I've shown may be able to coexist with a weak bot, provided you still have some alge which repopulates in the sim. But I'm not sure how long it would be stable though.

Offline pieflavor

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Re: Newbie starting a complex simulation
« Reply #6 on: April 19, 2014, 02:12:58 PM »
Thanks for the advice, Moonfisher.
My original statement wasn't totally clear regarding what specifically I want for the simulation. Basically, I want coevolution in which there is a prey and predator species in an "evolutionary arms race". This would require populations to not die out, and if possible I'd like it to be so that they reproduce by themselves and don't have to be repopulated by the simulation.
I would like to be able to document the changes, and ideally I would start with very simple DNA that would progressively get more complicated for both species as the sim went on; however, I'd also like (again, if possible) not to have to edit or replace any species mid-sim. I realize this might be a lofty goal, but I do have a significant amount of time to get this right so any ideas you have are greatly appreciated.
Thanks!

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Newbie starting a complex simulation
« Reply #7 on: April 19, 2014, 03:54:06 PM »
In order to keep it as stable as possible and keep bots from extinction, you'll need quite a simulation. At the least 1000 bots, if possible more, the more the better. And a sizable simulation.(size 10?)
 
Coexisting bots is hard. It can go well and they could run into a evolutionary arms race, but likely at some point one of them gets a solid advantage and wins it. Maybe if you get 3 different sims, one were the prey is at advantage, one where the predator is at a advantage and one where they're equal. Connect the sims with teleporters, et voila.
Anyone got a idea on which settings to use in sims like that to implement this? I was thinking higher light energy for the prey sim. Lower light energy and lower cost multiplier in the predator sim.
Oh my god, who the hell cares.

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Re: Newbie starting a complex simulation
« Reply #8 on: April 19, 2014, 05:42:46 PM »
Peters suggestion is a good one. High light and thick fluids along with higher costs in the prey sim I would say. And very low light and low costs in the predator sim (Maybe have some basic alge which repopulates in the predator sim). And well, something in between in the sim in between.
This should prevent either specie from being wiped out and keep an ongoing battle for the ground in the middle.
Or at least it'll increase the chances.
You should be aware that any specie can evolve using chloroplast though. So the predator could start using chloroplast and invade the prey sim eventually.

On a side note. Made 2 bots and tested them a bit. They seem to be able to coexist. But like peter mentions, the bigger the sim the better and the more bots the better. Also you can't actually cap the amount of bots really, so you need to tweak things like light and costs, which could just end up wiping out one specie.

One important thing, if you plan to try out Peters idea (And I think you should), then be aware that the predator of these 2 bots I'm posting is using chloroplast, but a small amount. (You could simply adjust light settings so the small amount the predator uses isn't enough, or you could just remode that from the code.)

Anyway here are the bots. I added some constant values at the top of each you can use to tweak. But things like maxpop tend to break very easily I'm afraid. Never took long before the population just exploded and sim speed went down to 0.1 cylce per sec.
(You should expect it'll take 1-2K cycles before sim starts to get going)

Prey:
Code: [Select]
def maxpop 1500
def maxchlryoung 300
def maxchlrold 1000
def childpct 20
def reprosize 3000

cond
*.robage 30 <=
start
.deltie inc
.mkchlr inc
*.nrg 50 >
100 .sx store
stop

cond
*.robage 30 >
*.nrg 100 <= or
*.totalmyspecies 150 <= or
*.nrg 10 > and
start
*.chlr .maxchlryoung <
dupbool
*.nrg 100 > and
100 .mkchlr store
dropbool
.mkchlr inc

*.chlr .maxchlrold <
*.nrg 100 > and
*.robage 1000 > and
100 .mkchlr store

*.nrg 500 >
*.body 1000 < and
*.nrg 5 div 100 floor .strbody store

*.shflav 0 !=
*.body .reprosize > or
*.numties 1 >
*.nrg 100 >
*.body 300 > or and or
*.totalmyspecies 150 < or
300 rnd .aimsx store
100 .dx store
0 .shflav store
.deltie inc

dupbool
*.timer 50 mod 0 != and
*.totalmyspecies .maxpop < and
.childpct .repro store

dropbool
*.timer 50 mod 0 = and
*.totalmyspecies .maxpop < and
.childpct .mrepro store
stop



Predator:
(Consider removing chloroplast from it, basically take out any part with .mkchlr)
Code: [Select]
def maxpop 1000
def childpct 30

cond
*.nrg 50 >
*.robage 100 < or
start
60 .sharenrg store

*.robage 0 =
450 .eye5width store
.eye5width .memloc store
.robage .tmemloc store

*.body 400 >
*.eye5 0 <=
*.body 700 > or and
*.totalmyspecies .maxpop < and
500 rnd .aimsx store
dupbool
*.timer 50 mod 0 != and
.childpct .repro store
dropbool
*.timer 50 mod 0 = and
.childpct .mrepro store

*.nrg 500 >
*.body 1000 < and
100 .strbody store

*.nrg 300 <
*.body 100 > and
100 .fdbody store

*.chlr 100 <
.mkchlr inc

*.eye5 0 >
*.memval 450 != and
*.refvelup 50 *.eye5 sub 0 floor add .up store
*.refveldx .dx store
*.refxpos *.refypos angle .setaim store
.tie inc

dupbool
*.refbody *.refnrg > and
*.tmemval 500 > and
-6 .shoot store

dropbool
dupbool
*.refbody *.refnrg <= and
*.tmemval 500 > and
.shoot dec

dropbool
not
30 60 rnd sub .aimsx store
30 .up store
.deltie inc
stop


The sim I ran was rather large (Over half way on the slider), with 1/8 mutation, started spawning 200 prey and 50 predators. Light settings are tricky, seems to work with either just 80 light, or 300 light per kilo veggy.
Biggest issue here is that there's a manually added maxpop in the code and this will break fast and end up freezing your sim eventually.
You may want to remove it or set it higher and then try to control population through environment settings instead, tweaking light and costs slightly.
Remember that when tweaking settings you should change them slightly and then give it lots of time to take effect before tweaking again, or you 'll suddenly have wiped the sim.

In any case good luck, and I second Peters idea. I think it's your best option.
I should also mention that when I made these 2 I simply had one large sim in mind. I think Peters idea is better, so if you want I can try to set that up myself and make some modifications to made the bots more suited for that purpose. (Unless you want to adjust them yourself)
« Last Edit: April 19, 2014, 05:53:20 PM by Moonfisher »

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Newbie starting a complex simulation
« Reply #9 on: April 20, 2014, 11:26:32 AM »
the vegi and prey are done but the predator doesn't work as well so i am letting it evolve a bit until it can hold it's own. when i have the predator good i will give it to you but you can see how the other are doing.

Edit: ok so i forgot about leaching so the predator is done too.

explained the vegi uses poison which is released when shot so the prey uses ties to feed from. the predator has slime to prevent ties but this is not a fool safe way so it also leaches when there is a tie. so lets see if the prey can find a way around this and so forth. i'm thinking about a virus for vegis to put in. hmmm :thinkey:
« Last Edit: April 20, 2014, 01:09:02 PM by Shadowgod2 »

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Newbie starting a complex simulation
« Reply #10 on: April 20, 2014, 11:59:00 PM »
there is an issue with the alga working properly by making a lot of chlr and stopping eventually the prey pop dies out and does the predator which is why i want a virus to prevent that. the virus has yet to work but i will find a way. here are the settings. for now disable the mutations for the vegi to see what happens to the other 2. i will post the virus when i get it working right.

Offline Shadowgod2

  • Bot Destroyer
  • ***
  • Posts: 387
    • View Profile
Re: Newbie starting a complex simulation
« Reply #11 on: April 24, 2014, 12:02:58 AM »
k so the virus idea isn't going well so here are the new settings that work well for me. the predator seem to evolve much faster and stops moving all together and destroy the prey and the whole sim fails i will try to fix this and post the new prey later this weekend.

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: Newbie starting a complex simulation
« Reply #12 on: April 24, 2014, 02:35:17 PM »
I've made a motley of species that seem to co-exist fine. You might have to play with the settings, though. The hunter-bots would need editing, too. More in next post
To być albo nie być, oto jest ze pytanie

Offline MysticalDumpling

  • Bot Destroyer
  • ***
  • Posts: 205
  • Kurwa chuj!
    • View Profile
Re: Newbie starting a complex simulation
« Reply #13 on: April 24, 2014, 02:36:24 PM »
Some more:
To być albo nie być, oto jest ze pytanie

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Re: Newbie starting a complex simulation
« Reply #14 on: April 24, 2014, 05:36:18 PM »
In case you plan to use viruses. I wouldn't use them if you want to keep the dna strands separate.
Oh my god, who the hell cares.