Author Topic: Divide by Zero  (Read 3198 times)

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Divide by Zero
« on: November 23, 2007, 06:04:32 PM »
I was trying to write a new bot and came across a few questions that I couldn't find an answer for.

What value does a divide by zero return? I saw in DB 3 it will yield a 0 is this true for 2.4x also?

True and False can be used to control whether parts of genes execute, can conditional operators be used to control them?
For example I have a gene (Which I doubt works, as this computer cant really run DB I cant test it) that asses if the bot is being hurt to much and should run away:
Code: [Select]
'See If I Am Being Hurt Too Badly
cond
 *.wellness 0 <=
start
 628 rnd 314 add .aimsx store
 *.maxvel .up store
 *.welltime 4 mod 0 =
 0 .wellness store
stop

Finally,
Code: [Select]
*.refnrg *.refkills div *.nrg *.kills div div 1 >=   'Less than one is bad/dangerousWould there be a better option for checking if the bot in eye5 is worth attacking? This one would have problems depending on what a divide by zero returns (veggies) and for low energy bots and a couple of other problems, such as never finishing off bots.

Edit: Also how many cycles does poison last for, is it the same as venom?

Sorry for all of the questions
« Last Edit: November 23, 2007, 06:53:42 PM by Shasta »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Divide by Zero
« Reply #1 on: November 24, 2007, 09:37:31 AM »
Quote from: Shasta
What value does a divide by zero return? I saw in DB 3 it will yield a 0 is this true for 2.4x also?

It's 0 too.  Generally any command that's mathematically invalid will return 0.  (like sqrt(-number)).

Quote
True and False can be used to control whether parts of genes execute, can conditional operators be used to control them?

Yes.  You don't even need to break up your genes into cond and start blocks even.

Quote
Edit: Also how many cycles does poison last for, is it the same as venom?

Yep, same as venom.  1 cycle per unit.

Quote
Sorry for all of the questions

Not at all.