I see that for 6 decks, H17, DAS, Aces split once, up to 4 hands max from splitting, 3:2 payout for BJ, no surrender rule the edge is 0.639% from the blackjack calculator on wizardofodds.
I've written some code as sort of a hobby project to simulate blackjack and eventually card counting and finding optimized bet spreads with AI. At the moment I think I have the simulator part of the project bug free. When I run 1 billion hands I find the house edge at 0.651%, this is using the same basic strategy chart as I found on the wizardofodds website. I'm trying to decide if this is within an acceptable variance or if maybe I have a small bug somewhere that is accounting for the 0.012% difference. When I change from H17 to S17 I see a difference of 0.22%, so it seems I did something right at least.
Thanks for any information to help me conclude this part of my project! If I know it was done with a certain amount of hands with software I can possibly estimate the variance to tell if my difference is acceptable.
Quote: crush1986Hello, I'm just curious how the edges for a certain set of rules for blackjack calculated on the Wizard of Odds website, either by simulation with some amount of hands with something like CVCX or with purely theoretical math perhaps?
I see that for 6 decks, H17, DAS, Aces split once, up to 4 hands max from splitting, 3:2 payout for BJ, no surrender rule the edge is 0.639% from the blackjack calculator on wizardofodds.
I've written some code as sort of a hobby project to simulate blackjack and eventually card counting and finding optimized bet spreads with AI. At the moment I think I have the simulator part of the project bug free. When I run 1 billion hands I find the house edge at 0.651%, this is using the same basic strategy chart as I found on the wizardofodds website. I'm trying to decide if this is within an acceptable variance or if maybe I have a small bug somewhere that is accounting for the 0.012% difference. When I change from H17 to S17 I see a difference of 0.22%, so it seems I did something right at least.
Thanks for any information to help me conclude this part of my project! If I know it was done with a certain amount of hands with software I can possibly estimate the variance to tell if my difference is acceptable.
link to original post
It is done by direct calculation of probabilities for each possible outcome for the next card. BJ is a really quick game to analyze by brute force. Since all 24 aces in an 6-deck game are effectively identical, you don't need track the suits, just the number of aces left in the shoe.
Eric Farmer has an open-source BJ calculator written in C++ that has been verified by other experts. It will give you exact EVs for any particular hand, which you can use to check you calculations. For example, 8 9 versus dealer ace.
Stand E(X) = -47.492350348%
Hit E(X) = -55.571058206%
Surrender E(X) = -50.000000000%
The complete strategy for S17 and H17 is shown in the spoilers below:
6 decks, S17, D9, DAS, SPL3, NRSA, CDP
Hard | Dealer's up card
hand | 2 3 4 5 6 7 8 9 10 A
-----------------------------------------------------------
10- 9 | S S S S S S S S S S
|
10- 8 | S S S S S S S s s s
|
10- 7 | s s s s S s s s s s
9- 8 | s s s s S s s s s s
|
10- 6 | s s s s s h h h h h
9- 7 | s s s s s h h h h h
|
10- 5 | s s s s s h h h h h
9- 6 | s s s s s h h h h h
8- 7 | s s s s s h h h h h
|
10- 4 | s s s s s h h h h h
9- 5 | s s s s s h h h h h
8- 6 | s s s s s h h h h h
|
10- 3 | s s s s s h h h h h
9- 4 | s s s s s h h h h h
8- 5 | s s s s s h h h h h
7- 6 | s s s s s h h h h h
|
10- 2 | h h h s s h h h h h
9- 3 | h h s s s h h h h h
8- 4 | h h s s s h h h h h
7- 5 | h h s s s h h h h h
|
9- 2 | DH DH DH DH DH DH DH DH DH H
8- 3 | DH DH DH DH DH DH DH DH DH H
7- 4 | DH DH DH DH DH DH DH DH DH H
6- 5 | DH DH DH DH DH DH DH DH DH H
|
8- 2 | DH DH DH DH DH DH DH DH H H
7- 3 | DH DH DH DH DH DH DH DH H H
6- 4 | DH DH DH DH DH DH DH DH H H
|
7- 2 | H DH DH DH DH H H h h h
6- 3 | H DH DH DH DH H H h h h
5- 4 | H DH DH DH DH H H h h h
|
6- 2 | h H H H H H h h h h
5- 3 | h H H H H H h h h h
|
5- 2 | h h h H H h h h h h
4- 3 | h h h H H h h h h h
|
4- 2 | h h h h h h h h h h
|
3- 2 | h h h h H h h h h h
|
Soft | Dealer's up card
hand | 2 3 4 5 6 7 8 9 10 A
-----------------------------------------------------------
A- 9 | S S S S S S S S S S
A- 8 | S S S S S S S S S S
A- 7 | S S S S S S S h h h
A- 6 | H H H H H H h h h h
A- 5 | h H H H H h h h h h
A- 4 | h H H H H H h h h h
A- 3 | H H H H H H H h h h
A- 2 | H H H H H H H h h h
Pair | Dealer's up card
hand | 2 3 4 5 6 7 8 9 10 A
-----------------------------------------------------------
A- A | PH PH PH PH PH PH PH Ph Ph Ph
10-10 | S S S S S S S S S S
9- 9 | PS PS PS PS PS S PS ps s s
8- 8 | Ps Ps Ps Ps Ps Ph ph ph ph ph
7- 7 | ps ps Ps Ps Ps ph h h h h
6- 6 | ph ph ps Ps Ps h h h h h
5- 5 | DH DH DH DH DH DH DH DH H H
4- 4 | h H H PH PH H h h h h
3- 3 | ph ph Ph Ph Ph ph h h h h
2- 2 | ph ph Ph Ph PH Ph h h h h
-----------------------------------------------------------
S = Stand
H = Hit
D = Double down
P = Split
Uppercase indicates action is favorable for the player
Lowercase indicates action is favorable for the house
When more than one option is listed, options are listed from left to right in order of preference.
Up |
card | Overall expected value (%)
---------------------------------
2 | 9.267510660
3 | 12.557844501
4 | 16.082827558
5 | 19.918799893
6 | 23.004243016
7 | 14.460102687
8 | 5.757242137
9 | -4.114157566
10 | -17.313880618
A | -34.165284767
---------------------------------
Total | -0.498953412
Up | Probability of outcome of dealer's hand
card | Bust | 17 | 18 | 19 | 20 | 21 |Blackjack
-------------------------------------------------------------------------------
2 | 0.35350 | 0.13966 | 0.13439 | 0.13002 | 0.12402 | 0.11841 | 0.00000
3 | 0.37419 | 0.13430 | 0.13054 | 0.12523 | 0.12082 | 0.11493 | 0.00000
4 | 0.39580 | 0.13056 | 0.12406 | 0.12127 | 0.11644 | 0.11187 | 0.00000
5 | 0.41841 | 0.12184 | 0.12244 | 0.11758 | 0.11179 | 0.10795 | 0.00000
6 | 0.42284 | 0.16571 | 0.10619 | 0.10643 | 0.10155 | 0.09728 | 0.00000
7 | 0.26194 | 0.36921 | 0.13793 | 0.07843 | 0.07868 | 0.07382 | 0.00000
8 | 0.24369 | 0.12894 | 0.35995 | 0.12872 | 0.06922 | 0.06947 | 0.00000
9 | 0.22924 | 0.12031 | 0.11735 | 0.35185 | 0.12037 | 0.06088 | 0.00000
10 | 0.21247 | 0.11191 | 0.11167 | 0.11194 | 0.34001 | 0.03482 | 0.07717
A | 0.11547 | 0.13002 | 0.13082 | 0.13059 | 0.13091 | 0.05350 | 0.30868
-------------------------------------------------------------------------------
Total | 0.28192 | 0.14525 | 0.13926 | 0.13368 | 0.17953 | 0.07287 | 0.04749
Composition-dependent stand/hit strategy variations:
----------------------------------------------------
( 24) Hard 16 vs. T : stand except, 88, 79, 6T, 466, 367, 33T, 268, 2266, 2239, 22336, 222T, 222226, A69, A366, A267, A23T, A2229, A22236, AA68, AA266, AA22T, AA22226, AAA67, AAAA66
( 1) Hard 12 vs. 4 : stand except, 2T
( 7) Soft 18 vs. A : hit except, A223, AA33, AA222, AAA23, AAAA22, AAAAA3, AAAAAA2
6 decks, H17, D9, DAS, SPL3, NRSA, CDP
Hard | Dealer's up card
hand | 2 3 4 5 6 7 8 9 10 A
-----------------------------------------------------------
10- 9 | S S S S S S S S S S
|
10- 8 | S S S S S S S s s s
|
10- 7 | s s s s s s s s s s
9- 8 | s s s s s s s s s s
|
10- 6 | s s s s s h h h h h
9- 7 | s s s s s h h h h h
|
10- 5 | s s s s s h h h h h
9- 6 | s s s s s h h h h h
8- 7 | s s s s s h h h h h
|
10- 4 | s s s s s h h h h h
9- 5 | s s s s s h h h h h
8- 6 | s s s s s h h h h h
|
10- 3 | s s s s s h h h h h
9- 4 | s s s s s h h h h h
8- 5 | s s s s s h h h h h
7- 6 | s s s s s h h h h h
|
10- 2 | h h s s s h h h h h
9- 3 | h h s s s h h h h h
8- 4 | h h s s s h h h h h
7- 5 | h h s s s h h h h h
|
9- 2 | DH DH DH DH DH DH DH DH DH DH
8- 3 | DH DH DH DH DH DH DH DH DH DH
7- 4 | DH DH DH DH DH DH DH DH DH DH
6- 5 | DH DH DH DH DH DH DH DH DH DH
|
8- 2 | DH DH DH DH DH DH DH DH H H
7- 3 | DH DH DH DH DH DH DH DH H H
6- 4 | DH DH DH DH DH DH DH DH H H
|
7- 2 | H DH DH DH DH H H h h h
6- 3 | H DH DH DH DH H H h h h
5- 4 | H DH DH DH DH H H h h h
|
6- 2 | h H H H H H h h h h
5- 3 | h H H H H H h h h h
|
5- 2 | h h h H H h h h h h
4- 3 | h h h H H h h h h h
|
4- 2 | h h h h H h h h h h
|
3- 2 | h h h h H h h h h h
|
Soft | Dealer's up card
hand | 2 3 4 5 6 7 8 9 10 A
-----------------------------------------------------------
A- 9 | S S S S S S S S S S
A- 8 | S S S S S S S S S S
A- 7 | S S S S S S S h h h
A- 6 | h H H H H H h h h h
A- 5 | h H H H H h h h h h
A- 4 | h H H H H H h h h h
A- 3 | H H H H H H H h h h
A- 2 | H H H H H H H h h h
Pair | Dealer's up card
hand | 2 3 4 5 6 7 8 9 10 A
-----------------------------------------------------------
A- A | PH PH PH PH PH PH PH Ph Ph Ph
10-10 | S S S S S S S S S S
9- 9 | PS PS PS PS PS S PS ps s s
8- 8 | Ps Ps Ps Ps Ps Ph ph ph ph ph
7- 7 | ps ps Ps Ps Ps ph h h h h
6- 6 | ph ph ps Ps Ps h h h h h
5- 5 | DH DH DH DH DH DH DH DH H H
4- 4 | h H H PH PH H h h h h
3- 3 | ph ph Ph Ph PH ph h h h h
2- 2 | ph ph Ph Ph PH Ph h h h h
-----------------------------------------------------------
S = Stand
H = Hit
D = Double down
P = Split
Uppercase indicates action is favorable for the player
Lowercase indicates action is favorable for the house
When more than one option is listed, options are listed from left to right in order of preference.
Up |
card | Overall expected value (%)
---------------------------------
2 | 9.238198581
3 | 12.531013285
4 | 16.112538439
5 | 19.934740419
6 | 23.198895497
7 | 14.460102687
8 | 5.757242137
9 | -4.114157566
10 | -17.313880618
A | -37.240360381
---------------------------------
Total | -0.721331490
Up | Probability of outcome of dealer's hand
card | Bust | 17 | 18 | 19 | 20 | 21 |Blackjack
-------------------------------------------------------------------------------
2 | 0.35666 | 0.13007 | 0.13598 | 0.13161 | 0.12566 | 0.12002 | 0.00000
3 | 0.37696 | 0.12590 | 0.13193 | 0.12666 | 0.12218 | 0.11637 | 0.00000
4 | 0.39847 | 0.12246 | 0.12541 | 0.12262 | 0.11783 | 0.11322 | 0.00000
5 | 0.41963 | 0.11809 | 0.12304 | 0.11822 | 0.11243 | 0.10859 | 0.00000
6 | 0.43926 | 0.11506 | 0.11457 | 0.11504 | 0.11018 | 0.10588 | 0.00000
7 | 0.26194 | 0.36921 | 0.13793 | 0.07843 | 0.07868 | 0.07382 | 0.00000
8 | 0.24369 | 0.12894 | 0.35995 | 0.12872 | 0.06922 | 0.06947 | 0.00000
9 | 0.22924 | 0.12031 | 0.11735 | 0.35185 | 0.12037 | 0.06088 | 0.00000
10 | 0.21247 | 0.11191 | 0.11167 | 0.11194 | 0.34001 | 0.03482 | 0.07717
A | 0.13915 | 0.05727 | 0.14282 | 0.14294 | 0.14328 | 0.06586 | 0.30868
-------------------------------------------------------------------------------
Total | 0.28576 | 0.13346 | 0.14120 | 0.13568 | 0.18153 | 0.07487 | 0.04749
Composition-dependent stand/hit strategy variations:
----------------------------------------------------
( 24) Hard 16 vs. T : stand except, 88, 79, 6T, 466, 367, 33T, 268, 2266, 2239, 22336, 222T, 222226, A69, A366, A267, A23T, A2229, A22236, AA68, AA266, AA22T, AA22226, AAA67, AAAA66
The variance for a billion hands should lead to a standard deviation of 0.0036%.
(What I used to do is work out the HE for an infinite deck, easy to do on a spreadsheet, and run the simulation for a larger number of decks. It should gradually get close to the calculated HE.)
(ii) In theory you can work out BJ HE as there are only a finite number of possible player hands and from these cards removed from the shoe, the chances of each one winning; this gradually gives a hit/stand/double/split strategy for hands with fewer cards. In theory you need to run these given you have also split cards, so a hand might be 8xxx with 888 also missing. The other complication is if the dealer has peeked since this gives you information on the cards that haven't gone: e.g. vs Ten this means all the Aces are available since the Dealer can't have one, whereas for the other cards, on average 1/12 of them would be missing.
(You can manually work out, say, specific 16s vs 10 and check these.)
It simplifies things by using infinite deck logic, but it’s very close to what a new 8 deck shoe would be.
https://wizardofodds.com/video/blackjack-basic-strategy/
The article is pretty much the script for the video.
The YouTube video also has a link to a completed Excel document, if desired.
I'm definitely not quite convinced I'm bug free but I've found a lot of resources already from this thread. I'll hopefully figure out if I have some odd edge case that is causing me to lose more hands than I should. I think I'll implement the exact basic strategy chart someone else posted here and see the results. Then maybe write up some code to test each hand a 100 million times and compare to the EV that I see in another chart posted here. I parallelized my code to run faster so hopefully that all won't take it too long.
Quote: crush1986I also had a bug with my handling of soft hands that I had to fix! The logic with splitting was also a pain to debug. When my code hit the max number of splits it was doing weird things, splitting aces was also messed up for a bit. I think I've worked all that out.
I'm definitely not quite convinced I'm bug free but I've found a lot of resources already from this thread. I'll hopefully figure out if I have some odd edge case that is causing me to lose more hands than I should. I think I'll implement the exact basic strategy chart someone else posted here and see the results. Then maybe write up some code to test each hand a 100 million times and compare to the EV that I see in another chart posted here. I parallelized my code to run faster so hopefully that all won't take it too long.
link to original post
Welcome to WOV. There are not enough programmers on the forum. It is immeasurably helpful to have detailed results from a reliable calculation when you are debugging new code. When I was working on my Bingo Blackjack analyzer, I compared results with charliepatrick. The strategy the DK provides for that game is wrong, so it was useful compare notes.
Just to be sure I understand you, it sounds like your program does not create a BJ strategy. Instead you input the Wizard's basic BJ strategy and then you are testing your code to see if it produces the correct EV. In other words, you are testing your simulator to see if it plays out the hands correctly against the chosen set of rules and scores the wins properly.
If this is the case, then you can isolate problems by just looking at a small subset of starting hands and comparing to known EVs. I could provide a complete set of EVs for every combination of two players cards and dealer up-card and playing decision if that would be useful.
That is what I was thinking I'd do, check the EV of certain hands. So I guess I'd force my dealer's up card to be a value and my player's hand to be something and run millions of these hands to see how much money lost per hand. I assume values from wizard of odds /games/blackjack/hand-calculator/ can be trusted for a certain hand?
Quote: crush1986That is correct, at the moment all it does is simulate blackjack with basic strategy taken from the wizard of odds website. I hope to in the future implement card counting (actually just finished this and testing, so far it looks good because it is beating the house with a simple bet spread of bet = base_bet + (true_count*base_bet). Then in the further future I want to try and use machine learning to find as optimized a bet spread as I can.
That is what I was thinking I'd do, check the EV of certain hands. So I guess I'd force my dealer's up card to be a value and my player's hand to be something and run millions of these hands to see how much money lost per hand. I assume values from wizard of odds /games/blackjack/hand-calculator/ can be trusted for a certain hand?
link to original post
I never used the Wizard's BJ calculator, but I would assume it gives correct results.
Do you have a background or experience with AI or machine learning?
What language are you programming in?
Quote: MentalQuote: crush1986That is correct, at the moment all it does is simulate blackjack with basic strategy taken from the wizard of odds website. I hope to in the future implement card counting (actually just finished this and testing, so far it looks good because it is beating the house with a simple bet spread of bet = base_bet + (true_count*base_bet). Then in the further future I want to try and use machine learning to find as optimized a bet spread as I can.
That is what I was thinking I'd do, check the EV of certain hands. So I guess I'd force my dealer's up card to be a value and my player's hand to be something and run millions of these hands to see how much money lost per hand. I assume values from wizard of odds /games/blackjack/hand-calculator/ can be trusted for a certain hand?
link to original post
I never used the Wizard's BJ calculator, but I would assume it gives correct results.
Do you have a background or experience with AI or machine learning?
What language are you programming in?
link to original post
I have had a tiny bit of experience with machine learning. I used it in a small project having to do with molecular simulations in grad school. I know I'm going to need data sets to train on probably, I'll have to generate some, maybe take from from CVCX's database that comes with the program.
My code is in Python, I kind of regret it now lol, it was what I was most comfortable with at the moment. I know Fortran pretty well and C++ somewhat OK. Both would have been much faster probably.
Quote: crush1986Hello, I'm just curious how the edges for a certain set of rules for blackjack calculated on the Wizard of Odds website, either by simulation with some amount of hands with something like CVCX or with purely theoretical math perhaps?
I see that for 6 decks, H17, DAS, Aces split once, up to 4 hands max from splitting, 3:2 payout for BJ, no surrender rule the edge is 0.639% from the blackjack calculator on wizardofodds.
I've written some code as sort of a hobby project to simulate blackjack and eventually card counting and finding optimized bet spreads with AI. At the moment I think I have the simulator part of the project bug free. When I run 1 billion hands I find the house edge at 0.651%, this is using the same basic strategy chart as I found on the wizardofodds website. I'm trying to decide if this is within an acceptable variance or if maybe I have a small bug somewhere that is accounting for the 0.012% difference. When I change from H17 to S17 I see a difference of 0.22%, so it seems I did something right at least.
Thanks for any information to help me conclude this part of my project! If I know it was done with a certain amount of hands with software I can possibly estimate the variance to tell if my difference is acceptable.
link to original post
crush1986,
Let me also welcome you to the board!
The EV difference you describe might be due to the "cut card effect" or CCE: an artifact introduced by using a cut card (in other words, a fixed penetration, like 75%) to determine when to end the shoe and shuffle.
The Wiz has a webpage over on WoO describing the CCE:
https://wizardofodds.com/games/blackjack/cut-card-effect/
To remove the CCE, have you program deal a fixed number of rounds per shoe, rather than a fixed penetration. For heads-up play, 40 rounds will use about 4 decks, so the risk of running out of cards is minimal for a 6 or 8 deck simulation.
If this resolves the EV discrepancy, then your code is likely correct. Don't forget to change back to fixed pen when you do later sims.
Hope this helps!
Dog Hand