flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
June 27th, 2014 at 12:35:18 AM permalink
Hi wizard, I'm curious as to how the basic strategy tables are calculated. Is it possible for you to briefly explain it to me? I roughly know that it's finding the probability of getting a value given initial hand and dealer's chance of getting a value given top card, but I'll be grateful if you could provide me with the maths. Thank you.
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
June 27th, 2014 at 7:10:40 AM permalink
Here's how I did mine:

First, given a particular deck size (1 deck, 2 deck, 6 deck, etc.) and whether or not the house hits or stands a soft 17, I calculated the probability of each possible house result (17, 18, 19, 20, 21, bust) for each possible up card - except for 2-card 21s, since you don't have to worry about standing / hitting / doubling on those.

Next, calculate the hit/stand strategy, starting with having a hard 21. Note that the strategy for each dealer up card is calculated separately.
Obviously, if you hit a hard 21, you always lose, so you stand on hard 21, but what you want to know is, what is the expected result? Since you push if the dealer ends up with 21 and you win if the dealer has anything else, the ER is +1 x (the sum of the probabilities that the dealer has 17, 18, 19, 20, and bust). This is important to know for later.
Now, hard 20. If you hit, there's a 1/13 chance that you will have hard 21, and 12/31 that you bust, so the ER for hitting is (the ER for hard 21) x 1/13 + -1 x 12/13. If you stand, you lose with a dealer 21, push with a dealer 20, and win with anything else, so the ER is +1 x (the sum of the probabilities of a dealer 17, 18, 19, or bust) + 0 x (the probability of a dealer 20) + -1 x (the probability of a dealer 21). The ER for 20 is whichever the ER for hitting or the ER for standing is better.
For hard 19, hitting has 1/13 chance of 20, 1/13 chance of 21, and 11/13 chance of bust, so the ER is (the ER for hard 20) x 1/13 + (the ER for hard 21) x 1/13 + -1 x 11/13. Calculate the ER for standing similar to how it was done for 20 and 21.
This is why you start at 21 and work down - you need to know the ER of the results above the number you are working on.

Once you have the hard ERs, work on the soft ERs from 21 down to 12. The ER for standing on, say, soft 15 is the same as it is for standing on hard 15. The ER for hitting on soft 15 is 1/13 x (soft 16 ER) + 1/13 x (soft 17 ER) + 1/13 x (soft 18 ER) + 1/13 x (soft 19 ER) + 1/13 x (soft 20 ER) + 1/13 x (soft 21 ER) + 1/13 x (hard 12 ER) + 1/13 x (hard 13 ER) + 1/13 x (hard 14 ER) + 4/13 x (hard 15 ER).

Now, calculate the ERs for doubling, first with hard numbers, then with soft ones; if they are better than the corresponding hit/stand ERs, you double on that number.

IIRC, as an example of splitting, for splitting 7s, it's 2 x (1/13 x (soft 18 ER) + 1/13 x (hard 9 ER) + 1/13 x (hard 10 ER) + ... + 1/13 x (hard 16 ER) + 4/13 x (hard 17 ER)); if the total ER > the ER for not splitting, then you split.
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
June 27th, 2014 at 12:03:03 PM permalink
Strategy table is calculated at the following protocol: For any dealers upcard and your hand (most often only for 2 cards), calculate the EVs of all your options - that is stand, hit, double down, split and surrender. Then take the action with the highest EV as the strategy tables element.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
June 28th, 2014 at 12:51:06 AM permalink
Thanks very much. I am not very good at maths so could you explain how to for example calculate the probability of dealer getting a 20 if if he has a 4, taking into accounts of multiple hits?
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
June 28th, 2014 at 2:05:12 AM permalink
Quote: flanderse

Thanks very much. I am not very good at maths so could you explain how to for example calculate the probability of dealer getting a 20 if if he has a 4, taking into accounts of multiple hits?



There are different methods for that. The most simple is to start from a 4 and basically draw a tree with a branch representing every card that could hit (there are 10 branches). From each branches tip, if the total value is 17 or more (where the dealer would stand) weight the branches with corresponding probabilities and "bin" them into results 17,18,19,20,21,bust. If the branches tip is less than 17, make 10 new branches and repeat the procedure for each new branch tip.

At the end, what you collect in the "bins" is the probability of the dealer standing on that value (or busting) when showing a 4. You would look into the "20" bin to answer your question. Repeat for any other upcard.

There are other ways to calculate these dealer probabilitites, depending on your goals regarding precision, memory consumption or speed. My favourite method is different, it enumerates all legal card combinations (without order) that will turn a 4 into a 20, and then convolute that list with the current deck distribution of cards.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
June 28th, 2014 at 9:29:15 PM permalink
Quote: MangoJ

There are different methods for that. The most simple is to start from a 4 and basically draw a tree with a branch representing every card that could hit (there are 10 branches). From each branches tip, if the total value is 17 or more (where the dealer would stand) weight the branches with corresponding probabilities and "bin" them into results 17,18,19,20,21,bust. If the branches tip is less than 17, make 10 new branches and repeat the procedure for each new branch tip.

At the end, what you collect in the "bins" is the probability of the dealer standing on that value (or busting) when showing a 4. You would look into the "20" bin to answer your question. Repeat for any other upcard.

There are other ways to calculate these dealer probabilitites, depending on your goals regarding precision, memory consumption or speed. My favourite method is different, it enumerates all legal card combinations (without order) that will turn a 4 into a 20, and then convolute that list with the current deck distribution of cards.



That looks very tedious. Is there a good approximate way to do that? How about for the player's hand? Like should I hit or stand with 13 against dealer 5?
Lemieux66
Lemieux66
  • Threads: 24
  • Posts: 1226
Joined: Feb 16, 2014
June 28th, 2014 at 9:33:27 PM permalink
Quote: flanderse

That looks very tedious. Is there a good approximate way to do that? How about for the player's hand? Like should I hit or stand with 13 against dealer 5?



YOU STAND. You stand all night long. I'm not even sure there's a negative count big enough to make hitting that even a possibility...and if there were you shouldn't be playing.
10 eyes for an eye. 10 teeth for a tooth. 10 bucks for a buck?! Hit the bad guys where it hurts the most: the face and the wallet.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
June 28th, 2014 at 9:46:00 PM permalink
Quote: Lemieux66

YOU STAND. You stand all night long. I'm not even sure there's a negative count big enough to make hitting that even a possibility...and if there were you shouldn't be playing.


I know that from the chart but what is the math behind that?
Lemieux66
Lemieux66
  • Threads: 24
  • Posts: 1226
Joined: Feb 16, 2014
June 28th, 2014 at 10:41:46 PM permalink
Quote: flanderse

I know that from the chart but what is the math behind that?



I don't know(people are worlds better on this site on this kind of math than I am). But you don't need to know either. Just don't do it. There are some negative count scenarios to hit 12 vs 2-6 though.
10 eyes for an eye. 10 teeth for a tooth. 10 bucks for a buck?! Hit the bad guys where it hurts the most: the face and the wallet.
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
June 28th, 2014 at 11:59:35 PM permalink
Quote: flanderse

That looks very tedious. Is there a good approximate way to do that?



Of course. One common approximative method is called "infinite deck". In the infinite deck approximation every card has the same probability to be dealt (i.e. there is no card removal effect), and hence all "dynamics" depend only on the hands value, and not it's composition.

With infinite deck approximation, you can solve the whole game in a simple spreadsheet.
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
June 29th, 2014 at 8:56:31 AM permalink
Quote: flanderse

I know that from the chart but what is the math behind that?


First, calculate the probabilities of the possible dealer hands (17, 18, 19, 20, 21, and bust).
I will use the "infinite deck" method mentioned - that is, the probability that a card will be an ace is always 1/13, a deuce is always 1/13, and so on; all face cards are considered 10s, so the probability of a 10 is 4/13.
To determine the probabilities from a 5, work backwards, starting with 16. If the dealer has hard 16, there is 1/13 chance of a 17, 1/13 chance of an 18, ..., 1/13 chance of a 21, and 8/13 chance of a bust.
For 15, there is 1/13 chance of 16, 1/13 chance of 17, ..., 1/13 chance of 21, and 7/13 chance of bust. This means the probability of 17 from 15 = (1/13 x 1/13) (i.e. the probability of getting 16 from 15 x the probability of getting 17 from 16) + 1/13 (i.e. the probability of getting 17 from 15) = 14/169.
Keep working backwards. Note that when you get to 10, there's a problem; you have to remember that an ace makes the hand a soft hand, which has to be calculated differently (e.g. if you have a soft 12, a 10 makes it a hard 12 instead of a bust). The probability of, say, a 17 from a 5 is 1/13 x (the probability of a 17 from a soft 16) + 1/13 x (the probability of a 17 from a 7) + ... + 1/13 x (the probability of a 17 from a 14) + 4/13 x (the probability of a 17 from a 15).

Now that you know what the probabilities of the dealer's final total are for an up card of 5, work out your expected return (ER) if you stand on 13. Obviously, you win if the dealer busts and you lose if the dealer has 17 through 21, so the ER = (-1) x (dealer has 17) + (-1) x (dealer has 18) + ... + (-1) x (dealer has 21) + (+1) x (dealer busts).

Once you know that, calculate the ER for hitting on 13, and if the hit ER is higher, you hit, but if the stand ER is higher, then you stand.
To calculate the ER for hitting on 13, start with the ER for hitting and standing on 21. The ER for standing on 21 with a dealer's 5 is (+1) x (probability of dealer having 17, 18, 19, or 20, or busting) + (+0) x (probability of dealer having 21). The ER for hitting a 21 is -1, since you always bust. Needless to stay, you stand on 21, and the ER for 21 is the ER for standing on 21.
Next, calculate the ER for hitting and standing on 20. The ER for hitting a 20 is 1/13 x (the ER for 21) + 12/13 x (the ER for busting, which is -1). Once you have the ER for 20, calculate the ER for 19, then 18, and so on back to 13.
The ER for hitting 13 = 1/13 x (the ER for 14) + 1/13 x (the ER for 15) + ... + 1/13 x (the ER for 21) + 5/13 x (the ER for busting).
The ER for standing on 13 = (-1) x (the probability that the dealer has 17 through 21) + (1/13) x (the probability that the dealer busts).

Like we said - this is very time-consuming if you don't have a computer.
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
June 29th, 2014 at 9:45:33 AM permalink
Quote: ThatDonGuy

...this is very time-consuming if you don't have a computer...

It took me several hours and a wad of mainframe computer printout paper (and accepting that I could only keep so many digits according to the calculator) when I first looked at Blackjack in the 80s - however it did help the long flight from London to LA go quickly! Since I had started at 2 working upwards, the first thing I found surprising was not splitting 9s vs 7, whereas most other people wonder why split 9s. It is also a good exercise in that you get to understand some of the decisions (e.g. hitting s18 vs 9 becomes obvious) and some of the close ones, as you can see the two figures, so are happier to hit those 12s. I must be one of the few to have worked out the strategy before seeing the game for real.

btw I've still never worked out how to handle splitting - I can compare the value of hitting 6 as opposed to starting with two hands of 3, so get the correct strategy, but not really worked out how to factor it into the House Edge (in the UK you can re-split for ever so can't keep, say, four levels of splitting).
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
June 29th, 2014 at 12:44:26 PM permalink
Quote: charliepatrick

I can compare the value of hitting 6 as opposed to starting with two hands of 3, so get the correct strategy, but not really worked out how to factor it into the House Edge



That's rather simple. Once you have the split EV and any other EV, cycle through all 3 possible card combinations (moduly the order of your hand). Then add up the best EV for each hand vs. each upcard weighted by their dealing probabiltiy. Remember to take into account all blackjacks and their ties, and you get the house edge.

For the split EV: My "zero order" ansatz is split EV = 2 * hit EV of single split card - where the other split hands card is removed from the shoe. Extra care must be made for splitting 10s and As, as there will be no blackjack. This calculation will assume no re-split.

For single re-split, first check that you still want to re-split the hand (observing the missing first split card from the shoe). Then calculate the re-split EV same as the split EV for an additionally removed split card. Adjust split EV for probabilities for a resplit. If there are multiple resplits allowed, go on accordingly.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
June 30th, 2014 at 2:40:43 AM permalink
Thanks ThatDonGuy, it was very helpful. I am currently doing a project on developing a blackjack strategy involving only hit or stand. Other rules remain. Do you have any tips or anything I should take note of?
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 1st, 2014 at 4:30:22 AM permalink
Quote: ThatDonGuy

First, calculate the probabilities of the possible dealer hands (17, 18, 19, 20, 21, and bust).
I...
Like we said - this is very time-consuming if you don't have a computer.



How do I calculate soft hands? Like probability of dealer busting if you consider he has soft 14?
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 1st, 2014 at 4:42:04 AM permalink
Quote: ThatDonGuy


For 15, there is 1/13 chance of 16, 1/13 chance of 17, ..., 1/13 chance of 21, and 7/13 chance of bust. This means the probability of 17 from 15 = (1/13 x 1/13) (i.e. the probability of getting 16 from 15 x the probability of getting 17 from 16) + 1/13 (i.e. the probability of getting 17 from 15) = 14/169.



What about longer strings? is getting 18 from 15 just: (18 from 15) + (17 from 15 x 18 from 17) + (16 from 15 x 18 from 16)?
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 1st, 2014 at 4:57:00 AM permalink
thanks
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
July 1st, 2014 at 5:46:02 AM permalink
Start as described above.
If the dealer has 26 he is 100% chances of busting
25 to 22 - 100%
21 to 17 - 0%
16 is (4/13 * [26] + 1/13 * [25] ... + 1/13 [17]) repeat process down to 4

Soft 26 to 12 is same as Hard 26 to 12
Soft 11 to 8 equals Hard 21 to 18 (assuming dealer stands - remember player's don't, you have to work out whether they hit, double or stand)
Soft 7 either equals Hard 17 or uses the hit algorithm depending on the rules you're working out.
Soft 6 to 2 uses the above hit algorithm.

The above assumes infinite deck - with finite deck it's harder.
AceTwo
AceTwo
  • Threads: 5
  • Posts: 359
Joined: Mar 13, 2012
July 1st, 2014 at 10:46:16 AM permalink
Quote: flanderse

How do I calculate soft hands? Like probability of dealer busting if you consider he has soft 14?



INFINITE DECK CALCULATIONS
DEALER PROBABILITIES
Start from 16

15 16 17 18 19 20 21 Bust
16 1/13 1/13 1/13 1/13 1/13 8/13
15 1/13 1/13 1/13 1/13 1/13 1/13 7/13
Then the 1/13 in 16 arising from 15 gets reallocated using the 16 %s and becomes:
15 14 14 14 14 14 99 (divided by 169)

14 1/13 1/13 1/13 1/13 1/13 1/13 1/13 6/13
Then the 1/13 from 16 and the 1/13 from 15 gets reallocated using the 16 and 15 %s (for 15 using the final %s that get it from 17-21).
And so on it continues.

SOFT HANDS (including Hard that become Soft)
Say 3,A (S14 that is 4,14) the table sequence similar to the above is S15, S16, 17, 18, 19, 20, 21, 12, 13, 14 (all 1/13 prob except 14 with 4/13)
Upto 16 it is Soft and from 17 is Hard (as the dealer stops on S17 like hard 17 unless it is S17 game)
Say 2,2 (4) the table sequence becomes S15, 6, 7, 8, 9, 10, 11, 12, 13, 14 (all 1/13 prob except 14 with 4/13)

For Hard Hands the tables is easy to produce and the progression on the table is always forward.
With Soft hands is a bit trickier as the value often goes backwards. Use Different Column for Soft and Hard Total (ie S15 and 15 should be diffrent columns).

To Do the Table for Individual Dealer Upcards you start from a Single Card, Start from 10 which is easier and produce one table per Upcard.
Then you get the Dealer probs for each Upcard.
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
July 1st, 2014 at 5:45:54 PM permalink
Quote: flanderse

What about longer strings? is getting 18 from 15 just: (18 from 15) + (17 from 15 x 18 from 17) + (16 from 15 x 18 from 16)?


It's a little harder than that.
If the dealer stands on Soft 17, then you can't "get 18 from 17".
If the dealer hits on Soft 17, you have to calculate Soft 16 separately from Hard 16 (as I said earlier, you calculate the hard numbers, at least down to 12, first); you can't get 18 from Hard 17, but you can from a Soft 17.

However, it looks as if you understand the basic idea.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 2nd, 2014 at 2:40:57 AM permalink
Quote: ThatDonGuy

It's a little harder than that.
If the dealer stands on Soft 17, then you can't "get 18 from 17".
If the dealer hits on Soft 17, you have to calculate Soft 16 separately from Hard 16 (as I said earlier, you calculate the hard numbers, at least down to 12, first); you can't get 18 from Hard 17, but you can from a Soft 17.

However, it looks as if you understand the basic idea.



Thanks, I missed out that dealer stands on 17. But does the 18 from 16 include 16 to 18 AND 16 to 17 to 18?
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
July 2nd, 2014 at 2:40:08 PM permalink
Quote: ThatDonGuy

If the dealer hits on Soft 17, you have to calculate Soft 16 separately from Hard 16



You need to separate all soft and hard hands. Soft hands turn hard eventually, but no hard hand will ever turn soft again.

The drawing sequence you would need to study is:
Hard 2 -> Hard 3 -> Hard 4 -> ... -> Hard 11 -> Soft 12 -> Soft 13 -> Soft 16 -> (Soft 17) -> Hard 12 -> Hard 13 -> ... -> Hard 17.
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
July 2nd, 2014 at 6:33:06 PM permalink
Quote: flanderse

Thanks, I missed out that dealer stands on 17. But does the 18 from 16 include 16 to 18 AND 16 to 17 to 18?


Yes, in a way - it already takes into account the fact that you can't get from 17 to 18. The only way to get from 16 to 18 is if your next card is a 2, so the probability is 1/13.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 3rd, 2014 at 12:24:03 AM permalink
Quote: ThatDonGuy

Yes, in a way - it already takes into account the fact that you can't get from 17 to 18. The only way to get from 16 to 18 is if your next card is a 2, so the probability is 1/13.



So is the prob of dealer busting a 15 (infinite deck):
(D Bust from 15) + (D 20 from 15 x D Bust from 20) + (D 19 from 15 x D Bust from 19) + ... + (D 16 from 15 x D Bust from 16) = 0.834?
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 3rd, 2014 at 1:10:25 AM permalink
Also, does anyone know why the ER for 21 in wizard's chart is not 1? it is 0.8-0.9. The chart is
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
July 3rd, 2014 at 1:47:57 AM permalink
You have to remember that if the dealer also gets 21 (in his table not a Blackjack) then you only stand-off and don't win. Thus most of the time you gain 1 unit, but occasionally you don't gain any units - so the average of this is what you see. Note that the dealer has a better chance of 21 when starting with a 2 - which may be counter-intuitive.
flanderse
flanderse
  • Threads: 2
  • Posts: 13
Joined: Jun 27, 2014
July 6th, 2014 at 9:08:10 PM permalink
Anyone knows how to get the house advantage by having an ER chart?
  • Jump to: