Darwinbots Forum

Bots and Simulations => DNA - General => The Gene depository => Topic started by: EricL on August 22, 2007, 01:57:34 PM

Title: Preditor effectivness gene for evo sims
Post by: EricL 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
Title: Preditor effectivness gene for evo sims
Post by: Jez 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?!!
Title: Preditor effectivness gene for evo sims
Post by: EricL 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.
Title: Preditor effectivness gene for evo sims
Post by: Numsgil on August 25, 2007, 01:38:26 AM
It was part of the DNA changes I made for 2.4
Title: Preditor effectivness gene for evo sims
Post by: Ispettore on November 15, 2007, 09:06:05 AM
Is it possible to put the ratio myspecie\totalspecies in hunt genes?
Title: Preditor effectivness gene for evo sims
Post by: EricL 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.
Title: Preditor effectivness gene for evo sims
Post by: Ispettore 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
Title: Preditor effectivness gene for evo sims
Post by: EricL 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.
Title: Preditor effectivness gene for evo sims
Post by: Ispettore 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.
Title: Preditor effectivness gene for evo sims
Post by: EricL 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...
Title: Preditor effectivness gene for evo sims
Post by: Ispettore 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.
Title: Preditor effectivness gene for evo sims
Post by: EricL 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 (http://www.darwinbots.com/Forum/index.php?showforum=46) with an explanation of what you think should be happening and attach a sim.  I'd be happy to take a look.  Thanks.
Title: Preditor effectivness gene for evo sims
Post by: Ispettore 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.
Title: Preditor effectivness gene for evo sims
Post by: EricL 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.
Title: Preditor effectivness gene for evo sims
Post by: Ispettore 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...
Title: Preditor effectivness gene for evo sims
Post by: EricL on November 20, 2007, 11:07:51 AM
All the conditions in a gene get ANDed together and have to be True for the gene to fire, right?  Just walk through each of your genes for a bot in a sim.  Use the gene activations dailog.  Your genes arn't firing because for varyign reasons, their conditions arn't being met.

Gene 1 will only fire once.  When the bot is born.  Then never again.

Genes 2 and 3 and 4 will only fire when the bot sees a bot of another species.

Gene 5 will only fire if the bot is fat.  I.e. has body > 800

Gene 6 only fies when the bot has tons of nrg

Gene 7 only fies when the bot has low nrg.

You either need to add some more genes that do something (like rotate or move when there is nothing in view) or change these to have less stringent conditions or both.
Title: Preditor effectivness gene for evo sims
Post by: Peter on November 20, 2007, 12:37:48 PM
I would only put it inside the shooting gene, so just only in this one.

If you put it in all genes a bot doesn't do anything at all. And they will suddenly repro and shoot and move at the same moment if population comes under 10%.

If you use this gene it will sudenly shoot if pop under 10%, hmmm, maybe something like a 'rnd' could be nice also. But this should work like that.

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

Edit: heh I posted this when I though the last post on page 1 was the last post.

I just looked, and yes this bot is missing something, by the way, why does this bot use eye6 instead of eye5. Is kinda strange. shoot if it sees something on the right.
Title: Preditor effectivness gene for evo sims
Post by: EricL on November 20, 2007, 12:43:46 PM
FYI, the problem has nothing to do with the specific line(s) using .totalbots/.totalmyspecies.  The bot would still pretty much do nothing if you remove them all.
Title: Preditor effectivness gene for evo sims
Post by: Peter on November 20, 2007, 12:56:08 PM
Yes, Eric you're right I just didn't looked at the first post of page 2.

I readed something that this bot was swarm2 with some modifications, and I just didn't really looked at the genes, I just thought, well that should be alright.

Wich brings me to anther point.

Quote
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.
I am no swarm expert, but the bot in the leagues doen't really look like this(I am pretty sure), compare your swarm with the swarm2.0 at the forum.

This could also explain the problem, that in the other topic where you claim, that the mutation-bot of swarm is stronger than swarm itself.

Is this the bot that is supposed to be swarm without this lines. That could explain something.
Quote
*.totalmyspecies 100 mult *.totalbots div 10 <
Title: Preditor effectivness gene for evo sims
Post by: Ispettore on November 21, 2007, 09:19:20 AM
lol, I mean it is this bot

' SWARM
' (Updated for v2.43)

' Delete birthtie and move

cond
start
.tie 1 *.robage sub 0 floor mult inc
.deltie inc
*.maxvel *.vel sub .up store
stop

' Set eye5

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

' Swarm

cond
*.robage 5 mod 0 =
*.eye5 0 >
*.refeye *.myeye =
start
*.refaim .setaim *.robage sgn mult store
stop

' Eat food

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

cond
*.eye5 50 >
*.refeye *.myeye !=
start
*.refvelup .up store
*.refxpos *.refypos angle .setaim *.robage sgn mult store
stop

cond
*.eye6 34 >
*.refeye *.myeye !=
start
-6 .shoot store
16 .shootval store
stop

' Reproduce

cond
*.body 700 >
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

' Anti-virus (just in case)

cond
*.mkvirus 0 !=
start
*.mkvirus .delgene store
stop

end

wich I found on the forum, only I have set that he can eat only other bots, and I removed the anti virus and the swarming tecnique (I wanted it to be less strong than swarm2.0, wich btw work perfectly)
Title: Preditor effectivness gene for evo sims
Post by: EricL on November 21, 2007, 12:23:11 PM
You broke the bot big time when you removed the first gene.  In particular, this line:

*.maxvel *.vel sub .up store

is critical.