Shut the Box is a dice game of chance where the player tries to eliminate all numbered tiles by rolling two die and flipping over tiles which add up to the sum of the two die. To “Shut the Box”, all tiles must be flipped over. The player is unable to shut the box if the sum of two die add to a number which cannot be reached by any open tiles in the box.

I want to know how likely it is to win a game of Shut the Box" by closing all numbers. In particular, I’m interested about what happens when the box goes all the way up to 12.

Given that the box has 12 numbers, and that we are able to roll only one die when the sum of the numbers left in the box is less than 6, what is the probability of shutting the box completely?

I wrote a python script that simulates playing a round of Shut the Box, and ran it 1 million times to find the chance of closing the box (scoring 0).

### Short answer: You can shut the box ~ 0.41% of the time, or about 1 in 250 tries

It may be possible to improve on the strategy I use, and if anyone wants to do so I’d love to hear about it!

library(ggplot2)
theme_set(theme_bw(base_size = 20))
#setwd("Projects/shut_the_box")

p <- ggplot(a, aes(x=V1)) + geom_histogram(color="black", fill="white", binwidth = 1) +
xlab("Score") + ylab("Count") +
geom_vline(aes(xintercept=mean(V1)), color="red", linetype="dashed", size=1) +
annotate("Text", x = 60, y = 33000, label = paste("Mean = ", round(mean(a$V1), 1)), size = 10) Here is a histogram of 1 million simulated rounds of playing Shut the Box. The average score (the red dashed line) is around 36: That’s cool. It’s also kind of interesting that there peaks where some scores are more likely than others. Even though the average score was around 36, the most common score in Shut the Box is a 33. At least in the way that I’m telling the computer to close numbers. library(dplyr); library(knitr); library(data.table); library(scales) Percent <- sort(summary(as.factor(a$V1)), decreasing = TRUE)
df <- as.data.frame(Percent)
setDT(df, keep.rownames=TRUE)
df\$percent <- transmute(df, Percent = percent(Percent / sum(Percent)))
x <- percent((df[rn %in% c(1:12),][, sum(Percent)]) / df[,sum(Percent)])
df <- df[, .(rn, percent)]
colnames(df) <- c("Score", "Percent")

The following table is a breakdown of the most common scores by percent that they showed up in 1 million simulations. I think one of the most interesting things is that shutting the box (scoring 0) is not the least likely outcome. According to the following table, it’s more rare that you’d end up with an end score of 9, for example. Some of that has to do with how the computer makes the decisions. But it’s also pretty common that you would roll a 5-9, and if not they can be used to close other numbers, so it’s rare that you would end up with, say, a 9 being the only number left.

So you might be less likely to end up with certain single digit scores than closing the box, but as a whole you have a 3.84% chance of ending on a single digit score compared to 0.41% chance of shutting the box.

Score Percent
33 3.82%
34 3.20%
42 3.14%
23 3.04%
32 2.97%
35 2.89%
36 2.84%
43 2.78%
38 2.75%
37 2.73%
41 2.73%
31 2.70%
40 2.69%
39 2.59%
44 2.59%
30 2.38%
24 2.34%
45 2.33%
26 2.21%
29 2.19%
28 2.18%
46 2.14%
25 2.13%
27 2.10%
47 2.09%
22 2.07%
48 1.94%
50 1.82%
49 1.75%
51 1.68%
21 1.68%
12 1.44%
53 1.41%
52 1.40%
54 1.24%
20 1.24%
55 1.04%
19 1.02%
13 0.96%
57 0.94%
17 0.91%
56 0.91%
15 0.91%
18 0.90%
14 0.85%
16 0.85%
59 0.80%
58 0.71%
11 0.67%
64 0.53%
61 0.48%
60 0.46%
62 0.42%
0 0.41%
10 0.39%
9 0.26%
63 0.23%
65 0.23%
66 0.19%
8 0.18%
1 0.16%
68 0.15%
7 0.14%
6 0.14%
70 0.12%
2 0.12%
3 0.12%
5 0.11%
4 0.11%
71 0.09%
76 0.08%
67 0.07%
72 0.04%
69 0.04%
73 0.03%