Two players pay a coin tossing game for money. If the coin shows heads, A wins ad if it shows tails, B wins. Draws are not possible. If player A starts with £3 and player B starts with £2, and each bets £1 on each throw, construct a transition matrix and find how long it will take for each player to win or lose all their money.
Each player can have between £0 and £5.
If A has £0, then he cannot play, so will have $0 for ever after.
If A has £1, then after 1 toss he will have either £0 or £2, each with probability 1/2, and £1, £3, £4 or £5 with probability 0..
If A has £2, then after 1 toss he will have either £1 or £3, each with probability 1/2, and £0, £2, £4 or £5 each with probability 0..
If A has £4, then after 1 toss he will have either £3 or £5, each with probability 1/2, and £0, £1, £2 or £4 with probability 0.
If A has £5, then player B has £0, so cannot play and player A has £5 for ever after.
We can construct the table:
A has\A has After 1 Toss £0 £1 £2 £3 £4 £5
£0 1 0 0 0 0 0
£1 1/2 0 1/2 0 0 0
£2 0 1/2 0 1/2 0 0
£3 0 0 1/2 0 1/2 0
£4 0 0 0 1/2 0 1/2
£5 0 0 0 0 0 1
The transition matrix is  
\[P= \left( \begin{array}{cccccc} 1 & 0 & 0 & 0 & 0 & 0 \\ 1/2 & 0 & 1/2 & 0 & 0 & 0 \\ 0 & 1/2 & 0 & 1/2 & 0 & 0 \\ 0 & 0 & 1/2 & 0 & 1/2 & 0 \\ 0 & 0 & 0 & 1/2 & 0 & 1/2 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{array} \right)\]
.
An absorbing state of a Markov chain when the probability of that state in the transition matrix is 1. Rewrite the table as
A has\A has After 1 Toss £0 £5 £1 £2 £3 £4
£0 1 0 0 0 0 0
£5 0 1 0 0 0 0
£1 1/2 0 0 1/2 0 0
£2 0 0 1/2 0 1/2 0
£3 0 0 0 1/2 0 1/2
£4 0 1/2 0 0 1/2 0
This matrix is of the form  
\[\left( \begin{array}{cc} P & O \\ S & Q \end{array} \right)\]
  where
 
\[P=\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right), \; O= \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{array} \right), S= \left( \begin{array}{cc} 1/2 & 0 \\ 0 & 0 \\ 0 & 0 \\ 0 & 1/2 \end{array} \right), \; Q= \left( \begin{array}{cccc} 0 & 1/2 & 0 & 0 \\ 1/2 & 0 & 1/2 & 0 \\ 0 & 1/2 & 0 & 1/2 \\ 0 & 0 & 1/2 & 0 \end{array} \right)\]

\[(I-Q)^{-1}= \left( \begin{array}{cccc} 1.6 & 1.2 & 0.8 & 0/4 \\ 1.2 & 2.4 & 1.6 & 0.8 \\ 0.8 & 1.6 & 2.4 & 1.2 \\ 0.4 & 0.8 & 1.2 & 1.6 \end{array} \right)\]

If a player starts with £2 the expected length of the game is (from row 2)1.2+2.4+1.6+0.8=6. If a player starts with £3 the expected length of the game is (from row 3) 0.8+1.6+2.4+1.2=6.