# Probability of a result of a game.

Problem statement:

Two players play the following game of several rounds. If some player wins a round, the winner is given $$1$$ point, and loser is given $$0$$ points, and there are no draws. The game ends when some player gets $$a$$ points.

It is known that probability that first player wins a round is $$p$$. Find probability that difference between winner's and loser's score is equal to $$b$$.

My approach:

First, notice that if the difference between winner's and loser's score is equal to $$b$$, then the final scores must be $$(a, a - b)$$ or $$(a - b, a)$$.

Suppose that the final scores are $$(a, a - b)$$. Consider an integer lattice with points $$(0, 0)$$ and $$(a, a - b)$$. Number of paths from $$(0, 0)$$ to $$(a, a - b)$$ such that we move only up or right is $$\binom{2a - b}{a}$$. Now suppose that probability of "up"-movement is $$p$$, then the probability of "right"-movement is $$1 - p$$. Hence, because any such path consists of $$a - b$$ "up"-movements and $$a$$ "right"-movements, the probability for such final scores is $$p_{(a, a - b)} = \binom{2a - b}{a} (1-p)^{a} p^{a - b} .$$ Similarly, the probability for final scores $$(a - b, a)$$ is $$p_{(a - b, a)} = \binom{2a - b}{a - b} (1-p)^{a - b} p^{a} .$$

Hence, the final probability: $$p' = p_{(a, a - b)} + p_{(a - b, a)} = \binom{2a - b}{a} (1-p)^{a} p^{a - b} + \binom{2a - b}{a - b} (1-p)^{a - b} p^{a} .$$

Is my approach correct? I've tried to simulate the game in Python and got different result ($$\approx 0.06$$ by the simulation vs. $$\approx 0.105$$ by the formula for $$a = 11, b = 3, p = 0.3$$).

It seems that your calculation includes the possibility, for example, that one player wins $$a$$ times and then the other player wins $$a-b$$ times, since this would be among the counted paths from $$(0,0)$$ to $$(a,a-b)$$, right?
Edit: To fix the calculation, I think you should consider all paths from $$(0,0)$$ to $$(a-1, a-b)$$, and then multiply by $$p$$ (and similarly $$(a-b, a-1)$$, and $$1-p$$).