Date

We were play testing my friend Sam's board game this weekend. It features "annihilator towers" - you build up N levels of tower, and then roll N 6-sided dice to determine the damage dealt. Here's the wrinkle though: If you roll two or more ones, then the tower explodes and the damage is dealt to the home team. What are the chances of rolling two ones, for a given tower level?

We thought a little about it, but nobody was keen on sitting down and actually working it out. I wrote a little Python program that produced statistical answers. That was sufficient to practically answer the question, but what's the "real" answer?

First the Python simulation:

import sys, random
def roll(n):
  R = [random.randint(1, 6) for i in range(n)]
  return len(filter(lambda x:x==1,R)) >= 2

N = 100000
dead = 0.0
for i in range(N):
  if roll(int(sys.argv[1])):  dead += 1

print dead / N

And the results:

N Dice Prob. of 2+ ones
2 0.02807
3 0.07452
4 0.13220
5 0.19485
6 0.26325
7 0.33054
8 0.39793

So, how to calculate it?

The chance of rolling exactly two ones on N dice is:

(1/6)2 × (5/6)N-2 × combin(N,2)

combin(N,2) is the number of ways of choosing two dice from N dice. The formula is:

combin(n,k) = n! / k!(n-k)!

But we're not finished yet. We need to count the possibilities where we roll more than two ones. In general, the chance of rolling exactly k ones on N dice is:

P(N,k) = (1/6)k × (5/6)N-k × combin(N,k)

So the chances of rolling two or more ones for N dice is:


N

Σ

P(N,k)

k=2

So for 3 dice, it's P(3,2) + P(3,3). For four dice it's P(4,2) + P(4,3) + P(4,4), etc. Here's a Python program to calculate that:

from math import factorial as f
def combin(N,k):
  return f(N)/(f(k)*f(N-k))
def P(N,k):
  return (1.0/6)**k * (5.0/6)**(N-k) * combin(N,k)

import sys
N = int(sys.argv[1])
print sum( [P(N,k) for k in range(2,N+1)] )

And the results...

N Dice Prob. of 2+ ones
2 0.0277777777778
3 0.0740740740741
4 0.131944444444
5 0.196244855967
6 0.263224451303
7 0.330204046639
8 0.39532309766

That accords pretty well with the numerical results. Apparently I have managed to remember something from my A-level maths!!