Vintage Cube Stats Puzzle

Supposing that Power 9 cards are always picked over non-Power 9 cards, what is the chance you never see a piece of power in the drafting phase of a Vintage Cube event?

This puzzle probably doesn’t make a whole lot of sense to people who don’t play Magic, and even then it requires a bit of knowledge about the Vintage Cube draft format.

That’s why I rewrote it in a different context and posted it here to the Math Riddles subreddit.

It’s more of problem than a riddle (and at the time of writing this entry the post is sitting on 3 upvotes, 2 downvotes, ouch) but I know that subreddit has a great community of problem-solvers so figured I’d post it there.

I have tried to solve this “by hand” but it seems to run into a bit of complexity, which I’ll briefly explain:

First of all, we know that if you have at least one piece of Power in any of your starting boosters then you’ll see one. That probability is easy enough to calculate. But we can’t just do 1 minus this probability to get the answer to the puzzle, because even if we don’t start with a piece of Power in our boosters, the person on our left or right might have two or more pieces in the starting booster they pass to us and so we would see one of those. We therefore need to also include the probability that one of those three boosters contains two or more pieces given that none of ours contained any pieces. That’s not too tricky…

…but then we need to think about the three starting boosters that are two passes away from us. If any of those have three or more pieces of Power in them then we’ll see one of those pieces. So we include the probability that one of those three boosters contains three or more pieces given that none of ours contained any pieces, and none of our neighbours’-starting-boosters-passed-directly-to-us had two or more pieces. That conditional should be just a case of (1 minus the two probabilities we already calculated) * (probability there are three or more in one of those packs). However, that “three or more” probability changes depending on whether our neighbours packs had one or zero pieces of power. We have multiple cases to consider.

Then when you think about three passes away from us and four or more pieces you run into even more cases to consider, and so on.

I think I could do a good job of this with dynamic programming, or perhaps an alternative inclusion/exclusion approach, but it’s actually where I decided to write a simulation instead to get an idea of the answer more quickly!

Here you can look at and execute the code I wrote. The output gives an estimate for the probability that you see at least one piece of power. So to answer to the original question subtract that from 1!

(Psst! It’s ≈0.24)

Creature Shorthand

A few weeks ago I made this:

Creature Shorthand

Click the image to check it out.

It’s a little hoverable grid of information about creature slang in Magic: the Gathering. I learned a lot in the process.

The biggest challenge was getting the images to transition while maintaining the hover-over enlarge effect. I have now since found out the correct way to do this in pure CSS.

However, at the time I used a kind of hacky solution: I did the transition in GIMP and made the images animated GIFs.

This is actually a really bad idea. The quality is worse than a CSS crossfade and the file sizes are massive compared to the CSS method. On my fast connection the page still takes a while to fully load.

However, I did learn more in the process, about how to do a crossfade in GIMP.

The page I used was this one, but I will repeat the information here for future use if that page ever disappears or I can’t find it again.

First, get the AnimStack plugin. This allows code to be written into layers which is then processed all at once and clever stuff gets done to your image.

Then, get your image in GIMP with one layer for each image to be crossfaded, and another on top. Append to the layers the following code: (The code is the square bracketed bits, the other is the names of the layers.)

Frame [*21]
Layer1 [bg] [x=inc:-5:100] [-;opacity:x]
Layer2 [bg]

Process AnimStack tags (in the filters -> animation menu) and it should all work.

The syntax of the code is straightforward to understand, and I look forward to using AnimStack for other projects in GIMP in future. Though, next time I need to crossfade on a webpage I will use CSS.

This Creature Shorthand page was a valuable project, which greatly informed the design of my website.

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: http://jdgmiles.github.io/Jesse’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.