Alice Community

Alice Community (
-   How do I...? (
-   -   HiLo game (

rmille2 12-10-2008 08:32 PM

HiLo game
I have students writing a simple HiLo game where they generate a random number from 1 to 100 and then some object tries to guess it. Sometimes when the guess is equal to the number and the two are compared in a while loop (while guess != number) the loop keeps going and the bject says too high or too low. How can I remedy this situation?

DrJim 12-11-2008 06:11 PM

The random number generator [I]occasionally[/I] doesn't generate an integer even when it is supposed to (a bug listed in the official bug list). This doesn't always happen (in one class I know of, for a specific program only about 4 people out of 20 had a problem) so it can be very discouraging to debug.

The fix is to basically multipy the result from the random number generator by 1.0 before making the test - for more detail do a forum search or look at the bug list on the Alice home page.

All times are GMT -5. The time now is 12:23 AM.

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