Exact blackjack solver using backward induction. Computes mathematically optimal play by solving the full decision tree via dynamic programming — no heuristics, no approximations beyond two standard, documented ones.
- Exact backward induction — every possible future card sequence and its optimal continuation is evaluated
- Per-hand solver — optimal action + EV for any hand vs any dealer upcard
- Overall house edge — probability-weighted enumeration of all possible initial deals
- Strategy chart generator — color-coded basic strategy with diff highlighting when cards are removed
- Web dashboard — interactive UI with hand analysis, dealer outcomes, shoe composition, and strategy charts
- Web Worker — all computation runs in a background thread, UI stays responsive
| Rule | Options |
|---|---|
| Deck count | 1–8 |
| Dealer soft 17 | Hit (H17) or Stand (S17) |
| Dealer peek | On (American) or Off (European/ENHC) |
| Double after split | Yes / No |
| BJ payout | 3:2 (default), 6:5, or custom |
| Dead cards | Arbitrary card removal from shoe |
Verified against the Wizard of Odds house edge calculator (no resplit baseline):
| Configuration | Published | Solver | Difference |
|---|---|---|---|
| 8-deck H17 peek DAS | -0.6993% | -0.7018% | 0.0025% |
| 6-deck H17 peek DAS | -0.6690% | -0.6723% | 0.0033% |
| 2-deck H17 peek DAS | -0.4244% | -0.4343% | 0.0099% |
| 1-deck S17 peek DAS | +0.1531% | +0.1362% | 0.0169% |
All basic strategy decisions match published tables — every hard total, soft total, pair, and boundary case verified.
Two standard approximations are used, consistent with professional-grade solvers:
-
Precomputed dealer outcomes — Dealer outcome probabilities are computed once from the initial shoe (after removing visible cards), not recomputed as the player draws. Error: ~0.003% for 8 decks, ~0.017% for 1 deck.
-
Split hand independence — Both split hands are solved against the same shoe. Cards drawn to one hand don't affect the other hand's shoe composition. Negligible error for 6+ decks.
| Feature | House Edge Impact | Notes |
|---|---|---|
| Late surrender | ~0.08% | Changes optimal play for 15 vs 10, 16 vs 9/10/A |
| Resplit (up to 4 hands) | ~0.05% | Would require recursive split solver |
| Double restrictions (9-11, 10-11) | ~0.09–0.18% | Some casinos restrict which totals can double |
| OBO for no-peek | ~0.11% | "Original Bet Only" variant where only base bet is lost to dealer BJ |
blackjack-solver.js Core solver (backward induction)
solver-worker.js Web Worker wrapper (routes EV + chart requests)
blackjack-calculator.html Dashboard UI (hand input, results, strategy chart)
strategy-chart.html Strategy chart renderer (loaded in iframe)
server.js Dev server (port 8000)
Dashboard → postMessage → iframe (strategy-chart.html)
→ Web Worker (solver-worker.js)
→ generateStrategyChart() / solveOverallEV()
→ solve() × N hands (backward induction per hand)
→ returns results
→ iframe renders tables → notifies parent
node server.js
# Open http://localhost:8000/blackjack-calculator.htmlOr run the solver directly:
node blackjack-solver.jsblackjack-odds.js— Original heuristic-based odds calculator (superseded byblackjack-solver.js)blackjack-simulator.js— Monte Carlo simulation engine using the old odds module