Python Blackjack Simulator: Martingale with Classic Strategy

Light Chu
4 min readAug 30, 2021
The online Blackjack from Bxt365

Blackjack

Blackjack, appearing in countless movie scenes, has been one of the most popular games in casinos. One of the fascinating features in the game is that, to some extent, it seems like it’s not only based on pure luck comparing to Baccarat or Roulette. It creates a delusion as if you were a math genius like those protagonists in the movies that can outwit the dealers. Nevertheless, when you placed your bet on the table, you have already fallen into the trap.

I’m not planning to talk about the rules, which you can see here if you are unfamiliar with this game. Instead, I’m going to demonstrate the result of a strategy that every rookie can ever come up with.

Classic Strategy

In fact, you can request a cheat sheet from dealers in casinos like the following table, which is the classic baseline blackjack strategy. For example, if you get a 14 combined(8-6, or 10-4, or 4-4-6, or whatever) facing a 4 in the dealer’s hand. You should stand. If facing an 8, then you should hit. Always split a pair of 8, Double(if not allowed, then hit) on A-5 v.s. 4. This is how this table works.
S = Stand, H = Hit, P = Split
DH/DS = Double if you can, otherwise Hit/Stand

The optimal strategy for Blackjack from Greg Sommerville

This table, representing the optimal ways, stands on probability, expected value, and the so-called Monte Carlo method. If you play blackjack using this classic baseline blackjack strategy, you can get up to 99.5% RTP(Return to player), which is the highest one you can ever find in casinos.

Martingale Method

Martingale, to put it short, is a strategy that doubles the wager next round while losing. To be more specific, if you bet $1 and lose, you need to bet $2 on the next round. If you lose again, then bet $4 next round. Therefore, the wager will become a series of powers of 2, like $1, $2, $4, $8, $16…, etc. The pro of this strategy is that, since the payout is 2 to 1, it can make up all your losses once you win. For example, you would lose $31(1+2+4+8+16) in a 5-straight loss, and then you need to bet $32 on the next round. If you win, you can take back $64, covering up the previous 5-straight losses. However, the con is that the sum of successive powers of 2 grows at a stunning speed. Imagine if you lose in 10-straight, you will need to place 1,024 times your initial wager next round to make up all your losses.

People having faith in the Martingale believe that they will not meet a tragedy such as 10-straight losses or even more. Hence, they go to casinos and anticipate earning some little pocket money every single day.

Simulator

To try this Martingale method combined with the classic blackjack strategy, You don’t really need to go to casinos and put the real money on the table. Here I have a blackjack simulator on my Github. It can show the whole process and the result. In some live casinos, the bet range could be a thousand times. The max bet is $1,000, and the min bet is $1. Let’s prepare $2,050(approx. 2¹¹), start from $1, double while losing, and see what’s going on.

The most common scenario could be like the following picture. As you can see, the balance went up steadily in the beginning. Then we might face some straight losses during the process, but it’s not a big deal because we could always win the money back by using the Martingale method. Everything was under control. Okay, now we reach 3K after 700 rounds. Let’s make another grand and go home, genius! However, we faced 12-straight losses, and everything collapsed in the blink of an eye. Since the max bet was $1,000, we could not place $2,000 or more to try to cover all the losses. The game is over!

The result from the Blackjack simulator

In fact, a 10-plus straight loss could happen anywhere. And if you run the simulator several times, you could find it happens more frequently than you imagine.

Conclusion

People are prone to get greedy once they taste blood but end up gambling away all their earnings. That’s human nature and the fundamental reason why casinos can survive for well over centuries.

Martingale is a way that only accelerates your losses and shortens your vacation in casinos. Here is the final reminder that casinos are places where only provide you entertainment and thrills. Never think about beating the house. Never.

--

--

Light Chu

Current Slot Machine Mathematician in the mobile casinos, Backend Developer, Data scientist, Sports Fan, Breaking Dancer, Whisky Lover, and Gambler from Taiwan.