MATH6028: Poker Hack and Spin the Wheel

A Poker Hack

Texas Hold’Em Poker

‘Texas‘ is a poker game where a number of players sit around a table. Two cards are dealt to each player. There after follows a round of betting, the reveal of three more cards (the flop), more betting, another card (the turn), another round of betting, another card (the river), and another round of betting:

What we are interested in is what happens after all this, before another hand is dealt?

The deck is shuffled.

A shuffle is required to mix up the deck. Here we used three terms: deck, shuffle, mixed up. These can all be given a precise mathematical realisation (see the introduction here for more). Mixed up means ‘close to random’. Here let me introduce a mathematical realisation of random:

If one is handed a deck of cards, face down, and if each possible order ofthe cards is equally possible then the deck is considered random.

Note there are possible orders that a deck can be in so when a deck is random the probability that a deck is in a specific order is

.

One popular method of shuffling cards is the riffle shuffle. In a remarkable 1992 paper by Bayer & Diaconis, with a really cool name: Trailing the Dovetail Shuffle to Its Lair, it is shown that seven riffle shuffles are necessary and sufficient to get a deck close to random:

Here we see , distance to random, plotted against , number of shuffles. After five shuffles the deck is still far from random, but then there is a fairly abrupt convergence to random. After seven shuffles the distance to random is less than .

So the idea is after, say, ten shuffles (or, equivalently, about ten rounds of hands), the deck is mixed up or close to random: each of the 52! orders are approximately likely.

This says something quite remarkable about the uniqueness of card games. Imagine each of the approximately 8 billion people on Earth own a deck of cards. Suppose we all spent 8 hours a day for 50 years shuffling our cards… at one shuffle per minute that is only about deck orders…

This is a tiny, tiny, fraction of the 52! possible orders! Only approximately

th

of all decks have ever been seen… so the probability of two orders ever have been repeated is tiny. When you play a deck of cards, the likelihood is that no other deck of cards have ever been in that order!

Now when we move online we need an algorithm to shuffle the deck. One algorithm works as follows.

So an online poker site can start with a random deck, and using a quasi-random number generator recurrence, generate a list of random-looking decks.

However, a serious error was made by the those in charge of one particular site. The way they stored the deck orders was not enough to encode all possible orders and in fact (using 32 bits rather than the 200+ necessary) only a tiny, tiny proportion of all possible deck orders were stored.

Spin The Wheel

How much would you pay to spin this wheel (the numerical values are prizes):

Such games should be analysed using expected average. Imagine playing it 80 times. You expect to hit each of the eight ‘prizes’ ten times:

winnings from 80 plays = 10*20+10*5+10*10+10*5=400,

and so dividing this by 80 we get an expected average of 5. This means, on average, when you play you win 5. Therefore if you intend on playing regularly, if you pay less than €5 you will win on average.

If we divide the above sum by 80 we see:

expected winnings = .

This sum here is ‘add up prize by probability of prize’.

When the spinning machine has a ‘spin again’ it is also possible to analyse it. Consider the following:

Using the expected winnings equal to , we have

expected winnings = .

But the spin again prize is the same as the expected winnings so we have, if we denoted by the expected winnings: