How to win at Blackjack (51% of the time)!

How to win at Blackjack (51% of the time)!

In this article I will describe what I learned in my latest side-project related to Blackjack and card counting. We first introduce the casino industry followed by an overview of the game. We also give a brief explanation of what Monte Carlo simulation is and how it can be applied in practice.

In the "Optimal Strategy" section, we give some examples of optimal decisions that need to be taken depending on the player hand. These were generated from the Monte Carlo simulations described in the prior step.

Finally one can optionally skip to the more interesting part, where we compare different strategies applied to Blackjack, and introduce how basic card counting works, even illustrating how a player can win in the long run.

INTRODUCTION

Like any business, a casino strives to make money. The way it does this is by offering a variety of games to players, promising the chance of a win on top of a placed wager. In the long run, however, all games are designed to favour the house, and a profit is statistically guaranteed. This "statistical favour" is known as the "house edge", and is the return that the casino expects to make off of every €1 played. For example, if the house edge is 5%, the casino is expected to win a profit of €0.05 out of every €1 wagered by the customer in the long run.


Each game that is offered has a separate house edge, whether it is Poker, Roulette, Slot Machines etc. Perhaps the most notorious of all are slot machines, frequently dubbed as being "rigged" against the player. While this may be true in a way, it is no different than any other game being offered by the casino, only differing in the fact that the Return to Player (RTP = 100% - HE) is usually around 80% to 95%. This is an extremely low value against the player, and is based purely on chance, with no clear way to exploit. Poker, on the other hand, is significantly more skill-based than most other games, where you must have a solid grasp of probability, bankroll management and emotional awareness to be able to succeed and consistently make money. The casino takes in a commission (a.k.a rake) from each player who takes part in a game.


Somewhere in between these two lies Blackjack (BJ), being one of the cheapest games for the players offered by the casino, assuming the player plays optimally. The typical house edge of a game of BJ (depending on the particular rules) are less than 1%. However, unlike almost any other game, there is a way for the player to gain a consistent advantage against the house, without cheating!

GAME RULES

The aim of BJ is to obtain a hand having a score as close to 21 as possible, without exceeding this amount. Each card has a value equaling its numeral value (if its value is numerical), whereas a face card (Jack, Queen or King) all have a value of 10. The Ace can have a value of either 1 or 11, whichever is best for the player. The player plays against the dealer, and the decisions of other players do not affect the outcome (unless you believe in superstition!).


A “shoe” contains multiple decks, which will be used to deal cards to the players and the dealer. The player wagers an amount at the beginning of the round, and following this, the player is dealt 2 face-up cards. The dealer, on the other hand, is dealt only one face-up card and another face-down card.


If the first two player cards totals a 21 (AT, AJ, AQ or AK) then that is a Blackjack! If the dealer does not have a Blackjack, then the player wins 1.5 times the wager. If the dealer also has a Blackjack, then the amount wagered will be returned to the player, which is essentially a draw.


If the first two cards have a value less than 21, the player has some options:

  • HIT: Ask for a card to be dealt to get a value closer to 21 and possibly exceeding this value (bust) and losing the wager.
  • STAND: Stop being dealt cards, and wait for the dealer’s turn.
  • DOUBLE: Double the wager on your hand and HIT exactly one more time.
  • SPLIT: Only applicable if your first two cards are of equal value. In this case, the two cards are split into two separate hands with an additional and equal wager on the new hand. Each is dealt an additional card, giving you two hands of two cards each, which can then be independently played of each other.

Once the player stands (or stays) with a hand totaling a value less than or equal to 21, the dealer must HIT until a value of 17 or more is reached, at which point they must STAND. If the dealer busts, then the player wins double their wager. If the dealer has a value of 21 or less, this value is compared to the player’s hand, and whoever has a higher value wins the wager. If the values are equal, then it is a draw and the wager is returned.


Below are some additional rules that affect the house edge that we have considered in our simulations.

  • The dealer must HIT on a soft 17 (i.e. a hand with an Ace counted as 11).
  • SURRENDER is not allowed.
  • DOUBLE after a SPLIT is allowed.
  • You can HIT a SPLIT Ace pair.
  • Re-splitting is allowed indefinitely.
  • 6 decks are used.
  • Only the original bet is lost on a dealer Blackjack.

MONTE CARLO SIMULATION

Obtaining an exact probabilistic value on each of the possible hands is infeasible to work out by hand. There are simply too many factors to take into account to obtain an exact value the casino expects to make based on the player’s and dealer’s hands. A numerical approach must be taken, and we opt for Monte Carlo (MC) simulation.


MC simulation is the process of generating random samples from a selected distribution or set of outcomes which can then be used to take statistics from. A common application of MC simulation is to obtain the fair pricing of options contracts. In short, most models revolve around the Stochastic Differential Equation known as the Black-Scholes Model. An exact solution is often infeasible for such equations, and thus many practitioners such as banks and hedge funds, opt for numerical MC simulations in order to approximate the fair price of a contract.


In our case, we will provide the starting player and dealer hands, and run millions of games for each possible decision that can be taken by the player. The average profit from all the games per decision-hand combination is used to decide what the optimal decision a player should take is.

OPTIMAL STRATEGY

Our rule set mimics the ones considered in this source, and so we aim to replicate this set of optimal decisions. The only difference we note, is that surrendering is not allowed in our case. The full set of optimal decisions can be found in the README file of my GitHub repository. I will give some notable cases.

Values less than 12

There is no risk of going over 21 if you take a card, and so it does not make sense to STAND in this case. The question is whether to HIT or DOUBLE your wager. In the particular case when you have a hard value of 11 on your first two hands, there is a significant chance that the player receives a 10 card giving you an unbeatable total of 21. (Note that 4 out of the 13 possible ranks have a 10 value.) There is no way to bust in this scenario, and receiving an Ace will simply count as 1, giving you a total of 12. In this specific case it is always beneficial to DOUBLE your amount, as you have a better chance of winning than the dealer.

Values greater than 17

It is simply too risky for the player to HIT at this stage, as there is a large chance that the player will bust, and the dealer will automatically win.

Pair Aces

This hand is very strongly in favour of the player due to the versatility of the Ace. In this case, it is always beneficial for the player to SPLIT their hand into two separate hands.


Simulations

Basic Strategy

Performing 10,000 game simulations, each of 1,000 rounds using the optimal strategy we generated in the previous step, we can average out the player profit to obtain the house edge given our rule set.

10,000 player simulations of Blackjack using basic strategy, each with 1,000 rounds.

Figure 1 displays all the simulated paths, assuming an initial bank roll of €10,000, and a constant stake of €10 at every round. The house edge averages out to around 0.3%. The red line takes the average player profit at that number of games played. Although barely noticeable, there is a general downward trend, which results in profit for the casino. Over thousands of games by hundreds of players, some of which not necessarily playing optimally, this will result in a significant profit for the casino.

Martingale Strategy

It is worth noting a popular strategy that will guarantee a profit for the player in the long run (in theory at least!). This is the so called Martingale strategy which involves wagering an amount €X, and if the wager is lost, the next wager is doubled to €2X. If this wager is also lost, the next wager will again be doubled to €4X, so on and so on. Once the player wins, they will recoup all their losses and gain an extra profit over and above their previous losses.


This strategy is a perfectly valid strategy, as a win is guaranteed with enough games played. In practice however, this fails for two main reasons

  • The assumption is that the player has enough money to finance their strategy, since wagers grow exponentially. This strategy essentially assumes that the player has infinite money.
  • There are no maximum wagers on games. This is usually not the case in casinos, and most BJ tables enforce a maximum stake, rendering such a strategy useless.

Example player bankroll using the Martingale strategy.

Figure 2 gives a simulated example customer journey using the Martingale strategy. Losses are always recouped with a little extra profit, resulting in an overall upward trend. However, this ends abruptly since eventually there will be enough losses which the customer will not be able to finance since their bankroll is finite.


The player bankroll is initially at €100,000, certainly more than most people are willing to risk, and the initial bet is at only €10. After around 3,000 rounds, the player loses almost all of their money with a string of losses, each doubling the wagered amount. After 8 consecutive losses the wagered amount already climbs up to €2,560 per bet. The player somehow continues their pursuit to infinite money, with small but consistent gains. However, there will eventually come a day where enough losses would result in a catastrophic loss, and all the gains along with the initial amount will be lost.

Card Counting

Card counting is less complicated than most people think. It does not involve perfect memorization of all the previous hands that have come up, and certainly does not entail knowing exact probabilities of all outcomes of any combination of hands. This misconception was popularized by movies such as Rain Man and 21.


Most card-counting strategies assign multiple cards a value of 0, +1 or -1. The card counter must only keep a running total of these three values, and there is no need to remember information about the specific cards that showed up. The simplest, and most popular card-counting strategy is the Hi-Lo strategy, which assigns a value of

  • +1 to cards 2, 3, 4, 5, 6
  • 0 to cards 7, 8, 9
  • -1 to cards 10, J, Q, K, A.

Having a large positive count means that more small-value cards showed up than large value ones. In turn it means that there is a significant change that dealer hits on a large-value card and busts, leaving the player with an overall positive edge. On the other hand, if the count is negative, it means that it is not advantageous for the player to wager a large amount since the dealer has a good chance of being dealt small-value hands, and hence comfortably ending up in the range 17 to 21.


The number of decks in the shoe also influences the decision the player takes, since a larger number of decks introduces what is called variance. A +2 count on a 2-deck game is much more significant than in a 6-deck game, since the chances of a high-value count is still small due to the large pool of available cards in the shoe. Instead of the raw count, card counters use the "True Count", which is simply the count divided by the number of decks being played.


In our simple implementation of this strategy, we will store the true count of the game at every iteration, and only when the true count is 2 or more, we will place a large-value bet, linearly increasing with the true count. In other words

  • for true counts of <= 1, we only stake €1, simply staying in the game and observing the count
  • when the count is 2 we play a relatively large amount, such as €100
  • when the count is 3 we play €200
  • when the count is >= 4 we play €300.

There are more complex variations of this strategy, where the basic strategy is dynamic depending on the true count.

10,000 player simulations each with 1,000 games using the Hi-Lo card-counting technique.

We simulate 10,000 games, each starting with a bankroll of €10,000 using the Hi-Lo strategy. Even with this relatively simple process, this results in a house edge of -0.84%, giving the player an advantage. Figure 3 shown above is a visualization of these simulations, with the average red line on a slight upward trend.

CONCLUSION

Blackjack is one of the few casino games where applying an optimal strategy and keeping track of cards that previously showed up will give you a mathematical edge over the house. However, the advantage is small, typically less than 1%, and the variance is high. In the short term, a player might lose, and only in the long run might a player actually make a profit. Unlike the movies, the player will still roughly lose around 50% of the time.


This is not even considering the fact that casinos nowadays are very aware of card counters and how to identify them. They will certainly not be fond of a player if it is suspected that they are counting cards, and such players are frequently banned from playing Blackjack, and in some cases even from the casino.


All code and further detailed explanations can be found on my GitHub repository.


So, what is the most optimized strategy for blackjack right now? Is it one of the strategies you mentioned, or is it a strategy based on reinforcement learning? If so, which RL algorithm?

回复

要查看或添加评论,请登录

Dylan Zammit的更多文章

  • Squid Game: Your Odds of Survival

    Squid Game: Your Odds of Survival

    Following Netflix's 2021 Squid Game debut, we now have the second installment of the show hitting the screens…

    1 条评论
  • Pigeon Racing and AI

    Pigeon Racing and AI

    Introduction Pigeon racing is an unconventional sport, loved by relatively few, and misunderstood by many. I recently…

    3 条评论
  • Malta Traffic Optimisation

    Malta Traffic Optimisation

    Introduction Commuting to and from work on a daily basis is a frustrating experience to say the least. It is especially…

    5 条评论
  • Ranking EPL Football Teams

    Ranking EPL Football Teams

    Introduction Predicting the probability of an outcome in a football match is of great interest to bookies and punters…

    1 条评论
  • Estimating the odds of teams that never encountered each other.

    Estimating the odds of teams that never encountered each other.

    Introduction In sporting events, the chances that there exists at least one pair of teams that never played each other…

  • Volatility Estimation

    Volatility Estimation

    What is Volatility? In simple terms: volatility is the degree of fluctuations in a time series, most commonly financial…

    1 条评论

社区洞察

其他会员也浏览了