Author Topic: Preditor effectivness gene for evo sims  (Read 3801 times)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« on: August 22, 2007, 01:57:34 PM »
The sysvars .totalbots and .totalmyspecies (new in 2.43b) allow for mutation disabled, hand coded preditors in an evo sim to regulate the population of the evo bots through prediation while regulating their own numbers.

One challenge in using prediation in evo sims is how to scale the 'lethalness' of the preditors as the popualtion of the evo bots grows and reduce their effectiness as the population shrinks.  One easy way to do this is simply to scale the population range over which the preditor begins hunting using the rnd command.  The following gene is a simple modification of the velocity matching and shooting gene from Animal_Minimalis.  

cond
*.eye5 0 >
*.refeye *.myeye !=
*.totalbots 1000 500 rnd add >
start
*.refveldx *.body mult 1000 div .dx store
*.refvelup *.body mult 1000 div 30 add .up store
-1 .shoot store
stop

Note the line in bold.  The gene will never fire and thus the bot will never hunt when the popuatlion of the sim as a whole is below 1000.  It will always hunt when the population is above 1500 and its effectness as a hunter will vary between 1000 and 1500 total bots, becoming increasingly more effecient as the population increases in this range.

For completeness, here is a sample preditor population control gene.  It prevents reproduction when the preditors are more than 5% of the total population.

cond
*.nrg 10000 >
*.totalmyspecies 100 mult *.totalbots div 5 <
start
50 .repro store
stop
« Last Edit: August 22, 2007, 04:39:44 PM by EricL »
Many beers....

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Preditor effectivness gene for evo sims
« Reply #1 on: August 24, 2007, 05:42:40 PM »
I thought we couldn't do calculations in the conditions section of the gene? Or has that changed now and I'm just living in the past?!!
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« Reply #2 on: August 24, 2007, 08:16:25 PM »
Quote from: Jez
I thought we couldn't do calculations in the conditions section of the gene? Or has that changed now and I'm just living in the past?!!

You can't do store, inc or dec outside the body (or else) portion of a gene.  Everything else you can do in the cond no problem.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7714
    • View Profile
Preditor effectivness gene for evo sims
« Reply #3 on: August 25, 2007, 01:38:26 AM »
It was part of the DNA changes I made for 2.4

Offline Ispettore

  • Bot Neophyte
  • *
  • Posts: 32
    • View Profile
Preditor effectivness gene for evo sims
« Reply #4 on: November 15, 2007, 09:06:05 AM »
Is it possible to put the ratio myspecie\totalspecies in hunt genes?

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« Reply #5 on: November 15, 2007, 10:10:57 AM »
Quote from: Ispettore
Is it possible to put the ratio myspecie\totalspecies in hunt genes?
Of course.  The population control gene in the above post does exactly that.
Many beers....

Offline Ispettore

  • Bot Neophyte
  • *
  • Posts: 32
    • View Profile
Preditor effectivness gene for evo sims
« Reply #6 on: November 15, 2007, 11:42:19 AM »
I mean, if I can put
*.totalmyspecies 100 mult *.totalbots div 5 <
in the shooting gene, example:

cond
*.eye5 0 >
*.refeye *.myeye !=
*.refeye 0 !=
*.totalmyspecies 100 mult *.totalbots div 5 <
start
*.refveldx *.body mult 1000 div .dx store
*.refvelup *.body mult 1000 div 30 add .up store
-1 .shoot store
stop

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« Reply #7 on: November 15, 2007, 11:47:40 AM »
Sure.  You just did!

In current versions, the only thing you can't do in the Cond section is write to bot memory I.e. execute a store, dec or inc.  (I may change this soon).   You can read from memory just fine.  The line:

*.totalmyspecies 100 mult *.totalbots div 5 <

reads from bot memory but does not store to memory, so you're golden.
Many beers....

Offline Ispettore

  • Bot Neophyte
  • *
  • Posts: 32
    • View Profile
Preditor effectivness gene for evo sims
« Reply #8 on: November 15, 2007, 12:48:45 PM »
Thank you, I think this gene is very useful. But sometimes the bot keep shooting also if his pop is more than 5%... I must have put something wrong.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« Reply #9 on: November 15, 2007, 01:09:02 PM »
If you catch a bot doing that, take a look at the .totalmyspecies and .totalspecies memory locations for the bot  that is shooting (using the console of the bot properties dialog)and see if they are correct.  Never know, could be a bug in the program.  Either that, or you have another shooting gene somehwere (handling waste perhaps?) that isn't regulated by the population control...
Many beers....

Offline Ispettore

  • Bot Neophyte
  • *
  • Posts: 32
    • View Profile
Preditor effectivness gene for evo sims
« Reply #10 on: November 18, 2007, 02:53:53 PM »
bots I was using didn't had waste ejection sistem (LOL). btw, the bot I posted don't even shot. I have the p version of DB.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« Reply #11 on: November 18, 2007, 03:31:35 PM »
If you think you've found a bug (I can't tell from your post) please create a new topic in the Bug Reports Forum with an explanation of what you think should be happening and attach a sim.  I'd be happy to take a look.  Thanks.
Many beers....

Offline Ispettore

  • Bot Neophyte
  • *
  • Posts: 32
    • View Profile
Preditor effectivness gene for evo sims
« Reply #12 on: November 19, 2007, 09:57:54 AM »
I don't think it is a bug, I think it is a stupid error of mine. I'll post you a code of a bot that shoul in theory work:

cond
*.robage 0 =
start
1220 .eye5width store
stop

cond
*.eye5 0 >
*.refeye *.myeye !=
*.refeye 0 !=
*.totalmyspecies 100 mult *.totalbots div 10 <
start
*.refvelup 50 add .up store
*.refxpos *.refypos angle .setaim *.robage sgn mult store
stop

cond
*.eye5 50 >
*.refeye *.myeye !=
*.refeye 0 !=
*.totalmyspecies 100 mult *.totalbots div 10 <
start
*.refvelup .up store
*.refxpos *.refypos angle .setaim *.robage sgn mult store
stop

cond
*.eye6 34 >
*.refeye *.myeye !=
*.refeye 0 !=
*.totalmyspecies 100 mult *.totalbots div 10 <
start
-6 .shoot store
16 .shootval store
stop

cond
*.totalmyspecies 100 mult *.totalbots div 10 <
*.body 800 >
start
30 .repro store
314 rnd .aimdx store
stop

' Feed on and store body

cond
*.nrg 2000 >
start
100 .strbody store
stop

cond
*.nrg 500 <
start
*.body 0 floor .fdbody *.body sgn mult store
stop

It is a carnivore modification of swarm 2.0. It should in theory attack and reproduce when his population is below 10%, but it doesn't do nothing all the time. Where did I made errors? Sorry but I'm not very good at programming.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Preditor effectivness gene for evo sims
« Reply #13 on: November 19, 2007, 12:00:33 PM »
I ran your bot.  .totalbots and .totalmyspecies are working and your lines that use them appear to be correct.  It simply looks like none of the condtions of your genes are being fully met.  

After it reproduces, body is below 800.  nrg is between 500 and 2000.  Its' so close that it's still staring at it's offspring.  refeye = myeye.   All of the gene conditions are false so nothing happens.

Try dropping some of your conditions.  You'll see some action.
Many beers....

Offline Ispettore

  • Bot Neophyte
  • *
  • Posts: 32
    • View Profile
Preditor effectivness gene for evo sims
« Reply #14 on: November 20, 2007, 03:59:03 AM »
thank you and sorry if I'm still bothering you, but I still don't understand. in swarm all this genes work at perfection, and here (apart that he's carnivore) they are all the same, but they should activate in theory when his population is below 10%. Are you telling me that I should put the line of population control only in one gene to make it work? Sorry again, I'm not very expert...