Cool. So the approach I'm suggesting is:
##E\Big[X\Big] = E\Big[E\big[X\big \vert T\big]\Big] ##
and ##E\big[X\big \vert T\big]## is of course a random variable, that takes on value 1 if ##T = 1## with probability ##p_1 = a##, takes on value 2 if ##T = 2## with probability ##p_2 = (1-a)b## and takes on value ##(2 + E\big[X\big])## if ##T = 3+## with probability ##p_{3+} := 1 - a - (1-a)b##.
Rationale:
The first two should be self explanatory.
For the ## T = 3+## case: we've partitioned the probability space into 1, 2 or 3+ shots and hence this sums to ##1 = p_1 + p_2 + p_{3+}##. If you get to the third shot, you have a 'sunk cost' of 2 shots that have been taken plus a 'marginal cost' that is a random variable whose
distribution is the same as the distribution of ##X## (this is the fresh start) -- and in expectation this value is ##E\big[X\big]##. For avoidance of doubt this reads
##E\big[X\big \vert T=3_{+}\big] = 2 + E\big[X\big] = 2 + \mu##.
Hence we have a nicely overlapping subproblem
- - - -
edit:
a slightly more careful way of introducing ##T## is to get rid of the "3+" and say that it takes on real values of 1, 2, and 3 because it is the truncated form of ##X##. I.e. ##T##
is ##X## for values 1 and 2 but then we truncate the distribution and allocate all residual mass and sample points to the value 3.
It may seem odd that we can get additional insights about the expected value of ##X## by conditioning on a truncated form of ##X## but that is exactly the point here.
I've dropped this into help clarify what ##T## is but honestly it seems like a bit of a distraction.
- - - -
##\mu = E\Big[X\Big] = E\Big[E\big[X\big \vert T\big]\Big] = 1\cdot p_1 + 2\cdot p_2 + \big(2 + \mu \big)\cdot p_3##
it simplifies to
##\mu = 1\cdot p_1 + 2\cdot p_2 + 2 \cdot p_3 + \mu \cdot p_3 ##
##(1-p_3)\mu =1\cdot p_1 + 2\cdot p_2 + 2 \cdot p_3##
##\mu =\frac{1\cdot p_1 + 2\cdot p_2 + 2 \cdot p_3}{1-p_3}##
which, barring a typo, should match your answer.
The only technical nit with this approach is that we know ##0\lt \mu## and indeed we know that ##0\leq X## (i.e. we're dealing with non-negative random variables here) but we are implicitly assuming ##\mu \lt \infty##. It's a common issue for any recurrence setup that you require ##E\big[\big \vert X\big \vert \big] \lt \infty## (e.g. its an issue too for martingales). You can argue that you
know ##E\big[\big \vert X \big \vert \big] = E\big[X\big] = \mu \lt \infty## because this entire problem can be solved by embedding it in a finite state markov chain (whether as an irreducible recurrent chain or an appropriate one with absorbing states), and expected times in these cases are always finite WP1. (Why?) A markov chain embedding argument is quite powerful, even if you don't model it directly as such. This motivates a final question:
are you familiar with the general purpose way of modelling this as a finite state markov chain? It offers yet another way of computing the answers to your problem and of course works great in say numpy (or sympy).
- - - -
I suppose I'm the kind of cat that really likes conditioning arguments
