Tuesday, October 1, 2013

I recently spent an hour or so at the local casino (Delaware Park) playing blackjack with my father-in-law. The table we chose had a side bet called “IN BETween”, which compares the player’s two cards to the dealer’s up card. If all three cards match, the player is paid a 30-1 return. If the dealer’s card is in between the two player cards (hence the name of the game), the player is paid based on a pay table. At Delaware Park, the current pay table is:

Result

Pay Ratio

Example Winning Hand

All Cards Match

30-1

7-7-7

One Card Spread

10-1

3-4-5

Two Card Spread

6-1

8-T-J

Three Card Spread

4-1

2-5-6

All Other Spreads

1-1

3-7-T

For comparison purposes, Aces are the highest possible card.

After watching this side bet for awhile, I began to wonder what the house odds were for this game. Sure, I can just look it up (h/t to the State of Washington - http://www.wsgc.wa.gov/docs/game_rules/in_between.pdf), but this seemed like a perfect excuse to spend a few minutes with Python. So I dusted off my old Poker python script and modified it to simulate this game. No one actually starts a Python script with an empty notepad file, right?

If you are interested in playing with this script, it takes two parameters. The first is the number of decks used. The number of decks is an important factor in this wager, as the majority of the value in the bet is due to the frequency of 30-1 payouts. Seeing three matching cards on a random draw from a single deck only happens .235% of the time (3/51 * 2/50), while the same result from eight decks happens .541% of the time, more than twice as often (31/415 * 30/414).

The second parameter is the number of iterations. Monte Carlo simulations benefit from many iterations. I’ve found that 1,000,000 iterations convergences on the mathematical results that the State of Washington has in their reference document.

Without further explanation, here is the script. If you notice any errors or anything I’ve done that is wildly inefficient please let me know; I always like improving my programming skills. If you want to improve this one suggestion would be to add the other pay tables listed in the State of Washington document. My local casino only seems to use the payouts I have listed, and since I rarely go to a casino (even the local one) these are the only payouts I was interested in.