##
A Mathematical Analysis of Exploding Dice *March 22, 2009*

*Posted by eric22222 in General, Math.*

trackback

trackback

(Session 66 has been posted)

I’m guessing the title caught your eye? I wrote this essay a while back, but decided to hold off on posting it until I had my power cord back. So… here we go:

With a normal die roll, the result is either 1, 2, 3, 4, 5, or 6. This will later be generalized to N-sided dice, but for now, the standard six-sided variety will suffice. Some games (dice-based tactics games, usually) use a system called “exploding dice.” With this system, rolling the maximum value on a die allows the roller to roll the die again and add the new result to the previous one. There is usually no limit on the number of rerolls.

For example, a player rolls a six. He rerolls the die, which lands on six once again. Once more, he rolls, but this time gets a two. His final result for this roll is effectively fourteen, even though the die has only six faces .

Put simply, expected value is what the average result for an experiment would be if were tried an infinite number of times. For example, if a coin flip was worth one point if heads lands and two points for tails, the expected value would be 1.5 since heads and tails are equally likely.

To compute expected value, the sum of each possibility times its respective chance is taken. For the coin flip example, this would be . That is, a 50% chance of 1 point plus a 50% chance of 2 points.

So the problem to be tackled here today is this: how does the expected value of an exploding die differ from its standard expected value?

The first step will be to find a pattern. Here is a quick comparison of values and their respective probabilities:

**x, Pr(x)**

1, 1/6

2, 1/6

3, 1/6

4, 1/6

5, 1/6

7, 1/36

8, 1/36

9, 1/36

10, 1/36

11, 1/36

13, 1/216

14, 1/216

…

So how can these be put into an elegant formula? First of all, a simple sum of products will be used:

The factors preceeding each sum are powers of six, so they can be consolidated into a nested sum:

Each sum, such as , is equal to the average value times the number of elements. The number of elements remains a constant 5, but the average value is increased by 6 for each subsequent sum, beginning with a value of 3. The formula can now be rewritten like so:

Simplifying some of the products, the formula can be rewritten once again:

Now an obvious pattern begins to develop. By expanding these nested products, the pattern becomes even more clear:

Six is factored out of all terms:

This new formula can be rewritten in sumation notation:

For each term added, our error will be reduced by a factor of 6, so just a few terms will return a very accurate result:

**N, sum to N
**0, 2.5

1, 3.75

2, 4.0972222

3, 4.178240741

4, 4.194058642

5, 4.197595165

The sum is swiftly approaching exactly 4.2, but what is the relation of that value to a six-sided die’s normally expected value?

Adding the exploding modifier to a six-sided die changes its expected value by a factor of . That is, the ratio of the number of sides on the die to the number of sides that do not “explode.”

I have performed the same calculations on four and eight-sided dice to compare results, and the forumla holds.

**For any N-sided die numbered 1 to N with all sides equally likely, the exploding modifier will increase the die’s expected value by a factor of .**

Interestingly enough, this formala holds for a hypothetical one-sided die. Heuristically, since the highest number will always be rolled, the total will constantly increase, returning an infinite result. Mathematically, the expected value of 1 will increase by a factor of , which approaches positive infinity from positive values.

*This essay was written by Eric Dobbs, an undergraduate student of computer science at the University of Tennessee, Knoxville. He can be reached at erictdobbs -at- gmail -dot- com.*

The Pathfinder Chronicles campaign setting sets some heavy restrictions on the user of firearms, what with chances to misfire, the need to have a special feat, penalties for different sized creatures and an obscene entry cost. The fact that these weapons do exploding damage might make up for this, but by this analysis, it doesn’t look like much of a difference.

But, a player might object, despite the vanishingly small probability at each iteration, there is at least some chance of blowing away a dragon with one shot. Okay. Well, in order to make an informed decision about that we would need to know for one thing what the chances even are of doing more than the maximum of the same damage roll that doesn’t explode. Is there a way to calculate that, or to calculate an expected maximum value?

Thanks for the comment, Johnny.

There’s a simple way to determine just how easily the result can explode. For a d6, you have a one in six chance of getting anything greater than 6; if you roll a natural six (one in six chance), you’ll add another roll.

The chance of it exploding a second time is a further one in six, so the chance of rolling higher than 12 is one in six to the second power, or one in thirty-six.

So the probability of rolling higher than x*N on a dN is N^(-x).

[…] then I had the brilliant idea of searching on the Internet. And I found Eric, who did an actual math analysis of exploding dice. Much better than my feeble attempt. I almost wanted to tear up all my calculations in shame. His […]

Thank you for the great essay!

I’m fiddling with an exploding coin-based system (heads count as “hits”, and get one reroll as well), and you’ve made it much easier for me to figure out target numbers.

[…] like to start with some data, then find a pattern. This is going to use expected value, too, so brush up on that if you need […]

In the hope the author is still active…I have a question on the subject, how if the system your playing is built so that you if you roll a 6 have to pick it up, add another die and roll them together and if any of them is a six you do the same thing over, then the value of the two die could be lower than your first six, how would you calculate the average result of rolling 3 dices then? I myself calculated it to 10,66666 but i’m sceptical beacuse it’s very close to the “normal” average of 10,5.

Thanks for the question Michael.

If I’m reading your post right, the idea is that the player starts by rolling one die. If a six is rolled, the player discards the result and rolls two dice. If either of them is a six, the player discards that total and tries again with three, and so on.

Am I on the right track? I’ll see if I can come up with an answer sometime in the next bit, but let me know if you had some other system in mind for how this works.

Yes it’s how it works, the number of dice you throw in the beginning is based on the difficulty of the task but the normal is 3D6. And like you say if you roll a six you pick it up and roll 2 dice and so on.

But i guess the simpliest is to calculate for one dice and multiply that with 3. Thx for the help 🙂

[…] meant in my discussion of Dice to explain why I don’t like exploding dice, I’ve had this prejudice since I first encountered it with the firearms rules of AD&D 2nd […]

I’m hoping the author is still active and can answer my question.

If, using a 6 sided die, all 1’s were rerolled, how would it affect the exploding dice result? And what would the average value now be for each die?

Thanks for the question. I’ve tried quickly recalculating things with only 1’s being rerolled, and the results are pretty awesome:

It doesn’t change the expected value at all!

This completely unintuitive, and I keep thinking of several reasons that this shouldn’t happen, but the numbers don’t lie. I’d guess the same would hold true regardless of which number explodes.

It’s hardly proof, but I’m in a rush right now, so this link will act as an explanation for now: http://tinyurl.com/3e5tsrc

So what would the “exploding’ relationship be say if:

Dice still “exploded” on rolls of six but in addition, all 1’s were rerolled but not tallied towards the sum of the roll. Specifically I’m thinking of 4E’s “Brutal” mechanic.

For example, a player rolls a six. He rerolls the die, which lands on six once again. Once more, he rolls, but this time gets a one. He then rolls again getting a two. His final result being fourteen (6+6+2) not counting the 1 which is a reroll but does not count towards the sum.

(How) Does this relate compared to the standard die roll?

Anthony:

With 1s not being counted, you essentially have each die roll being from 2 to 6, rather than 1 to 6. So it’s like using a five-sided die, but adding the total number of rolls made to the sum. It would take a little number-crunching, but shouldn’t be too difficult to figure out what the expected value of that system would be.

I may go through that problem in more detail if time permits in the near future. Thanks for the comment!

Eric:

What would happen with Fudge dice? Consider two scenarios:

1) Uncancelled fudge positives explode. The probabilities for -4,-3,-2,-1, and zero should remain unchanged right? What about the right hand side of the distribution?

2) All positives explode. I don’t have any intuition as to what would happen.

I am interested in modifying Fudge to be unbound on the top end. I like the distribution being zero centered and bound on the lower end but want to skew the normal distribution to be more like a gamma distribution.

Russ:

On 1), the probabilities for some values seem like they’ll be the same, but zero becomes MORE likely. Consider getting -1, +1, +1, and +1. Your net value of 2 means 2 exploding dice, and a 1/3 ^ 2 chance of dropping back down to zero! (This is assuming I understand how this system works; I read through it pretty quickly and think I have the idea of it).

For 2), I _think_ it wouldn’t change anything on the expected value. Regardless of which numbers explode, this system has an expected value of zero. Even with positive values exploding, you have a chance of getting negatives just as easily. Granted, this does mean you have a slim chance of getting high positives, but you also have a higher chance for dropping your value a little bit.

Ah, I wish I had more time to crunch the numbers on this, and look into the exact values for 1)… Sorry I can’t give you a more though-out answer than that right now, but thanks for the question!

Thanks for your reply Eric. I will see if I can write a script to simulate both case 1 and 2 and plot the distributions.

Case 1:

def reroll(seed):

roll=randint(-1,1)

if roll==1: seed=reroll(seed+roll)

return(seed)

y=[(randint(-1,1),randint(-1,1),randint(-1,1),randint(-1,1)) for i in range(temptemp)]

z=dict((x,0) for x in range(-5,20))

for quartet in y:

current=sum(quartet)

foobar=current

while foobar > 0:

current=current+reroll(0)

foobar-=1

try: z[current]+=1

except: pass

summer=0

for i in range(-5,20):

print(i,’ >> ‘, z[i])

summer+=i*z[i]

print(‘mean = ‘,summer/temptemp)

-5 >> 0

-4 >> 12551

-3 >> 49539

-2 >> 122722

-1 >> 198097

0 >> 233946

1 >> 132184

2 >> 98732

3 >> 65732

4 >> 40320

5 >> 22953

6 >> 12045

7 >> 6019

8 >> 2846

9 >> 1298

10 >> 572

11 >> 251

12 >> 126

13 >> 39

14 >> 14

15 >> 11

16 >> 2

17 >> 1

18 >> 0

19 >> 0

mean = 0.32029

Case 2:

def reroll(seed):

roll=randint(-1,1)

if roll==1: seed=reroll(seed+roll)

return(seed)

y=[(randint(-1,1),randint(-1,1),randint(-1,1),randint(-1,1)) for i in range(1000000)]

z=dict((x,0) for x in range(-5,20))

for quartet in y:

current=sum(quartet)

for i in quartet:

if i == 1: current=current+reroll(0)

try: z[current]+=1

except: pass

summer=0

for i in range(-5,20):

print(i,’ >> ‘, z[i])

summer+=i*z[i]

print(‘mean = ‘,summer/1000000)

-5 >> 0

-4 >> 12154

-3 >> 49208

-2 >> 106949

-1 >> 159171

0 >> 181193

1 >> 165938

2 >> 128313

3 >> 86641

4 >> 52673

5 >> 29122

6 >> 14992

7 >> 7302

8 >> 3515

9 >> 1625

10 >> 660

11 >> 330

12 >> 125

13 >> 51

14 >> 30

15 >> 5

16 >> 0

17 >> 2

18 >> 1

19 >> 0

mean = 0.666231

realized I screwed up, reroll should return (seed+roll)

Case 1:

-5 >> 0

-4 >> 12386

-3 >> 49185

-2 >> 123586

-1 >> 198264

0 >> 316030

1 >> 98861

2 >> 53122

3 >> 49220

4 >> 29381

5 >> 23082

6 >> 14679

7 >> 10782

8 >> 7001

9 >> 5001

10 >> 3233

11 >> 2128

12 >> 1403

13 >> 955

14 >> 576

15 >> 392

16 >> 268

17 >> 167

18 >> 101

19 >> 60

mean = 0.316747

Case 2:

-5 >> 0

-4 >> 12315

-3 >> 65853

-2 >> 147959

-1 >> 188539

0 >> 163155

1 >> 118834

2 >> 89146

3 >> 65830

4 >> 46828

5 >> 32605

6 >> 22580

7 >> 15367

8 >> 10570

9 >> 7045

10 >> 4648

11 >> 3072

12 >> 2022

13 >> 1314

14 >> 801

15 >> 544

16 >> 344

17 >> 234

18 >> 132

19 >> 99

mean = 0.659422

Case 2 is a lot smoother at (0,1) I think I like it better. I just wish it would drop off faster.

I will get this right eventually. Should be:

def reroll(seed):

roll=randint(-1,1)

if roll==1:

roll=roll+reroll(0)

return(roll)

Case 1:

-5 >> 0

-4 >> 12298

-3 >> 48920

-2 >> 123273

-1 >> 198050

0 >> 315862

1 >> 133076

2 >> 79703

3 >> 44299

4 >> 23107

5 >> 11543

6 >> 5373

7 >> 2516

8 >> 1120

9 >> 499

10 >> 217

11 >> 63

12 >> 50

13 >> 21

14 >> 4

15 >> 4

16 >> 1

17 >> 1

18 >> 0

19 >> 0

mean = 0.00216

Case 2:

-5 >> 0

-4 >> 12491

-3 >> 65801

-2 >> 153794

-1 >> 211560

0 >> 202355

1 >> 150298

2 >> 95262

3 >> 54115

4 >> 28080

5 >> 13999

6 >> 6751

7 >> 3115

8 >> 1404

9 >> 571

10 >> 233

11 >> 98

12 >> 51

13 >> 11

14 >> 4

15 >> 7

16 >> 0

17 >> 0

18 >> 0

19 >> 0

mean = 0.001973

Thanks! This is great for determining the average, but how can you help me even further by telling me how I can use this (or other some other smarter-than-me-math) to determine the probability of a specific sum (or more) being rolled for a given dice pool of exploding dice? We know six exploding d4 will result in a sum of 20+ more often than four d6, but how can I determine the specific probability? Ultimately I’d like to be able to map these probabilities and compare them against different targets and numbers of dice in the pool so as to better understand the impact and effectiveness of lowering the target or adding a die (and vice versa).

[…] Exploding Dice: Noen spill bruker et system med “eksploderende terninger” – det vil si at om man ruller det høyeste mulige tallet på en terning, får man kaste om igjen og legge resultatet til totalen. Gitt uendelig hell, er derfor det teoretisk mulige høyeste resultatet på terningkastet uendelig stort. Se også: A Mathematical Analysis of Exploding Dice (Eric22222, 22.03.09) […]

this is a great article.

thanks… I was able to figure out the numbers.

I think you might want it to update to represent the sum of the expected values / possible values * number of values / (number of values – number of values that do explode)

do you know anything about best of probability (i.e. 4d6, keep best 3)

[…] I could tell you about the math of the game Minesweeper (you can play it here), or about exploding dice. But the kind of explosion I want to share with you today is what’s called a […]

What about systems that use successes, rather than numerical value? For example, 1-3 are failures, and 4-6 are successes. On a 6, you get to roll another dice, with the possibility of more successes, or even more 6’s.

What would be the expectation of successes?

(EDIT) I think I misinterpreted how to tally successes. Modified calculations in the next comment down.

Let’s see…

In any roll of 1d6, you have a 3/6 chance of no success, 1/6 chance of 4 successes, 1/6 chance of 5 successes, and a 1/6 chance of 6 successes PLUS another roll’s worth of successes. So let x be the expected number of successes from a single roll.

x = 4/6 + 5/6 + (6+x)/6

6x = 4 + 5 + 6 + x

5x = 4 + 5 + 6

5x = 15

x = 3For comparison, without the exploding modifier, this rule set gives us an expected value of 15/6. And… hmm. Interesting! It still has the same modifier that a typical exploding die does! The expected value goes up by a factor of 6/5, or the ratio of sides to non-exploding sides.

And if you mean that 4-6 counts as one success…

x = (2/6)*1+ (1/6)*(1+x)

6x = 2 + 1 + x

5x = 3

x = 3/5

Which still follows the 6/5 modifier from the expected unexploded value of 1/2.

Dear Eric,

You seem to still be paying attention to this, so I have another question for you, if you could please take look:

What if the number of rerolls itself explodes?

This shows up in Ars Magica’s experimental magic rules, pg 109 of 5th edition. The problem I’m looking at is basically:

A wizard runs an experiment. For some probability 0.01<P<0.1, depending upon a couple parameters, a disaster happens.

Now, given that a disaster has happened, (so ignoring the above) 3 things basically happen:

1.) There is a disaster of some kind with probability 0.5

2.) The wizard gains "N" number of warping points depending on the parameters mentioned before. with probability 0.2

3.) Reroll again TWICE with probability 0.3

I'm trying to get some kind of estimate for the probability density function for estimating the warping points (btw, weird magic juju) the PC wizard gains.

Any thoughts?

Ok, so number 2 is what we want to count up, but I’m not sure on 1 and 3. The three events happen when a disaster happens (1)? Or if one of the rerolls comes back up (3)? Or either?

Hi Eric,

So on table, you first get a roll of Disaster.

Then you’re rolling on a Sub Table too see which kind *of* disaster.

1)i.e. Losing all your notes, blowing up your lab, destroying the local community you live in, etc I’ve lumped them together for my purposes with a probability 0.5

2.) warping points, with probability 0.2

3.) reroll again twice with probability 0.3

So a PC can get lovely combinations like getting massive warping and destroying everything in a 1 km radius. 😉

Alright, for every roll we make, we’ll wind up with an expected 0.5 disasters from (1) and 0.2N warping points from (2). So all we really need to do is figure out how many rolls we can expect.

Every roll gets us, on average, 0.6 more rolls. Those 0.6 get us an average of 0.6*0.6, and so on. This geometric series sums up to 2.5.

Therefore, starting from one initial roll, we get an average of 1.25 disasters from (1) and an average of 0.5N warping points.

Eric, interesting way of thinking about it. Thanks so much for the help! 🙂

Hello, Eric, and thank you for a very interesting article. Your conclusion makes it so much easier for me as a game master / dungeon master / guy-who-kills-player-characters to pick the nastiest weapons for my monsters, so now the bosses will feel all the more horrible. Thank you, again!

I have two questions for you, both on exploding dice, if I may.

1) In Hackmaster, they are called penetrating dice, and the rule is that any maximum rolled die gets rerolled, adding it’s total to the score with 1 subtracted every time the die is rerolled. So a d4p (four-sided penetrating die) yielding results of 4, 4, 4 and 2, is mechanically a single roll of a four-sided die yielding 11 (because 4 + (4 − 1) + (4 − 1) + (2 − 1) = 4 + 3 + 3 + 1 = 11). How can this change in how the ‘explosion’ works be factored into your formula? (i.e. _expected value = n + (n ÷ (n − 1))_)

2) Another novelty in Hackmaster, is that thieves get to roll for penetration if they are using their special weapons on the maximum _and_ the maximum minus 1. Using a d4p as example, a thief’s damage roll of 4, 3, 3, 4, 3, 2 would be a single die roll (threes and fours penetrating) resulting in 14 (since 1 is subtracted from all penetration rolls but the first). If using a d6p, the same thief would get penetrating rolls on fives and sixes. How could this be factored into your formula?

Crap. I got the formula wrong. It should read _expected value = (n ÷ 2 + ½) + (n ÷ (n − 1))_) Rght?

I don’t have time to actually figure this out, so I ran a Monte-Carlo simulation to get the results. For each Hackmaster set-up, I ran one million iterations on d4 – d12, then found a formula to express the results.

For a n-sided die…

Regular expected value is

( n / 2 ) + ( 1 / 2 )

Exploded expected value is

( (n + 1) / 2 )( n / (n – 1))

Hackmaster rules (subtract one from each roll past the first) expected value (exploding on highest value) is

( n / 2) + 1

Hackmaster rules expected value (exploding on highest two values) is

( n ^ 2 + n – 4 ) / ( 2 * n – 4 )

Hope this helps!

Thanks a lot! I hope you don’t mind me blogging about this (referencing to you, of course).

Just a couple of quickies:

Exploded is: ( (n + 1) / 2 ) + ( n / (n – 1) ) Right?

Hackmaster rules, reroll two highest: Is it really ( n ^ 2 + n – 4 ) / ( 2 * n – 4 ), or should it read ( n ^ 2 + n – 4 ) / ( 2 * (n – 4) )

Adding parentheses for clarification:

Exploded: ( (n + 1) / 2 ) * ( n / (n – 1) )

Hackmaster rules, two highest: ( ( n ^ 2 ) + n – 4 ) / ( ( 2 * n ) – 4 )

I don’t mind at all if you want to use this in your blog. Hopefully you can put this to good use in your game; exploding modifiers on enemy attacks can make damage seem a lot scarier, even if it’s just on a d4.

Sorry for hogging this post, but your version of the exploding die in your answer above had me wondering whether I am mistaken or you had a typo. You wrote in your post that ‘For any N-sided die numbered 1 to N with all sides equally likely, the exploding modifier will increase the die’s expected value by a factor of [n ÷ (n − 1)].’ A standard die yields an average of ((n + 1) ÷ 2). Wouldn’t an _increase_ mean to _add_? In other words,

regular exploded n-sided die = regular die average + increase = ((n + 1) ÷ 2) + (n ÷ (n − 1))

If I am wrong, please explain why, as my algebra skills have …waned through lack of use. In advance, thank you for your kind replies.

To “increase by X” means to add X.

To “increase by a factor of X” means to multiply by X.

It’s a weird little quirk of the English language when dealing with math written out in words.

Thank you very much for explaining that for me; I didn’t realise that. I’ll come back to you with a link when I’ve done the post.

[…] [https://eric22222.wordpress.com/2009/03/22/a-mathematical-analysis-of-exploding-dice/] […]

[…] Dadurch sind in der Theorie beliebig hohe Ergebnisse möglich, in der Praxis liegt der Erwartungswert eines Würfelwurfs bei explodierenden Würfeln etwas höher. Die explodierenden Würfel führen aber zu einem Restrisiko, das immer wieder mal […]

So i have a question

What if i have a system that counts 4-6 as a success and a 3 and below as a failure, with 6 exploding endlessly as long as 6s are rolled , how would i calculate the probability of a number of successes on a given a number of dice?

A physicist friend of mine gave me the mathematical proof I need to answer that some time in October 2014; I can try to dig out the answer and provide the method. The method provided by Eric22222 works well enough, but is slightly inprecise.

Since any 6’s rolled are already successes, the exploding mechanic has no impact on success or failure: you have a 50% chance to succeed or fail per die- all the explosions do is make some successes bigger than others. Expected number of successes will be number of dice / 2.

Great article!

Couple questions:

How to calculate the expected value of multiple exploding dice when only keeping the highest? (eg: roll 4d6, keep the best)

Also, how to calculate the probability of hitting a particular number with a given set of exploding dice?

[…] to 11 Gamesciene / Lou Zocchi Würfel im Würfel Eskapodcast – Folge 80: Death, Frost, Doom Wahrscheinlichkeiten bei explodierenden Würfeln Chainmail Talisman (Brettspiel) Eskapodcast – Folge 17: Brettspiele mit Spielleiter Werwölfe […]