Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
help with random numbers and if/else statements
Old
rich2k2r6
Guest
 
Status:
Posts: n/a
Default help with random numbers and if/else statements - 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.
Attached Files
File Type: a2w wackamole.a2w (895.9 KB, 469 views)
   
Reply With Quote
Try this.
Old
DrJim
Guest
 
Status:
Posts: n/a
Lightbulb Try this. - 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 - but it has seemed to work for me and other in this forum.
   
Reply With Quote
Old
rich2k2r6
Guest
 
Status:
Posts: n/a
Default 10-31-2006, 11:10 PM

Thanks, that worked
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.