PageRank algorithm to predict type usefulness - Question for CAP veterans

Not open for further replies.
Hey everyone. I'm currently trying to use a modified version of an algorithm called PageRank ( to predict mathematically which the best defensive and offensive types will be once the GEN VI metagame stabilizes.

Essentially, a good defensive type has resistances (especially to good offensive types) and has few weaknesses (especially not to good offensive types). A good offensive type is super-effective against other types (especially good defensive types), and is not resisted by many types (especially not good defensive types).

If you read the above definition, you'll see that it's circular. In the same way, when Google is trying to decide the best pages to show you for whatever you typed in the search bar, sites are "good matches" if they are linked to by other "good matches". PageRank is an algorithm that takes the connection data (in Google's case, which pages link to which pages, and in Pokemon, who is weak/resistant to whom) and finds the mathematical equilibrium, depending on the weighting of weaknesses/resistances. That's where you guys come in; I need to figure out how to weight them.

My questions are these:
Say you're designing a bunch of new Pokemon types from scratch.
1. We are concerned with creating a type that is good defensively (we don't care about offense right now). How many resistances are worth one weakness? (Assume that the types that you would be weak/resistant to are equally good).

2. We are going to give this defensive type either one immunity or some number of resistances. How many resistances are worth one immunity (again, if all the other types are equally good)?

3. We want to give this type an additional immunity. How many weaknesses would we have to add to balance out an immunity?

4. Now, we care only about the type's offensive capability. What's better: having another type resist it and a third be weak to it, or having both types be neutral to it? If it's better for them to be neutral, how many types weak to it would balance out one type resisting it? If not, how many types resisting it would balance out one type being weak to it?

5. How many types would have to resist the attacking type to be as bad as one type being immune to it?

6. How many types would have to be weak to it to balance out one type being immune to it?

If you feel any of these questions would best be answered with a fraction, please do so. For instance, a good answer to number 1 would be "3 resistances balance out 2 weaknesses," or "1.5 resistances are worth one weakness".

I posted this in CAP because you guys do a lot of playtesting and balancing. Although you haven't added a new type (yet), I feel that you're in the best position to answer my questions.

Thanks for your help!
Is the PageRank algorithm publicly available? Since it's made the owners of Google among the richest people on the planet, I would have thought they would have kept it a trade secret.

EDIT: oh, it's a modified version. Ignore me.
Last edited:
PageRank is a pretty simple, generic algorithm; Google presumably uses a proprietary version that is complex and built to deal with all the specific issues that arise from trying to rank web pages specifically.


Was fun while it lasted
is an Artist Alumnusis a CAP Contributor Alumnusis a Contributor Alumnusis a Smogon Media Contributor Alumnus
I'm not exactly a fantastic mathematician, but just looking at what you have so far, your questions are fairly hard to answer in a vacuum as all the different types have different distributions, power, and individuals of that type which kind of wreck the assumption that all types are equal. Assuming that all types were, in fact, equal, then naturally one resistance is worth one weakness. Immunity is harder to model since it also has to take into account immunity to status - Poison-types being immune to Toxic, Grass-types being immune to Spore, that sort of thing - but I suppose it's reasonable to say that, if we ignore the above, there are two resistances to one immunity, since in terms of raw damage a 4x resistance tends to be an effective immunity anyway. In terms of offensive moves, generally it is better to have both types be neutral to it IF it is a STAB move, but to have one weakness and one resistance if it is a coverage move - your assumption that the best offensive moves are those that necessarily have more super effective coverage to resistances is not necessarily correct. Again, immunity is affected by whether or not the attacking type has STAB - mono-attackers such as Dragonite were great in BW, but now that Fairy is immune to Dragon, the type is far less valuable. This is much less relevant if the attacking type is a coverage move, since the point is to hit something super effectively; some other type being immune to it does not matter. Other factors are also relevant, such as access to STAB priority or conflicting STAB types - Fighting/Ground shares much of its super effective coverage, for example.

If you're interested, X-Act was working on something a bit like this before he left, in that he was trying to provide a mathematical system of rating for all possible typings to predict what the best ones would be, where the worth of defensive typings (plus, I think, the effects of resistance/immunity abilities) is judged by the average damage output of the moves of each type. It's not perfect, and it doesn't say anything about offensive typings (given the effects of coverage moves as stated earlier introduce complications) and it would need to be updated to XY (and indeed BW) to be relevant now, but it's a nice thing if you're wondering what's been done on the subject here before.

For the record, we don't ever intend to add a new typing - that would be interfering with the existing mechanics in a way that we have decided to no longer countenance.


fudge jelly
Since a lot of your questions are pretty similar and I don't feel you've provided enough information for me to give an informative answer, I'm going to give my general opinion on all of your questions at once.

1. We are concerned with creating a type that is good defensively (we don't care about offense right now). How many resistances are worth one weakness? (Assume that the types that you would be weak/resistant to are equally good).
This is a tough question to answer because it depends on the stats and moveset of the Pokemon in question. Bulky Pokemon tend to value not having weaknesses while flimsy Pokemon tend to value having resistances. For instance, a wall like Chansey doesn't really care so much about whether or not it resists Ice or Fire type moves because it's going to easily tank them anyways. It really doesn't want to have to deal with more weaknesses than Fighting, however. On the other hand, a flimsy sweeper like Cawmodore which has to sack half of its health to set up would love having more moves it could set up on even at the cost of having more weaknesses. I feel like this holds true no matter what type you're talking about and this tradeoff happens accordingly.

For a bulky Pokemon like Chansey, I'd say that at least 3-4 resistances would balance out one weakness. For a flimsy attacker like Syclant or Lucario (yes, it's flimsy by CAP standards), I'd go with a 1-1 ratio. The Fairy type as a whole is a good example of Nintendo being aware of this, as it only has two relatively uncommon weaknesses due to primarily being made up of bulky, specially defensive Pokemon. If it was a more offensive type, like Ice or Dragon, I imagine it would have a lot more common weaknesses like Rock or Fighting types to deal with.

So first come up with what kind of Pokemon archetype you want your type to lean towards, and then I can give you a more precise ratio.
I tried to take a crack at this and immediately noticed that dual type combinations are necessary and that this would take me several days to do the math for just one single type. to accurately do this you must solve every type at the same time including all the double and single types for both offense(for single types and flying fighting) and defense. This is ignoring all the questions you brought up. on top of this you have to decide how effectiveness would change the effect of a page rank.

Overall, despite how having this done would be cool and helpful and interesting, we would need the brainpower of all competitive battlers in existence or several supercomputers to do it in a timely manner. It just isn't plausible. yet.
This interests me, but I think it's hard to do. The weighting is not obvious, even if you have access to showdown statistics.

Anyway, I wrote a little script for fun to rank the type combinations based on someone arbitrary criteria. It's not great, but I think it will be interesting to compare my results to yours. Here's the outcome:

Physically defensive typing:
Specially defensive typing:
(sorry if I'm not allowed to post this here)
Last edited:
It's not clear what is a better type here I assume positive is better than negative higher is better? and what was your formula, just curious because
i am still trying to figure out how to make it accurate instead of generally spitting out seemingly random values. and are you taking into account the general stats of said types and type attacking them. good Idea splitting special and physical but it seems worrying that you do not ave attacking type yet because they effect each other and my understanding is that you repeat a formula until it evens out to stay about the same for all values.
The simple version of the formula is "the ranking of a defensive type is the number of resistances minus the number of weaknesses". Of course, it's slightly more complicated than that though: I weighted attacking types and also weighted 4x much higher than 2x.

Here's the crappy program if you want to mess with it:

The biggest problem with this method is that is doesn't understand relationships between attacking types, only their overall usage. For instance, [Flying,Poison] is ranked high because it resists fighting and ground, despite being weak to edgequake and elemental punches.

It works really well for finding specific counters to individual Pokemon though. For instance, it ranks
[Rock,Ghost] as the best counter to double bird, [Grass,Dragon] as the best Rotom Wash counter, and [Water,Poison] as the best Azumarill counter. All of these are very good choices.
The biggest problem with this method is that is doesn't understand relationships between attacking types, only their overall usage. For instance, [Flying,Poison] is ranked high because it resists fighting and ground, despite being weak to edgequake and elemental punches.
I would imagine you could take the weighted average power of physical/special moves in OU, set that equal to the offensive type rank, and that would give you a closer answer. As an example, Landorus-Therian sees play on 28.38% of teams 1695 or greater. He carries Earthquake on 100% of his sets, and Earthquake has 100 power, Thus, 0.2838*1.00*100 = 28.38. Thus Landorus alone contributes 28.38 to the offensive rank of Physical Earth moves. Apply this over all pokemon in OU, and you should have a pretty accurate representation.


JAPE Judge! New JAPE for Christmas!
is a Community Contributor
Though I'm not a veteran, thought I'd just point out something. I think context would play a pivotal role in what types it would be able to be defensive against. Like you can lay down a list of types a Pokemon to be resistant/weak/immune to, but then you got to name that type. Simply put, I think creating a new type you can't really rely on math.

For example, let's use the Fairy-type. Dragon-type were dominating the metagame and GameFreak wanted to add another type to nerf them. That's 1 type which they were only thinking about countering. So GameFreak thought and did some research and created the Fairy-type since Dragons are often slayed in fairytales (at least I think that was the reasoning. I guess also in some tales Dragons were probably only vulnerable to magic but I would imagine a Magic-type is a bit obtuse so focused on a magical creature). So now that they have this Fairy-type, how would the fairy's react to the other types? After some more research and possibly balancing decisions, we have the Fairy-type we know today.

Of course there are sometimes strange type choices which were probably made for balancing reasons, but I think for the most part the type chart makes sense.
This is an extremely interesting subject and I hope some good results can start coming forward!

I would strongly recommend looking into the methods that sports analysts use to come up with Power Rankings. The number one goal there is to find a mathematical model that agrees with reality: hopefully when you feed data in from last season your rankings end up producing good matches with the real playoff winners. If this is the case with many seasons from the past then you could feel pretty confident in using your model for sports gambling on future games. This is very much related to your issue because a lot of circular reasoning goes on: especially with comparing offenses vs defenses and strength of schedule.

You absolutely NEED to come up with justifiable and useful weightings in your type rankings. Resisting dragon is far far more useful than resisting psychic for example. You'll have to pull usage stats into your calculations. And furthermore common coverage moves! The aforementioned dragon resistance isn't all that stellar if you're also, say, 4x weak to ground moves; dragons almost always have earthquake! Similarly, resisting electric isn't necessarily great if you're 4x weak to ice.

This is definitely no simple matter but I think there's plenty of room for useful data in this otherwise underdeveloped field.
Not open for further replies.

Users Who Are Viewing This Thread (Users: 1, Guests: 0)