Sanity checking my home-grown simulator

#1
My background: I'm 70-something, math major in college, 40+ years in computer work of all sorts. I have been a BJ card-counting admirer for many years. I have read several books on it, but I have never tried card counting in a casino, although I can play basic strategy easily. I'm now ready to try card counting For Real.

Mostly as an exercise, I have written a casino blackjack simulator program. It's not a simple, demonstration program, but an attempt to do it right. It plays basic strategy against a dealer, flat bets, using typical Vegas strip rules. I have run tens of millions of hands through it, and am getting numbers that I think are pretty good, but I want to hear an expert's opinion. Recently, I have added keeping track of the true count, and varying my bet with the true count. The numbers I'm seeing here don't look right to me, but I haven't found a definitive source of truth, so I will ask (below) for an expert's opinion here, too. So there are two questions:
1. Do my flat-betting numbers look okay? Do they match what gold-standard BJ simulators show? (If not, then maybe #2 is irrelevant.)
2. Do my numbers for bet-spreading, but still using basic strategy look right to you?

Here are my results for 200 million hands, dealt in the following way:
5 players at the table
75% penetration
6 decks
Dealer hits S17
DAS allowed
max split hands 4
max split aces 2
no hitting split aces
later surrender

I think that should pin down all the variables. Let me know if it doesn't.
So, for 200 millions hands (40 millions rounds of 5 hands), my programs says the house edge is 0.51%.
QUESTION: How far off is that from The Accepted Value?
From what I can find, that number looks pretty reasonable.

But my numbers for bet spreading look suspect to me, because I have to go to more than a 4-1 spread to achieve ANY edge over the house. Details:

I configured the bet chooser to bet the true count in betting units, when the true count is positive, up to a maximum that was defined for each run of about 50 million hands. Of course, it bets one unit in zero or negative counts. First, I set the max bet to TWO; i.e., it would bet 2 units for true count of 2 or above. Then I set max to 3, 4, and 6, and re-ran the test. I was thinking that when max was 2 or 3, I would be even with the house, but that's not what I see.

Here are the results. Remember that when MAX is n, the bet is the true count in bet units, but is capped at n units. Remember, I am NOT doing any deviations from basic strategy.

MAX player edge
==== ===========
1 -0.51% (flat betting)
2 -0.26%
3 -0.15%
4 -0.03%
6 +0.05%

I skipped the max=5 case, but notice that even a 4-1 bet spread does not overcome the house edge! I felt sure that it should, but maybe I didn't research enough.

So, to anyone who really knows what he's talking about, I invite you to give me your thoughts, based on Real BJ sims, on my results. Are they pretty close?
 

DSchles

Well-Known Member
#2
Analytically, the house edge for the game you describe is 0.529%. There is a cut-card effect for running the sim, which introduces a further edge for the house. Typically, it isn't more than about 0.02%-0.03% for the shoe game, so that would bring the value down to about 0.549%-0.559%. Norm's calculator, which includes the CCE, gives 0.556%, which is in my range, so, your sim looks a bit off. I'm not sure that 200 million hands is enough.

Don
 
#3
DSchles said:
Analytically, the house edge for the game you describe is 0.529%. There is a cut-card effect for running the sim, which introduces a further edge for the house. Typically, it isn't more than about 0.02%-0.03% for the shoe game, so that would bring the value down to about 0.549%-0.559%. Norm's calculator, which includes the CCE, gives 0.556%, which is in my range, so, your sim looks a bit off. I'm not sure that 200 million hands is enough.

Don
Thank you for your thoughts. I can run more hands and see if the numbers change. But can you comment, numerically, on the house edges I get with various bet spreads. Does one really have to spread more than 4-1 to get a dead even game?
 

DSchles

Well-Known Member
#4
OldGuy said:
Thank you for your thoughts. I can run more hands and see if the numbers change. But can you comment, numerically, on the house edges I get with various bet spreads. Does one really have to spread more than 4-1 to get a dead even game?
You surely would have to spread more than 1-4 playing only BS and play-all to beat a crummy game like this. The idea would be to back-count such a game and not play the negative counts.

Table 10.67 in BJA3 gives a SCORE of only 15.10 for a 1-8 spread, using all of the I18 and the Fab4. For a 1-4 spread, CVCX gives a SCORE of 3.82 for your game, but that uses Sweet 16 and Fab 4. That edge will surely be wiped out playing BS alone.

Don
 
#5
Ah, that's the sort of answer I was looking for. Thank you.

Pardon my newbie-ness: What is BJA3? Presumably, that's a book.

One more question: Your answer seems to imply that it's hopeless to play BJ without deviations from BS. Is that indeed what you're saying? I watched a Youtube video from Colin Jones where he said half (or so) of a counter's edge comes from bet spreading, but the other half comes from BS deviations. I inferred that omitting deviations was important but not essential to having a winning game. Apparently not.

One more: You called the scenario I simulated "crummy". Is it? I thought those rules were pretty liberal. What's an example of a decent game that is available in the wild (USA) today?

<later>
OHHH, I just caught on. You're the author of the famed "Blackjack Attack", and the 3 means 3rd edition I just ordered that from Amazon.
 
Last edited:

gronbog

Well-Known Member
#6
The SCORE for playing this game with a 1-4 spread and no deviations is a minuscule 0.84 (EV=0.13%). So while you can gain a tiny advantage using a bet spread alone with no deviations, the problem is that your spread is insufficient to accomplish that. The SCORE and EV above were for optimal betting. As Don says, if you're not going to use any deviations, your spread will need to be much more aggressive and/or you will need to avoid playing negative counts.

Flat betting, I get a house edge of 0.552% (cut card used) which matches the numbers Don posted.
Using your ramp of betting 1 unit per true count and 1 unit for TC=0 or less, I get EV=-0.025%.

Back-counting (avoiding negative counts) alone increases the SCORE to 33.83 (EV=1.80% -- optimal betting, optimal entry point TC>=+2). Playing your ramp (betting 1 unit per true count, 1 unit at TC=0 and skipping the negative counts) reduces the EV to 0.32%. Once again, even for back-counting, your ramp is in adequate.

As for your sim results, 200 million rounds is definitely insufficient to obtain results accurate to 2 decimal places or more. Also, why 5 players? If you want to compare against published house edges for flat betting, you should use one player. If you want to compare against published results for counting (e.g. BJA3) you will need to duplicate the conditions documented by the author.

Finally, if you're watching videos from Colin Jones, keep watching as he will definitely get into optimal betting ramps, bankroll requirements and risk of ruin. EV (house/player edge) is only the beginning if you want to be successful.
 
Last edited:
#7
gronbog said:
The SCORE for playing this game with a 1-4 spread and no deviations is a minuscule 0.84 (EV=0.13%). So while you can gain a tiny advantage using a bet spread alone with no deviations, the problem is that your spread is insufficient to accomplish that. The SCORE and EV above were for optimal betting. As Don says, if you're not going to use any deviations, your spread will need to be much more aggressive and/or you will need to avoid playing negative counts.

Flat betting, I get a house edge of 0.552% (cut card used) which matches the numbers Don posted.
Using your ramp of betting 1 unit per true count and 1 unit for TC=0 or less, I get EV=-0.025%.

Back-counting (avoiding negative counts) alone increases the SCORE to 33.83 (EV=1.80% -- optimal betting, optimal entry point TC>=+2). Playing your ramp (betting 1 unit per true count, 1 unit at TC=0 and skipping the negative counts) reduces the EV to 0.32%. Once again, even for back-counting, your ramp is in adequate.

As for your sim results, 200 million rounds is definitely insufficient to obtain results accurate to 2 decimal places or more. Also, why 5 players? If you want to compare against published house edges for flat betting, you should use one player. If you want to compare against published results for counting (e.g. BJA3) you will need to duplicate the conditions documented by the author.

Finally, if you're watching videos from Colin Jones, keep watching as he will definitely get into optimal betting ramps, bankroll requirements and risk of ruin. EV (house/player edge) is only the beginning if you want to be successful.
Great insights here. Thank you very much. I didn't realize that having 5 players would give any different results than with ONE player. I did that just for compute efficiency. I will change that to one player and start "simming" (if that's a word) again.

Yes, I would like to match up to results from Known Good simulators, because I can't think of any other way to convince myself that my code is correct. I've reviewed the code carefully, and have done much spot-checking, but that's not proof, of course.
 

gronbog

Well-Known Member
#8
Using five players effectively increases the penetration and alters the magnitude of the cut card effect. I should be even more specific. Most house edges for flat betting are calculated by combinatorial analysis (CA) of one round at the start of the shoe. There is no cut card effect. If you want to duplicate these results using simulation, you should use one player and shuffle after every round. A great free CA program is MGP's Blackjack CA which you can download here: https://github.com/Neurobaby/MGPs-BJ-CA

For verifying your simulated results, the best software to compare against is CVCX for typical conditions and CVData + CVCX for more complex situations. Some here (me included) also have our own software and may be inclined to help, depending on how busy we are.
 

gronbog

Well-Known Member
#9
In case anyone is wondering, the results I posted above for playing with no deviations are from early results of the project involving indices that Don and I have been mentioning lately. Part of the analysis is to establish a baseline beginning with using no indices.
 

BJgenius007

Well-Known Member
#10
gronbog said:
The SCORE for playing this game with a 1-4 spread and no deviations is a minuscule 0.84 (EV=0.13%). So while you can gain a tiny advantage using a bet spread alone with no deviations, the problem is that your spread is insufficient to accomplish that. The SCORE and EV above were for optimal betting. As Don says, if you're not going to use any deviations, your spread will need to be much more aggressive and/or you will need to avoid playing negative counts.
I want to be sure I understand your optimal betting.

Since this is H17 game, I suppose player gains advantage 0.5% before TC (using Hi-Lo) reaches +2. Is 4-1 spread optimal betting on this particular casino rule set the following:

TC Bet
0 or Neg 1
+1 1
+2 4
+3 4
+4 or above 4

My second question is if H17 6D optimal betting using Hi-Lo the following:
TC Bet
0 or Neg 1
+1 1
+2 4
+3 8
+4 12
+5 16
+6 or above 20
 

BoSox

Well-Known Member
#11
OldGuy said:
Dealer hits S17
I had the same confusion as BJgenius007. Not knowing which way you were going in your example and thought that you meant S17. Either way, you either say if the game is H17 or S17.

OldGuy said:
Here are the results. Remember that when MAX is n, the bet is the true count in bet units, but is capped at n units. Remember, I am NOT doing any deviations from basic strategy.

MAX player edge
==== ===========
1 -0.51% (flat betting)
2 -0.26%
3 -0.15%
4 -0.03%
6 +0.05%
Those numbers I believe look all wrong somehow, apparently, the game example was actually H17. Even then the figures do not look right.
 

DSchles

Well-Known Member
#12
Some neophytes write dealer HITS S17, instead of H17. But, you mustn't misunderstand it; he didn't write dealer STANDS on S17. In this case, the S17 means "soft 17."

Don
 

gronbog

Well-Known Member
#13
BJgenius007 said:
I want to be sure I understand your optimal betting.

Since this is H17 game, I suppose player gains advantage 0.5% before TC (using Hi-Lo) reaches +2. Is 4-1 spread optimal betting on this particular casino rule set the following:

TC Bet
0 or Neg 1
+1 1
+2 4
+3 4
+4 or above 4
Remember that the OP is playing this game with no indices, so the advantage does not ramp up as quickly as you might expect. Here are the actual advantages by true count. As much as is possible, conditions are the same as BJA3 Chapter 10 Page 211.
-1: -0.65%
0: -0.22% (note advantage at TC=0 is not the same thing as the house edge for flat betting)
+1: 0.31%
+2: 0.78%
+3: 1.22%
+4: 1.62%
+5: 2.01%
+6: 2.36%

Play-all optimal full Kelly bets for a 1-4 spread in units for the ramp above are:
<= 0: 1
>= 1: 4

With such a small spread, you need to get that max bet out there as soon as there is an advantage!

BJgenius007 said:
My second question is if H17 6D optimal betting using Hi-Lo the following:
TC Bet
0 or Neg 1
+1 1
+2 4
+3 8
+4 12
+5 16
+6 or above 20
For a spread of 1-20 on the same game under the same conditions, the play-all optimal full Kelly bets in units are:
<= 0: 1
+1: 5
+2: 12
+3: 19
>=+4: 20
 

KewlJ

Well-Known Member
#14
DSchles said:
You surely would have to spread more than 1-4 playing only BS and play-all to beat a crummy game like this. The idea would be to back-count such a game and not play the negative counts.
I chuckle to myself at the description of "crummy game". At first I thought I was missing something and went back and re-read the rules, confusing hit S17 and all.

I know I play games that many other players deem almost unplayable, going back as far as the start of my career in AC. Those were some "crummy games". :eek:

For me, the above mentioned game is very average, maybe even slightly above average because of late surrender. :oops:

I have about a 30 game rotation right now (and most times). 23 of those games are shoe games including 3, 8 deck games. So 20 are 6 deck. Of those 20, 6 decks, the above rules excluding surrender and 75% pen are about average. My better games of that 20 subset are 85-90% penetration and there are only a few that offer surrender so I place them just above the "average". So this game with surrender would probably be in my 6-10 position of best 6 deck games. :rolleyes:

Now of course I don't play all any game. I exit negative counts very agressively.

Not being critical of the description "crummy game", it probably is for most players. Just got a chuckle out of it.

Hope all is well for everyone. :)
 

BJgenius007

Well-Known Member
#15
gronbog said:
Remember that the OP is playing this game with no indices, so the advantage does not ramp up as quickly as you might expect. Here are the actual advantages by true count. As much as is possible, conditions are the same as BJA3 Chapter 10 Page 211.
-1: -0.65%
0: -0.22% (note advantage at TC=0 is not the same thing as the house edge for flat betting)
+1: 0.31%
+2: 0.78%
+3: 1.22%
+4: 1.62%
+5: 2.01%
+6: 2.36%

Play-all optimal full Kelly bets for a 1-4 spread in units for the ramp above are:
<= 0: 1
>= 1: 4

With such a small spread, you need to get that max bet out there as soon as there is an advantage!


For a spread of 1-20 on the same game under the same conditions, the play-all optimal full Kelly bets in units are:
<= 0: 1
+1: 5
+2: 12
+3: 19
>=+4: 20
I thought we should bet $40, $80, $120, $160 and $200 at $10 minimal table when the player has advantage of 0.5%, 1%, 1.5%, 2% and 2.5% based on full Kelly criterion. If the fraction number TC is allowed, should the five TC points be +1.5, +2.5, +4, +5 and +6.5 based on your probability chart?
 

DSchles

Well-Known Member
#16
"Not being critical of the description 'crummy game,' it probably is for most players. Just got a chuckle out of it."

Once upon a time, blackjack games were very, very good. Nowadays, for the most part, they suck. So, when you find a game that sucks less than some of the others, you tend to characterize it as "average" or even "good." Just because it's better than most games today doesn't make it good. It still sucks. It just sucks less than some of the other garbage games. Unfortunately, you really don't know what good blackjack games are. Of course, that's not your fault.

Don
 

gronbog

Well-Known Member
#17
BJgenius007 said:
I thought we should bet $40, $80, $120, $160 and $200 at $10 minimal table when the player has advantage of 0.5%, 1%, 1.5%, 2% and 2.5% based on full Kelly criterion. If the fraction number TC is allowed, should the five TC points be +1.5, +2.5, +4, +5 and +6.5 based on your probability chart?
The size of full Kelly optimal bets in dollars depends on the size of your bankroll. I gave the numbers in units because that's what everyone was using so far in this thread. For blackjack, the formula for a full Kelly optimal bet is (EV / Variance) x Bankroll. For a $10,000 bankroll (required for a true SCORE) the optimal unit size for this game, played with no indices, was a paltry $5 which is why this game has such a low SCORE.
 

BJgenius007

Well-Known Member
#18
For players interested on this topic, this is what I do. First, I want to be clear on full Kelly bet with RoR of 13.5% and never resize bets, the bet size is

advantage / variance * bankroll

or

0.7 * advantage * bankroll

(Over the years, I have seen people said the variance for Blackjack is 1.2. Some said 1.3. And now many discussions just remove the variance from the formula and just use coefficient 0.7. But this implies the variance for Blackjack is 1.42857 since
1/1.42857 = 0.7)

For $10,000 BR, the bet size at 0.5% advantage is

0.7 * 0.5% * $10000 = $35

I would rather use $40 instead of $35, so I created SCORE1.14, which raised the bankroll from $10,000 (for SCORE) to $11400 (SCORE1.14). The benefits of SCORE1.14 over SCORE is that for a bankroll $28,500 ($25,000*1.14), the five step bet size at 0.5%, 1%, 1.5%, 2%, 2.5% are exactly $100, $200, $300, $400 and $500 as

0.7 * 0.5% * $28,500 = $100

0.7 * 1% * $28,500 = $200

0.7 * 1.5% * $28,500 = $300

etc

The spread $25 to $100, $200, $300, $400 to $500 (should reduce to $450 so you don't bet purple chip) is considered safe in larger casinos if you also play with some cover. Last advice, at your home base casino, players might consider just spread from $25 to $300 on shoe games.
 
Last edited:

DSchles

Well-Known Member
#19
"For players interested on this topic, this is what I do. First, I want to be clear on full Kelly bet with RoR of 13.5% and never resize bets, the bet size is
0.5 * advantage / variance * bankroll"

The 0.5 doesn't belong there.

Don
 

London Colin

Well-Known Member
#20
gronbog said:
There is no cut card effect. If you want to duplicate these results using simulation, you should use one player and shuffle after every round.
Can't you shuffle after any number of rounds, so long as it is not a function of the number of cards that happen to come out in each round?
 
Top