# Simulating Blackjack

## Simulating Blackjack (Part I)

Let's say you go to Las Vegas to play blackjack. You find a $10 minimum table, and you play perfect blackjack for the next three hours, placing uniform minimum bets each hand. How much do you stand to win (or lose)?

First, let's be clear on the strategy. Blackjack is a relatively simple game. Face cards are worth ten points; an ace can be worth either one or 11 points. All other cards have a point value equal to the number on the card. The player's goal is to beat the dealer, who is initially dealt one card. They can do this by getting a final score higher than the dealer's without exceeding 21 ("busting"). After getting an initial two cards, the player has the option "hit" (take a card), "stand" (end their turn), "double" (double wager, take a single card and finish), or "split" (if the two cards have the same value, separate them to make two hands).

Given the casino-specific rules and any combination of player cards and dealer cards, there is a probablistically optimal move. In our case, we're playing 6 decks, dealer stands on soft 17, double any two cards, double after split, allow surrender, split up to 4 hands, no resplitting aces, blackjack pays 3:2. For this game, our best strategy is summarized by this chart:

Even if we play perfect strategy, the house edge for this set of rules is around 0.3%. The game is rigged, slightly, in their favor such that over millions of plays they can expect to make a good deal of money. That's how casinos profit.

But now let's return to the original question: playing perfect blackjack for the next three hours, how much do can we expect to win or lose? We've specified that we'll play $10 each hand and the house edge is 0.003. Dealers deal, on average around 65 hands of blackjack per hour, so we can expect to play 195 hands.

A simple model of the number of blackjack hands we would win should roughly resemble a binomial distribution, ~B(*n,p*), where *n* is the number of hands and *p* is our probability of winning. Expected value of a binomial distribution is simply equal to n*p. So if we play *n* hands, betting ß* *each hand, and the house edge is θ, our expected loss is equal to -*n*ßθ.

Expected Loss = **- nß**

**θ**= -(195)(10)(.003) =

**-$5.85.**

Not too shabby. Over our three hours, we should only expect to lose around $6. But we won't lose that amount every time we play 195 hands. There's an element of chance to the game, meaning that the variance is strictly positive. According to Stanford Wong's *Professional Blackjack*, the true variance of *n* hands of blackjack is: 1.32**n* + .48**n**(*n*-1). The standard error of our specific 195 hands would then be:

S.E. = **sqrt(1.32* n + .48*n*(n-1)) ÷ sqrt(n) ** = sqrt(18415.8)/sqrt(195) = 9.718

But since we're betting $10 for each hand, we need to multiply our S.E. by that ß, meaning that our total standard error for our purposes is **97.18.**

The standard deviation of the normal approximation of our binomial estimate is smaller: ßnp(1-p) = 69.65. The difference between these two estimates is summarized in the following graph:

Around 47.6% of the time, you can come out ahead after 195 hands. That doesn't sound too bad. The more you play, however, the less likely you are to make money:

And your expected losses keep getting bigger:

############################################## n <- c(100,200,400,800,1600,3200,6400,12800,25600,51200,102400, 204800) b <- 10 storage <- matrix(data = rep(0,12*4),nrow = 12, ncol = 4) # Calculate expected loss for (i in 1:length(n)) { expected_loss <- -1*n[i]*b*.003 sdestimate1 <- (sqrt(1.32*n[i] + .48*n[i]*(n[i]-1))/sqrt(n[i]))*b pno <- pnorm(q = 0, mean = expected_loss, sd = sdestimate1, lower.tail = F) storage[i,1] <- n[i] storage[i,2] <- round(expected_loss,1) storage[i,3] <- round(sdestimate1,1) storage[i,4] <- round(pno,1) } storage <- as.data.frame(storage) colnames(storage) <- c("Hands", "EV", "SD", "Prob_Profit")

Hands EV SD Prob_Profit 1 100 -3 69.9 0.5 2 200 -6 98.4 0.5 3 400 -12 138.9 0.5 4 800 -24 196.2 0.5 5 1600 -48 277.3 0.4 6 3200 -96 392.0 0.4 7 6400 -192 554.3 0.4 8 12800 -384 783.9 0.3 9 25600 -768 1108.6 0.2 10 51200 -1536 1567.7 0.2 11 102400 -3072 2217.0 0.1 12 204800 -6144 3135.4 0.0

Notice that as the number of hands you play increases, your profitability tends to 0. So whereas you might be able to get lucky playing blackjack for a day or even a weekend, it's very unlikely that you would make money or just stay even playing basic strategy blackjack as your day job.