In the last blog post, we learned how to make the best plays irrespective of what the opponent chooses to do. To make this work, it was necessary to look at a payoff-matrix listing all the possible moves that could happen. But what if you are unsure of what moves are even available to your opponent? There are thousands of possible move sets. How do you decide which one she is most likely to use?

You can obtain a good first guess by looking at some usage statistics (like those for the Battle Spot Single format). This information is called a prior in mathematical terms. Of course, you should always update your guesses once you obtain new information. So if you see a team with Charizard and Hippowdon in the team preview, you can be a little bit more confident that the Charizard will be a Charizard Y because Hippo is often paired with Charizard Y to reset its weather.

By using Baye’s theorem, you can calculate how much you should adapt your predictions to new evidence:

Let’s go through an example of how to use this formula. Please imagine the following situation:

You have your Ferrothorn out against the opponent’s Greninja. Greninja can only beat your Pokemon if it carries the move Hidden Power Fire. If it has this move you should switch out, otherwise, you should stay in and attack. Luckily your Ferrothorn carries the move Protect so you can scout for the opponents move by protecting your Pokemon for one turn. You do this, and the Greninja attacks with Dark Pulse. But the opponent could be trying to hide his Hidde Power Fire move. How sure can you be now that he really does not have it? Let’s plug the numbers into the formula:

P(A|B) is the probability that the Greninja has Hidden Power Fire in spite of observing that it attacked with Dark Pulse. We want to calculate this.

P(A) is the probability of Greninja having the Hidden Power Fire move (given no evidence indicating otherwise). We can look that up: It’s ~20%.

P(B) is the probability of Greninja attacking with Dark Pulse in this situation.

P(B|A) is the probability of Greninja attacking with Dark Pulse, given that it also has Hidden Power Fire.

Often it’s more natural to just reason about the quotient P(B|A) / P(B). How much more likely/unlikely is it that Greninjna attacks with Dark Pulse if it also has Hidden Power Fire? This ratio is tough to calculate precisely, as it depends on the play style of your opponent. But it’s possible to make pretty accurate guesses if you witnessed situations like that in the past and were able to learn from them. So if you think that the ratio in our example is 1/2, then you would arrive at 1/2 * 20% = 10% likelihood of Greninja having Hidden Power Fire.

Not calculating P(A|B) directly but thinking of P(A|B) as Prior * Evidence might help you avoid some mistakes:

**1.) Avoid base rate neglect**: Try not overreacting to evidence. If you see a Garchomp use Toxic on your Heatran, that’s evidence that it does not have Earthquake, but it’s still improbable as 98.9% of Garchomps carry this move.

**2.) Always try to imagine alternative explanations for your opponent’s behaviour**. He switched in Volcarona on your Landorus’ Earthquake? Sure, that’s pretty good evidence that this Volcaron has Hidden Power Ice and maybe even a Choice Scarf. But it could also be a trick to scare you out and set up with Quiver Dance. Or perhaps your opponent predicted that you would click U-Turn instead of Earthquake last turn?

This post took me a long time to write as I struggled a little bit to make using Bayes’ Theorem for Pokemon sound useful. The next (and last) blog post in this series will be about game tree pruning and will hopefully be a little bit easier to apply

Pingback: The math behind competitive Pokemon, Part 3: Nash Equilibria | Niklas Riewald