Optimize EVs for a goal
optimize_evsDerive a minimal EV spread to survive a named attack, outspeed a target, and/or guarantee a KO in 1-4 hits. Leftover EVs go to a chosen stat; returns stats, totals, and verification.
Instructions
Derive a minimal EV spread for one Pokémon satisfying up to three goals: survive a named attack, outspeed a target Speed, and guarantee a KO in 1-4 hits. Use it when EVs must come from a goal — calculate_stats evaluates a spread you already have, check_speed ranks Speed without deriving EVs, and get_set returns a curated spread. Supplying none of survive/outspeed/kill errors; outspeed takes a set target or a raw speed, and leftover EVs fill maximize (default spe). Returns the spread, resulting stats, totalEVs/unusedEVs of the 508 usable, and a verification line per goal. Read-only and offline; an unreachable goal returns an isError.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ivs | No | IVs to hold fixed while searching, keyed by stat id; omitted stats default to 31 (use 0 for a Trick Room Speed IV). | |
| item | No | Item held while solving, e.g. "Assault Vest"; it changes the bulk or Speed the goals are tested against. | |
| kill | No | Add a KO goal: minimizes Atk or SpA so that even the lowest damage roll reaches the per-hit HP threshold. | |
| field | No | Battlefield conditions applied while testing the survive and kill goals; omit for a neutral Singles field. | |
| level | No | Level 1-100; default 50 (VGC), where bulk and Speed benchmarks are tightest. | |
| nature | No | Nature used for every stat calculation, e.g. "Adamant", "Calm"; default Serious. Change it to trade one stat for another. | |
| ability | No | Ability assumed active while solving, e.g. "Intimidate", "Protosynthesis". | |
| species | Yes | Species or form name to optimize, e.g. "Garchomp", "Incineroar". | |
| survive | No | Add a "always live this hit" goal: the search minimizes HP plus the relevant Defense EVs that keep the worst roll below max HP. | |
| maximize | No | Stat that receives leftover EVs after the goals are met, capped at 252 (default spe); EVs are added in steps of 4. | spe |
| outspeed | No | Add an outspeed goal: supply `target` or `speed` (one is required here, otherwise that goal errors). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| evs | Yes | The solved spread: all six keys, each a multiple of 4 from 0 to 252, with the `maximize` stat holding the leftover EVs. | |
| item | No | Held item assumed while solving, as supplied; absent when the call gave none. | |
| note | Yes | Caveat about how the spread was built: EVs come in steps of 4 (508 usable of 510), the maximize stat is capped at 252, and unused EVs can be reallocated by hand. | |
| level | Yes | Level every stat was computed at, 1-100. | |
| stats | Yes | The six stats this exact spread reaches at this level and nature; recompute with `calculate_stats` to check a different spread. | |
| nature | Yes | Nature the spread was solved with, e.g. "Adamant"; Serious when the call omitted one. | |
| species | Yes | Canonical species name the spread was solved for. | |
| totalEVs | Yes | Sum of the six solved EVs, spent in multiples of 4 so 508 is the practical maximum. | |
| unusedEVs | Yes | EVs left over after the goals and the maximize step: 508 minus `totalEVs`, never negative. | |
| verification | Yes | One line per goal that was solved, e.g. "survive: Dragapult Dragon Darts -> 96-114 vs 175 HP (max 65%)" or "kill: 132 ATK EVs -> 187-221 vs 175 HP (min 100%)"; the evidence that the spread meets each goal. | |
| championsPoints | Yes | The spread as Pokémon Champions stat points (whole numbers, at most 32 in a stat, 66 total) — what the game’s training screen takes; stats left uninvested are omitted and a maxed stat reads 32. The two systems budget differently (510 EVs against 66 points), so a spread trimmed to fit the EV cap reads back a point or two under what was asked: this is the nearest point spread for the stats actually computed, not a copy of the input. |