As a result of working on upgrades for this Pokémon Effort Value Calculator, math has been a pretty big part of my life for the past few months, as I’ve been rearranging the games’ formulas for stat and damage calculation to make my own that fit my needs.
One such formula was the EVs needed one, which gives you the amount of EVs you need to invest to raise a stat by n points. Everyone knows that at Level 100, you get 1 stat point for every 4 EV points you invest; but what happens when you’re not at Level 100, or when you factor in stat modifiers like Nature, or item and ability boosts?
Don’t know what effort values are? Start with this article from Bulbapedia. Don’t play the mainline Pokémon games? Then you should start with these.
The stat formula
A good starting point for this would be the stat formulas below — they determine a Pokémon’s stat at any given time. The formula for determining the HP stat is slightly different from the other stats.
As an aside, it’s interesting to note that the HP stat formula can be simplified into this:
This reorganisation makes the formula harder to read, but can actually allow your code to be more concise, because this makes it possible to combine both stat formulas:
Article continues after the advertisement:
Pulling out the EV portion
The math that we were doing above actually have nothing to do with calculating needed EVs to raise a stat — it was just some interesting trivia. Let’s get to what you came here for.
First, let’s reorganise the fractional part of the stat formulas, so it becomes clear how the Base, IVs and EVs affect the stat:
Since we are most concerned about the EVs, let’s examine that portion first and add in the rest of the formula as we go along:
We have to reorganise the formula so that EV
alone ends up on one side.
We need to break the floor operation to isolate EV
on the right-hand side, which is tricky. Let’s ignore the floor operation for a moment:
The floor operation basically makes it so that any remainder of the EV value after being divided by 4 is discarded. This means that, to move the floor operation to the other side, we have to round the result up to the nearest multiple of 4:
Cleaning up our formula and making it more presentable:
Factoring in IV contributions
If you’re a competitive Pokémon player, you might be aware of this little quirk when it comes to EV-ing Level 50 Pokémon (all Pokémon have their Levels set to 50 in a competitive match). If a stat has 31 IVs, it takes 4 EVs to raise the stat by 1 point, then 8 EVs for every subusequent point.
IV stands for Individual Values. You can find out more about what they are in this Bulbapedia article.
This quirk exists because IVs affect how many EVs you need to raise a stat, as we see when we reorganise the stat formula above.
At Level 50, with 31 IVs, you will get the following stat contribution:
If you refer to the stat formula again, you’ll see that the stat total is not rounded down until the base stat, IVs and EVs are totalled. That means that the decimal portion of the IV reduces the amount of EVs you’ll normally need to raise the stat.
Let’s rewrite this so that we can see their stat contributions more clearly:
At Level 50, with 31 IVs and (for example) 12 EVs invested, we will get the following:
Essentially, 12 EVs give us 1.5 points of stats, which total up with the stats from 31 IVs (15.5) to give us 17 points of stats. If we don’t fill up the .5 stat from the 31 IVs with EVs, it will be rounded down and wasted. This is why the calculator often recommends a spread of 244 HP / 4 Def / 4 SpD instead of 252 HP — you are essentially getting your first stat point at half the EV cost.
How do we factor this into our EVs needed
formula? Remember that we only care about the fractional part of the IV contribution (i.e. the part after the decimal point).
Note: { and } in the formula mean we only take the fractional part. For e.g. { 4.5 } = 0.5.
Article continues after the advertisement:
Factoring in base stat contribution
Your Pokémon species’ base stat actually affects your EV cost too, similar to how IVs do. It’s just that at Level 50, the formula always works out in such a way that base stats always end up without any fractional part.
At Levels outside of 50 and 100, however, the base stat contribution can create a fractional part. For example, at Level 32 with a base stat of 70:
Which means we have to factor this into our formula too.
Fun fact: There have been official online Pokémon tournaments that were held with Pokémon set to Levels outside of 50 and 100; but it was a long time ago.
Factoring in existing EV contribution
If you’ve already got existing EV investment in a stat, you’ve got to factor that in too. You should know the drill by now.
Since the formula is getting a little unwieldy, let’s also reorganise and simplify it:
Factoring in nature and other modifiers
If a stat is affected by Nature or other modifiers, you are going to have work that into the formula too. It may sound complicated, but since stat modifiers multiply into the stat, we just have to divide them from the stat in the formula.
We also have to round the result of the division up, since stats are normally rounded down after modifiers are applied.
The final formula
Here is the final formula for calculating how many EVs you need to raise a stat by a specific number of points.
Gotta say, I’m pretty proud of working this out on my own. Nonetheless, please feel free to point out any errors or mistakes in the comments section!
Thank you for this, incredible work! I’m making a Speed calculator spreadsheet, and was always just a few EVs off—your write-up helped me realize I have to round up instead of truncating :)