11.07.2006

Shuffling Cards Is Hard Work

It's always weird when my Chemical Engineering background shows its ugly face in unexpected places.

I've been working on a collectible card game for the last couple of months and have just completed the second major revision of my game concept. One of the more annoying hassles with these revisions is that I have to print out, cut and then shuffle the revised deck. It always bothers me that putting the new deck together takes almost as much time as the re-design does.

I've managed to reduce the printing and the cutting to about as efficient a process as they can be without investing in new tools. There's definitely more fat to trim, but I need to wait until I know exactly what the base deck is going to look like.

Until recently, shuffling was the real beast and wildly inefficient in that I could spend a significant amount of time shuffling with a mechanical card shuffler and still come away with a deck that I just KNEW wasn't as random as it should be. The deck is currently quite large (I'll shrink it once I have a stable mechanic and can use play testing to figure out what the minimum optimal size is) so it's difficult to get all the cards spread out through the deck.

Usually what I do is split the cards (which start off as a highly ordered stack where numerous cards of the same type are all right next to one another) into a number of smaller decks that can be processed through the mechanical shuffler. I then split each of these smaller sub-decks in half, combine halves from different sub-decks and then run each recombined sub-deck through the shuffler a number of times. I then split each subdeck in half again and repeat the process. If I'm methodical I can get a decent amount of randomization across the deck, but I have to shuffle a number of different sub-decks that is, at minimum, equal to the square of the initial number of sub-decks. Even after all that, the amount of randomization is sub-optimal.

Shuffling is annoying and I hate doing it. So, having printed and cut the most recent revision, I decided to take a shower and vote before getting down to the business.

Oddly enough, showers seem to be where I've had most of my (hopefully) good ideas regarding my card game, and today was no different. My mind was wandering haphazardly around the topic of card shuffling, when I suddenly thought about, of all things, molecular diffusion.

Imagine if you will, a large tank filled with salt water. Then imagine that I very carefully and slowly add another volume of water, this time with no salt dissolved in it, such that the layer of fresh water essentially sits on top of the salt water. The dissolved salt will immediately begin to diffuse via brownian motion into the fresh water. The water will also diffuse from the fresh water layer into the salt water layer, though probably at a slower mass rate.

Diffusive mixing of liquids is an exceedingly slow process. I remember reading in one of my mass transfer texts that after a year the diffusing molecules described in the system above would only have managed to penetrate a few centimeters into the other layer. This why you stir when you want to mix two things together rapidly. Adding convection into the mix greatly increases the rate of mixing.

And that's the mental leap. Shuffling cards in the previously described manner is essentially a macro version of diffusive mixing. No matter what I do, it's going to take a long time to randomize the molecules, err I mean cards. The only way to increase the rate of mixing is to add in convection. So that's what I did.

I grabbed two large plastic tubs from the basement closet under the stairs and dumped the entire revised deck into one of the tubs. I then transferred those cards into the other tub by letting them fall into it over a distance of a couple of feet. Within about five minutes, the deck was entirely random. Now all I have to do is go through all the cards, repack them into a proper deck and flip half of them around. That will still take far less time than it would have to properly randomize the deck via diffusive mixing.

2 comments:

the beastlet said...

hee hee. you said "brownian"

Robert Farley said...

Nerds. I have nerds for friends.