12/06/2026
Project:

Blackjack AI

Blackjack AI monitors a blackjack table live, independently recognizes which cards are dealt, and provides advice for each hand based on the mathematically exact probabilities, not according to a fixed strategy table.

Development

Blackjack AI

Two years after the first prototype, I have completely rebuilt Blackjack AI. The old version recognized cards and looked them up in a CSV file; the new version is a full-fledged detection engine with a strict separation between a worker thread that processes screenshots and the Tk-GUI, which only reads snapshots and never performs calculations itself. Card recognition is handled via YOLO: local ONNX or ultralytics weights when present, otherwise via two hosted Roboflow models (trained separately for players and dealer). TensorFlow and Keras from the old version have been removed; everything now runs on OpenCV, NumPy, and Roboflow. Heavy calculations, such as the full pre-deal EV sweep across 55 starting hands and 10 dealer-up cards, take about 15 seconds of CPU time and therefore run in separate subprocesses instead of threads, so that the interface never freezes while calculations are in progress.

Perception

Card recognition

The system no longer looks only at individual cards, but at the entire round. The dealer’s up-card is only locked after two consecutive frames with the same recognition, after which the dealer’s playout is tracked until the hand is over, even when cards fall outside a strictly defined area. In addition to card recognition, the app also reads the balance, the current bet, and the win/loss banner from the table itself via the built-in Windows OCR, so that bankroll tracking does not need to be tracked separately. A thumbnail diff of each frame ensures that inference only runs when something actually changes on the table.

Math

Exact EV engine

The core of the project is a custom-built, composition-dependent EV solver: not a static base strategy table, but a recursive calculation that weighs all unplayed cards in the shoe for each hand. In addition, a Hi-Lo count and Illustrious 18/Fab 4 indices track when it is wise to deviate from the base strategy. The outcome is used for betting advice via the Kelly criterion, a risk-of-ruin calculation, and exact EVs for the six supported side bets (Perfect Pairs, 21+3, Hot 3, Bust It, Lucky Lucky, and Lucky Ladies). Everything is validated against Wizard of Odds reference values.

Disclaimer: This project is still under development and is intended for educational purposes.

Questions? Contact me or return to the overview