Friday, September 29, 2017
Sunday, September 17, 2017
Saturday, September 16, 2017
Rolling 1–3 with a d6
How would you generate a random number in the range 1–3 uniformly using a d6?
There are at least three ways which seem natural to me:
Most people, I imagine, would divide by two and round up.
Rounding strikes me as a trait of a poorly designed game. I prefer to use modular arithmetic.
There is the problem that the modulus operator returns a number in the range 0–2, at least when we are computing a number modulo 3. We can add 1 to the result, but I prefer to use 3 in place of 0. After all 0 and 3 are the same modulo 3.
There are at least three ways which seem natural to me:
d6 ⌈d6/2⌉ d6%3+1 d6%3 replace 0 w/ 3
---- ------ ------ -------------------
1 1 2 1
2 1 3 2
3 2 1 3
4 2 2 1
5 3 3 2
6 3 1 3
Most people, I imagine, would divide by two and round up.
Rounding strikes me as a trait of a poorly designed game. I prefer to use modular arithmetic.
There is the problem that the modulus operator returns a number in the range 0–2, at least when we are computing a number modulo 3. We can add 1 to the result, but I prefer to use 3 in place of 0. After all 0 and 3 are the same modulo 3.
Friday, September 8, 2017
Subscribe to:
Posts
(
Atom
)