Evidently $A$ has a $3/6 \times 1/6 = 1/12 = a$ chance of winning on their turn and $B$ has a $1/6 = b$ chance of winning.
From $A$'s perspective, their chance $p_A$ of winning this game is the sum of
The chance of winning immediately, equal to $a,$ and
The chance of not winning immediately ($1-a$) times the chance $B$ does not win on their turn ($1-b$) times the chance $p_A$ of winning, because at that point the game restarts.
Thus
$$p_A = a + (1-a)(1-b)p_A\tag{*}$$
whose unique solution is easily found (which I leave to you to work out).
I you like to test things with simulations, here is one using R
:
play <- function(a, b) ifelse (runif(1) < a, 1, 1 - play(b, a))
mean(replicate(1e3, play(1/12, 1/6)))
[1] 0.3458
This result differs from the correct value only by chance variation.
This answer disagrees with the value (0.0769) stated in the question, so let's look at the Markov chain. There are four states:
- It is A's turn.
- It is B's turn.
- A has won.
- B has won.
The initial state is $(1,0,0,0),$ the final state is $(0,0,1,0),$ and the transition matrix (which reflects the definitions of $a$ and $b$ -- there's no computation needed) is
$$\mathbb P = \pmatrix{0&1-a&a&0\\ 1-b&0&0&b \\ 0&0&1&0 \\ 0&0&0&1}$$
You could compute eigenvalues and eigenvectors and turn the Markov Chain crank, but the block matrix structure of $\mathbb P$ suggests a simpler way. Notice that
$$\mathbb P = \pmatrix{\mathbb A&\mathbb B\\ 0 & \mathbb I}$$
with $\mathbb A = \pmatrix{0&1-a\\1-b&0}$ and $\mathbb B = \pmatrix{a&0\\0&b}$ for the top $2\times 2$ blocks. When squaring any matrix in this form you find
$$\mathbb P^2 = \pmatrix{\mathbb A^2 & (\mathbb A + \mathbb I)\mathbb B\\ 0 & \mathbb I}.$$
Iterating reveals a pattern in the upper right block: within $\mathbb P^{2^n}$ it takes the form
$$(\mathbb A^{2^n-1} + \mathbb A^{2^n-2} + \cdots + \mathbb A + \mathbb I)\mathbb B$$
(easily established by induction). This is a geometric series of matrices with limiting form
$$\lim_{n\to\infty} \mathbb P^{2^n} = (\mathbb I - \mathbb A)^{-1}\mathbb B.$$
You can read the chance of $A$ winning from the $(1,3)$ entry of $\mathbb P,$ equal to the $(1,1)$ entry of this limit,
$$(\mathbb I - \mathbb A)^{-1}\mathbb B = \pmatrix{1 & a-1\\b-1&1}^{-1}\pmatrix{a&0\\0&b} = \frac{1}{1 - (1-a)(1-b)}\pmatrix{a & *\\* & *},$$
which you can verify solves $(*)$ above.