Playing cards and probability (13 card hands)
In many card games, there are always different combination of cards and they have a different “ranking” when playing them. For example, a full house is stronger than a flush. In general, the higher the ranking of the cards, the lower the probability. For this post, we will be focusing only on the full house, flush and straight in particular.
In a 5-card hand, the probability of getting a full house, flush and straight is 0.1441%, 0.1965% and 0.3925% respectively, which is inversely related to the strength of the hand.
5 Card Hand Probability
Hand Ranking:
Straight < Flush < Full House
Probability:
0.393% > 0.197% > 0.144%
13 card Hand Probability
Straight ?? Flush ?? Full House
However, we don’t even deal 5 card hands to everyone in most games. In Singapore at least, it’s either 2 cards (blackjack) or 13 cards (dai di/bridge). Can we say the probability is consistent with the hand rankings the same for a 13 card hand?
Let’s work on the mathematics behind getting the probability of a flush. We say that a 13 card hand has a flush if there are at least 5 cards of the same suit (clubs, diamonds, hearts or spades).
The theoretical probability of getting a flush from a 13 card hand is 64.9%
Now, we use the Monte Carlo method to verify that the mathematics is correct. The idea is to use a package (pydealer) to simulate a deck of cards, randomly draw 13 cards, check if the card has a fullhouse, flush or straight, then repeat this sufficient times such that the margin of standard deviation is close to negligible.
We now write 3 functions (check_straight, check_flush, check_fullhouse) here that will check every hand if there is a straight/flush/full house respectively.
Both check_straight and check_fullhouse takes in a list of cards. An example of a card_list is [‘2’, ‘2’, ‘3’, ‘4’, ‘7’, ‘7’, ‘Jack’, ‘Jack’, ‘Queen’, ‘King’, ‘King’, ‘Ace’, ‘Ace’].
For check_straight, the logic is quite straightforward as we run all possible straight combinations and check if the straight combo exists in the 13 card hand.
For check_fullhouse, we first iterate the card list and check if any particular card value has more than or equals to 3 cards. If there is, we record that as a triple. If it happens again, we can record that triple as a pair. We also check if any particular card value has exactly 2 cards and record that as a pair. A hand has a full house if there is a triple and a pair (double).
check_flush takes in the Stack class from pydealer, calls the find_list method and returns a list of all the indexes that has a particular suit. We iterate all suits (Diamonds, Clubs, Hearts and Spades) and check if the length is more than or equals to 5.
To summarize, all three functions will return a True if there is a straight/flush/full house and a False otherwise.
We then write another function play_games where n is the number of simulations ran.
If the hand has a straight/flush/full house, we add them to the count and returns a dictionary of the percentages.
Indeed, for flush, we have earlier proven the theoretical probability is 64.9%, which is well within the probability calculated by the Monte Carlo method (64.94607%). Notice that for dai di, where it was universally agreed that a full house is stronger than a flush, which is stronger than a straight, the probability thinks otherwise!
5 Card Hand Probability
Hand Ranking:
Straight < Flush < Full House
Probability:
0.393% > 0.197% > 0.144%
13 Card Hand Probability
Hand Ranking:
Straight < Flush < Full House
Probability:
56% < 65% > 48%
Just something to take note of when playing cards in future!