I'm trying to build a small game similar to D%26amp;D and need a ';simple'; way to generate random numbers. The only problem is that they need to have ranges. For example:
I'm trying to get a randomly generated number between 5 and 7.
I thought dice would be the way to go. But I'm also trying to get random numbers between 1 and 50, 29 to 36 etc.
Two ten sided die work great for making percentages but they dont give me the ability to have ranges.
I hope there is a solution! Thanks for reading :)How can I get random numbers using dice?
Roll a single six-sided die. A 1 or a 2 gives you 5, a 3 or a 4 gives you 6, and a 5 or a 6 gives you 7.
In math terms X = 5 + int((%26lt;roll%26gt;-1)/2) where int(x) gives the integer part of x.
For numbers 1-50, use your two ten-sided dice to give you a two-digit number from 00 to 99. X = 1 + int((%26lt;roll%26gt;)/2).
For 29 to 36--mmm this one's tricky---ah!:
Use 1 ten-sided die; if the number is 8 or 9, roll it again until is ISN'T 8 or 9. Then X = %26lt;roll%26gt; + 29.How can I get random numbers using dice?
There is only one number between 5 and 7
good luck
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment