dickwilliams
dickwilliams
  • Threads: 4
  • Posts: 13
Joined: Mar 23, 2010
March 25th, 2010 at 11:31:43 AM permalink
Dear Wizard of Odds,

I am attempting to write my own expected return algorithm, but none of the values I obtained conformed with yours. Here's my algorithm for stand:


stand( deck, player_hand, dealer_hand, bet ):
// deal with instant wins here
if player bust:
return -bet
else if dealer bet:
return bet
else if player blackjack:
if dealer cannot blackjack:
return 1.5 * bet
else if dealer blackjack:
return -bet

// dealer wants to hit here
if dealer should hit:
expected_return = 0

for i from 1 to 10:
probability = ( number of cards with value == i ) / ( total number of cards )

if number of cards with value == i > 0:
dealer hits
remove 1 card of value i from deck
expected_return = expected_return + stand() * probability
add 1 card of value i back to deck
remove last card from dealer

return expected_return

// neither were bust and dealer stands
if player hand > dealer hand:
return bet
else if dealer hand > player hand:
return bet
else // tie
return 0


It seems like my values are always higher than yours. For example, for 1 deck, dealer hits on soft 17, your value for dealer A and player A, 2 is -0.589084 while mine is -0.723261. For 6 decks of same hands, your value is -0.597220 while mine is -0.722356.

If you can let me know which part of my algorithm is faulty it would be greatly appreciated. Thanks!
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
March 25th, 2010 at 2:44:03 PM permalink
Quote: dickwilliams

Dear Wizard of Odds,

If you can let me know which part of my algorithm is faulty it would be greatly appreciated. Thanks!



The Wizard has categorically stated he will not comment on algorithms, since he receives too many of them and they are time consuming.

If it helps, I put the partial results of a test run where I got the exact same results as in appendix 9.

I did the case of a dealer 10 against a player 10,9 for a single deck game. The EV is 0.102517 if the player chooses to stand. There is only one extra line of calculation if there is more than a single deck.

The entire table did not fit in the forum, so I just put part of it so you can see intermediate results. If you add some print lines to your code, you should see if you are getting the same intermediate results.

I can see that your code is not correct. You need a table to keep track of how many remaining cards there are of each type.

expected return of simple play where dealer stands .

If I may suggest that you download the table that I did into a spreadsheet, put in formulas, and see if you can fill out the missing lines in a spreadsheet, then you will have something to check against your code.

It's my understanding that the calculation of split case can be very difficult.
dickwilliams
dickwilliams
  • Threads: 4
  • Posts: 13
Joined: Mar 23, 2010
March 25th, 2010 at 4:17:16 PM permalink
Hi,

Thanks for your reply. I in fact did have a table which keeps track of all remaining cards, which is the "deck" variable passed in. Thanks for your link, I think I've found my problem!
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
March 25th, 2010 at 4:39:05 PM permalink
Tell me if you get the correct EV's for the splits.
dickwilliams
dickwilliams
  • Threads: 4
  • Posts: 13
Joined: Mar 23, 2010
March 25th, 2010 at 5:01:10 PM permalink
Actually I had some problems with your stand table, can you post your excel file?
DorothyGale
DorothyGale
  • Threads: 40
  • Posts: 639
Joined: Nov 23, 2009
March 25th, 2010 at 5:14:11 PM permalink
Quote: dickwilliams




stand( deck, player_hand, dealer_hand, bet ):
// deal with instant wins here
if player bust:
return -bet
else if dealer bet:
return bet
else if player blackjack:
if dealer cannot blackjack:
return 1.5 * bet
else if dealer blackjack:
return -bet



Doesn't this lose one unit on a blackjack/blackjack tie? Also you are dealing with the dealer busting before evaluating the dealer's hand (I think ... you have "dealer bet" and I think you meant "dealer bust").

You want:


stand( deck, player_hand, dealer_hand, bet ):
// deal with instant wins here
if player bust:
return -bet;
else
if not dealer blackjack && player blackjack:
return 1.5 * bet;
else
if dealer blackjack && not player blackjack:
return -bet;
else
if dealer blackjack && player blackjack:
return 0;

else {
finish dealer's hand ...
if dealer busts, return bet
if dealer doesn't bust compare ...
}



Maybe that was just a typo.

--Dorothy
"Who would have thought a good little girl like you could destroy my beautiful wickedness!"
miplet
miplet
  • Threads: 5
  • Posts: 2111
Joined: Dec 1, 2009
March 25th, 2010 at 5:25:40 PM permalink
Also, the Wizards return in BJ Appendix 9 are after the dealer has checked for blackjack.
“Man Babes” #AxelFabulous
dickwilliams
dickwilliams
  • Threads: 4
  • Posts: 13
Joined: Mar 23, 2010
March 25th, 2010 at 5:26:02 PM permalink
O.K. so I realized that dealer blackjack is not part of the calculation, and thus my expected values were off by exactly the probability of getting a dealer blackjack. (If the dealer were not to peek for blackjack and let you do all the fancy stuff before declaring blackjack).
dickwilliams
dickwilliams
  • Threads: 4
  • Posts: 13
Joined: Mar 23, 2010
March 25th, 2010 at 5:26:56 PM permalink
Quote: miplet

Also, the Wizards return in BJ Appendix 9 are after the dealer has checked for blackjack.



Yes I just realized that, so evil. In Vancouver (where I play), the dealer does not check for blackjack and thus I never realized that is not how the rest of the world works.
  • Jump to: