In the actual game, you get five rolls instead of three. But as with rolling a 2 or 12, rolling a number that you have already rolled is a wasted turn. With five rolls of the dice, what are your chances of getting three Xs in a row, either horizontally, vertically, or diagonally?
Let's just simulate our way out of this. We have the same 8 possible winning sets, that we will encode as sets in Python and then after simulating a 5 rolls of two dice, we can check whether the resulting set of roll outcomes contains any of the winning sets. See the code snippet below that we can use to encode playing a random round of Tic-Tac-Deal.
import numpy as np
r = np.random.default_rng()
WINS = [ {3, 4, 5}, {3, 6, 9}, {3, 7, 11},
{4, 7, 10}, {5, 8, 11}, {5, 7, 9},
{6, 7, 8}, {9, 10, 11}
]
def play_tic_tac_deal_2dot0(r, rolls=5):
draws = r.integers(low=1,high=7, size=(rolls,2))
final = set(draws.sum(axis=1))
for win in WINS:
if win.issubset(final):
return True
return False
Running $1$ million simulations, we infer that the probability of winning the game with $5$ dice rolls is about $36.0907\dots\%.$ In particular, the $95\%$ confidence interval is $(35.996568\%, 36.184832\%).$ Further, note that if we run these simulations with the parameter $rolls = 3,$ then we get a $95\%$ confidence interval of $(5.725294\%, 5.816706\%)$ which certainly contains our analytics answer of $\frac{113}{1944}.$
No comments:
Post a Comment