In the classic board game Monopoly, rolling "doubles" (where both dice land on the exact same number, like 2-2 or 6-6) is great: you move your token and earn an extra roll!
However, there is a famous catch: if you roll doubles three times in a row on the same turn, you are immediately arrested and sent directly to Jail!
What are the chances of rolling three doubles in a row?
On any single roll of two six-sided dice, there are 6 doubles out of 36 combinations:
$$\frac{6}{36} = \frac{1}{6} \approx 16.7\%$$
Because each roll is independent, the chance of rolling doubles three times in succession is:
$$\frac{1}{6} \times \frac{1}{6} \times \frac{1}{6} = \frac{1}{216} \approx 0.463\%$$
Let's simulate $10{,}000$ player turns in Lua to test how often you get sent to jail!
if d1 == d2 then ... end
Move the mouse over a dotted box for more information.
Notice how close the simulated fraction gets to the exact theoretical value of $1/216 \approx 0.463\%$.
Now you try.
What is the chance of rolling doubles twice in a row? Try changing the code to count turns where at least two doubles occur (theoretical: 1/36 = 2.78%).
Type your code here:
See your results here:
To complete this lesson: In Monopoly, rolling doubles earns an extra turn, but rolling doubles 3 times in a single turn sends you directly to Jail.
Look at the code above:
1. Near the top, target_doubles is set to 0—change it to target_doubles = 3.
2. Inside the roll loop, if d1 == 0 then is incomplete—change it to check if both dice match: if d1 == d2 then.
Then click Run to simulate 10,000 turns and see how close your results get to $1/216 \approx 0.463\%$! (Click Example above for the full solution).
Share your code
Show a friend, family member, or teacher what you've done!