# Probability problem of dice game

I heard a problem from a riddle book:

$A$ and $B$ roll two standard dice and record the sum of two numbers. $A$ wins when two consecutive outcomes are $7$ and $B$ wins when three consecutive outcomes are in increasing order. $A$ will continue rolling until one of the two players wins. What is the probability that $A$ will win?

For example:If the outcomes are $10,4,6,6,7,7$, $A$ wins. If the outcomes are $7,3,7,9$, $B$ wins.

Does someone have an idea? Thanks a lot!

-
On first look, it really looks like a Markov process. I got a few questions: so A and B independently roll 1 die and then they record the sum of 2 numbers? – bryansis2010 Feb 2 '13 at 18:37
For B, do the numbers have to be strictly increasing? Are ties acceptable? – Ross Millikan Feb 2 '13 at 18:58
@Ross: If the OP's examples are to be trusted, they have to be strictly increasing. Otherwise B would win the first example. – TonyK Feb 2 '13 at 19:38
Thanks a lot for your reply, all the rolls are independent and the increasing means strictly increasing. – Higgs88 Feb 2 '13 at 23:17
What riddle book? – Gerry Myerson Feb 3 '13 at 0:07

As others have remarked, this can be solved exactly, but the solution would be rather tedious and uninspiring. You can find the probability for $A$ to win by introducing as variables the probabilities for $A$ to win in each of $22$ states determined by the last roll and whether it increased, and solving the system of linear equations in these variables that's determined by the transition probabilities. The initial state could be taken to be $12$ (increased or not).

You can find lots of examples of such calculations on this site; instead of going through all the details of that, I'd like to do something perhaps more interesting and illuminating and estimate the desired probability on the basis of a simple approximation. The various winning events are not independent; for instance, given that $A$ didn't win on the last roll, it's less likely that she will win on this roll, since she can't have had a $7$ in both last rolls. But since the probability of winning in a given roll is rather low for both players, let's neglect this effect and see how good the resulting estimate is.

So let's model the process by one in which on each roll there's a probability $p_A$ of $A$ winning, a probability $p_B$ of $B$ winning and a probability $1-p_A-p_B$ of the game continuing, and let's use the marginal probabilities of winning in a general round for $p_A$ and $p_B$, neglecting the fact that $A$ can win on the second roll and $B$ can't. Then the probability $q_A$ that $A$ wins the game satisfies the recurrence $q_A=p_A+(1-p_A-p_B)q_A$, so $q_A=p_A/(p_A+p_B)$. We have $p_A=1/36$, and here's an evaluation of $p_B$ in Sage:

sage: i,j,k = var ('i,j,k')
sage: p (n) = (6 - abs (n - 7)) / 36
sage: sum (p (i) * sum (p (j) * sum (p (k),k,j+1,12),j,i+1,11),i,2,10)
895/7776


Thus the probability $q_A$ that $A$ wins is estimated to be $\frac1{36}/(\frac1{36}+\frac{895}{7776})=\frac{216}{1111}\approx0.1944$. This compares surprisingly well with the result of a simulation:

sage: count = 0;
sage: ntrials = 1000000;
sage: for n in range (0,ntrials):
...       seven = false
...       last = 12
...       increased = false
...       while true:
...           roll = 2 + ZZ.random_element (6) + ZZ.random_element (6)
...           if seven and roll == 7:
...               count = count + 1
...               break
...           if increased and roll > last:
...               break
...           seven = roll == 7
...           increased = roll > last
...           last = roll
...
sage: q = count / ntrials
sage: print q.n (), "+-", sqrt (q * (1 - q) / ntrials).n ()
0.191416000000000 +- 0.000393415702462421


The good agreement seems somewhat spurious; taking into account that $A$ has a chance to win on the second roll and $B$ doesn't "improves" the estimate to $\frac1{36}+(1-\frac1{36})\frac{216}{1111}=\frac{8671}{39996}\approx0.2168$.

On second thought, it didn't seem quite so tedious to set up the linear system and solve it:

sage: d=6
sage: nsums = 2 * d - 1
sage: nstates = 2 * nsums
sage: a = matrix (QQ,nstates)
sage: b = matrix (QQ,nstates,1)
sage: for prev in range (2,2*d+1):
...       for up in range (0,2):
...           index = prev - 2 + nsums * up
...           for next in range (2,2*d+1):
...               p = (d - abs (next - (d+1)))/(d*d)
...               if prev == d + 1 and next == d + 1:
...                   b[index] = p
...               else:
...                   if next > prev:
...                       nextup = 1
...                   else:
...                       nextup = 0
...                   if up * nextup == 0:
...                       nextindex = next - 2 + nsums * nextup
...                       a[index,nextindex] = -p
...
sage: for i in range (0,nstates):
...       a[i,i] = a [i,i] + 1
...
sage: result = a.solve_right (b)[nsums-1]
sage: print result, "~", result.n ()
(106460465616/556534555787) ~ (0.191291743718327)


So the desired probability is

$$\frac{106460465616}{556534555787}\approx0.1913\;,$$

in agreement with the simulation result. The large numerator and denominator suggest that there's unlikely to be a simpler solution that would have been worthy of a "riddle book".

-
Thanks a lot for Joriki's help. I tried to solve the linear system and I get the same result. But the book asks to find a fractional answer, for example $2/7$, $3/10$. Thank you all the same – Higgs88 Feb 3 '13 at 9:26