View Full Version : generate Random number
05-14-2008, 11:24 PM
i have a simple question. Is it already exists a methods that can generate random numember given a fixed interval?
thank you so much
05-15-2008, 12:23 AM
Look at the description of the "?" operator. This uses a linear feedback shift register to transform a 32 bit number to another 32 bit number in a pseudo-random fashion. You can then modify these numbers to get any interval you want. For example, you can use the modulus operator "//" to get pseudo-random numbers in the interval 0-n given a 32 bit pseudo-random number.
05-15-2008, 12:49 AM
For the Ladder game that I just posted, I used this. Also, I used CNT to seed this generator when the user hits the "P" for play button.