Devlog #3: Finally got the blackjack engine to work!!!!!!!
After a tedious and treacherous 6 hours of coding… the blackjack engine is consistently beating the house. I had to rewrite the code as my initial code was not clean and had tons of bugs.
The engine supports a pretty large ruleset: here
It uses a bruteforce algorithm which explores all of your possible options and then evaluates the expected value of each choice based on the probabilities of other cards showing up for you and the dealer. It is currently capped to depth 8 for the hit action.
Splits are approximated to avoid the exponential increase in computation that comes from recursively simulating every possible sequence of re-splits and draws. Instead, each split hand is evaluated independently by averaging over all possible second cards, calculating the best EV (stand, hit, or double) for that hand, and then doubling the result to represent the two split hands. The error this introduces is tiny and the computational and complexity costs an exact solution would bring outweighs the benefits (marginal).
For determining bet size, the betting module calculates the optimal blackjack bet based on the player’s estimated edge, bankroll, and table limits using Kelly Criterion and configurable betting ramps. It is able to determine when to bet high even better than human card counters as it is able to keep a perfect count (it knows how much of each rank of card is remaining in the deck rather than whether there are more high cards left, which is called Hi-Lo counting, a technique used by humans).
As you can see in the simulation (might have to open the image in a new tab to see all the data), it achieved about a 3.7% edge over the house (NOTE: the ruleset used does not benefit the house as much).
Next steps are wiring this up to the Beaglebone’s OLED display which I created the driver for previously and allowing for the Webcam to connect to the board to autodetect the cards played via OpenCV.
Current Project State
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.