Hugues Hoppe — [Open in Colab] [Open in Kaggle] [Open in MyBinder] [GitHub source]
Blackjack — "the most widely played casino banking game in the world".
Goals:
-
Solution methods for both:
-
Probabilistic analysis of blackjack actions and outcomes under many strategies, and
-
Monte Carlo simulation for cut-card effects and precise split-hand rewards.
-
-
Support for many rule variations (12 parameters including #decks, dealer hit soft17, cut-card, ...)
-
Optimal action tables for basic strategy under any rules, reproducing Wikipedia and WizardOfOdds results.
-
Six separate composition-dependent strategies based on different levels of attention.
-
Computation of house edge under any rules, with either basic or composition-dependent strategies.
-
Comparisons with online hand calculator and house edge calculator results.
-
Novel analysis and visualization of the cut-card effect and its surprising oscillations.
-
Open-source Python, sped up with jitting (~30x) and multiprocessing (~10x), simulating ~$10^{8}$ hands/s.
Versions:
- 1.0 (March 2022): use probabilistic analysis for basic strategy tables and approximate house edge.
- 2.0 (July 2022): add Monte Carlo simulation, hand analysis, and cut-card analysis.
Running this Jupyter notebook:
- The notebook requires Python 3.10 or later.
- We recommend starting a Jupyter server on a local machine with a fast multi-core CPU.
(The notebook can also be executed on a Colab server, but it runs ~20x slower due to the older, shared processor.) - Within a Linux environment (e.g., Windows Subsystem for Linux):
sudo apt install python3-pip
python3 -m pip install --upgrade pip
pip install jupyterlab jupytext matplotlib numba tqdm
jupyter lab --no-browser
- Open the URL (output by
jupyter lab
) using a web browser (e.g., Google Chrome on Windows). - Load the notebook (
*.ipynb
file). - Evaluate all cells in
Code library
and then selectively evaluateResults
. - Adjust the
EFFORT
global variable to trade off speed and accuracy.
References:
- https://en.wikipedia.org/wiki/Blackjack
- https://wizardofodds.com/games/blackjack/basics/#rules
- https://www.casinoguardian.co.uk/blackjack/ -- rich; explore more?
- https://wizardofvegas.com/guides/blackjack-survey/
- https://www.blackjackinfo.com/ -- created by Ken Smith; explore?
- https://www.onlinegambling.com/blackjack/odds/
- https://www.onlineunitedstatescasinos.com/las-vegas/blackjack/
- https://en.wikipedia.org/wiki/Gambling_mathematics
- https://www.gamingtheodds.com/blackjack/house-edge/ -- looks like truncated results of WizardOfOdds assuming no late surrender.
- https://github.com/johntelforduk/blackjack -- Python simulator to evaluate house edge for various strategies.
- First reddit post
(See also references in Tables for basic strategy, Hand calculators, and House edge calculators.)