1. New to the forums? Check out our Mentorship Program!
    Our mentors will answer your questions and help you become a part of the community!
  2. Welcome to Smogon Forums! Please take a minute to read the rules.

PageRank algorithm to predict type usefulness - Question for CAP veterans

Discussion in 'Create-A-Pokémon Project' started by dann7686, Dec 16, 2013.

  1. dann7686

    dann7686

    Joined:
    May 17, 2013
    Messages:
    3
    Hey everyone. I'm currently trying to use a modified version of an algorithm called PageRank (http://en.wikipedia.org/wiki/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!
  2. noobcubed

    noobcubed

    Joined:
    Jun 9, 2013
    Messages:
    643
    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: Dec 16, 2013
  3. dann7686

    dann7686

    Joined:
    May 17, 2013
    Messages:
    3
    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.
  4. bugmaniacbob

    bugmaniacbob Floats like a Butterfree, stings like a Metapod
    is a Smogon Media Contributoris an Artist Alumnusis a CAP Contributor Alumnusis a Contributor Alumnus

    Joined:
    Sep 19, 2008
    Messages:
    2,295
    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.
    Luigifan likes this.
  5. Vryheid

    Vryheid fudge jelly

    Joined:
    Oct 15, 2013
    Messages:
    156
    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.

    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.
  6. finnaggann

    finnaggann

    Joined:
    Apr 5, 2014
    Messages:
    46
    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.
  7. poonta

    poonta

    Joined:
    Oct 3, 2013
    Messages:
    6
    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:
    Code:
    (49.530003,[Flying,Steel])
    (29.100002,[Ghost,Dark])
    (28.149998,[Flying,Ground])
    (26.099998,[Ghost,Fairy])
    (24.550007,[Ghost,Water])
    (23.95,[Normal,Ghost])
    (23.05,[Ground,Ghost])
    (20.399998,[Water,Fairy])
    (19.95,[Ghost])
    (19.55,[Fighting,Ghost])
    (16.55,[Flying,Poison])
    (15.050003,[Fighting,Flying])
    (14.4,[Ground,Water])
    (14.100002,[Flying,Electric])
    (14.030001,[Ghost,Steel])
    (11.149999,[Ground,Fairy])
    (8.700003,[Flying,Ghost])
    (7.450001,[Flying,Water])
    (7.3800006,[Bug,Steel])
    (7.18,[Psychic,Fairy])
    (6.1500053,[Ghost,Dragon])
    (4.95,[Fairy])
    (4.9000015,[Flying,Fairy])
    (4.6000004,[Water])
    (3.179998,[Steel,Fairy])
    (3.0999994,[Ground])
    (0.1500001,[Dragon,Fairy])
    (-4.9999237e-2,[Flying])
    (-1.75,[Ghost,Grass])
    (-3.0,[Water,Dragon])
    (-3.449998,[Ghost,Electric])
    (-4.5,[Normal,Fairy])
    (-4.75,[Fighting,Fairy])
    (-5.1,[Fighting,Water])
    (-6.600001,[Fighting,Ground])
    (-6.8500004,[Fighting,Psychic])
    (-7.119999,[Flying,Psychic])
    (-7.5999994,[Electric,Fairy])
    (-7.949999,[Dark,Fairy])
    (-8.67,[Water,Psychic])
    (-9.5,[Normal,Flying])
    (-9.7,[Fighting])
    (-10.17,[Ground,Psychic])
    (-10.250001,[Ground,Dragon])
    (-10.450001,[Ground,Bug])
    (-10.569998,[Ghost,Psychic])
    (-10.650002,[Poison,Ghost])
    (-11.349999,[Poison,Fairy])
    (-12.950001,[Flying,Dark])
    (-13.250004,[Poison,Water])
    (-13.27,[Psychic])
    (-13.8,[Dragon])
    (-14.100001,[Grass,Electric])
    (-14.75,[Poison,Ground])
    (-15.799999,[Flying,Dragon])
    (-16.300001,[Poison,Grass])
    (-17.1,[Water,Grass])
    (-17.250002,[Water,Electric])
    (-17.599998,[Fighting,Electric])
    (-19.400002,[Poison])
    (-19.519999,[Steel,Grass])
    (-20.47,[Normal,Psychic])
    (-21.0,[Flying,Rock])
    (-21.000002,[Ground,Electric])
    (-21.390001,[Steel,Psychic])
    (-22.999998,[Bug,Electric])
    (-23.349995,[Grass,Fairy])
    (-23.4,[Electric])
    (-24.35,[Ground,Grass])
    (-25.85,[Poison,Psychic])
    (-26.7,[Fighting,Poison])
    (-27.0,[Fighting,Dragon])
    (-27.07,[Psychic,Dragon])
    (-28.299995,[Poison,Dark])
    (-28.75,[Rock,Ghost])
    (-28.8,[Psychic,Dark])
    (-28.849998,[Normal,Poison])
    (-29.599995,[Fighting,Steel])
    (-29.650002,[Normal,Water])
    (-29.87,[Steel,Water])
    (-30.100004,[Poison,Dragon])
    (-30.65,[Bug,Water])
    (-30.999998,[Grass])
    (-31.149998,[Normal,Ground])
    (-31.150002,[Bug,Ghost])
    (-32.77,[Ground,Steel])
    (-34.25,[Normal])
    (-34.5,[Poison,Bug])
    (-34.85,[Ground,Fire])
    (-34.9,[Ghost,Ice])
    (-34.95,[Bug,Fairy])
    (-36.67,[Electric,Psychic])
    (-37.2,[Electric,Dragon])
    (-37.419994,[Steel,Dragon])
    (-38.0,[Flying,Grass])
    (-39.119995,[Steel])
    (-39.29999,[Water,Dark])
    (-39.899998,[Bug])
    (-40.799995,[Ground,Dark])
    (-42.3,[Fighting,Bug])
    (-43.899998,[Dark])
    (-43.949997,[Ghost,Fire])
    (-43.95,[Normal,Fighting])
    (-45.2,[Grass,Dragon])
    (-45.699997,[Fighting,Fire])
    (-48.049995,[Normal,Dragon])
    (-48.1,[Fire,Fairy])
    (-49.35,[Normal,Bug])
    (-50.0,[Fighting,Dark])
    (-50.599995,[Bug,Dragon])
    (-51.269997,[Grass,Psychic])
    (-51.999996,[Fighting,Grass])
    (-52.849995,[Flying,Fire])
    (-53.170002,[Bug,Psychic])
    (-53.45,[Rock,Bug])
    (-54.599995,[Fire,Grass])
    (-54.649998,[Fire,Water])
    (-57.649998,[Normal,Electric])
    (-58.999996,[Bug,Dark])
    (-59.85,[Ground,Ice])
    (-61.199993,[Dragon,Dark])
    (-62.499996,[Poison,Steel])
    (-62.7,[Rock,Fairy])
    (-63.149998,[Rock,Grass])
    (-63.899994,[Fire])
    (-65.25,[Normal,Grass])
    (-66.49999,[Rock,Water])
    (-67.3,[Electric,Dark])
    (-68.399994,[Fire,Dragon])
    (-70.8,[Poison,Electric])
    (-70.96999,[Fire,Psychic])
    (-71.770004,[Rock,Psychic])
    (-72.299995,[Water,Ice])
    (-73.35,[Ice,Fairy])
    (-75.75,[Fighting,Ice])
    (-77.5,[Fighting,Rock])
    (-79.149994,[Flying,Bug])
    (-79.32,[Psychic,Ice])
    (-81.90002,[Grass,Dark])
    (-83.299995,[Rock])
    (-85.45,[Poison,Ice])
    (-85.45,[Ground,Rock])
    (-90.52,[Steel,Electric])
    (-90.85,[Ice])
    (-91.0,[Flying,Ice])
    (-91.9,[Bug,Grass])
    (-92.45,[Rock,Dragon])
    (-98.149994,[Normal,Fire])
    (-98.450005,[Ice,Dragon])
    (-98.50001,[Fire,Dark])
    (-101.369995,[Normal,Steel])
    (-102.00001,[Steel,Dark])
    (-103.11999,[Steel,Fire])
    (-103.4,[Electric,Ice])
    (-103.899994,[Bug,Fire])
    (-104.35,[Poison,Rock])
    (-106.850006,[Normal,Dark])
    (-111.299995,[Poison,Fire])
    (-115.299995,[Fire,Electric])
    (-122.25001,[Grass,Ice])
    (-123.85,[Rock,Electric])
    (-125.819984,[Steel,Ice])
    (-137.45001,[Bug,Ice])
    (-145.55,[Normal,Rock])
    (-153.1,[Normal,Ice])
    (-155.20001,[Rock,Dark])
    (-162.75002,[Ice,Dark])
    (-164.32,[Rock,Steel])
    (-166.3,[Rock,Fire])
    (-168.8,[Fire,Ice])
    (-211.3,[Rock,Ice])
    
    Specially defensive typing:
    Code:
    (13.5,[Steel,Dragon])
    (13.099998,[Water,Dragon])
    (12.200001,[Steel,Water])
    (11.400001,[Fire,Water])
    (11.1,[Fire,Dragon])
    (10.7,[Water,Electric])
    (10.55,[Ground,Water])
    (9.400001,[Water,Fairy])
    (8.2,[Water,Grass])
    (8.059999,[Dragon,Fairy])
    (8.0,[Steel,Fairy])
    (7.5,[Electric,Fairy])
    (7.41,[Normal,Fairy])
    (7.35,[Normal,Ghost])
    (7.200001,[Poison,Water])
    (6.96,[Poison,Fairy])
    (6.6000004,[Fire,Fairy])
    (6.5,[Steel,Fire])
    (6.450001,[Normal,Water])
    (6.2,[Fire,Grass])
    (5.76,[Ghost,Fairy])
    (5.400001,[Ghost,Water])
    (4.66,[Fairy])
    (4.55,[Normal,Electric])
    (4.500001,[Water])
    (4.3,[Poison,Dark])
    (4.25,[Normal,Poison])
    (4.06,[Dark,Fairy])
    (4.0000005,[Ghost,Steel])
    (3.65,[Normal,Fire])
    (3.5000005,[Ghost,Electric])
    (3.0500002,[Normal,Steel])
    (3.0,[Steel,Electric])
    (2.9600003,[Psychic,Fairy])
    (2.9499998,[Normal,Psychic])
    (2.9000006,[Bug,Water])
    (2.9,[Ghost,Dark])
    (2.8999991,[Poison,Dragon])
    (2.7000012,[Water,Dark])
    (2.6000004,[Ghost,Fire])
    (2.6000001,[Electric])
    (2.5,[Poison,Steel])
    (2.5,[Steel])
    (2.4000006,[Electric,Dragon])
    (2.1999998,[Fire,Electric])
    (2.0000005,[Water,Psychic])
    (2.0000002,[Poison,Electric])
    (1.95,[Normal])
    (1.8999996,[Fire,Dark])
    (1.750001,[Normal,Dragon])
    (1.6999998,[Fire])
    (1.500001,[Water,Ice])
    (1.5000002,[Poison])
    (1.4000005,[Poison,Ghost])
    (1.2000004,[Steel,Psychic])
    (1.0999994,[Poison,Fire])
    (0.9000002,[Ghost])
    (0.80000067,[Electric,Dark])
    (0.69999933,[Ghost,Dragon])
    (0.5600004,[Ice,Dragon])
    (0.5,[Fighting,Steel])
    (0.3000002,[Steel,Dark])
    (0.2000004,[Poison,Psychic])
    (0.1000005,[Electric,Psychic])
    (-0.13999987,[Fighting,Fairy])
    (-0.19999981,[Dragon])
    (-0.29999948,[Fighting,Water])
    (-0.4000001,[Fire,Psychic])
    (-0.6000004,[Bug,Fire])
    (-0.8499994,[Flying,Steel])
    (-1.1000004,[Fighting,Fire])
    (-1.25,[Ground,Steel])
    (-1.7999997,[Fighting,Electric])
    (-1.7999997,[Dark])
    (-2.0,[Fire,Ice])
    (-2.1400003,[Bug,Fairy])
    (-2.1999998,[Ice,Fairy])
    (-2.35,[Flying,Electric])
    (-2.4899998,[Ground,Fairy])
    (-2.5,[Psychic])
    (-2.6000004,[Bug,Electric])
    (-2.7000003,[Psychic,Dragon])
    (-2.75,[Normal,Dark])
    (-2.8499997,[Normal,Fighting])
    (-3.0,[Bug,Dragon])
    (-3.1,[Fighting,Poison])
    (-3.3999996,[Rock,Water])
    (-3.4999998,[Fighting,Ghost])
    (-3.5499992,[Flying,Fire])
    (-3.6,[Psychic,Dark])
    (-4.05,[Normal,Bug])
    (-4.1000004,[Poison,Bug])
    (-4.2,[Rock,Fairy])
    (-4.3999996,[Electric,Ice])
    (-4.5400004,[Ghost,Ice])
    (-4.7999997,[Fighting])
    (-4.8000007,[Dragon,Dark])
    (-4.8999996,[Grass,Electric])
    (-4.9399996,[Poison,Ice])
    (-5.0,[Ghost,Psychic])
    (-5.04,[Rock,Dragon])
    (-5.2,[Poison,Grass])
    (-5.25,[Poison,Ground])
    (-5.4400005,[Grass,Fairy])
    (-5.7,[Fighting,Psychic])
    (-5.799999,[Steel,Grass])
    (-6.0,[Normal,Ground])
    (-6.589999,[Flying,Fairy])
    (-6.6000004,[Rock,Steel])
    (-6.6900005,[Normal,Ice])
    (-6.8,[Bug])
    (-6.9,[Bug,Ghost])
    (-7.0000005,[Ghost,Grass])
    (-7.049999,[Flying,Poison])
    (-7.0499997,[Ground,Ghost])
    (-7.1499996,[Normal,Grass])
    (-7.2,[Fighting,Dark])
    (-7.24,[Ice])
    (-7.5399995,[Rock,Ghost])
    (-7.54,[Rock,Grass])
    (-7.6499996,[Ground,Fire])
    (-7.7999997,[Fighting,Dragon])
    (-7.7999997,[Bug,Dark])
    (-7.8500004,[Flying,Water])
    (-7.95,[Ground])
    (-8.499999,[Normal,Flying])
    (-8.5,[Bug,Steel])
    (-8.64,[Poison,Rock])
    (-8.94,[Psychic,Ice])
    (-9.1,[Grass])
    (-9.24,[Rock,Bug])
    (-9.299999,[Bug,Psychic])
    (-9.3,[Rock,Electric])
    (-9.49,[Normal,Rock])
    (-9.75,[Ground,Dark])
    (-9.849999,[Ground,Electric])
    (-10.039999,[Rock])
    (-10.440001,[Ice,Dark])
    (-10.449999,[Ground,Psychic])
    (-10.790001,[Ground,Ice])
    (-11.25,[Flying])
    (-11.349998,[Flying,Ghost])
    (-11.6,[Grass,Dark])
    (-11.639999,[Fighting,Ice])
    (-11.739999,[Rock,Psychic])
    (-11.85,[Flying,Dark])
    (-11.9,[Fighting,Bug])
    (-12.299999,[Grass,Psychic])
    (-12.300001,[Grass,Dragon])
    (-12.5,[Steel,Ice])
    (-12.75,[Fighting,Ground])
    (-13.15,[Ground,Bug])
    (-13.24,[Rock,Dark])
    (-13.349998,[Flying,Psychic])
    (-14.200001,[Fighting,Grass])
    (-14.389999,[Flying,Ice])
    (-14.439999,[Fighting,Rock])
    (-14.450001,[Ground,Dragon])
    (-14.85,[Flying,Dragon])
    (-15.099998,[Rock,Ice])
    (-15.65,[Fighting,Flying])
    (-16.0,[Rock,Fire])
    (-16.5,[Flying,Ground])
    (-16.59,[Flying,Rock])
    (-19.34,[Grass,Ice])
    (-20.25,[Flying,Bug])
    (-20.94,[Bug,Ice])
    (-22.55,[Ground,Grass])
    (-23.6,[Bug,Grass])
    (-24.85,[Flying,Grass])
    (-27.09,[Ground,Rock])
    
    (sorry if I'm not allowed to post this here)
    Last edited: Jun 6, 2014
  8. finnaggann

    finnaggann

    Joined:
    Apr 5, 2014
    Messages:
    46
    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.
  9. poonta

    poonta

    Joined:
    Oct 3, 2013
    Messages:
    6
    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: http://ideone.com/dWxaIQ

    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.

Users Viewing Thread (Users: 0, Guests: 0)