Jesse’s Deck Problem

A Magic: the Gathering picture

About a year ago, one of my Magic friends asked something along the lines of this:

Do you know of any way to search decklists so that, given what cards I have seen in an opponent’s deck, I can get a probability of them playing another, specific card?

That is, some way of using a deck database to calculate whether or not you should play around something, given what you’ve already seen from the deck.

Well, firstly, there’s always MTGtop8, and simply putting the cards you’ve seen into the search to return what possible decks your opponent may be on. From there you can look through the results and see if the card you’re curious about is in the lists.

It’s also worth noting that it really doesn’t take much time in a format to learn the landscape of decks and generally  be able to quickly put your opponent on an archetype. Raw probabilities of “card Z, given cards ABCDEF” are not as helpful as a bit of deck knowledge and some judicious searching on MTGtop8 when you get really stuck.

Even so, I wanted to make something that had a more direct answer to the question, as posed, so I set about it.

My first thought was that if you have a long list of decks, then you could just do something clever with regular expressions which would return the number of decks featuring cards ABCDEF, then the number of decks featuring cards ABCDEFZ and the ratio would then be your probability.

And that’s pretty much what I built.

However, I learned in the process that regular expressions couldn’t do the whole thing. They were an important and useful tool for one part of “the whole thing” – the search markup. I guess I’d fallen into an old trap.

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.

-Jamie Zawinski.

Anyway, what resulted was this:’s Deck Problem/. It’s not flashy, and it’s not exactly elegant either, but I learned a lot in making it, and it does what I wanted it to, even if “what I wanted it to” isn’t something a Magic player should really want to.