Probability in Hearthstone
Author - madmaxx On: Twitter | Youtube | TwitchTV | GitHub
Basics of Probability
At the beginning of the match, the game throws a coin. The chance of you getting the coin - if the RNG is actually truly random - is one-in-two, or 50%. Instead of using percentages though, lets express it as 1/2. Fractions are not only the best way to express probability, they are also the most complicated math we need to deal with.
If you have 20 cards left in your deck, and you need to draw your Flamestrike - of which you have only one - the chance of drawing that Flamestrike is one-in-twenty, or 1/20. You have one favourable outcome out of 20 possible outcomes. The number of favourable outcomes is your numerator, the number of possible outcomes your denominator.
Another example: same situation, but you have two Flamestrike in your deck. That means two out of the twenty possible cards you can draw are now a Flamestrike, which increases your chance to two-in-twenty or 2/20, which is the same as 1/10.
This is the very basis of probability, but it gets more interesting. Lets say your opponent didn’t play anything, and you have the chance to play a Mad Bomber - should you risk it? By now we know that the chance of a single shot hitting the opponent is 1/2 - there are two possible targets, and one favourable outcome. But what is the chance of the Mad Bomber hitting the enemy three times in a row?
The answer to this is actually 1/8 - or 12.5%. But why? Every shot has a 1/2 chance of hitting the opponent, so the chance of hitting the opponent three times in a row is 1/2 * 1/2 * 1/2 = (1/2)³ = 1/8. To visualize this, look at the following table. H stands for your hero being hit, and O stands for your opponent being hit. In other words HOH means you get hit - opponent gets hit - you get hit again.
1 HHH
2 HHO
3 HOH
4 HOO
5 OHH
6 OHO
7 OOH
8 OOO
So we have eight possible distinct outcomes, only one of which is the favourable one - the one where the opponent gets hit three times (OOO). Hence the chance is 1/8. You can also easily see that there are four cases where the opponent gets hit more often than the hero. That means the chance of Mad Bomber doing more damage to the enemy is 4/8 - or 1/2, unsurprisingly.
Maximizing Chance 1: Random Damage
In a lot of cases, you have the following situation: A Warlock plays a Blood Imp. You sigh. You look at your hand. Mad Bomber laughs you in the face. Silently, you mouth a whisper to RNJesus and play him. What is his chance of hitting the imp?
This is actually more complicated than it looks because you do NOT have 27 (3³) different possible outcomes. Its less, because as soon as the Blood Imp dies, you only have two possible targets left. In the table at the beginning of this article, the minions have infinite health - minions dying is not part of the calculation, because it would make for too many different factors to put in a table. Long story short, the chance that your Mad Bomber kills his bloody Imp is 3/5. Thats 60%.
This actually brings up a very important point: random damage effects like Mad Bomber or Arcane Missiles are more likely to hit creatures with more than one health.
Sounds weird, but at the end of the day, there are 20 possible ways your Mad Bomber can bomb with a 1 - health creature.
H=Hero, O=Opponent, I=Imp:
1 HHH
2 HHO
3 HHI
4 HOH
5 HOO
6 HOI
7 HIH
8 HIO
9 OHH
10 OHO
11 OHI
12 OOH
13 OOO
14 OOI
15 OIH
16 OIO
17 IHH
18 IHO
19 IOH
20 IOO
12 of which hit the one-health. 12/20 = 6/10 = 3/5 = 60%.
For a three health minion however, there are 27 potential outcomes, 19 of which are favourable. 19/27 = 70% chance Mad Bomber hits at least once.
Here are the numbers for the chance to hit one, two and three-health minions with mad bomber at least n times (provided they are the only minions):
| Health | 1 | 2 | 3 |
|---|---|---|---|
| 1 Hit | 60.0 | 69.2 | 70.3 |
| 2 Hits | - | 23.0 | 25.9 |
| 3 Hits | - | - | 3.7 |
And here the same table without friendly-fire (aka: Arcane Missiles):
| Health | 1 | 2 | 3 |
|---|---|---|---|
| 1 Hit | 80 | 85.7 | 87.5 |
| 2 Hits | - | 42.8 | 62.5 |
| 3 Hits | - | - | 12.5 |
From these numbers and the ones at the top you can easily see that random damage effects which DO NOT friendly fire are vastly superior, because they reduce the number of possible targets. To hit a Blood Imp, Mad Bomber only gets 60%, whereas Arcane Missiles get 80%. 80% is high enough to no longer be considered random, whereas 60% clearly is. So the two rules of random damage effects are:
- Random damage spells have a higher chance of hitting a specific higher health creature
- Reducing the number of targets increases the chance that a particular target gets hit.
|
|
|









Unless it’s been changed in a recent patch, Mad Bomber (and Arcane Missiles) sample each hit individually. I’ve tested this extensively. The twenty permutations in your mad bomber table do not happen with equal probability.
Your conclusion on page 2 that random damage spells have a higher chance of hitting a high health creature is false. A Mad Bomber kills a lone Blood Imp just over 70% of the time. An Arcane Missiles kills a lone Blood Imp 87.5% of the time, and kills a Faerie Dragon 50% of the time.
Your right if the hits are sampled individually all the permutations do not happen with same probability: for example:
P(HHH) = (1/3)^3 and P(IHH) = (1/3)*(1/2)^2
The easiest way to calculate the probability of killing an imp with 3 random shots is :
P(“Killing imp”) = 1 - P(“Not Killing imp”) = 1 - (2/3)^3 = 19/27 wich is just above 70%
Unless it’s been changed in a recent patch, Mad Bomber (and Arcane Missiles) sample each hit individually. I’ve tested this extensively. The twenty permutations in your mad bomber table do not happen with equal probability.
Your conclusion on page 2 that random damage spells have a higher chance of hitting a high health creature is false. A Mad Bomber kills a lone Blood Imp just over 70% of the time. An Arcane Missiles kills a lone Blood Imp 87.5% of the time, and kills a Faerie Dragon 50% of the time.
Hey man!
Great article. I’m glad to see others trying to work out the math behind the game. The code was a nice addition!
In your article, you gave … well let me just quote it:
Now what’s that? I read the article over and over to try and deduce how card cost relates to draw probability, and I don’t think it does, man. They are what’s known as independent variables.
I’m pretty sure the forumula you’re looking for is still just a regular old hyper geometric distribution. External
Here’s a great calculator for it: External
For turn 1 drop in population size 26 as there are 26 cards left to draw and you can assume you’re looking for *a* specific one. Mulligan would be 23 because you’re discarding 3 before you draw three. The sample size is always 1. The number of successes in sample is 1 as well, because “duh”. And the number of successes in the population is either 2 or 1, unless you’re running arena.
Your math doesn’t run up with what I’ve been doing. Why do you include the card cost in calculating draw odds at all? It literally doesn’t matter, right?
@Rafajafar he mentions that it’s “to show the chance you get a specific card before or at the time you need it.”
That said, I’m sad my two math-related articles weren’t linked to/mentioned in this article =(
Yes, but that makes no sense, my man. The cost has zero impact on drawing whatsoever.
Let’s say you need a 4 drop and it’s turn 3. Lo! You draw a card and it is a 4 drop! Oh but it’s not the one you needed… see what I mean?
Here’s another one. You need a 4 drop and you get it! What are the odds that that happens rather than you do not get the card you needed? The same, right?
So what is the probability that you draw a 4 drop before turn 4? Is that the question? Well, that wasn’t clear. He said a “specific card.” and the odds of that happening follow the hypergeometric distribution.
Card cost plays no role.
I agree, the article isn’t calculating this correctly. The probability of the first shot from the mad bomber hitting imp should be 1/3.
This is probably pretty obvious, but I would calculate it as follows:
(chance hit imp) + (chance miss imp) times (chance hit imp) + (chance miss imp twice) times (chance hit imp):
mad bomber:
(1/3) + (2/3)*(1/3) + (2/3)*(2/3)*(1/3) ~= 70%
arcane missile:
(1/2) + (1/2)^2 + (1/2)^3 = 87.5%
(Of course its possible the game calculates it the way the article says, but based on the comments it dosn’t sound like it, nor does it seem like a hugely intuitive way to code it)
@Rafajafar
I thought he was using the cost to determine the turn you needed the card.
Really, C represents the number of draws you get to use before you need the card, not the cost. “What is the odds that you will get this specific card by turn C, or after C draws”. If you have no extra draws (roughly including mulligan but thats not exact since those cards go back into your deck), then we might assume that you usually want to play a card, one you really NEED, the first turn you can. This sets C = cost of the card for this specific but not uncommon situation.
@Turamarth: Handy tip: probabilities often become easier to calculate if you look at the chance of something not happening and then negate it:-
What’s the chance to miss the imp three times? (2/3)^3 ~= 29%. So what’s the chance to kill the imp? 100-~29 ~= 71%.
@Rafajafar: If you’re asking the question “What are the chances that I have this card that costs X by turn X” then an appropriate expansion of the hypergeometric function will certainly include X as a term.
You’re right, though. The formula posted in the article is wrong. Even before you account for the mulligan, the probability that you’ll have one of your two Leper Gnomes on turn 1 after your draw going first is just over 25%, not 6.7% as quoted in the table. Similarly, the probability that you’ll have one of your two Faerie Dragons on turn 2 after your draw going first is just over 31%, not 13.1%. If you have six two-drops and you mulligan for them going second, the probability you’ll have at least one is over 70%, not 41.5%.
There’s also some really weird rounding in the Nat Pagle table on page 1. 75.2% chance of at least 1 card after two turns? 25.1% chance of two cards after two turns? It doesn’t really make much difference, but I’m really curious about what method was used that would result in any error at all… O.o
Hey, as the author of this article, I might be ablte to shed light on some questions.
First, thanks for discussing this, I included all formulas, code, etc. for exactly the reason of review. So good on you for trying to shoot holes in this.
1. You are right that there is a mistake in the article, this was also extensively discussed in the reddit thread. The chance to hit an imp is equal to the chance to hit any other creature.
2. Card draw: cost doesnt factor in to card draw, but I use C to determine when you need the card. Flamestrike for example has a cost 7 so you have 7+starting hand draws to get flamestrike.
3. Weird rounding: I use random samples from a binomial distribution, bascially I didnt want to code binomial distribution myself, because I didnt want to mess it up. The numpy library has a random number generator based on the binomial distribution. So I just draw 100000 samples from that. That means its an approximation, but a really good one. As you said, the second decimal really doesnt matter.
Welcome to ihearthu!
#2 clears that up. Don’t think that was evident in the article, but that may be my poor reading.
“12 of which hit the one-health. 12/20 = 6/10 = 3/5 = 60%.
For a three health minion however, there are 27 potential outcomes, 19 of which are favourable. 19/27 = 70% chance Mad Bomber hits at least once.”
This logic is wrong. The first scenario only has 20 outcomes, but each outcome is not equally likely. After the bomber hits the 1 health minion, there are only 2 possible outcomes for future shots, each with a 50% chance.
That’s why the math should be as someone else said
1/3 to hit on first shot +
2/3 miss first * 1/3 hit second +
2/3 miss first * 2/3 miss second * 1/3 hit third
It’s 70% to hit one time, no matter how much health the minion has.
[…] original author- madmaxx for ihearthu.com […]
GREAT article! I’d peer-review it if I had the time. Basic-counting-probability and Hearthstone forever, Brother!