Bots and Simulations > DNA - General
How do I do "and" and "or" statements?
havingphun:
Would I do it like this:
--- Code: ---cond
*.nrg 1000 >
and
*.body 100 >
start
30 .repro store
stop
--- End code ---
Is that how to do it because i cant get it working.
Also I have another question whats the difference of putting *.nrg and .nrg
Thanks in ahead and i hope you can help me.
Panda:
You put it after the two things you want to compare
--- Code: ---cond
*.nrg 1000 >
*.body 100 > [b]and[/b]
start
30 .repro store
stop
--- End code ---
*.nrg gets the value in the location of .nrg
.nrg just gets you the location(which is 310)
*310 would do the same as *.nrg the ".nrg" is just a label.
310 by itself is just a number
havingphun:
do i need the b's surrounding the and? So it would be
--- Code: ---cond
*.nrg 1000 >
*.body 100 >
and
start
30 .repro store
stop
--- End code ---
Then if nrg and body are both more than the number specified then the bot will reproduce, right?
Panda:
No, they were meant to make it bold, but I realise now that I put it into a code box, nevermind. :L Yes, it would, with 30% of it's resources transferred to the new bot.
Panda:
You don't need the "and", in this case, it is already assumed by DarwinBots. You would need it, however, if you were doing more complex functions or using "or"... for example
--- Code: ---cond
*.nrg 1000 >
*.body 100 >
and
*.nrg 10000 >
*.body 10 >
and
or
start
30 .repro store
stop
--- End code ---
The bot would then reproduce under those 2 conditions. There would be other ways to that condition more efficiently, though.
Navigation
[0] Message Index
[#] Next page
Go to full version