EDIT 1: I have found the probaabilities for the soft hands, so I only need $P12, P13, P14 \:\&\: 15$ and th eprogramming bit.
Let us say that we have a regular game with infinite decks. It is assumed that the dealer stands at a soft 17. Furthermore, normal blackjack rules apply.
I am working on a project where I eventually want to create the optimal strategy for blackjack, although with infinite decks as this makes the calculations easier. I have started by calculating the probabilities of the dealers bustings probabilities.
I have noticed that the easiest way to do this is via recursion and backwards induction. Since, there are infinite decks the total is the only thing that matters as it does not matter how the total is made up. I have started by looking at hard totals first.
I have come up with the following:
- Probability of busting with a 17, 18, 19, 20 & 21: 0 (trivial)
- $P1$: Probability of busting with a 16: $\frac{8}{13}$ (As 8 out of 13 cards make 22 or more)
- $P2$: Probability of busting with a 15: $\frac{1}{13}*\frac{8}{13} + \frac{7}{13} = \frac{99}{169}$ or another way of writing this is $\frac{1}{13}*P1 + \frac{6}{13}$.
Until a total value of 10 nothing changes, I'll list the probabilities down below as reference:
- $P3$: $0.5540$
- $P4$: $0.5196$
- $P5$: $0.4826$
- $P6$: $0.2121$
At $P7$ (total value 10) I noticed that I had to alter the recursion a bit as a 10 followed by an ace makes blackjack, hence a ten can never become a 11. So, $P7$ becomes:
- $P7$: $\frac{1}{13}*(P5 + P4 + P3 + P2 + P1) = 0.2121$ (We do not use P6)
The same applies to P8, P9 and P10, hence:
- $P8$: $\frac{1}{13}*(P6 + P5 + P4 + P3 + P2 + P1) = 0.2284$
- $P9$: $\frac{1}{13}*(P7 + P6 + P5 + P4 + P3 + P2 + P1) = 0.2447$
- $P10$: $\frac{1}{13}*(P8 + P7 + P6 + P5 + P4 + P3 + P2 + P1) = 0.2623$
At $P11$ something else happens, as 6 gets to a total value of 16 in 4 ways as four cards have a value of 10 (10, jack, queen & king), so:
- $P11$: $\frac{1}{13}*(P9 + P8 + P7 + P6 + P5 + P4 + P3 + P2) + \frac{4}{13} * P1 = 0.4232$
The place I am struggling at is how to do $P12$, $P13$, $P14$ and $P15$ as the ace can now be a 1 or an 11 both not busting the hand.
Furthermore, I wanted to program this in python, however due to the nature of the recursion changing later on I couldn't produce the code, is there a way to program this instead of hard coding it?
In addition, how can I calculate the probabilities of soft hands, as this becomes increasingly difficult I assume.
Thank you in advance! If something is not clear, please comment down below and I will gladly provide more.
You need to split your $\ P11\ $ to $\ P15\ $ (i.e. hands totalling from $2$ to $6$) into two cases—hard hands with the appropriate total containing no aces, and soft hands with the appropriate total when all aces are counted as one, and containing at least one ace. Call the first lot $\ P11\ $ to $\ P15\ $, and the second lot $\ P11s\ $ to $\ P15s\ $. You've already calculated $\ P11\ $, but the value of $\ P11s\ $ is different.
If the dealer has a soft six, and draws any card from ace to $5$, he or she must count one of the aces as being $11$ and stand on the resulting total (which will be in the range $17$ to $21$). If the card drawn is a $6$ or higher, then counting any of its aces as eleven would bust the hand, so all aces must thereafter be counted as one, and the new hand will effectively be no different from one with a hard total of from $12$ to $16$. Therefore \begin{align} P11s&=\frac{1}{13}(P5+P4+P3+P2+4P1)\\ &=\frac{1709274}{13^6}\\ &\approx 0.354121 \end{align}
Likewise, \begin{align} &P12\\ &=\frac{1}{13}(P11s+P10+P9+P8+P7+P6+P5+P4+P3+4P2)\\ &=\frac{4415752453}{13^9}\\ &\approx0.416404\ , \end{align} and so on.
You can write your recursion in matrix form as $$ p=Mp+b\ , $$ where $\ p\ $ is the $\ 21\times1\ $ column vector whose entries are $\ P1,$$\,P2,$$\,\dots,$$\,P15,$$\,P11s,$$\,P12s,$$\,\ \dots,$$\,P16s\ $, $\ b\ $ the $\ 21\times1\ $ column vector whose first four entries are $\ \frac{8}{13},$$\,\frac{7}{13},$$\,\frac{6}{13},$$\,\frac{5}{13}\ $ and $\frac{4}{13}\ $, and whose remaining entries are all $\ 0\ $, and $\ M\ $ is the $\ 21\times21\ $ matrix $$ \pmatrix{0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0\\ \frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0\\ 0&\frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&\frac{1}{13}&0&0&0&0&0\\ 0&0&\frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&\frac{1}{13}&0&0&0&0\\ 0&0&0&\frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&\frac{1}{13}&0&0&0\\ 0&0&0&0&\frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&\frac{1}{13}&0&0\\ \frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&0\\ 0&\frac{4}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&\frac{1}{13}&0&0&0&0&0\\ 0&0&\frac{4}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&\frac{1}{13}&\frac{1}{13}&0&0&0&0\\ 0&0&0&\frac{4}{13}&\frac{1}{13}&0&0&0&0&0&0&0&0&0&0&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0&0\\ 0&0&0&0&\frac{4}{13}&0&0&0&0&0&0&0&0&0&0&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0&0\\ 0&0&0&0&0&0&0&0&0&0&0&0&0&0&0&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&\frac{1}{13}&0}\ . $$ You can apply the equations of your recursion to calculate the bust probabilities in the order $\ P1,$$\,P2,$$\,\dots,$$\,P11,$$\,P11s,$$\,P12,$$\,P12s,$$\,\dots,$$\,P15,$$\,P15s,$$\,P16s\ $. However, if you have a good linear algebra package available, you could use it to compute $$ p=(I-M)^{-1}b\ . $$ Because $\ M\ $ is nilpotent with $\ M^{11}=0\ $ we have $$ (I-M)^{-1}=I+\sum_{n=1}^{10}M^n\ . $$ In light of this identity, you can also calculate $\ p\ $ with the following recursion \begin{align} \pi_0&=b\\ \pi_{i+1}&=M\pi_i+b\ \ \text{ for }\ i=0,1,\dots,9\ , \end{align} which will end with $\ \pi_{10}=p\ $. The following Magma code implements this last procedure to calculate $\ p\ $. If you copy and paste it into the online Magma calculator, it will print out the following values: $$ \begin{array}{l} P1= 8/13 \approx 0.615385\\ P2= 99/169 \approx 0.585799\\ P3= 1217/2197 \approx 0.553937\\ P4= 14841/28561 \approx 0.519625\\ P5\approx 0.482673\\ P6\approx 0.212109\\ P7\approx 0.212109\\ P8\approx 0.228425\\ P9\approx 0.244741\\ P10\approx 0.262312\\ P11\approx 0.423151\\ P12\approx 0.416404\\ P13\approx 0.394468\\ P14\approx 0.373875\\ P15\approx 0.353608\\ P11s\approx 0.354121\\ P12s\approx 0.327196\\ P13s\approx 0.299951\\ P14s\approx 0.272495\\ P15s\approx 0.244958\\ P16s\approx 0.115286\ . \end{array} $$