charles_platt
New member
For a game, I am thinking I can get an evenly weighted random integer from 1 through 6 by doing this:
--use the byte value from the random function.
--if 252 or greater, discard and get another random byte.
--divide by 6 using modulus // operator and assign the result to a variable.
--add 1
Is there a more elegant way to do it? I would prefer to have every result taking an equal amount of processor time, so throwing away numbers =>252 and trying again is not optimal.
--use the byte value from the random function.
--if 252 or greater, discard and get another random byte.
--divide by 6 using modulus // operator and assign the result to a variable.
--add 1
Is there a more elegant way to do it? I would prefer to have every result taking an equal amount of processor time, so throwing away numbers =>252 and trying again is not optimal.