The meat of this project was building the application that allows for finding “optimal” spreads. To note, when I say “optimal”, I mean for the scenarios that you as the user will input. There may be cases that you have not considered that will exploit a weakness in the spread that you get, or you may be overvaluing survival against a situation that has too high an opportunity cost for it to justify. For example, Zapdos can survive a +1 Jolly Tyranitar Rock Slide with 236 HP / 248+ Def after Sandstorm damage. This comes at the cost of specializing Zapdos for a role that it is more commonly valued for—threatening Water- and Flying-types—since the significant Def investment is marginally useful at best in serving this role. The application will not be able to decide whether scenarios such as this are worth prioritizing, so use the application at your own discretion. Beyond this point, I will focus discussion on what is seen in the application and what all of the options can do for you.
The Defender
At the very top of the application is a slider that controls the Level of the Defending and Attacking Pokemon. It can be dragged with the mouse or controlled with arrow keys for finer adjustments. Currently, there is no way to consider scenarios involving defenders and attackers that have different levels. This is because it is extremely rare to face Pokemon of different levels than your own in standard competitive play. I recommend that you perform your own calculations with the Damage Calc if you are wanting to experiment with lower-level Pokemon.
Below the “Defender” header, you can pick from any of the 386 Pokemon that are usable in the various ADV formats. You can scroll to find the Pokemon in the alphabetical dropdown list or delete the default Pokemon (i.e. Abra) and type in the Pokemon that you want to examine. When you select a Pokemon, the “Defender Ability” will change to match the abilities that the Pokemon can have. The dropdown can be selected to change the ability to any of the legal abilities of the defender. The ability selected may not always affect damage calculation (e.g. Rock Head, Pressure), but abilities that do affect damage calculation such as Thick Fat and Volt Absorb will function as they do in-game. Some modern-generation abilities may be selectable, but they will not be functional at this time—they may be functional in the future if I decide to expand this project for multiple generations.
There are three checkboxes below the ability. One says “Defender using Hidden Power?”. Selecting this will allow you to change the IVs of the HP, Def, and SpD stats since they may affect the EV calculation later (Atk/SpA/Spe do not affect the calculation and are thus not asked for). You may find this useful if, for example, you are planning to use an Aerodactyl set that has a Hidden Power Flying IV configuration that drops each of its HP, Def, and SpD to 30 IVs. Be sure to lock in your preferred Hidden Power IV configuration before running the rest of your calculations since changing it later may invalidate results that you’ve already obtained. Note that Hidden Power Flying has another IV configuration that allows it to retain 31 IVs in HP, Atk, and Def at the cost of dropping to 30 in SpA, SpD, and Spe.
The next checkbox reads “Leftovers”. This will assume that the defending Pokemon is holding Leftovers, which will add 1/16th max HP chip healing for scenarios that take place over the course of multiple turns. The final checkbox says “Sandstorm”. This will assume that permanent Sandstorm is active and apply 1/16th max HP chip damage at the end of each turn. The app resolves end-of-turn effects such as Leftovers and Sandstorm in the proper in-game order. It knows that Sandstorm damage is applied after the attack and before Leftovers. A resultant spread will only be valid if it survives the full sequence—including a final tick of Sandstorm damage.
Entry Hazards
In ADV, the only entry hazard is Spikes. Spikes can be stacked up to three layers and deal damage to any Pokemon that switches in and is not Flying-type and does not have the ability Levitate (as a shorthand: the Pokemon is “grounded”). (The damage is 1/8 max HP for one layer, 1/6 for two layers, and 1/4 for three layers.) Adding layers will factor the damage into the calculation for surviving the given scenarios.
There is a dropdown menu for “Spikes Timing”. The options are “Switch” and “Revenge”. Switch will assume that the defending Pokemon will be switching into the Spikes and immediately taking the attacks provided. Revenge will assume that the defending Pokemon will switch in after a KO has been dealt. The defender will take Spikes damage and then resolve end-of-turn effects such as Sandstorm and Leftovers. In cases where Sandstorm and Leftovers cancel out, there may not be much difference between the modes, but since Sandstorm affects much of the tier and Leftovers is the most common held item, it is a worthwhile consideration for cases when Sandstorm and Leftovers do not cancel out.
Stat Floors
The “Enable Stat Floors” checkbox allows you to input pre-allocated EVs. There may be situations where you know how much Speed or Attack that your set is required to have. You can input those stats here and use the application to verify that you have enough unassigned EVs leftover to survive the given scenario that you have presented. You can use the + and - signs to move the stats 4 EVs in either direction or delete and type in the investment that you want. If you manually type the number, click Enter afterwards to save the value. You are allowed to type in any whole number between 0 and 252, including non multiples of four, but note that stats are only incremented by every multiple of four EVs.
Additionally, Stat Floors can be assigned for HP, Def, and SpD. This may be useful if you have a particular bulk benchmark in mind that you would like to stress test against other scenarios. For example, say that you know that 8 HP / 0 Def / 188 SpD allows Salamence to survive a -1 Rock Slide from 252+ Atk Tyranitar or a 0 SpA Ice Punch from Gengar assuming that Sandstorm is active. (This is similar to the scenario from Part 2 but requires additional SpD investment to overcome the added Sandstorm damage.) Now you want to see if that spread is capable of surviving a 252+ Atk Metagross Meteor Mash and a 0 SpA Swampert Ice Beam. Input 8 HP and 188 SpD into their respective Stat Floor sections and run a new calculation. If the result doesn’t change, then both scenarios are covered by the spread that was inputted into the Stat Floor.
(It should go without saying, but if you attempt to pre-allocate more than 508 EVs, the app will not be able to return a spread.)
The Attackers
It is not required to enable either attacker—though the application is not very useful if you don’t choose at least one. Physical and special attackers are divided into their own sections. Moves that have fixed damage such as Seismic Toss and Night Shade are selectable in both sections to improve quality of life. Enabling either attacker will pull up dropdown menus for the attacker, which attack they are using, and which ability they have. Like defenders, most abilities will not affect damage calculation, but some such as Pure Power will be functional. Conditional damage-boosting abilities such as Blaze, Torrent, Overgrow, Swarm, and Guts will populate a new checkbox that asks if the ability is active—meaning the condition has been met.
There is a checkbox for adjusting the Atk or SpA IV of the attacking Pokemon in case that Pokemon is using a Hidden Power that affects these stats. (Note: Hidden Power can affect other stats, but those stats are not relevant to this calculation.) Additionally, there are checkboxes that correspond to possible held items that the Pokemon may have that will affect the damage calculation. The items will only populate if the move selected will have its damage affected. For example, a Marowak using AncientPower will have the opportunity to select among three different items: Choice Band (since AncientPower is physical), Hard Stone (since AncientPower is a Rock-type move), and Thick Club (since it is Marowak’s signature item). Choosing any one of the possible items will cause the other item checkboxes to disappear to avoid stacking otherwise unstackable damage modifiers.
If the move is a multi-hit move, a slider will appear that asks how many hits of the multi-hit will land. Any whole number from 1 to 5 is selectable.
Below the checkboxes, there will be a ticker box that asks for how many attacks are used. This corresponds to how many turns in a row an attack will land on the defending Pokemon to check the minimum invested to avoid a chance of a XHKO, where X is the number you entered (e.g. 3 checks for a spread that no longer has a chance to be 3HKO’d without crits). Leftovers and Sandstorm interactions can be considered between each of these hits depending on whether these options were selected earlier. Attack Stage corresponds to the stage of boosts that the attacking Pokemon has on their relevant attacking stat. For example, if the defending Pokemon is Salamence, you may want to set the physical attacking Pokemon’s stage to -1 to reflect Intimidate. Alternatively, if a Suicune has set up to +6 with Calm Mind, you may input that to see how much Salamence needs to survive the incoming Surf.
There is an EV slider which will set the attacking Pokemon’s investment in their attacking stat. The default is 252 but can be set to any multiple of 4 between 0 and 252. Also, the nature can be selected in a dropdown menu. The options are +, Neutral, and -. The default is +.
After all of the defender and attacker options have been configured, there are two more options. One is to allow defensive natures to be considered when calculating the optimal EV spread. The application will test defensive natures and pick whichever one minimizes total EV expenditure. The second option is to “Combine Physical + Special”. This will attempt to find a spread that allows the defender to survive the physical hit sequence and then the special hit sequence together. Right now, the code cannot cleanly handle one specific edge case: if the defender is faster and KOs the first attacker, it might take an extra tick of Sandstorm damage or Leftovers healing that cannot currently be accounted for. Because of this, I recommend that you use this feature with extra scrutiny.
Results
Clicking the Calculate button will provide a “Results” section. We’ll use the Tyranitar vs Metagross and Suicune example from Part 2 to provide an example of how the Results might look. We will assume that Tyranitar only has to survive one Meteor Mash or one Hydro Pump, no Spikes are on the field, no Stat Floors are selected, none of Tyranitar’s IVs have been affected, and defensive natures are not allowed to be assigned to Tyranitar. A screenshot of this scenario will be included below.
Sure enough, the calculator agrees with our by-hand calculation from earlier. The first result is the 232 HP / 8 Def spread that I mentioned in Part 2. The “Total Defensive Investment” has been summed to 240 EVs. Additionally, there is a skeleton of a Showdown import in case you want to copy this spread into your builder. Only information that has been given such as the item (i.e. Leftovers), ability, and calculated EVs will be reported. A nature is also reported, but it defaults to Hardy for defensively-neutral natures (Bold for +Def and Calm for +SpD). Change this nature at your own discretion, but note that natures that positively or negatively impact Def or SpD may deviate from the intended optimization of the spread.
You may notice that additional results populate. In this case, the calibration rule spread of 224 HP / 16 Def and a third spread of 208 HP / 24 Def / 8 SpD have been reported. Both of these spreads also only have a Total Defensive Investment of 240 EVs. You might decide to pick one of these spreads for specific purposes, but in general, the higher HP investment variant is preferred and defaults to the top of the results.