PDA

View Full Version : generate Random number



Johnnyfumi
05-15-2008, 12:24 AM
Hy guys,
i have a simple question. Is it already exists a methods that can generate random numember given a fixed interval?
thank you so much

Johnny

Mike Green
05-15-2008, 01: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.

Rayman
05-15-2008, 01: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.