# Taking Chances: A Guide to Using Probability in Deck Building

Hi, jez2718 here. As some of you may know, I am a mathematics PhD student and as Batteriez has occasionally let slip on Discord this has lead to team TGP blackmailing asking me to do probability calculations to inform various deck building choices that arise in Eternal.  So I thought I’d write an article about the basic techniques that I’ve been using.

# What do these calculations achieve?

It’s important to remember what we are and aren’t doing here. The advantage of calculating probabilities is of course that it tells you what you should expect to happen, whilst it takes a lot of testing to be sure that the results of the testing aren’t just variance.

But we must remember two things. First, a probability is just a number. It informs your decision of whether to play a card in your deck, but it doesn’t make that decision for you. Whether or not, say, a 66% chance of having the influence when you draw your splash card is worth the risk is a judgement that is going to take into account various other factors beyond just the maths.

Second, the probabilities we’ll be deriving will be approximations. Some of these approximations are for convenience: I’ll be assuming we draw cards truly at random, with no digital trickery to ensure 2-4 power in hand etc. This isn’t that hard to correct for, but it adds a bunch of messiness and my intuition is that it won’t make a huge difference in many cases. Other approximations are deeper though. Cards like Seek Power or Diplomatic Seal require the player to make choices. To fully account for these would elevate us from doing simple probability to designing a crude AI. Draw power like Wisdom of the Elders or Strategize obviously raise the chance of drawing into other cards, but to fully account for this involves conditioning on how many of each you draw, and crucially too whether we have the time to play them.

Thus to do this exactly would greatly increase the complexity of our calculations, and is it in the long run worth the effort? Instead we take shortcuts. We can treat Seek Powers and Diplo Seals as 3/4 or 2/3 of an influence. We can say that from testing we have, say, typically played one “Draw 2” spell before turn 5, so we model ourselves as having drawn 13 (or 14 on the draw) cards by turn 5 rather than 11 (or 12).

# Six key numbers

As a TL:DR before getting into the meat of the method, following the great Yu-Gi-Oh! content producer Jason Grabher-Meyer here are “six numbers to make you a better duelist”: (the two numbers are ‘on the play’ and ‘on the draw’ respectively).

1. Chance of opening with at least 1 of a card you run 4 of: 33%, 37%
2. Chance of opening with at least 1 of 2 exact cards: 18%, 20%
3. Chance of opening with at least 2 of a card you run 4 of: 4%, 5%
4. Chance of opening with a 2-card combo running 4 of each: 10%, 13%
5. Chance of opening with at least 1 of 6 target cards: 46%, 50%
6. Chance of opening with 1 exact card: 9%, 11%

# Hypergeometric probability

So, where do these numbers come from? The answer is an incredibly exciting sounding name for a rather mundane concept. In general, in Eternal you are sampling your deck without replacement. Thus if you draw a Power, that makes you slightly less likely to draw another Power, etc. This subtlety makes it kinda annoying to do these calculations by hand, for example the first probability above comes from:

$1-\frac{71}{75}\times\frac{70}{74}\times\cdots\times\frac{65}{69}$

But fortunately we don’t have to do this ourselves! Websites such as http://stattrek.com/online-calculator/hypergeometric.aspx provide an easy to use calculator for these probabilities (as does Microsoft Excel). So to find the first probability above, I put in a population of 75 (the deck size), with 4 successes in the deck, a sample size of 7 (8 on the draw) (i.e. the size of the starting hand) and the number of successes as 1. I then looked at the P(X≥1) output. We will simplify this by writing

$\text{HG}(75,4,7,1,\geq)=0.330$

This compact form will let us write more detailed formulae later for more advanced questions. Remember: you find HG(P,s,S,x,-) by putting those numbers into the calculator in order, and looking at the box indicated by the symbol.

# Conditional probability

But wait, how did we find the 4th probability above? To do that, we had to find the probability of one thing happening AND another thing happening. As you may know, if these events are independent you can just multiply the two probabilities. But here drawing one combo piece is one fewer card in which to draw the other, so they aren’t independent. The general formula is:

$\text{Pr}(A \& B) = \text{Pr}(A)\times \text{Pr}(B|A)$

Where Pr(B|A) denotes the probability of B given that A has occurred. So the formula for the fourth probability is the more complicated expression:

$\text{HG}(75,4,7,1,=)\text{HG}(71,4,6,1,\geq)+ \text{HG}(75,4,7,2,=)\text{HG}(71,4,5,1,\geq)+\text{HG}(75,4,7,3,=)\text{HG}(71,4,4,1,\geq)+\text{HG}(75,4,7,4,=)\text{HG}(71,4,3,1,\geq)$

Before I explain what this formula is doing, let us introduce a way of writing this sort of expression more compactly. We can write this sum using the notation:

$\sum_{i=1}^{4} \text{HG}(75,4,7,i,=)\text{HG}(71,4,7-i,1,\geq)$

Where the Σ tells us to add up the terms inside it substituting the ‘i’ variable for 1,2,3 and 4 in turn. So here in each term the first HG is the probability of drawing exactly i copies of the first combo piece in the opening hand. We then look at the conditional probability. We’ve drawn every one of the first combo piece that we were going to draw, so our deck now behaves as a 71-card deck (i.e. without those cards), and our remaining hand has size 7 – i. We then attempt to draw at least one of our other combo piece with this hand. Finally, we sum over all the possibilities, i.e. over i = 1, 2, 3 and 4. Why do we sum the probabilities? This is our final tool, called the Law of Total Probability. It says that if a collection of events Ai are mutually exclusive (i.e. at most one of them can occur) and exhaust all the possible ways that an event B can occur, then:

$\text{Pr}(B) = \sum_{i}\text{Pr}(A_i)\times \text{Pr}(B|A_i)$

And that is actually all the formulae we need. Everything you want to do can be done by careful application of these ideas. For example if you want to find the probability of some event A on the redraw (with 25 power in deck) then you would use the Law of Total Probability and calculate:

$\frac{1}{3}\sum_{i=2}^{4} \text{Pr}(A|i\text{ Power in opening hand})$

# A note on what to calculate

When deciding on whether to run a card, there are four basic cases

1. You draw it and it is live. This is the best case scenario. If the card in question is some game-winning bomb, making this number large is typically what you want to do.
2. You draw it and it is dead. For most cards, this is the most important number. Running blank cards is a bad idea, so you usually want to make this number as low as possible unless the card is really worth the risk.
3. You don’t draw it and it would be live. This number basically governs whether a hate card is worth it. If the card is meant to be saving you from some major threat, then how often you die to that threat even with the card in deck matters.
4. You don’t draw it and it would be dead. Meh.

Sometimes you might also want to compare these numbers. For example if a card is dead twice as often as it is live in the cases when you draw it, probably not a great card to include unless it is very powerful.

# Example 1: How much Shadow does Makto need?

To illustrate how one might use this stuff to inform deck building choices, let us turn to a deck very close to my heart: JPS Nostrix. One of the primary strategies of this deck (when it isn’t getting hosed by In Cold Blood) is grinding out the opponent with Makto, preferably buffed up by Nostrix. However this is in tension with a number of other factors. Having Nostrix in the deck demands a lot of Justice and Primal, as does wanting Pacifier, Wisdom, Hailstorm and perhaps Valkyrie Enforcer live on turn 3. So we want to run enough Shadow to have SS when we need it, but otherwise not cut too much into our Justice and Primal (also for tempo reasons we can’t have too much depleted power). So we ask the following question:

What is the probability of drawing at least one Makto and less than two Shadow by turn 5?

Note that this isn’t the only question we could ask. We could ask about drawing Makto and only one J, or not drawing 5 Power. But in these cases, having a dead Makto in hand is the least of your worries. Finding the right question to ask is the true art here, and requires careful consideration.

We make some approximations. Let us treat the 4 Seek Power as 3 Shadow sources, and let us suppose that we usually draw two bonus cards by turn 5. So we have a sample of 13 cards. The decklist above has 15 shadow sources. Thus we calculate (on the play) a probability of

$\sum_{i=1}^{4} \text{HG}(75,4,13,i,=)\text{HG}(71,15,13-i,2,<)$

and this gives us the answer of about 12.6%. That is, a dead Makto on curve about every 1 in 8 games.  For context, the chance of drawing a Makto by turn 5 is 54%. Calculating for different numbers of Shadow sources gives:

 Number of Sources Probability of dead Makto 10 25.8% 11 22.7% 12 19.8% 13 17.1% 14 14.7% 15 12.6% 16 10.7% 17 9.0% 18 7.5%

Especially given the approximations we’d made (maybe 4 Seek Power really just counts as two sources, say, or if you don’t draw any card draw that game) we felt that 15 was a safer number than 14 given these numbers, the 17% from 13 felt too risky, whilst there was little real gain in going above 15 and potentially messing up things relying on JJ and/or PP. Were one feeling a little bolder though, one might wish to shave some of the shadow sources (perhaps to add in some of the upcoming Hooru Crests), and these numbers tell you how much risk that strategy would incur.

# Example 2: Can you run Amilli in TJP Midrange?

As another question, let us turn to a (sadly for my pet Nostrix’s) more meta deck. Before the release of Svetya, the above was a bit of an important question. The received wisdom was no, so this lead to TJP having to run the kinda underwhelming Copperhall Elite. This issue was largely fixed by Svetya, but with many TJP lists running Mirror Image Amilli is still an attractive card. But of course, 5JJJ in a deck already notorious for mana issues is surely insane right? TL:DR It probably is indeed insane, but it is nice to check just in case you break the metagame. So we ask:

On each turn from 5 onwards, what is the probability (on the play) of drawing Amilli but not having 5JJJ?

This turns out to be a fair bit harder to answer than the Makto question, because whether you draw 5 powers affects your chance of drawing JJJ. We shall consider camat0/Tobboo’s deck from the invitational. This has 29 Power, and approximating Seeks as 3/4 of an influence and Diplo Seal as 1/2 an influence it has 20 Justice sources.

On turn N, one has drawn 6 + N cards on the play. Thus we have the formula, where A is the number of Amilli we run:

$\sum_{i=1}^{A} \text{HG}(75,A,6+N,i,=)\text{Pr}(\text{No 5JJJ}|i\text{ Amilli})$

To find the second probability, we need to use the Law of Total Probability a second time. Given that we drew exactly i Amilli, this is the same as drawing a hand of 6 + Ni from a deck of 75 – A cards. Given this, we have

$\text{Pr}(\text{Draw 5JJJ}) = \sum_{P=5}^{6+N-i}\text{Pr}(\text{Draw }P\text{ Power})\text{Pr}(\text{3 of that }P\text{ Power is J})$

and so

$\text{Pr}(\text{No 5JJJ}|i\text{ Amilli}) = 1-\sum_{P=5}^{6+N-i}\text{HG}(75-A,29,6+N-i,P,=)\text{HG}(29,20,P,3,\geq)$

So bringing this all together involves doing both sums. To do this, especially for all the different values of A and for N, it is best to use software like Excel (or MatLab etc. if you have access to them) to implement these formulae. The below table gives the answers:

 Probability of Drawing a dead Amilli turns 5 through 8 Number of Amilli Turn Number 5 6 7 8 1 10.3% 9.6% 8.7% 7.7% 2 19.0% 17.6% 15.8% 13.8% 3 26.4% 24.2% 21.6% 18.6% 4 32.6% 29.7% 26.2% 22.4%

So either you run so few Amillis as to not be worth it, or you have a really high chance of them drawing dead. Indeed, even the 1 Amilli plan is bad if you plan to cast it on curve: you have a 14.7% chance of drawing it by turn 5, and 10.3% of the time it is dead vs 4.4% it is live. So if you run one Amilli, it is with the intention of not drawing it until much later, which is not really why I’d want to be putting Amilli in TJP. For similar comparisons, a simple hypergeometric calculation gives:

 Probability of Drawing an Amilli turns 5 through 8 Number of Amilli Turn Number 5 6 7 8 1 14.7% 16.0% 17.3% 18.7% 2 27.4% 29.6% 31.9% 34.1% 3 38.3% 41.2% 44.0% 46.7% 4 47.7% 51.0% 54.1% 57.1%

NOTE: It is possible these numbers might not tell the whole story. If you look at the Hooru Fliers decks that preceded TJP, they ran very similar Power and Justice counts, yet also seemed to get away with running 4 Amilli. A large factor in all of this is that the redraw makes you more likely to have more Power, and by extension more influence. You might as an exercise want to apply the methods above to see if Amilli is more acceptably live on the redraw. But even if that is the case, it remains true that Hooru Fliers can afford to use the mulligan and target their Seek Powers to maximise the chance of a live Amilli. TJP on the other hand already has enough things to manage, and can’t really afford to mulligan with the goal of getting to 5JJJ.

# Wrapping up

So I hope this has given a little insight into how one can use probability to approach deck building decisions in a bit of a more objective way, and will prove useful to you when you are tuning your own decks and want to know if say, a risky splash is worth it.

In other TGP news, keep an eye out for an announcement regarding an exciting new tournament we’re organising coming soon! And don’t forget, we also host a “Casual Friday” tournament every Friday at 5 EDT!

Until next time,