Possible Improvment for IV Calculation

  • 23
    Posts
    20
    Years
    • Seen Oct 22, 2008
    This only deals with providing the Hidden Power Type. My IV Calculator does take this into consideration, but it seemed to only have a small impact. I just calculated the type by cycling thru all the currently valid IVs. If a particular IV didn't show up from the calculations, then I knew it was invalid.

    However, I just noticed something that may make quite a difference. Since the type is in part determined by the evenness or oddness of an IV, we can eliminate whole sets. However, each power of 2 that gets produced has less and less of an impact, so only a few stat types will see a huge reduction in IVs:

    int t1 = GetHiddenPowerTypeNumber(hpIV, 0);
    int t2 = GetHiddenPowerTypeNumber(attIV);
    int t3 = GetHiddenPowerTypeNumber(defIV, 2);
    int t4 = GetHiddenPowerTypeNumber(speedIV, 3);
    int t5 = GetHiddenPowerTypeNumber(spaIV, 4);
    int t6 = GetHiddenPowerTypeNumber(spdIV, 5);

    privateint GetHiddenPowerTypeNumber(int iv, int power)
    {
    if (iv % 2 == 1)
    return (int)Math.Pow(2, power);
    else
    return 0;
    }

    Special Defense will almost always have it reduced one way or the other. Since the equation does this:

    int hpTypeValue = (int)Math.Floor((double)((t1+t2+t3+t4+t5+t6) * 15 / 63));

    And these are the correlating types:

    switch (hpTypeValue)
    {
    case 0 :
    hpType = 5; //Fighting
    break;
    case 1 :
    hpType = 7; //Flying
    break;
    case 2 :
    hpType = 13; //Poison
    break;
    case 3 :
    hpType = 10; //Ground
    break;
    case 4 :
    hpType = 15; //Rock
    break;
    case 5 :
    hpType = 1; //Bug
    break;
    case 6 :
    hpType = 8; //Ghost
    break;
    case 7 :
    hpType = 16; //Steel
    break;
    case 8 :
    hpType = 6; //Fire
    break;
    case 9 :
    hpType = 17; //Water
    break;
    case 10 :
    hpType = 9; //Grass
    break;
    case 11 :
    hpType = 4; //Electric
    break;
    case 12 :
    hpType = 14; //Psychic
    break;
    case 13 :
    hpType = 11; //Ice
    break;
    case 14 :
    hpType = 3; //Dragon
    break;
    case 15 :
    hpType = 2; //Dark
    break;
    default:
    // Let it return -1
    break;
    }

    We know that the first 0-6 MUST have the SpD be even because otherwise it would already go past their base numbers... Just like we know that numbesr 8-15 MUST have the SpD be odd because otherwise it wouldn't be able to reach that high of a number. 7 (Steel) is the only type that could end up either way. These are all the number I've compiled. I don't know if I can further add to this list, but it seems promising:

    Stat | IV Must Be This | case #
    SpD | Even | 0-6
    SpD | Odd | 8-15
    SpA | Even | 0-2
    SpA | Odd | 12-15
    Speed | Even | 0
    Speed | Odd | 14-15
    Def | Odd | 15
    Att | Odd | 15
    HP | Odd | 15

    If the type ends up being Dark, then we know all IVs must be an Odd number. The opposite (even) isn't the case for Fighting because Math.Floor messes things up.

    At any rate, I was hoping some people might help me take a deeper look into this because we may be able to find some more specific cases that might occur. Thanks!
     
    Could you post the source for this program as an attachment?
     
    show some examples.... that is just a big blob of words.
     
    It is part of v5.00 of my program, which is far from done yet. I've got a bunch of different combinations figured out now, but there must be some way to program it instead of hardcoding tests.

    As for examples... That is what that 0-6, 8-15 thing is. I'll explain it further.

    If the hidden power type is Fighting, Flying, Poison, Ground, Rock, Bug, or Ghost, the Special Defense IV has to be 0, 2, 4, 6, 8, 10, 12, ... 28, or 30. If the hidden power type is Fire, Water, Grass, Electric, Psychic, Ice, Dragon, or Dark, then the Special Defense IV has to be 1, 3, 5, 7, 9, 11, 13... 27, 29, or 31.

    This may seem insignificant, but I have found some more patterns now. For instance, lets say that you have a hidden power type of Flying. (You know this from fighting a Kecleon or a combination of Pokemon.) If all the possible IVs for Speed are odd, then we know that all the Defense, Attack, and HP IVs must be even. This is because of the equation:

    Math.Floor((t1+t2+t3+t4+t5+t6) * 15 / 63), which can be reduced to Math.Floor((t1+t2+t3+t4+t5+t6) * 5 / 21).

    In order to have a hidden power type of Flying, you must have a total point count between 21 and 41 (inclusive). 21/21 = 1 and Math.Floor(41/21) = 1. Where are the point counts coming from? Well:

    t1 is HP
    t2 is Att
    t3 is Def
    t4 is Speed

    If each of these IVs are odd, then t1 is worth 5, t2 is worth 10 and t3 is worth 20, t4 is worth 40. If all the Speed IVs are odd, that would be worth 40 points. 41 - 40 = 1. That means that if you try to use any of the other IVs as odd, it would go above 41, meaning it would no longer be hidden power type Flying. Thus, we know all of those have to be even because otherwise it would break the equation.

    That help? :)
     
    Back
    Top