Probability Random Number Generator

Posted by Excl on Stack Overflow See other posts from Stack Overflow or by Excl
Published on 2010-06-10T16:38:35Z Indexed on 2010/06/10 16:42 UTC
Read the original article Hit count: 279

Let's say I'm writing a simple luck game - each player presses Enter and the game assign him a random number between 1-6. Just like a cube. At the end of the game, the player with the highest number wins.

Now, let's say I'm a cheater. I want to write the game so player #1 (which will be me) has a probability of 90% to get six, and 2% to get each of the rest numbers (1, 2, 3, 4, 5).

So, how can I generate a number random, and set the probability for each number?

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about random