Skip to content

Blackjack Notebook (bjnb): Probabilistic analysis and simulation

License

Notifications You must be signed in to change notification settings

hhoppe/blackjack

Repository files navigation

bjnb: Blackjack Notebook

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:

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 evaluate Results.
  • Adjust the EFFORT global variable to trade off speed and accuracy.

References:

(See also references in Tables for basic strategy, Hand calculators, and House edge calculators.)