Bots and Simulations > The Gene depository

carnivore gene

(1/1)

Ispettore:
Hello... I don't know if I can post here this request...
I'd like just to have a carnivore gene... so that the bot with it can't eat veggies... and I also would like to have the gente from T preseverant that avoid killing veggies... can you help me?

MacadamiaNuts:
The old and most common way of checking if a target is a veggie is checking its number of eyes. Veggies usually doesn't have them:

*.eye5 0 >
*.refeye 0 =

Then you use that condition (or negate it *.refeye 0 !=) in the targetting and hunting eyes to avoid them.

To avoid killing the target, check it's energy, like:

*.refnrg 500 >

Ispettore:
could you please make me an example of where should I put it in the eat gene? I'm not very good ad bot programming  

Peter:
For example in the shooting gene.


--- Quote ---cond
*.eye5 25 >
*.refeye 0 !=
start
-1 .shoot store
stop
--- End quote ---

explanation

cond:             start gene
*.eye5 25 >    check oponent close
*.refeye 0 !=   check is it a veggy if not go thru
start                go if conditions are true
-1 .shoot store  :shoot
stop                   :end gene


for just changing a bot behaviour to herbovore
put this in the shooting gene.Between cond and start.

--- Quote ---*.refeye 0 !=
--- End quote ---

Hope this helps.

Peter:
for the T-preservants
the gene

  *.refnrg  500  >

This one checks if the veggie has enough energy to survive. And this condition(between cond and start)
has then to be put in every shooting gene.
Just as the carnivoures gene.

The complete gene

cond
  *.eye5  49  >
  *.refdn  20  <
  *.refnrg  500  >(.......<---------the one it's about.)
  *.refshoot  0  =
start
  -1  .shoot  store
stop

Navigation

[0] Message Index

Go to full version