Dice Computation Question

Hmm, okay, I thought d4xd6 would work. So we have only a solution for range 1-24, that is, d12 with d2 as explained. What are the solutions for the other ranges? For instance, 1-81 wouldn’t be obtained by d9xd9 (using a d10 and ignoring the roll if it’s a ten)?

I know I could use an appropriately-sized card deck for each range, but I’m looking for a quick sequence of die rolls for results since I don’t want to have to keep various card decks at the ready.

Or a random number generator on a computer or programmable calculator.

As an aside, there are shapes which would make for a fair d24 or d30 (or, in fact, for a fair d48, d60 or d120), but there’s no reasonable shape which would make for a fair d100. The d100s that you can buy are acknowledged not to be completely fair; the hope is just that with 100 possible outcomes, it would take a really long time for the unfairness to show up. Alternately, as with any even number, you could make a fair d100 from a dipyramid, but that would be horribly impractical, as it’d basically just be a couple of cones, and would be even harder to read than the golf-ball ones.

All the solutions I gave would work; you just shouldn’t interpret the numbers that come up on the dice by multiplying them. Rather, you can interpret them as akin to consecutive digits.

So, with the example of rolling a d4 and a d6 to simulate a d24, you can interpret the results as follows:

1 on the d4: the result is the value on the d6
2 on the d4: the result is the value on the d6 + 6
3 on the d4: the result is the value on the d6 + 6 * 2
4 on the d4: the result is the value on the d6 + 6 * 3

So, for example, 2 on the d4 and 5 on the d6 would be considered a result of 11.

Or to put it another way, for any dice with facets numbered 1-X and 1-Y, the formula to get a random roll within the range 1-X*Y is : (roll(X)-1)*Y + roll(Y)

Yes, I just worked that out and I’m quite proud of myself. Don’t judge me, I’m an English major ! :slight_smile:

So for range 1-81 using two d9 (d10 ignoring any roll of ten), plugging into your equation:

range 1 to (99) = range 1 to 81
(roll(9)-1
9) + roll(9) = [d(9-1)d9] + d9 = (d8d9) + d9

yields these example results:

(11) + 1= 2
(8
9) + 9 = 81

Wouldn’t that yield range 2 to 81?

So far I think these will be the easiest rolls for me:
for range 1-24, use d12 and a d2 (I Ching coin) to determine results 1-12 versus 13-24.
for range 1-78 and 1-81, use d10 for tens and another d10 for ones, reroll if resulting number is too high (79-100 or 82-100).

Still looking for easy rolls for ranges 1-32, 1-33, 1-48, 1-52, 1-54 and 1-64.

OK, so what if I want the odds of any number coming up to be the same across the range?

Um. Never mind for most of these. I was too preoccupied with the World Series game, but 1-32, 1-48, 1-54 and 1-64 are easily obtained as explained above. If anyone has a solution for 1-33 or 1-52, let me know.

Don’t multiply the dice as I previously thought you’re supposed to do. For range 1-24, use d6 and d4 (or d12 and d2), but don’t multiply the results.

Roll the d6 and d4.

For d4 result

of 1, result will be 1-6,

of 2, result will be 7-12,

of 3, result will be 13-18,

of 4, result will be 19-24, depending on the d6 roll. They all have an equal 1-in-24 chance.

Sorry if you’ve already thought of this, and I know you said you don’t want loads of decks of cards hanging around, but for 1-52 a standard deck of playing cards is going to be easiest and quickest, I think. As pointed out up-thread, the factor of 13 makes it awkward with dice.

Speaking of emulating dice with cards, have you ever lacked a pair of dice for playing craps?

You can emulate rolling a pair of dice by drawing one card from a deck of 36 cards taken from an ordinary playing deck.
Use the 2, 3, 4, 5, 6, 7, 8, J, Q of each suit. Cards have their face value; Jacks count 4, Queens 6. Add 0 for a club, 1 for diamond, 3 for heart, 4 for spade.
Thus 4 or Jack of clubs would be a Four total, 4 or Jack of spades an Eight, and so on.

This gives the exact same distribution (8 occurs 5/36 etc.) as a pair of dice. For example, 8C, 7D, 5H, 4S, JS are the five ways to get 8. Crap cards are 2C, 2D, 3C, 8S. The six ways to seven-out are 7C, 6D, QD, 4H, JH, 3S.

In craps, the only time it matters which particular way a total is reached is the Hardway Bets. Hard Four, Hard Six, Hard Eight are achieved with Diamonds. The Queen of Spades is Hardway Ten.

For 1-33, use the d6 and d12. If the d6 shows 1 or 2, select a number in the range 1 to 11. If it shows 3 or 4, your number is in the range 12 to 22. If it shows 5 or 6, your number is in the range 23 to 33. Use the d12 to pick a number from within the selected range. Reroll if the d12 shows 12.

For 1-52, use the d4 to select a range from 1 to 13, 14 to 26, 27 to 39, or 40 to 52, and use the d20 to pick a number from the selected range. Reroll if the d20 shows 14 or higher.

Do you mind if I ask what this is all for? Unless you’re doing these rolls over and over again, coming up with a unique roll for each range seems way too complicated.

What I would do is roll the percentile dice. (That’s the d10 marked with ones and the d10 marked with tens.) That gives you a number from 1-100.

Does the number fall in your range? That’s your result! Does it fall outside your range? Re-roll until it does!

Even for relatively low ranges you still only have to make a handful of rolls to get a result. And that’s much less work than trying to come up with an elegant way to generate 1-33 with a single roll.

I think the penultimate equation in your post should be:

(0*9) + 1 = 1

Think of it this way: since there’s 9*9 different ways that two 9-sided dice can land, there must be 81 different values you can map those results to. And the range of 2 to 81 is only 80 different values. So what your post implies is that 2 different rolled dice results/combinations would have to map to some equivalant value, which obviously isn’t the case.

Well, it has already been explained, but the lowest value for (roll(d9)-1) is 0, not 1. So the lowest result would be (1-1)*9 + 1 = 1

[QUOTE=septimus]
Speaking of emulating dice with cards, have you ever lacked a pair of dice for playing craps?
[/QUOTE]

Speaking of emulating dice with cards, have you ever sat at a roleplaying table and lacked a d10 ? Well, lucky for you, you always carry your Bible with you. Or a dog-eared copy of the Lord of the Rings. Or the Dungeons & Dragons Advanced Player Guide.
Flip to a page at random. Look at the right page’s number. The last digit is your d10. The second-to-last digit is a +0/+1 toggle based on whether that digit is even or odd, where 0 counts as even (because all other things being equal, the page number for the right page will always be odd, and we can’t have that).

Similarly, you could use a d10 for the ones digit, and another die that’s just larger than the desired range for the tens digit. So if you want to roll 1-33, use a d4 and a d10. That gives you a 0-39 range, and re-roll on a 1 or 34-39. Just remember that the digits need to be in 0-[n-1] range. For a d10, that usually means you treat the 10 as a 0. For other dice, you need to subtract one.

For 1-33, roll your 2 D10s as a D100, and divide by 3, discarding the remainder. If you roll 00, try again. If you roll 01 or 02, it’s a 33. (Assuming dice marked 0-9, all my D10s were back when I played).

Assuming that the goal is to minimize the total number of dice rolls, and assuming that the number of outcomes you want has a prime factor not found in any of the dice you have, a good general algorithm is to first roll your largest die as many times as you need to to give a range larger than your target range. If the number you roll is less than or equal to the largest multiple of the target range, then just take it modulo the target range, and you’re done. If it’s in the remainder, then you’ll have to roll more, but you probably won’t need to start from scratch: You’ve still got some entropy left over, and you can use that.

This would probably be clearer by example. Let’s say, for instance, that you have the standard set of D&D dice, and you’re trying to get a 33 (which has 11 as a prime factor, unlike any of the standard D&D dice). The largest die you have is a d20, so that’s all you’ll roll. A single roll of the d20 isn’t enough, since 33 > 20. Two rolls is enough to start with, since 400 > 33.

So you’ve got your two rolls of the d20, and you use that to generate a number from 1 to 400. Now, 396 is the largest multiple of 33 in that range, so if you get a number between 1 and 396, you just take that number mod 33, and you’re done. If you get 397, 398, 399, or 400, you have to roll more… But you still have the equivalent of a 1d4 roll lying around, for free.

Use that d4 and another roll of the d20 to give you a number from 1 to 80. If that number is 66 or less, again, take the modulo, and you’re done. If it’s 67 or higher, you now have the equivalent of a d14 leftover, which you combine with another d20 roll to make a d280, and so on.

Now, this method isn’t guaranteed to be optimal. It might sometimes be better to use the d12 instead, or even the d8. And it doesn’t even touch on the cases where the target range has all of its prime factors in common with your dice, in which case you can guarantee a result without ever needing rerolls. But it’s still a pretty good general algorithm.

Note, incidentally, that it’s never optimal to use the d6, d4, or d2, since those are all factors of 12. And it’s very rarely optimal to use the d8, since all it has to recommend it over the d12 is an extra factor of 2.

Love your work Chronos. However, I am having difficulty of envisaging a scenario where converting a roll of 18,7 to (20×18+7)[sub]mod33[/sub] is more convenient than other methods described.

For me, if I absolutely needed 1-33 in a single roll I would type randint(1,33) on my trusty casio and be done.