There are sites where you can play "casual" games against other people for money. One of the more interesting games, in my opinion, is inspired by blackjack.

On Worldwinner / GSN Cash Games it's called Catch 21 and on Royal Games it's GoGo 21. The gist is you get a standard deck of cards, and given a maximum of four concurrent "hands", you try to make as many 21's as possible. You can't go over, you can throw away cards, you get points for speed but get the most for accuracy.

Months ago, working on my Scrabble Boggle bot, I'd take breaks and play this game, trying to deduce optimal strategy. It's easy to play - what's the best way to play?

I recently ran simulations to figure it out.

## TL;DR

"WHAT'S THE OPTIMAL STATEGY??"

For humans, the best way to play is trying to make 21 (duh-huh) or trying to make 11 if that's not possible. Otherwise put the cards wherever they can go. It actually helps to always consider the decks from left to right, instead of some random frantic order.

For computers, optimize the human strategy. You have the processing power and memory to constantly track which cards are most abundant in the deck. There are times when, if you can't make 21, you won't necessarily be trying to make 11. Example - there are two 7's left in the deck and 1 ten. It would be preferable to set up a 14 instead of an 11.

## How to play

Still don't understand how to play? I think it's easiest to show. Here's a YouTube video someone playing GoGo 21.

## Analysis, up to optimal human strategy

To initially analyze the game, I wrote a rough Python script to simulate it.

Then I just added parts and checks as I went along.

The first strategy I tried out is the simplest. Look at the first hand - as long as it's possible to add cards, do that. If you can't, look at the second hand. And so on, until you can't put a card anywhere, at which point you start to discard.

The metrics I've judged these strategies on are blackjacks per match and discards per match. Obviously - and these have a negative correlation - we want to maximize blackjacks and minimize throwaways.

All figures from here in are from 100,000 sim rounds.

- 567,600 blackjacks = 5.676 / game
- 1,889,862 throwaways = 18.89862 / game

Next, I was curious about a small tweak. Instead of methodically analyzing the open decks, left to right, what if we randomized that part?

Things actually turned out worse.

- 563,862 blackjacks = 5.63862 / game
- 1,911,062 discards = 19.11062 / game

At this point, I decided to use some more realistic strategy. I added a check to look at all the hands to see if we could make 21 and then put the card there if so.

- 902,747 blackjacks = 9.02747 / game
- 1,138,283 discards = 11.38283 / game

Now we're getting somewhere. I added another check after the one for 21, this time to check for 11. Since the most common card value is 10, the next best thing to 21 is usually 11.

- 959,662 blackjacks = 9.59662 / game
- 1,056,945 discards = 10.56945 / game

So that's the best strategy for humans, I'm quite certain.

## Deducing optimal strategy for computers

Computers are better built to play this game. For my next strategy, after the 21 check, I'd calculate the most common card value* left in the deck then subtract it from 21. Whatever the result was, that's what we'd be shooting for.

** Note I always counted aces as being worth 11, because I was extra lazy in this prototype script.*

Most of the time, yes, most common card is 10 so we still shoot for 11. But once in a blue moon it's not.

- 961,034 blackjacks = 9.61034 / game
- 1,056,246 discards = 10.56246 / game

At this point I decided to write out a more elaborate simulator than my initial hackjob. My ultimate goal was to expand on the check I described above, now considering the abundance of all cards left in the deck.

The better simulator is here on Github. Here are results from running what I deem optimal computer strategy.

- 973,889 blackjacks = 9.73889 / game
- 1,054,623 discards = 10.54623 / game

Just a little better, but so small it could've been lost in Monte Carlo run stats fuzz.

Ultimately the crack to a blackjack-inspired game is really just card counting. Big surprise, right?

## Closing

One way to figure out a game's optimal strategy is by coding its basics, then testing strategies over thousands of runs.

That's what I did here. The initial script took maybe 5 minutes to write.

Obviously, all games aren't this simple. I don't think it's as easy to model Texas Hold'em.

Stay tuned for a possible followup post, with a bot. The trickiest part of that would be the image recognition. We'll see. 🙂