Blackjack Simulation Engine
A C++ engine that plays thousands of hands to see which strategy actually wins.
A C++ simulation engine that plays 1,000+ blackjack hands per strategy — basic strategy, Hi-Lo card counting, and a deliberately reckless baseline — and tracks earnings and win rates to compare how each holds up. Containerized with Docker for reproducible runs.
bankroll from $1,000
$ ./simmer --hands 1000
- Hi-Lo count
- +$212
- Basic strategy
- −$41
- Reckless
- −$389
The motivation
Everyone “knows” card counting works and that basic strategy beats playing on instinct. I wanted to actually measure it — to replace folklore with numbers I generated myself, and see how big the gaps really are over a large number of hands.
How it works
The engine models decks, dealer rules, and player strategies as pluggable decision functions. A “player type” is just a strategy — Basic Strategy plays the textbook chart, the Card Counter tracks a running Hi-Lo count and adjusts, and the Reckless player is the control group. The engine deals thousands of hands per strategy and tracks bankroll and hands won over time.
Engineering decisions
Strategy-as-interface keeps the simulation honest: adding a new approach means writing one decision function, not touching the core loop. I wrote it in C++ for the raw throughput needed to run enough hands that the results mean something rather than reflecting noise, and wrapped it in Docker so a run is reproducible on any machine.
Outcome
The numbers back the folklore: disciplined basic strategy and Hi-Lo counting meaningfully out-earn instinct once you play enough hands. This is a probability and strategy engine, not a playable game — the next step is visualizing the earnings curves it produces rather than adding anything you could bet on.