# 2 player dice game probability

For some homework in one of my classes, we are given this problem:

In a certain dice game, player $A$ rolls six six-sided dice vs. player $B$ who rolls nine four-sided dice. Each player rolls exactly once, and $A$ wins provided that the sum of his dice is strictly greater than $B$'s, otherwise $B$ wins. What is $A$'s probability of winning? Solve this analytically.

So, seeing how the highest number either one can get is $36$, I calculated each player's probabilities of making a number from within $1\dots 36$. However, I am stuck in terms of how to figure out $A$ probability of winning the dice roll. Can anyone explain to me the steps to figure this out?

Thank you kindly.

• Erm I'm hesitating on how advanced I want to get... What chapter is this a part of (i.e. under what topic)? – Shahar Mar 10 '14 at 0:02
• It is actually for a computer science class. We have to solve it using code as well, but I first want to find out how to do it analytically. – JCMcRae Mar 11 '14 at 4:17

Well, if you have all the individual probabilities figured out, your answer would be:

$$P(winning)=P(A>36\mid B=36)+P(A>35\mid B=35)+\cdots+P(A>4\mid B=4)$$

Since your events are independent, we have $$P(winning)=P(A>36)P(B=36)+P(A>35)P(B=35)+\cdots+P(A>4)P(B=4)$$

Then $P(A>n)=\sum_{k=n+1}^{36} P(A=k)$ so $$P(winning)=0\cdot P(B=36)+P(A=36)P(B=35)+\cdots+[P(A=36)+\cdots+P(A=4)]P(B=4)\\$$

Finally, $$P(winning)=\sum_{n=4}^{36}\left(P(B=n)\sum_{k=n+1}^{36} P(A=k)\right).$$

Since you are talking about computer science, here's a quick code I wrote to determine that percentage. Here's a sample output:

50 games = 21 wins (42.0%)
100 games = 36 wins (36.0%)
150 games = 61 wins (40.666666666666664%)
200 games = 80 wins (40.0%)
250 games = 95 wins (38.0%)
300 games = 104 wins (34.66666666666667%)
350 games = 122 wins (34.85714285714286%)
400 games = 143 wins (35.75%)
450 games = 159 wins (35.333333333333336%)
500 games = 181 wins (36.199999999999996%)
550 games = 201 wins (36.54545454545455%)
600 games = 223 wins (37.166666666666664%)
650 games = 234 wins (36.0%)
700 games = 247 wins (35.285714285714285%)
750 games = 264 wins (35.199999999999996%)
800 games = 288 wins (36.0%)
850 games = 303 wins (35.647058823529406%)
900 games = 317 wins (35.22222222222222%)
950 games = 333 wins (35.05263157894737%)
1000 games = 353 wins (35.3%)


http://pastebin.com/K2V9T9mx

So it seems like it's about 36%.

• I also got about 36% using my code as well. Thanks! – JCMcRae Mar 11 '14 at 17:11

Once you have the probabilities for each player to roll each number you are almost there. For each roll of $A$, calculate the probability that $B$ gets a lower number and add them up. For example $A$ has a chance of $\frac 1{6^6}$ to roll $36$. He wins unless $B$ also rolls $36$, which is $\frac 1{4^9}$. So this contributes $\frac 1{6^6}(1-\frac 1{4^9})$ to $A$'s chance to win. Since $B$'s average is $9 \cdot 2.5=22.5$, $A$ will win precisely $50\%$ of the time he rolls $23$. If his chance to roll $23$ is $p$ (which you have calculated), it contributes a chance to win of $\frac p2$. Add them all up.

A probability generating function can solve this: $G(x)={\left(\dfrac{x^{6} + x^{5} + x^{4} + x^{3} + x^{2} + x}{6}\right)}^{6} {\left(\dfrac{\dfrac{1}{x} + \dfrac{1}{x^{2}} + \dfrac{1}{x^{3}} + \dfrac{1}{x^{4}}}{4}\right)}^{9}$

Sum all the coefficients of x which are greater than 1.

E.g. In Sage, it can be done like this:

fx = expand((sum(x^i for i in range(1,7))/6)^6*(sum(1/x^i for i in range(1,5))/4)^9)
sum([fx.coefficient(x,i) for i in range(1,36-8)])


which is:

$\dfrac{725864657}{2038431744}\approx 0.356089753378566$

which also agrees with a simulation (done in J)

sim=: 3 : '(+/1+?6#6)>(+/1+?9#4)'
(+/%#)(sim"0)100000#0


$\approx 0.35643$