Random Numbers in Games

12102016, 12:10 AM
Post: #1




Random Numbers in Games
When I write a game for the calculator or for Microsoft Small Basic I typically use uniformly distributed random generated numbers. I then use a low or high threshold probability value (such as 0.90, 0.95, 0.10, 0.15, and so on) to compare with the random numbers and determine the occurrence of an event. Since I am using uniformly distributed random numbers, the probability of reaching any of these threshold values is uniform.
To make things more difficult, you can use normallydistributed random numbers such as: r = 0.5 + normalRand() / 6 The values for r have the highest probability at 0.5 and die out as you go above and below 0.5. The above equation gives ranges of values slightly below 0 and slightly above 1, so that values close to 0 and 1 don't become very unlikely (in case you want to use, say 0.01 as a threshold level in a game). You can use thresholds of say 0.2 or 0.8 (and values near them) to allow events to occur. However, unlike the uniformly distributed counterparts, the probability of occurrence of r around 0.2 or 0.8 is lower! This makes the game more challenging or more frustrating, depending on the game and your own patience to win. Namir 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)