What is the best way to shuffle cards?

Using python to find the best, practical way to shuffle (magic) cards

Every Friday night thousands of fellow nerds spend their evening playing playing Magic the Gathering at their local gameshop. At least they used to before the pandemic hit. I used to be one of them but I was never any good and always blamed it on my inability to shuffle cards the right way. Lately I've been coming back to the game and find myself in the same old predicament and blaming habits. But now I can use computer modeling to once and for all put that excuse to bed and find out the best practical way to shuffle cards!

Before we can start coding and model shuffle techniques we need to set some bounds and define what practical means. Fancy perfect shuffling algorithms ain’t gonna cut it as my hands are only human. So every shuffle technique needs to be reproducible by hand. And what does shuffled even mean? is there any way we can quantify shuffledness? There are two obvious metrics available for quantifying how much a deck has been shuffled:
1. The average distance between the positions of cards before and after shuffling.
2. The average distance between previously neighboring cards.

Simply reversing the order of the deck keeps all neighbors close together and will count as optimally shuffled when using the first metric. This is undesirable as we want to randomize the cadence of the deck as much as possible(assuming we want to play fair).
The second metric tells us how much a cluster of cards is broken up, which is exactly what we want to achieve when shuffling the deck. But how shuffled is enough?

A perfect example of the unpredictable nature of randomness

well remember when i said i couldn’t reproduce fancy shuffle algorithms with my hands? What we can do is use it as a guideline and it turns out the built in shuffle function of reaches a cool average distance of 20 cards! This sets our goal straight: reach as close to an average card distance of 20 with the least amount of shuffles as possible.

The amount of decks means how often the experiment is performed

The first shuffling technique we’re going to look at is possibly the easiest technique: the overhand shuffle. by dropping randomly sized packets from the deck in your right hand to your left hand stacking them on top of each other we create an inverse order of card clusters. Not really what we’re looking for and that’s why it takes 50+ iterations to reach the desired ACD of 20. (Approx. 5 minutes of shuffling)

keep in mind that we’re only looking at 10 shuffles this time

The next shuffling technique we’re going to model will be riffle shuffling. This type of shuffling is what casino’s used to do . The deck of cards will be divided in two piles. both piles are lifted with the shufflers thumb and be dropped card for card doing this when holding the two piles in an overlapping position will shuffle the cards and is a lot more efficient then the overhand shuffle.

When looking at the graph it seems we’ve hit the holy grail of shuffling, even surpassing the 20 ACD briefly. This type of shuffle comes with a side-note practicality wise though. Although riffle shuffling regular magic cards is easy to do it comes with some drawbacks. Magic cards can be very very expensive and are often kept and played in sleeves. This makes performing a riffle shuffle somewhat more difficult as the cards will be more bulky and bending the cards to riffle them will most likely damage them.

My go-to shuffle as a graph

Our next experiment is the one I used to do al the time, the overlap shuffle (better known as the Faro-shuffle, only this one overlaps). We again make 2 piles, overlap them vertically en push them together. repeat this a couple of times and your cards are supposedly shuffled. Modeling this technique proved a flaw. it dit not shuffle the cards all that well. reaching shuffledness in about 27 repetitions.

Tweaking this technique slightly gives us some better results. When we alternate the piles instead of constantly overlapping the bottom pile with the upper pile we get a slightly better effect! We reach 20 at approximately 17 shuffles.

This does however explain my experience with horribly shuffled deck as I never even got close to 17 repetitions, Let alone 27! The last technique I want to try out i the one everybody advised me to do but takes a lot of effort, shuffling the cards into eight piles. We’re going to model the pile-shuffle. when preforming the pile shuffle we deal the cards in separate piles and then stacking them on top of each other. This shuffling technique takes a long time per shuffle but shuffling once is enough so an ACD graph won’t make any sense. Instead of a plot I’ve made a bar graph representing the amount of piles and the resulting shuffledness, the results are unexpected.

Apparently the eight-pile shuffle outperforms a lackluster overlapping faro-shuffle. In a sense the advise I got was right but shuffling the cards into 2 stack reigns supreme in maximizing card distance! The downside of this technique however is the fact that this is not true randomization.

This shuffle is deterministic and can be learned and remembered. the technique can however be used as a base to effectively break up card clusters and when combined with a quick overhand shuffle to break the patterns and overlapping faro to rearrange the order of close cards we’ve found the perfect shuffle easily done in under a minute with an average ACD of 23.5 over 10000 shuffles:

Pile shuffle into two piles, overhand shuffle and a reversed overlapping Faro to seal the deal.

Computer Science student by day and avid programmer by night.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store