A random walker moves at each step two units to the right or one unit to the left, with corresponding probabilities $p$ and $q = 1-p$. The allowed range is $[-A, B]$ and the starting position is $0$.
Is the recursion formula $f[z]= p f[z-2] + q f[z+1]$ valid?
I'm looking for the three boundary conditions in order to solve the formula.
$f(z)=P(S(τ)=B|S(0)=z)$ where $τ=\min \{n≥0:S(n) = B \text{ or } S(n) = −A\}$ where $S(n)$ is the position of the random walker after $n$ steps.