Tuesday, November 11, 2014

probability of no trump cards in a hand of the card game spades

[tl;dr: so far as I can tell, cards are dealt perfectly randomly at World of Card Games. If you think that the deck is stacked, it's probably an odd run of bad (or good) luck that you're seeing.]

Sometimes, players will tell me that they think the deck has not been properly shuffled. They've had an unusual run of bad luck. Perhaps in Euchre, they haven't seen a bower in their last 5 hands, and it looks suspicious. In Gin Rummy, their opponent was dealt a Gin hand immediately. Or in Spades, they've been dealt a hand with no trump cards too many times to be believable.

At World of Card Games, the cards are dealt randomly, and I see no way that the deck could be stacked. Here's how the deal of cards works in every game on the site:
  1. Every time that cards are dealt, an entirely new, ordered deck of cards is created by the system. It's as if I took a fresh pack of cards out of a sealed deck; the old deck is not re-used.
  2. Then, these cards are "shuffled" using a random number generator.
That's it! It's very simple. You may see odd results, just like you might see a long run of "heads" in a repeated coin toss. But it's just random.

For those who are curious, just what is the probability of getting a trump-less hand in Spades? Here's an explanation:

A hand in Spades consists of 13 cards from a deck of 52. The number of combinations of such cards is 52! / (13! * (52 - 13)! ). According to Google's calculator, that is 635,013,559,600 (over 635 billion). That number includes all trump-less hands, and all hands with trumps as well.

To be clear, this does not count combinations in which the cards are merely reordered. For example, this count includes an entire hand filled with Spades, but only one such hand - the order of cards in the hand does not matter. For those who are hoping, this means the chance of ever getting a hand completely filled with Spades is 1 in 635 billion. "Not very likely" would be an overstatement.
all spades - dream on!
Okay, so how many of these hands are there that exclude trumps (Spades)? That is computed by taking all combinations of cards from a trump-less deck. A trump-less deck contains 39 cards (52 cards minus 13 Spades suit cards). Applying the formula for combinations again, we get 39! / (13! * (39-13)!). Google's calculator says this is 8,122,425,444 - about 8 billion different combinations of non-Spades cards.

So, there are about 8 billion trump-less hands in all 635 billion possible hands of Spades. The probability of getting a trump-less hand is the ratio of trump-less hands to all hands, which is about 1.28%. Not very likely, but it happens.

To test all this out, I ran a million simulations of Spades cards being dealt exactly as they are done at World of Card Games (using the same computer code). Here are the results:
  • There were 4,000,000 hands dealt in total
  • There were a total of 51368 trump-less hands, which is, indeed, 1.28% of 4 million [100 * (51368 / 4000000) = 1.28%]
  • The count of trump-less cards for the first player was 12772, second player was 12790, third player was 12996, and fourth player was 12810.
In case you are wondering about that last bit, a certain amount of variation is expected between the different players. Notice the third player was getting slightly more of the trump-less hands in the above experiment. When I ran the experiment again, it was the second player who got most trump-less hands (12945). A little bit of variation is expected because of the random nature of the events.