Page 1 of 1

Rather Simple Question

Posted: Wed Aug 25, 2004 7:21 am
by Yoshi348
I was looking through the source code for the robot/alien/whatever's move delay, and I found it, but I'm kind of stuck on what it means.

8 + 8 * !RND(3)

From an earlier topic Zomis said that regular RND(3) will produce an integer from 0-2... but since I don't actually KNOW C, I have no idea what !2 will end up being. !1 and 0 would end up 0 and 1 respectivly, I think, but the only guess I have for !2 would be a bitwise not bringing it to 1. A nifty short hand for a 1/3 of a zero, but two possible delays doesn't seem to fit with what I experience with the game.

Posted: Wed Aug 25, 2004 7:43 am
by Flumminator
! is logical negation

0 is false
everything else is true

results in:

!0 == 1

!1 == !2 == !3 == ... == 0

Posted: Wed Aug 25, 2004 7:54 am
by Zomis
What Flummi said is true, so when bringing it to a more understandable level, the possible turnouts is:

Code: Select all

8 + 8 * !RND(3) = 8 + 8 * !0 = 8 + 8 * 1 = 16
8 + 8 * !RND(3) = 8 + 8 * !1 = 8 + 8 * 0 = 8
8 + 8 * !RND(3) = 8 + 8 * !2 = 8 + 8 * 0 = 8
Which means that there's 1/3 chance for a movedelay of 16 and 2/3 chance for 8.