Can You Actually Beat the Dealer in Blackjack?  Simulation of Most Popular Strategies
Source: tai_blog

In this article I explore if it is actually possible to beat the blackjack dealer using strategic thought. Of course  the underlying idea here is to show the use of simulation and how a game can be modeled mathematically. (But please do feel to try out any of below mentioned strategies if interested!)   The framework discussed below implements a blackjack game simulation and compares the performance of a few selected counting strategies.   Knowledgeable Blackjack players are able to beat the casinos using a technique called card counting. Card counting is technically legal  however a casino reserves the right to deny entry to any individual they suspect of using this skill to their advantage.   A statistical analysis is done on these strategies simulating multiple independent blackjack games. Blackjack  as most games in Casino  is heavily dependent on luck. Without counting cards or using any strategy  it is almost always the dealer that gets an advantage.   While  per the rules and design of the game  chances of winning are less than 50%  just following the well-known Basic Strategy for counting cards can decrease the advantage of the house and increase the probability of winning to ~50%. There are various Blackjack strategies developed and taught all over the world  this analysis builds a system to compare these strategies and determine which is the most profitable approach. Multiple independent blackjack games are thus simulated to understand the profit and loss in various scenarios. On comparison  Hi-Opt I and Hi-Opt II have been identified to maximise win expectation.   Rules of the Game: Blackjack allows for multiple players. Each players plays the Casino dealer  and each game is independent. Each game may contain multiple rolls. In a roll  using the cards  both the player and the dealer try to generate highest number possible without crossing the sum of 21. Crossing this threshold indicates going bust  meaning you have lost. As the player goes first  there is always a slight advantage to the dealer. Please find below  a summarized view of common scenarios during the game.   The players cards are dealt face up. One of the dealers cards is dealt face down while the other is dealt face up.Each card from 2 to 10 has a value corresponding to its number.The face cards are worth 10An ace is worth either 1 or 11  depending on what is advantageous during the game.A player can either decide to Hit that is request for another card or Stand that is keep current cards during a game.A player can also Double the amount of bet made during the game and receives just one additional card.If the player is dealt a pair of same cards  they can Split their hand. That is  they can play two separate games using their cards.While exploring these strategies  this analysis explores two major areas    Identifying point of convergence for expected wins in independent blackjack games (After how many simulations can winning probability be determined)Explore and compare different card counting strategiesIn the upcoming sections  scope and assumptions are defined  followed by brief explanation of the development architecture  describing the logic used to simulate the game of blackjack with different strategies. Key findings are then described that set forth the results of the analysis on Black Jack simulation strategies.   Key Assumptions:I focus on just one player and the dealer. To reduce complexity  options like splitting  doubling down  surrendering and insurance are not considered. A six-deck card system has been considered for this simulation. A player is awarded 1 point on each win  however in case of Blackjack the reward is 3/2 points.   Ten counting strategies are considered for this analysis. Please find below the values associated with each card for different strategies. In case of No Strategy  no counting strategy is followed  apart from basic Blackjack Strategy.   Development and Architecture:Implementation is primarily done in Python using Jupyter Notebook (Fig. 1). Card values for each card of the deck is taken as input for each strategy using a CSV file. The Blackjack simulation script inputs this information along with number of simulations to be run. Multiple blackjack games are then simulated and expected winning is logged.   Script Overview:   Counting strategies CSV and number of simulations to be run are input by the user.Cards are dealt to the player and the dealer.Running count and True count (based on values defined in strategies.csv) are maintained based on open card count throughout the game.In case no blackjack is achieved by either player or dealer both have an option to Stay or Hit.Player choice is determined by threshold on true count of currently open cards.A game ends if < 12 cards are left in the deck or < 1 card is left in the last roll.Winnings/Losses are determined at end of each roll and count is logged.2000 blackjack games are played using each strategy.Full code is available here: https://github.com/eramkhan94/blackjack_simulator   Key FindingsIdentifying point of convergence: Blackjack games were simulated 10 000 times with No Strategy. Expected winnings were logged and plotted (Fig. 2). The simulation reached convergence with a predefined delta of 0.01  between the average expected win of previous 200 iterations (i.e. 12001400) and next 200 iterations (i.e. 14001600)  reaching ~1600 games. Additional 400 iterations were added as a buffer to account for variance in convergence of different strategies. Thus  for further analysis and comparison  each strategy was simulated 2000 times and expected winnings were observed (Fig. 2).2. Strategy Analysis and Comparison: To further compare strategies  2000 games were simulated for each counting strategy 30 times and results were logged. The expected winnings for each strategy were compared against No Strategy using a one way ANOVA test. For six strategies out of ten  a p-value of less than 0.05 was observed indicating that the mean of expected winnings was significantly different than the expected winnings mean when No Strategy was followed (Fig. 4).   On further analysing the distribution of expected wins (Fig. 5)  it is found that Hi-Opt I has the highest expected wins at 50.43  followed by Hi-Opt II (50.31)  Halves (50.31)  Wizard Ace (50.30)  Red 7 (50.297) and Zen (50.291). Other strategies did not yield significantly different results than No Strategy. However all strategies resulted in higher expected wins compared to No Strategy. Highest variance in result was observed for Hi-Opt I  Halves and Omega II.   Conclusion:Counting strategies do offer an edge compared to an intuitive game in Blackjack. Hi-Opt I has resulted in maximum expected gain. In further analysis assumptions on player moves can be relaxed. The optimisation for player moves like splitting  doubling down will further generalise this framework and aid in developing and testing new blackjack strategies. Relaxing these assumptions may also result in an increased difference in wins when using a counting strategy and some counting strategies might yield higher expected wins.