PeterMorris
PeterMorris
  • Threads: 9
  • Posts: 17
Joined: Apr 13, 2010
April 13th, 2010 at 6:26:35 PM permalink
I'm writing a program to calculate the EV for various hands in Blackjack.

I've checked my results against the tables at the usually reliable

In most cases I calculate exactly the same values they do, except in a few cases. These cases being where the dealer has an ace or a ten showing. In such cases my program will always calculate a result slightly different to WOO's, and as far as I can tell, this is the only occasion it ever does so.

The difference is only slight. For example, given a 6 deck shoe, stand on soft 17, dealer shows a ten, player has A8 the odds are:


WOO Mine
stand +0.063321 0.064313
hit -0.087616 0.086395
double -0.233592 0.226191



My program uses a recursive algorithm. At each loop, the program considers in turn every card that might be drawn next, the chance of drawing that card, and the EV for that card:


total EV =
chance of ace * EV for ace +
chance of two * EV for two +
chance of three * EV for three +
...


The calculation of the EV for each card appears to work correctly.


After long consideration of the matter, I think the error must lie in the calculation of the chance of drawing a particular card. This will be slightly different depending if the dealer has an ace or ten showing. And this is the only difference between the ones I'm getting right, and those I'm getting wrong.

Note that I'm assuming the dealer has checked for Blackjack, and hasn't got it. Thus if the dealer shows a ten, the hole card cannot be an ace, and vice-versa. So, for example, assuming a single deck, player has stood on 4,8,6, dealer shows a ten, I figure that there are 44 possible cards the dealer might have for the hole card.


Chance of an ace = 0
chance of a 2 = 4 in 44
chance of a 3 = 4 in 44
chance of a 4 = 3 in 44
chance of a 5 = 4 in 44
chance of a 6 = 3 in 44
chance of a 7 = 4 in 44
chance of a 8 = 3 in 44
chance of a 9 = 4 in 44
chance of a 10 = 15 in 44


The above is the logic I'm using at the moment, but it appears to give incorrect results.

Here's the section of the program In the following code, cards_in_deck is a structure that holds information about the cards not in play and still in the shoe, available to be dealt.

cards_in_deck.cards_remaining is an integer showing the total number of cards left
cards_in_deck.Ace is an integer showing the number of Aces left



If dealer_hand = "A" And dealer_checks_for_blackjack Then
'----------------------------------------------
' This code operates only if dealer has a single
' ACE showing, and checks for Blackjack. We know
' the hole card cannot be a TEN, so the chance of
' any other card increases.
'----------------------------------------------


search_type = "ace_showing"
number_of_cards = cards_in_deck.cards_remaining - cards_in_deck.ten
chance_of_ace = cards_in_deck.Ace / number_of_cards
chance_of_ten = 0

ElseIf dealer_hand = "X" And dealer_checks_for_blackjack Then
'----------------------------------------------
' This code operates only if dealer has a single
' TEN showing, and checks for Blackjack. We know
' the hole card cannot be an ACE, so the chance of
' any other card increases.
'----------------------------------------------

search_type = "ten showing"
number_of_cards = cards_in_deck.cards_remaining - cards_in_deck.Ace
chance_of_ace = 0
chance_of_ten = cards_in_deck.ten / number_of_cards
Else
'----------------------------------------------
' This code operates in all other situations.
' 1) the dealer has a 2-9 showing or
' 2) dealer does not check for Blackjack
' 3) dealer has already drawn one or more cards.
'----------------------------------------------

search_type = "normal"

number_of_cards = cards_in_deck.cards_remaining
chance_of_ace = cards_in_deck.Ace / number_of_cards
chance_of_ten = cards_in_deck.ten / number_of_cards
End If

chance_of_two = cards_in_deck.two / number_of_cards
chance_of_three = cards_in_deck.three / number_of_cards
chance_of_four = cards_in_deck.four / number_of_cards
chance_of_five = cards_in_deck.five / number_of_cards
chance_of_six = cards_in_deck.six / number_of_cards
chance_of_seven = cards_in_deck.seven / number_of_cards
chance_of_eight = cards_in_deck.eight / number_of_cards
chance_of_nine = cards_in_deck.nine / number_of_cards

...

[/spoiler]

So, what am I missing?
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
April 13th, 2010 at 8:30:54 PM permalink
the only thing I can think of is in those special cases you know beyond a doubt that there dealer's hold card is not an ace or a ten, so you should have a routine that says one card is randomly removed (similar to a cut card routine).

The appendix 9 figures have been checked against other EV calculations and they were the same.

For instance this table calculates the probabilities of a hand occurring that appear in Appendix 9 (single deck only). You have to take into account what the hole card is not.

Player Deal Probability Prob total Total 2-9 Single Order Player 1 Player 2 Dealer Hole not Hole Hole card
x,y z 0.096531% 21.622926% 1,404,928 224 6,272 2 4 4 4 49 0 any
x,10 y 0.386124% 21.622926% 1,404,928 56 25,088 2 16 4 4 49 0 any
x,10 10 1.329763% 10.638101% 691,200 8 86,400 2 16 4 15 45 4 not an Ace
x,y 10 0.354603% 9.928895% 645,120 28 23,040 2 4 4 16 45 4 not an Ace
10,10 x 0.723982% 5.791855% 376,320 8 47,040 1 16 15 4 49 0 any
x,y x 0.072398% 4.054299% 263,424 56 4,704 2 4 4 3 49 0 any
A,10 x 0.386124% 3.088989% 200,704 8 25,088 2 16 4 4 49 0 any
x,A 10 0.362483% 2.899868% 188,416 8 23,552 2 4 4 16 46 3 not an Ace
10,10 10 2.327085% 2.327085% 151,200 1 151,200 1 16 15 14 45 4 not an Ace
x,x y 0.036199% 2.316742% 150,528 64 2,352 1 4 3 4 49 0 any
x,10 x 0.289593% 2.316742% 150,528 8 18,816 2 16 4 3 49 0 any
x,10 A 0.267923% 2.143380% 139,264 8 17,408 2 16 4 4 34 15 not a 10
x,y A 0.065011% 1.820297% 118,272 28 4,224 2 4 4 4 33 16 not a 10
A,10 10 1.359313% 1.359313% 88,320 1 88,320 2 16 4 15 46 3 not an Ace
x,x 10 0.132976% 1.063810% 69,120 8 8,640 1 4 3 16 45 4 not an Ace
x,A x 0.072398% 0.579186% 37,632 8 4,704 2 4 4 3 49 0 any
10,10 A 0.517130% 0.517130% 33,600 1 33,600 1 16 15 4 35 14 not a 10
x,A A 0.048758% 0.390064% 25,344 8 3,168 2 4 4 3 33 16 not a 10
A,10 A 0.200942% 0.200942% 13,056 1 13,056 2 16 4 3 34 15 not a 10
x,x A 0.024379% 0.195032% 12,672 8 1,584 1 4 3 4 33 16 not a 10
x,x x 0.018100% 0.144796% 9,408 8 1,176 1 4 3 2 49 0 any
A,A 10 0.138886% 0.138886% 9,024 1 9,024 1 4 3 16 47 2 not an Ace
A,A A 0.012189% 0.012189% 792 1 792 1 4 3 2 33 16 not a 10
==== BJ 4.826546% 4.826546% 313,600 1 313,600 2 50 49 16 4 45 Ace
100.000000% 6,497,400 551


The dealer show card, and player cards are input to cover all situations.
The dealer hold card is 49-(not hole card)
Order is 1 or 2 depending on if the order of the player cards matters or not.
Single is the number of possibilities for a single value of x, y, and z.
--- It is the product of order and player and dealer card
Column labeled "2-9" is combinations
Total = (value of 2-9) * ( Single (
Probability = Single / 6,497,400 (all combinations possible)
Prob total = (Probability)* (column labeled 2-9)
PeterMorris
PeterMorris
  • Threads: 9
  • Posts: 17
Joined: Apr 13, 2010
April 14th, 2010 at 3:32:47 AM permalink
Can you explain what the table means? for instance :

PLAYER - x,y DEAL - z
PLAYER - x, 10 DEAL - y

what are x, y and z? What does the DEAL column signify? There's a lot of stuff like that where I don't know what it meams.
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
April 14th, 2010 at 4:04:01 AM permalink
If I can try to rephrase what Paco was saying, the fact that the dealer doesn't have a blackjack also affects the player probabilities. For example, assume a single-deck game, the dealer has an ace up, and the player has 5,7. The player hits, what is the probability the next card is a 9?

Using conditional probability, the answer should be [(33/49)*((4/33)*(3/48) + (29/33)*(4/48))]/(33/49) = 8.08%.

Note that is a little less than the probability of the dealer didn't peek of 4/49 = 8.16%, because there is a greater chance the dealer's hole card is a 9. Hopefully I did my math right at 4 AM.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
April 14th, 2010 at 5:02:22 AM permalink
Quote: PeterMorris

Can you explain what the table means? for instance :

PLAYER - x,y DEAL - z
PLAYER - x, 10 DEAL - y

what are x, y and z? What does the DEAL column signify? There's a lot of stuff like that where I don't know what it meams.



DEAL means DEALER

x,y,z means three different cards (values 2-9).
x,x,y means two cards that are the same, and one that is different (values 2-9).

If you count the permutations of 4 cards out of 52 you get 6,497,400. In Excel the function is =PERMUT(52,4) . The table calculates the probabilities of each combination. These values are used in the Wizard's Appendix 9.

If you look at the Appendix 9 table it says
2 7,2 has a probability of 0.00072398

If you look in my table for x,y x it says 0.072398% but you can calculate this number using the formulas.
===================
Expressing the calculation that the WIZ did as a fraction it is 8/99=.808080% which is slightly smaller than 4/49=8/98 .
PeterMorris
PeterMorris
  • Threads: 9
  • Posts: 17
Joined: Apr 13, 2010
April 14th, 2010 at 6:09:10 AM permalink
Quote: WIZARD

Using conditional probability, the answer should be [(33/49)*((4/33)*(3/48) + (29/33)*(4/48))]/(33/49) = 8.08%.

Note that is a little less than the probability of the dealer didn't peek of 4/49 = 8.16%, because there is a greater chance the dealer's hole card is a 9. Hopefully I did my math right at 4 AM.




This sounds promising. But I don't understand the formula you are using. Can you explain where those specific numbers come from, and give me a general forula to cal;culate the odds in any given situation.


Also, are there any tables showing the EV if dealer doesn't check for BJ? I'd like to check my figures for those.
Would I be correct in thinking they will be exactly the same if dealer shows 2 to 9?
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
April 14th, 2010 at 3:21:11 PM permalink
For every fraction write down what you think the fraction corresponds to.
For instance (33/49) refers to all the cards in the deck except the three you know that are not a ten.
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
April 15th, 2010 at 6:55:30 AM permalink
Quote: PeterMorris


This sounds promising. But I don't understand the formula you are using. Can you explain where those specific numbers come from, and give me a general forula to cal;culate the odds in any given situation.

Also, are there any tables showing the EV if dealer doesn't check for BJ? I'd like to check my figures for those. Would I be correct in thinking they will be exactly the same if dealer shows 2 to 9?



I could have just said (4/33)*(3/48) + (29/33)*(4/48). That is pr(dealer has 9 in the hole)*pr(player has 9, given that dealer has a 9 in the hole) + pr(dealer doesn't have 9 in the hole)*pr(player has 9, given that dealer does not have a 9 in the hole). Any questions?

Sorry, I've never seen such tables for European rules. If the dealer has a 2-9 up, the results would be the same.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
PeterMorris
PeterMorris
  • Threads: 9
  • Posts: 17
Joined: Apr 13, 2010
April 15th, 2010 at 11:31:47 AM permalink
Quote: Wizard



I could have just said (4/33)*(3/48) + (29/33)*(4/48). That is pr(dealer has 9 in the hole)*pr(player has 9, given that dealer has a 9 in the hole) + pr(dealer doesn't have 9 in the hole)*pr(player has 9, given that dealer does not have a 9 in the hole).



That's a lot clearer. I'll alter my program accordingly.


Quote:

Any questions?



A couple:

Q1 - should I use this formula for all hands, or only if the dealer shows ace or 10?

Q2 - is there any practical difference between the following rules variants?
a) Dealer gets a hole card, but doesn't peek/ check for BJ.
b) Dealer only gets one card, only gets a second card after all players stop hitting.
PeterMorris
PeterMorris
  • Threads: 9
  • Posts: 17
Joined: Apr 13, 2010
April 18th, 2010 at 5:08:41 PM permalink
Thank you so much, Mr Wizard. I've adjusted my program according to your advice, and it's now getting exactly the same results as in your tables.

Except for splits. I'll ask about that in another post.
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
April 18th, 2010 at 8:59:52 PM permalink
Quote: PeterMorris

Thank you so much, Mr Wizard. I've adjusted my program according to your advice, and it's now getting exactly the same results as in your tables.

Except for splits. I'll ask about that in another post.



You're welcome. I assume you don't require an answer to your two questions two posts above then. Things get even uglier when it comes to splitting. I'll await your questions.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
PeterMorris
PeterMorris
  • Threads: 9
  • Posts: 17
Joined: Apr 13, 2010
April 19th, 2010 at 9:24:05 AM permalink
I would like an answer, if possible.

I think the answer to my first question is that when thje dealer shows 2-9 the terms in the formula cancel out, and it becomes much simpler. The chance of hitting a nine becomes (number of unseen nines) / (total number of unseen cards).

I think the answer to my second question is that there's no difference.

But I could be wrong, so I'd welcome your answer.
scotty81
scotty81
  • Threads: 8
  • Posts: 185
Joined: Feb 4, 2010
April 19th, 2010 at 10:20:01 AM permalink
General questing regarding calculating EV for BJ hands:

When computing EV, do you take into account push action, or just raw win/loss action? An extreme example would be:

You play 1 million hands of a specific combination you are researching. 500,000 hands are winners, 400,000 hands are losers, and 100,000 hands are pushes.

Is the EV (1 - 1100000/1000000) [10%] or (1 - 1000000/900000) [10.11%]?

Some of the popular published tables seem to ignore the pushes, and thus skew the EV values.
Prediction is very difficult, especially about the future. - Niels Bohr
  • Jump to: