## Wednesday, 20 May 2015

### Theory: Engine Draw Basics

I have written elsewhere about the benefits of Engine Economies (and I will probably port that over here at some point). But in order for all that to work, you actually need to draw your deck consistently. Given this, a good question to ask is, how consistent is it?

Fortunately, we have mathematics. The first thing to note are some very basic statistics. How many cards can your deck draw? Seriously, this is as easy as totaling up the number of +cards on all your cards, and adding five for your initial hand. Obviously you need to subtract out cards you discard (e.g. Embassy counts for 2, not 5), and cards like Journeyman which don't technically draw cards should still count for their obvious number (in this case, 3). Obviously variable-drawers like Scrying Pool will make things trickier, but for now I'm going to focus on your more basic engines. You can compare your total draw to the number of cards in your deck, and this will tell you whether it's even possible to draw your deck. Consistency, however, is another question, and it requires math that's a bit more advanced.

The specific math we're going to be leaning on here is a mainstay of card games, the Hypergeometric Distribution. There are a number of Hypergeometric Calculators available on line, such as this one. I do most of my work in Excel, which has this stuff built in, of course. The biggest reasons for this are that it's easy to generalize doing a lot of similar calculations across a spreadsheet, and I almost always have at least one Excel tab open anyways.

I'm not going to walk through all the mechanics here, but I will outline you through how to calculate the basics for the first scenario I'm looking at. That scenario is 12 "dead" cards (anything that doesn't draw, from Curse to Goons), which is going to be reasonably common, as you start with 10 and often have to add about 2 payload cards to get your economy going, along with 4 Villages and 4 Smithies. Ok, this means 20 cards in our deck total, and we start with 5. The Villages each draw a card, and the Smithies each draw 3, so 5 + 4*1 + 4*3 = 21, or actually one more card than we have in our deck. Great. So we should be able to draw our deck pretty reliably, right? Let's see.

The first thing we need to get going on our turn is a village. So we use our hypergeometric calculator to come up with the chance of getting zero of those out of 5 cards. You should come up with 28.17%. Then, we need a Smithy. Of course, we can play any number of Villages before that Smithy. So the way to model this is, we need to see the chance of drawing none of 4 Smithies in a hand of 5 cards, from a total of 16 cards, where the 16 is the size of our deck minus the Villages, since we can just cycle through those. We should come up with 18.13% here. Okay, so now we've hit at least one Village and a Smithy. To continue, we need another Village. The key thing here is that it doesn't actually matter whether we found one before the Smithy or after, the overall chances of getting at least one remain the same - we just need to check for having none in our hand, which is now 7 cards, from our deck, which now has 3 Villages left out of 18 total cards. We get a 20.22% chance of missing now. Same thing for hitting the next Smithy - 3 left out of a deck of effectively 15 cards, and a 7-card hand. That's a 12.31% chance to whiff.

Continue that pattern down the line until the deck is drawn. Remember that what we've been calculating are the chances to miss. To get from this to the chance to draw our deck, we first need to turn them into chances to succeed by subtracting them from 1 (=100%). This gets us the chance of e.g. drawing AT LEAST one Village. Then, because we need ALL of them to succeed, we need to multiply those chances together to get the chance we draw our deck. When we do that, for our example, we get... a whopping 20.08% chance to draw the deck on any given turn, starting from a fresh shuffle. It's worth noting that if we only hit 3 Smithies, we will have drawn all but 1 payload card - the chance of doing this with an action live is not much better, though, at only around 30%.

As we move to bigger decks and adding more cards, it's important to note that, as we get to the point we're over-drawing our decks, we don't necessarily need to hit EVERY village and smithy - at a certain point, the deck is drawn, and the superfluous drawing components do nothing (except, perhaps, give us enough actions to complete all our payload).

As for the strategic implications of what all this means, I'm going to leave that for a different post. For now, let's just say to not be too surprised or upset when you get those dud hands - they're most likely more common than you think.