We can generalise your problem by allowing any $y \in \mathbb{N}$ and assuming discrete states $x = 0,1,2...,y$. Assuming that gamble outcomes are independent with fixed win-probability $0 < \theta <1$ , the transition matrix $\mathbf{P}$ for the Markov chain has elements:
$$\mathbf{P}_{x_t,x_{t+1}}(y) = \begin{cases}
\mathbb{I}(x_{t+1} = 0) & & \text{for } x_t = 0, \\[6pt]
(1-\theta) \cdot \mathbb{I}(x_{t+1} = 0) + \theta \cdot \mathbb{I}(x_{t+1} = 2x_t) & & \text{for } x_t = 1,...,\lfloor y/2 \rfloor, \\[6pt]
(1-\theta) \cdot \mathbb{I}(x_{t+1} = 2x_t-y) + \theta \cdot \mathbb{I}(x_{t+1} = y) & & \text{for } x_t = \lfloor y/2 \rfloor + 1,...,y-1. \\[6pt]
\mathbb{I}(x_{t+1} = y) & & \text{for } x_t = y. \\[6pt]
\end{cases}$$
The generalised transition matrix can be programmed in R
as follows:
TRANS_MATRIX <- function(y, theta) {
#Create transition matrix of zeros
DIMNAMES <- 0:y;
MATRIX <- matrix(0, nrow = y+1, ncol = y+1,
dimnames = list(DIMNAMES , DIMNAMES));
#Set absorbing states
MATRIX[1,1] <- 1;
MATRIX[y+1,y+1] <- 1;
#Set states for lower gambles
for (x in 1:floor(y/2)) {
MATRIX[x+1, 1] <- 1-theta;
MATRIX[x+1, 2*x+1] <- theta; }
#Set states for upper gambles
for (x in (floor(y/2)+1):(y-1)) {
MATRIX[x+1, 2*x-y+1] <- 1-theta;
MATRIX[x+1, y+1] <- theta; }
MATRIX }
Setting $y=20$ and $\theta = \tfrac{1}{2}$ gives the desired transition matrix, which we can display in R
as follows:
#Generate transition matrix
MATRIX <- TRANS_MATRIX(20, 0.5);
#Print formatted matrix
print(format(MATRIX, nsmall = 1), quote = FALSE);
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0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