Author Topic: How do I do "and" and "or" statements?  (Read 4122 times)

Offline havingphun

  • Bot Builder
  • **
  • Posts: 54
    • View Profile
How do I do "and" and "or" statements?
« on: September 26, 2011, 03:07:49 PM »
Would I do it like this:

Code: [Select]
cond
*.nrg 1000 >
and
*.body 100 >
start
30 .repro store
stop

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.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: How do I do "and" and "or" statements?
« Reply #1 on: September 26, 2011, 03:11:07 PM »
You put it after the two things you want to compare

Code: [Select]
cond
*.nrg 1000 >
*.body 100 > [b]and[/b]
start
30 .repro store
stop

*.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
« Last Edit: September 26, 2011, 03:12:40 PM by Panda »

Offline havingphun

  • Bot Builder
  • **
  • Posts: 54
    • View Profile
Re: How do I do "and" and "or" statements?
« Reply #2 on: September 26, 2011, 03:19:11 PM »
do i need the b's surrounding the and? So it would be

Code: [Select]
cond
*.nrg 1000 >
*.body 100 >
and
start
30 .repro store
stop


Then if nrg and body are both more than the number specified then the bot will reproduce, right?

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: How do I do "and" and "or" statements?
« Reply #3 on: September 26, 2011, 04:41:16 PM »
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.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: How do I do "and" and "or" statements?
« Reply #4 on: September 26, 2011, 04:47:29 PM »
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: [Select]
cond
*.nrg 1000 >
*.body 100 >
and
*.nrg 10000 >
*.body 10 >
and
or
start
30 .repro store
stop
The bot would then reproduce under those 2 conditions. There would be other ways to that condition more efficiently, though.

Offline havingphun

  • Bot Builder
  • **
  • Posts: 54
    • View Profile
Re: How do I do "and" and "or" statements?
« Reply #5 on: October 13, 2011, 06:27:38 PM »
ok thanks