##### technology

# Optimal Dealer Forking

The game “Fork the Dealer” (or Skewer the Dealer or perhaps some other verb for the uncouth) is a simple guessing game where a player attempts to defeat the dealer by guessing the top card of a deck of playing cards. The player is given two guesses, and is told if the first guess is too high or low. Suit doesn’t matter, aces are high, and after each round the card is exposed and removed from play, making the guessing easier as the game progresses.

The question is, what strategy should one follow to be the best possible Forker?

To define a strategy, we’ll make some assumptions. First, the deck is well-shuffled and the dealer’s playing fairly. This probably takes us well into the realm of the theoretical. Then a strategy for a given deck can be explained by three guesses– the initial guess followed by two more guesses, one higher and the other lower than the initial. For the rest of this post, I’ll denote this as (x,y,z).

If your sole interest is in guessing the card correctly and forking the dealer, your choice becomes trivial. In the end, if any of those 3 guesses is correct you’ll win, otherwise you lose. So regardless of the numbers, you should make all 3 guesses the ones that have the most unexposed cards. That is, if there have been no 2s, 3s, or 4s exposed, a guess of (3,2,4) is optimal. It might seem odd to open a guess on a fresh deck with a “3”, but it’s no better or worse than a guess of “7” or “8” for picking the correct card.

To keep this from being the end of the blog post, let’s add a second criteria. After your second guess, you’re penalized by how far your guess was from the actual value. So while (3,2,4) might have the same chance of being right as (8,4,Q), the latter has a worst-case of 3 (if the card is a 7 or 9) while the former could get you a penalty of 10 (if the card is an ace).

To optimize for this second criteria, we’d make sure the second guesses have the lowest minimum penalty between them. An illustration might help.

Here’s an arbitrary game where 25 cards are left, denoted across the top. Our potential guesses are down the left side. You can see with one guess, you can expect an average penalty of no better than 3.6 in this setup:

But if you take into account the partitioning you get with your first guess, you can do much better. For this deck, the ideal guesses are (9,4,K). If we split the deck between 4 and K and won’t get penalized for a 9 (as it wins immediately), our expected penalty is 1.2:

In this example, the lowest penalty strategy also had the highest chance to fork the dealer. What about cases when the two don’t align so well? With a deck containing

spreading out your last two guesses with something like 4 and Q makes sense. But any strategy that doesn’t include an A is not going to optimize your chances to fork the dealer. In cases like this you’d need to weigh how much you want the dealer to lose compared to the penalty you’re willing to take on. Optimizing for a lowered penalty here will save you on average 0.12 points, but you’ll only fork the dealer 31% of the time, down from 44%.

If you play perfectly, on average a forking-maximizing strategy will achieve a 42.5% fork rate and cost 1.23 penalty points where a penalty-minimizing strategy will fork 40% of the time, but only take on 1.08 points on average.

These optimal solutions aren’t very helpful when you’re sitting at a table looking at a deck of cards. Frankly, you’re probably only willing to devote 20 seconds to learning a strategy, so here’s a simple heuristic you can use to get reasonably good outcomes:

- For your first card, pick from 6-T the card that has the highest number still in the deck. In case of a tie, tend toward the middle (value 3 8s over 3 9s, but value 4 6s over either of them)
- If the card is higher or lower, pick from the remaining cards (2-5 or J-A) using the same plan, choosing the card closer to 8 if more than one rank has the same number of cards remaining.

With just these two rules, you’ll be forking 40% of the time, but only risking 1.26 penalty points.

This blog post came from a discussion at a non-Jana event with 27 Jana employees last weekend. Do you have 26 coworkers you’d voluntarily spend your weekend with? If not, we’re hiring!

## Discussion