kw2107
kw2107
Joined: Mar 4, 2014
  • Threads: 2
  • Posts: 13
March 4th, 2014 at 3:00:46 PM permalink
I wrote a fairly simple blackjack strategy simulator (~500 lines of C#) for my own personal use and I'm looking for another software developer to review it and make sure there's nothing I'm missing. My simulated house edge calculations don't match up with what I see for the rule and strategies I'm using and I can't figure out why.

So, if you're a software developer who can understand C# and knows blackjack and very basic card counting concepts, please let me know!

Thanks.
AcesAndEights
AcesAndEights
Joined: Jan 5, 2012
  • Threads: 65
  • Posts: 4191
March 4th, 2014 at 3:08:34 PM permalink
Quote: kw2107

I wrote a fairly simple blackjack strategy simulator (~500 lines of C#) for my own personal use and I'm looking for another software developer to review it and make sure there's nothing I'm missing. My simulated house edge calculations don't match up with what I see for the rule and strategies I'm using and I can't figure out why.

So, if you're a software developer who can understand C# and knows blackjack and very basic card counting concepts, please let me know!

Thanks.


Can you offer anything in return?
"So drink gamble eat f***, because one day you will be dust." -ontariodealer
kw2107
kw2107
Joined: Mar 4, 2014
  • Threads: 2
  • Posts: 13
March 4th, 2014 at 3:12:46 PM permalink
Mmm... Not really. I can review some of your code I guess? Haha...
AxiomOfChoice
AxiomOfChoice
Joined: Sep 12, 2012
  • Threads: 32
  • Posts: 5761
March 4th, 2014 at 3:34:17 PM permalink
Quote: kw2107

I wrote a fairly simple blackjack strategy simulator (~500 lines of C#) for my own personal use and I'm looking for another software developer to review it and make sure there's nothing I'm missing. My simulated house edge calculations don't match up with what I see for the rule and strategies I'm using and I can't figure out why.

So, if you're a software developer who can understand C# and knows blackjack and very basic card counting concepts, please let me know!

Thanks.



I don't mind taking a look. I've done the same thing for several games and these errors can be a pain to track down.

However, before I look at it:

Do you have the dealer "checking for blackjack" correct? In other words, the dealer checks for blackjack before you play out your hand, and you don't play out your hand if he has blackjack.

Do you have the dealer not playing out the hand when you have busted or have BJ on all your hands?

Are you using a cut card? If you are, are you looking at the house edge numbers for that game including the cut card effect? The cut card effect is SIGNIFICANT for single deck.

Are you sure you are looking at the house edge for the right strategy that you are using (total-dependent vs composition dependent?) Again, this is significant for single-deck.

The first time that I did this for single deck, I had a strange bug with the way that split aces were handled (it was really stupid). It changed my simulated edge by 0.2%. Not insignificant!
kw2107
kw2107
Joined: Mar 4, 2014
  • Threads: 2
  • Posts: 13
March 4th, 2014 at 3:59:21 PM permalink
Thanks for your reply.

Yes I think have the dealer blackjack coded correctly. Yep I have a check for the dealer needing to play out the hand. Although, does the down-card get revealed if the dealer doesn't need to play? That would affect counting I would image...

No I'm not using a cut card, but I'm using 6-8 decks typically. Does it matter as much then?

Just a while ago I discovered a stupid bug where I was allowing hitting after splitting aces... That was a pretty significant change as well.

One odd thing I'm doing though is working out all of the "Split" decisions before playing out any of the hands for that player. Not sure if that matters though. The other odd/lazy thing I'm doing is using the average of 2.71 cards per player to burn through the other players at the table.

For my rules (Dealer hits soft 17, 8 decks, split 4 times, late surrender, double after split) and my counting strategy (Hi-Lo, but only to increase wager, not using it to change decision table) I'm getting about a 0.19% advantage for the player. If I disable the counting (by always betting 1 unit) the house edge is about -0.559% which is pretty accurate I think.
AxiomOfChoice
AxiomOfChoice
Joined: Sep 12, 2012
  • Threads: 32
  • Posts: 5761
March 4th, 2014 at 4:35:49 PM permalink
Quote: kw2107

Thanks for your reply.

Yes I think have the dealer blackjack coded correctly. Yep I have a check for the dealer needing to play out the hand. Although, does the down-card get revealed if the dealer doesn't need to play? That would affect counting I would image...

No I'm not using a cut card, but I'm using 6-8 decks typically. Does it matter as much then?



If you are not using a cut card, how do you decide when to end the shoe?

Quote:

Just a while ago I discovered a stupid bug where I was allowing hitting after splitting aces... That was a pretty significant change as well.

One odd thing I'm doing though is working out all of the "Split" decisions before playing out any of the hands for that player. Not sure if that matters though. The other odd/lazy thing I'm doing is using the average of 2.71 cards per player to burn through the other players at the table.

For my rules (Dealer hits soft 17, 8 decks, split 4 times, late surrender, double after split) and my counting strategy (Hi-Lo, but only to increase wager, not using it to change decision table) I'm getting about a 0.19% advantage for the player. If I disable the counting (by always betting 1 unit) the house edge is about -0.559% which is pretty accurate I think.



That is pretty close to the "realistic results" here: http://wizardofodds.com/games/blackjack/calculator/

Why do you think you have a mistake?
MathExtremist
MathExtremist
Joined: Aug 31, 2010
  • Threads: 88
  • Posts: 6526
March 4th, 2014 at 5:22:48 PM permalink
Most analytical calculations are based on the first hand out of a full shoe, however many decks that is. If you're simulating down to a cut card, your numbers will be different. Try putting in a reshuffle after every hand and see if your results match up with your references. Once you get your basic algorithm working, then you start adding features like playing to 75% penetration or count analysis.
"In my own case, when it seemed to me after a long illness that death was close at hand, I found no little solace in playing constantly at dice." -- Girolamo Cardano, 1563
AxiomOfChoice
AxiomOfChoice
Joined: Sep 12, 2012
  • Threads: 32
  • Posts: 5761
March 4th, 2014 at 7:39:58 PM permalink
Quote: MathExtremist

Most analytical calculations are based on the first hand out of a full shoe, however many decks that is. If you're simulating down to a cut card, your numbers will be different. Try putting in a reshuffle after every hand and see if your results match up with your references. Once you get your basic algorithm working, then you start adding features like playing to 75% penetration or count analysis.



Note that the Wizard's "realistic results" on his HE calculator include the cut card effect.
kw2107
kw2107
Joined: Mar 4, 2014
  • Threads: 2
  • Posts: 13
March 5th, 2014 at 7:17:40 AM permalink
Ah yeah I am using a cut card I guess. Not sure what I thought that meant. I'm going through 75% of the shoe. The reason why I thought something was wrong is that I thought you didn't turn the odds in your favor by counting cards unless you started altering your decision tables based on the count.

I'll just post my code anyways:
kw2107
kw2107
Joined: Mar 4, 2014
  • Threads: 2
  • Posts: 13
March 5th, 2014 at 7:25:37 AM permalink
Quick note, in the PlaceBet method, comment out the "return 1" in order to enable the counting effect.

  • Jump to: