PDA

View Full Version : help with random numbers and if/else statements


rich2k2r6
10-31-2006, 10:18 PM
I am practicing in alice and trying to do a wack a mole game, i made a variable and set it to random number between 1 and 4. I have my if then else statements set up to true if variable is 1, ect. the variable is changing, but for some reason the if/else statements are not doing their action.

DrJim
10-31-2006, 10:59 PM
This seemed to work - at least I got different behavior with the added statement enabled or disabled.

After the random number call, add a statement:

world.which mole = world.which mole*1.0

(do not write it as *1 but as *1.0)

This will convert the variable to double precision format and the comparison will work.

I don't know why this is sometimes needed and sometimes not :mad: - but it has seemed to work for me and other in this forum.

rich2k2r6
10-31-2006, 11:10 PM
Thanks, that worked