diff --git a/.github/workflows/cpp-ci-serial-programs-base.yml b/.github/workflows/cpp-ci-serial-programs-base.yml index 150c3f6e37..ba282b0a9a 100644 --- a/.github/workflows/cpp-ci-serial-programs-base.yml +++ b/.github/workflows/cpp-ci-serial-programs-base.yml @@ -392,9 +392,9 @@ jobs: uses: actions/checkout@v7 if: inputs.run-tests with: - # The fork's fixtures: upstream's, the SystemKeyboardDetector and HomeTileReader screenshots and pending FRLG image submissions (Fly landing, party menu, Route 21 battle, Pokemon Mansion 1F and B1F hold frames, and the Pidgey known-moves frame). + # The fork's fixtures: upstream's, the SystemKeyboardDetector and HomeTileReader screenshots and pending FRLG image submissions (Fly landing, party menu, Route 21 battle, Pokemon Mansion 1F and B1F hold frames, and the Pidgey known-moves frame, the PC's box-screen fade, Bruno's Onix Roar battle menus). repository: 'dayfine/CommandLineTests' - ref: '6e1d3bb33a0365d295280fcce9a01194d0df01a9' + ref: '3c9d2c1dfb31af1e2a1ff44e3f71a24f50f5238d' path: 'CommandLineTests' # The unit tests assume the downloadable resources they need are already downloaded diff --git a/.github/workflows/fork-draft-ci.yml b/.github/workflows/fork-draft-ci.yml index 84c95408ab..ae8a401106 100644 --- a/.github/workflows/fork-draft-ci.yml +++ b/.github/workflows/fork-draft-ci.yml @@ -19,5 +19,6 @@ jobs: compiler: default run-clang-query: true run-tests: true - # The build takes ~5 minutes with ccache; a run past an hour has a test hanging. - timeout-minutes: 60 + # The build takes ~5 minutes with ccache; the FRLG sims take most of the rest. + # A run past two hours has a test hanging. + timeout-minutes: 120 diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h index 7f74f32480..12a663fb7d 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h @@ -39,6 +39,7 @@ #include "Pokemon_StoryStepExecutor_Tests.h" #include "Pokemon_Transitions_Tests.h" #include "Types/Pokemon_StoryActionArg_Tests.h" +#include "Types/Pokemon_StoryCheckLevel_Tests.h" namespace PokemonAutomation{ namespace Pokemon{ @@ -59,6 +60,7 @@ inline void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_StoryStepExecutor(database); add_tests_StoryStepJson(database); add_tests_StoryActionArg(database); + add_tests_StoryCheckLevel(database); add_tests_AuthoredCheckpointJson(database); add_tests_StoryFiles(database); add_tests_StorySavePolicy(database); diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_InterruptHandlers.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_InterruptHandlers.h index 8a0501aa1a..c685adc59b 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_InterruptHandlers.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_InterruptHandlers.h @@ -77,13 +77,12 @@ struct StoryInterrupts{ InterruptKnobs knobs = {}; InterruptHandlerTable handlers = {}; // Looks at a screen that stays UNSETTLED (a fade with no battle yet) - // before it fails the step as "interrupt_unsettled". A step that + // before it fails the step as "interrupt_unsettled": enough for a + // battle's opening to show its battle, or for a door's fade to settle + // as a warp, battle_after_fade (8 s) after it came back up. BDSP's + // 300 ms looks cover 12 s, FRLG's 400 ms looks 16 s. A step that // starts on it gets it on the first look. - size_t max_looks = 3; - // The same, for a screen that may be a battle's opening: enough looks - // for its battle to show. BDSP's 300 ms looks cover 12 s, past its - // battle_after_fade (8 s), after which a fade with no battle settles. - size_t max_opening_looks = 40; + size_t max_unsettled_looks = 40; // Interrupts cleared for one step before it fails as // "too_many_interrupts". size_t max_per_step = 3; diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.cpp index 2e7376990e..c4d10e88f9 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.cpp @@ -91,15 +91,22 @@ void StepGuard::on_failure(const StoryStep&, const OperationFailedException&){} void StepGuard::on_interrupt(const StoryStep&, const InterruptCheck&){} void StepGuard::on_screen(const StoryStep&, const ScreenSettle&){} +void StepGuard::on_check_skipped(const StoryStep&, const std::string&){} -TableExecutor::TableExecutor(const StoryActionTable& table, StepGuard& guard) +TableExecutor::TableExecutor(const StoryActionTable& table, StepGuard& guard, StoryCheckLevel check_level) : m_table(table) , m_guard(guard) + , m_check_level(check_level) {} Outcome TableExecutor::run(const StoryStep& step, RunState& state){ m_guard.before_step(step); + const StoryAction* action = m_table.find(step); + if (action != nullptr && action->check && !runs_check(m_check_level, *action->check)){ + m_guard.on_check_skipped(step, skipped_check_line(step.name, m_check_level)); + return outcome_unchanged(); + } size_t cleared = 0; while (true){ if (std::optional failed = clear_interrupts(step, state, cleared)){ diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.h index 23711eb83c..ca4b45498f 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.h @@ -31,6 +31,7 @@ #include "Pokemon_StoryInterrupts.h" #include "Pokemon_StoryStepExecutor.h" #include "Types/Pokemon_StoryActionSpec.h" +#include "Types/Pokemon_StoryCheckLevel.h" namespace PokemonAutomation{ namespace Pokemon{ @@ -51,6 +52,9 @@ struct StoryAction{ // The args its steps may carry (StoryStep::args); a step with any // other, or without a required one, fails lint_story_checkpoint(). std::vector args = {}; + // A pure check, the kind it is (StoryActionSpec::check): a + // TableExecutor skips it at a level that does not run that kind. + std::optional check = {}; }; @@ -105,6 +109,9 @@ class StepGuard{ // failed) ended, interrupt or not: e.g. log it, so a run log shows // whether the scene before had ended before the step's first input. virtual void on_screen(const StoryStep& step, const ScreenSettle& screen); + // The step is a check the run's level skips (skipped_check_line()): + // e.g. log `line`. + virtual void on_check_skipped(const StoryStep& step, const std::string& line); }; @@ -122,8 +129,9 @@ enum class AfterFailure{ // Runs each step with the table's action for it, inside `guard`. class TableExecutor : public StoryStepExecutor{ public: - // `table` and `guard` must outlive the executor. - TableExecutor(const StoryActionTable& table, StepGuard& guard); + // `table` and `guard` must outlive the executor. `check_level` is the + // run's (StoryRunOptions): TESTING, every check, by default. + TableExecutor(const StoryActionTable& table, StepGuard& guard, StoryCheckLevel check_level = StoryCheckLevel::TESTING); // The table's action for the step (run_action()); with none, the // step is unsupported (unsupported_step()). An OperationFailedException @@ -132,6 +140,8 @@ class TableExecutor : public StoryStepExecutor{ // With interrupts set, each step first clears what stopped the player // since the step before, and a failed step that an interrupt explains // runs again once it is cleared. + // A step whose action is a check of a kind the check level doesn't run + // (runs_check()) changes nothing and runs nothing. virtual Outcome run(const StoryStep& step, RunState& state) override; // The game's interrupts between steps, which must outlive the @@ -153,6 +163,7 @@ class TableExecutor : public StoryStepExecutor{ const StoryActionTable& m_table; StepGuard& m_guard; const StoryInterrupts* m_interrupts = nullptr; + const StoryCheckLevel m_check_level; }; diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions_Tests.cpp index a4e8020210..a937ce2667 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions_Tests.cpp @@ -180,6 +180,9 @@ class FakeGuard : public StepGuard{ virtual void on_failure(const StoryStep& step, const OperationFailedException& error) override{ trace.push_back(std::format("failed {}: {}", step.name, error.message())); } + virtual void on_check_skipped(const StoryStep&, const std::string& line) override{ + trace.push_back(line); + } }; StoryAction throwing(){ @@ -252,6 +255,50 @@ UnitTestResult test_guard_stop_rethrows(){ return true; } +// A check step (a LEVEL step's PARTY_STATS) at each check level: run where +// the level runs its kind, else skipped as unchanged and logged. A step +// that is not a check runs at every level. +UnitTestResult test_check_steps_follow_the_level(){ + struct Input{ + StoryCheckLevel level; + StoryStep step; + }; + struct Expectation{ + std::string failure; + std::vector trace; + }; + struct Case{ + std::string name; + Input input; + Expectation expectation; + }; + const StoryStep check = make(StoryStepKind::GAME, "lead_lv50", "level"); + const StoryStep talk = make(StoryStepKind::TALK, "giovanni"); + const Case cases[] = { + {"a check at thorough", {StoryCheckLevel::THOROUGH, check}, {"level ran", {"before lead_lv50"}}}, + {"a check at default", {StoryCheckLevel::DEFAULT, check}, {"", {"before lead_lv50", "lead_lv50: skipped (checks: default)"}}}, + {"not a check at speedrun", {StoryCheckLevel::SPEEDRUN, talk}, {"talk ran", {"before giovanni"}}}, + }; + StoryActionTable table; + StoryAction level = named("level ran"); + level.check = StoryCheckKind::PARTY_STATS; + table.add(StoryStepKind::GAME, "level", std::move(level)); + table.add(StoryStepKind::TALK, "", named("talk ran")); + for (const Case& item : cases){ + FakeGuard guard; + TableExecutor executor(table, guard, item.input.level); + RunState state; + const Outcome outcome = executor.run(item.input.step, state); + if (outcome.failure != item.expectation.failure || guard.trace != item.expectation.trace){ + return std::format("{}: got \"{}\" after {} guard lines.", item.name, outcome.failure, guard.trace.size()); + } + if (item.expectation.failure.empty() && !outcome.changed_nothing){ + return std::format("{}: expected the skipped check to change nothing.", item.name); + } + } + return true; +} + struct StoryActionsCase{ struct Input{ @@ -306,6 +353,10 @@ const StoryActionsCase STORY_ACTIONS_CASES[] = { .input = {.name = "executor: a stop row rethrows", .test = test_guard_stop_rethrows}, .expectation = {.description = "rethrows on a stop row and passes other exceptions through"}, }, + { + .input = {.name = "executor: a check step at each check level", .test = test_check_steps_follow_the_level}, + .expectation = {.description = "runs where its kind runs, else skipped, unchanged and logged"}, + }, }; } // namespace diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.cpp index 78ab78df44..0c871f4cac 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.cpp @@ -55,41 +55,16 @@ bool InterruptHandlerTable::step_starts_on(StoryStepKind step, InterruptKind kin namespace{ -// Whether an UNSETTLED verdict on `look` may be a battle's opening: its -// fade is white (an encounter's flash), still down (a battle's fade ends -// on the battle), or came after a dialog box (a trainer's lines). -bool may_open_a_battle(const ScreenLook& look, const InterruptVerdict& verdict){ - const auto fade = std::find_if(verdict.evidence.begin(), verdict.evidence.end(), [](const ScreenEventChange& change){ - return change.edge == ScreenEventEdge::ROSE && - (change.event == ScreenEvent::FADE_WHITE || change.event == ScreenEvent::FADE_BLACK); - }); - if (fade == verdict.evidence.end()){ - return false; - } - const bool still_down = std::none_of(verdict.evidence.begin(), verdict.evidence.end(), [](const ScreenEventChange& change){ - return change.edge == ScreenEventEdge::FELL; - }); - if (fade->event == ScreenEvent::FADE_WHITE || still_down){ - return true; - } - return std::any_of(look.log.changes().begin(), look.log.changes().end(), [&](const ScreenEventChange& change){ - return change.event == ScreenEvent::DIALOG_BOX && change.edge == ScreenEventEdge::ROSE && - look.window.start <= change.time && change.time < fade->time; - }); -} - // The look's verdict, looked at again while it is unsettled, up to -// max_looks looks in all, or max_opening_looks while it may be a battle's -// opening; not again before a step that starts on it. `screen` is how the -// last look ended. +// max_unsettled_looks looks in all; not again before a step that starts +// on it. `screen` is how the last look ended. InterruptVerdict settled_verdict(const StoryInterrupts& interrupts, StoryStepKind step, ScreenSettle& screen){ ScreenLook look = interrupts.look(true); InterruptVerdict verdict = classify_interrupt(look.log, look.window, interrupts.knobs); const bool home = look.log.showing().has(ScreenEvent::SWITCH_HOME_MENU); if (!home && !interrupts.handlers.step_starts_on(step, InterruptKind::UNSETTLED)){ for (size_t looks = 1; verdict.kind == InterruptKind::UNSETTLED; looks++){ - const size_t limit = may_open_a_battle(look, verdict) ? interrupts.max_opening_looks : interrupts.max_looks; - if (looks >= limit){ + if (looks >= interrupts.max_unsettled_looks){ break; } look = interrupts.look(false); diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.h index 82f9d3b965..8ebce14b34 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.h @@ -22,12 +22,14 @@ * that is its battle's opening, still playing (BDSP's Starly battle right * after the starter is picked), and the step waits for it itself. * - * Before another step, an unsettled screen that may be a battle's opening - * (a white flash, a fade still down, a fade after a dialog box) is looked - * at until its battle shows, up to max_opening_looks looks: the walk - * before the step ended in grass or in a trainer's sight. The battle is - * then cleared as any other. A fade that came back up with no box before - * it (a door's) is looked at max_looks times only. + * Before another step, an unsettled screen is looked at until it settles, + * up to max_unsettled_looks looks. A battle's opening (a white flash, a + * fade still down, a fade after a dialog box) settles on its battle: the + * walk before the step ended in grass or in a trainer's sight. The battle + * is then cleared as any other. A door's fade, back up, settles as a warp + * once no battle came for battle_after_fade; whatever the game scripts + * after the door (the Elite Four rooms walk the player in for 2.5 s, + * taking no input) is over by then, and the warp is cleared as any other. * */ diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts_Tests.cpp index e994e11745..5a3f34c9c3 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts_Tests.cpp @@ -319,11 +319,55 @@ UnitTestResult test_unsettled_looks_again(){ return expect_trace(game, {"look", "look again", "clear warp", "told warp ", "run walk"}); } -// A door's fade is no battle's opening: three looks, as before. +// The looks before the scene after an Elite Four door, 400 ms each: the +// step into the door ended before its black (100 to 500 ms), then the +// room's script walks the player in for 2.5 s with no input taken, the +// screen showing nothing (FRLG reports no PLAYER_CAN_MOVE), until the +// look at `until_ms`. Console B, 20.02 enter_brunos_room, 2026-11-16. +std::vector door_then_walk_in(int until_ms){ + const ScreenEvents nothing; + std::vector out; + for (int ms = 400; ms <= until_ms; ms += 400){ + std::vector frames = {{0, nothing}, {100, BLACK}}; + if (ms > 500){ + frames.push_back({500, nothing}); + } + frames.push_back({ms, frames.back().events}); + out.push_back(look_of(frames, ms)); + } + return out; +} + +// A door's fade back up, then a scripted walk: unsettled while a battle +// may still show (battle_after_fade, 8 s after the fade), looked at +// until it settles as a warp, not failed after a few looks. The scene +// after it runs, then the next step. +UnitTestResult test_door_then_scripted_walk(){ + FakeGame game; + game.screens = door_then_walk_in(8800); + StoryInterrupts interrupts = fake_interrupts(game); + const FakeRun scene = run_step(game, interrupts, make(StoryStepKind::MASH, "enter_brunos_room")); + if (!scene.outcome.succeeded()){ + return std::format("Expected the scene to run after the walk, got {}", to_string(scene.outcome)); + } + game.screens = {quiet()}; + game.looks = 0; + const FakeRun next = run_step(game, interrupts, make(StoryStepKind::ROUTE, "before_bruno")); + if (!next.outcome.succeeded()){ + return std::format("Expected the next step to run, got {}", to_string(next.outcome)); + } + std::vector expected = {"look"}; + expected.insert(expected.end(), /*count=*/21, "look again"); + expected.insert(expected.end(), {"clear warp", "told warp ", "run enter_brunos_room", "look", "run before_bruno"}); + return expect_trace(game, expected); +} + +// A door's fade that never settles: at most max_unsettled_looks looks. UnitTestResult test_unsettled_is_bounded(){ FakeGame game; - game.screens = {black_unsettled()}; + game.screens = door_then_walk_in(8800); StoryInterrupts interrupts = fake_interrupts(game); + interrupts.max_unsettled_looks = 3; const FakeRun run = run_step(game, interrupts, make(StoryStepKind::ROUTE, "walk")); if (run.outcome.failure != "interrupt_unsettled"){ return std::format("Expected interrupt_unsettled, got {}", to_string(run.outcome)); @@ -348,8 +392,7 @@ UnitTestResult test_unsettled_before_a_battle(){ // A battle's opening still playing when a walk step begins: the walk // before it ended in grass or in a trainer's sight. The looks wait for the -// battle, past max_looks, -// and its handler clears it before the step. +// battle, and its handler clears it before the step. UnitTestResult test_opening_before_a_walk(ScreenLook opening, ScreenLook battle, const std::string& kind, const std::string& handler){ FakeGame game; game.screens = {opening, opening, opening, opening, std::move(battle), quiet()}; @@ -370,12 +413,12 @@ UnitTestResult test_trainer_opening_before_a_walk(){ return test_opening_before_a_walk(trainer_opening(), trainer(), "trainer sight", "trainer"); } -// A white that shows no battle and does not settle: max_opening_looks. +// A white that shows no battle and does not settle: max_unsettled_looks. UnitTestResult test_opening_is_bounded(){ FakeGame game; game.screens = {white_unsettled()}; StoryInterrupts interrupts = fake_interrupts(game); - interrupts.max_opening_looks = 5; + interrupts.max_unsettled_looks = 5; const FakeRun run = run_step(game, interrupts, make(StoryStepKind::ROUTE, "walk")); if (run.outcome.failure != "interrupt_unsettled"){ return std::format("Expected interrupt_unsettled, got {}", to_string(run.outcome)); @@ -468,7 +511,7 @@ UnitTestResult test_screen_before_each_step(){ // fails unsettled, and the guard hears the fade was showing. game.screens = {look_of({{0, WALK}, {100, BLACK}}, 300)}; StoryInterrupts interrupts = fake_interrupts(game); - interrupts.max_opening_looks = 2; + interrupts.max_unsettled_looks = 2; const StoryActionTable table = table_of({}, game); ScreenGuard guard(game); TableExecutor executor(table, guard); @@ -733,8 +776,12 @@ const StoryInterruptsCase STORY_INTERRUPTS_CASES[] = { .expectation = {.description = "a white with no battle after it is a warp"}, }, { - .input = {.name = "unsettled: at most max_looks looks", .test = test_unsettled_is_bounded}, - .expectation = {.description = "a door's fade: interrupt_unsettled after three looks"}, + .input = {.name = "unsettled: a door's fade, then the room's scripted walk", .test = test_door_then_scripted_walk}, + .expectation = {.description = "looked at until it settles as a warp; the scene, then the next step"}, + }, + { + .input = {.name = "unsettled: at most max_unsettled_looks looks", .test = test_unsettled_is_bounded}, + .expectation = {.description = "a fade that never settles: interrupt_unsettled after them"}, }, { .input = {.name = "unsettled: a battle's opening before a battle step", .test = test_unsettled_before_a_battle}, @@ -749,7 +796,7 @@ const StoryInterruptsCase STORY_INTERRUPTS_CASES[] = { .expectation = {.description = "waits for the battle, fights it, then the walk"}, }, { - .input = {.name = "unsettled: at most max_opening_looks for an opening", .test = test_opening_is_bounded}, + .input = {.name = "unsettled: at most max_unsettled_looks for an opening", .test = test_opening_is_bounded}, .expectation = {.description = "a white with no battle: interrupt_unsettled"}, }, { diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h index f9deb09ebb..c8e8bf5c06 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h @@ -14,6 +14,7 @@ #include #include #include "Pokemon_StoryActionArg.h" +#include "Pokemon_StoryCheckLevel.h" #include "Pokemon_StoryStepKind.h" namespace PokemonAutomation{ @@ -40,6 +41,9 @@ struct StoryActionSpec{ // keyboard, a battle AI): the engine refuses it on any other backend // (StoryBackendKind) with the failure "console_only". bool console_only = false; + // A pure check, which changes nothing in the game: the kind it is. A + // run whose level does not run that kind (runs_check()) skips it. + std::optional check = {}; }; // Each way `args` don't fit `spec`: a key it doesn't name, a value of diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.cpp index aade2b3809..4c27d72a78 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.cpp @@ -4,6 +4,8 @@ * */ +#include +#include #include "Pokemon_StoryCheckLevel.h" namespace PokemonAutomation{ @@ -27,6 +29,82 @@ std::string story_check_level_name(StoryCheckLevel level){ } +namespace{ + +std::span story_check_kinds(){ + static constexpr StoryCheckKind KINDS[] = { + StoryCheckKind::SAVE_PLACE, + StoryCheckKind::START_SCREEN, + StoryCheckKind::MENU_ROW, + StoryCheckKind::LEG_END_TAP, + StoryCheckKind::BAG_CONTENTS, + StoryCheckKind::PARTY_STATS, + }; + return KINDS; +} + +std::string_view story_check_kind_name(StoryCheckKind kind){ + switch (kind){ + case StoryCheckKind::SAVE_PLACE: + return "save place"; + case StoryCheckKind::START_SCREEN: + return "start screen"; + case StoryCheckKind::MENU_ROW: + return "menu row"; + case StoryCheckKind::LEG_END_TAP: + return "leg end tap"; + case StoryCheckKind::BAG_CONTENTS: + return "bag contents"; + case StoryCheckKind::PARTY_STATS: + return "party stats"; + } + return "?"; +} + +StoryCheckLevel lowest_check_level(StoryCheckKind kind){ + switch (kind){ + // Cheap, and a wrong save or start wastes the whole checkpoint. + case StoryCheckKind::SAVE_PLACE: + case StoryCheckKind::START_SCREEN: + return StoryCheckLevel::SPEEDRUN; + // A wrong row buys or uses the wrong item for the rest of the run. + case StoryCheckKind::MENU_ROW: + case StoryCheckKind::LEG_END_TAP: + return StoryCheckLevel::DEFAULT; + // The story keeps the counts and the plan the levels: reading them + // again is for the user who wants everything confirmed. + case StoryCheckKind::BAG_CONTENTS: + case StoryCheckKind::PARTY_STATS: + return StoryCheckLevel::THOROUGH; + } + return StoryCheckLevel::TESTING; +} + +} // namespace + +bool runs_check(StoryCheckLevel level, StoryCheckKind kind){ + // The levels run from the most checks (TESTING) to the fewest. + return level <= lowest_check_level(kind); +} + +std::string skipped_check_line(std::string_view name, StoryCheckLevel level){ + return std::format("{}: skipped (checks: {})", name, story_check_level_name(level)); +} + +std::string story_checks_help(){ + std::string help; + for (StoryCheckKind kind : story_check_kinds()){ + const StoryCheckLevel lowest = lowest_check_level(kind); + help += std::format( + "
• {}: {}", story_check_kind_name(kind), + lowest == StoryCheckLevel::SPEEDRUN ? std::string("every level") : std::format("{} and above", story_check_level_name(lowest)) + ); + } + return help; +} + + + } // namespace Pokemon } // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h index 86de9f8c76..0f456b8ec8 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h @@ -3,8 +3,9 @@ * From: https://github.com/PokemonAutomation/ * * How much a story step reads the screen to confirm what it did. The - * program's options choose it (StoryRunOptions); each game decides what - * its steps check at each level. + * program's options choose the level (StoryRunOptions); the one table here + * (runs_check()) says which kind of check runs at which level, and + * every check site asks it by its kind, so no step decides on its own. * */ @@ -12,12 +13,14 @@ #define PokemonAutomation_Pokemon_StoryCheckLevel_H #include +#include namespace PokemonAutomation{ namespace Pokemon{ -// How much a step reads the screen to confirm what it did. +// How much a step reads the screen to confirm what it did, from the most +// to the least. enum class StoryCheckLevel{ // Everything THOROUGH checks, each checkpoint run 3 times by default to // make sure it really passes. @@ -37,6 +40,44 @@ enum class StoryCheckLevel{ std::string story_check_level_name(StoryCheckLevel level); +// What a check reads, which decides the lowest level it runs at +// (runs_check()). A check only verifies: its answer is logged or passes +// or fails its step, and no later step reads it. A step that acts on what +// the screen shows (a battle's items, a member's level for a GRIND) reads +// it itself, at every level, and has no kind here: a precheck skipped at +// DEFAULT left 19.01's rival fought with 0 Potions and no X item (console +// B, 2026-11-15). +enum class StoryCheckKind{ + // After a reload, the save card's place against where the checkpoint + // starts: a save that didn't happen leaves an older one. + SAVE_PLACE, + // The screen where a checkpoint starts against the frame kept of it. + START_SCREEN, + // A menu or Bag row's name read before pressing on it: a Mart row + // before buying it, an item before using it. + MENU_ROW, + // A tap into the wall a leg walked to, to confirm it ended there. + LEG_END_TAP, + // The Bag's pockets read against the counts the story keeps: after a + // reload, after shopping. It changes no count. + BAG_CONTENTS, + // A party member's summary read to check its level or stats before a + // fight: a plan's LEVEL step, a precondition. + PARTY_STATS, +}; + +// Whether a run at `level` does checks of `kind`: the one table of the +// lowest level (the one with the fewest checks) at which each kind still +// runs; every level with more checks runs it too. +bool runs_check(StoryCheckLevel level, StoryCheckKind kind); +// "lead_lv50: skipped (checks: default)": the line logged for a check of +// `name` that `level` skips. +std::string skipped_check_line(std::string_view name, StoryCheckLevel level); +// The table as the option's help shows it: each kind and the levels that +// run it, one line each, HTML. +std::string story_checks_help(); + + } // namespace Pokemon } // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.cpp new file mode 100644 index 0000000000..aa8c5f5650 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.cpp @@ -0,0 +1,118 @@ +/* Story Check Level Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon_StoryCheckLevel.h" +#include "Pokemon_StoryCheckLevel_Tests.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +namespace{ + +const StoryCheckLevel LEVELS[] = { + StoryCheckLevel::TESTING, + StoryCheckLevel::THOROUGH, + StoryCheckLevel::DEFAULT, + StoryCheckLevel::FAST, + StoryCheckLevel::SPEEDRUN, +}; + +struct CheckTableCase{ + struct Input{ + StoryCheckKind kind; + }; + struct Expectation{ + // Whether it runs at testing, thorough, default, fast, speedrun. + std::vector runs; + // Its line in the option's help. + std::string_view help; + }; + + std::string_view name; + Input input; + Expectation expectation; +}; + +const CheckTableCase CHECK_TABLE_CASES[] = { + { + .name = "the save card's place after a reload", + .input = {.kind = StoryCheckKind::SAVE_PLACE}, + .expectation = {.runs = {true, true, true, true, true}, .help = "save place: every level"}, + }, + { + .name = "the screen a checkpoint starts on", + .input = {.kind = StoryCheckKind::START_SCREEN}, + .expectation = {.runs = {true, true, true, true, true}, .help = "start screen: every level"}, + }, + { + .name = "a menu row before pressing it", + .input = {.kind = StoryCheckKind::MENU_ROW}, + .expectation = {.runs = {true, true, true, false, false}, .help = "menu row: default and above"}, + }, + { + .name = "a tap at a leg's wall", + .input = {.kind = StoryCheckKind::LEG_END_TAP}, + .expectation = {.runs = {true, true, true, false, false}, .help = "leg end tap: default and above"}, + }, + { + .name = "the Bag's counts", + .input = {.kind = StoryCheckKind::BAG_CONTENTS}, + .expectation = {.runs = {true, true, false, false, false}, .help = "bag contents: thorough and above"}, + }, + { + .name = "a member's level or stats before a fight", + .input = {.kind = StoryCheckKind::PARTY_STATS}, + .expectation = {.runs = {true, true, false, false, false}, .help = "party stats: thorough and above"}, + }, +}; + +class Test_StoryCheckTable : public UnitTest{ +public: + explicit Test_StoryCheckTable(const CheckTableCase& scenario) + : UnitTest(std::format("Pokemon::StoryCheckLevel - checks: {}", scenario.name)) + , m_scenario(scenario) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + std::vector runs; + for (StoryCheckLevel level : LEVELS){ + runs.push_back(runs_check(level, m_scenario.input.kind)); + } + if (runs != m_scenario.expectation.runs){ + std::string got; + for (size_t c = 0; c < runs.size(); c++){ + got += std::format(" {}={}", story_check_level_name(LEVELS[c]), runs[c] ? "runs" : "skips"); + } + return std::format("Ran at the wrong levels:{}", got); + } + if (story_checks_help().find(m_scenario.expectation.help) == std::string::npos){ + return std::format("Expected \"{}\" in the option's help: {}", m_scenario.expectation.help, story_checks_help()); + } + return true; + } + +private: + CheckTableCase m_scenario; +}; + +} // namespace + + +void add_tests_StoryCheckLevel(UnitTestDatabase& database){ + for (const CheckTableCase& scenario : CHECK_TABLE_CASES){ + database.add(scenario); + } +} + + + +} // namespace Pokemon +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.h b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.h new file mode 100644 index 0000000000..fd98d5e469 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.h @@ -0,0 +1,23 @@ +/* Story Check Level Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_Pokemon_StoryCheckLevel_Tests_H +#define PokemonAutomation_Pokemon_StoryCheckLevel_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// Registers unit tests for the check table: which kind of check runs at which level. +void add_tests_StoryCheckLevel(UnitTestDatabase& database); + + + +} // namespace Pokemon +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h new file mode 100644 index 0000000000..5430919d92 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h @@ -0,0 +1,48 @@ +/* Story Level Check + * + * From: https://github.com/PokemonAutomation/ + * + * The one rule for a check that a party member has reached a level, which + * every game's level check applies. + * + */ + +#ifndef PokemonAutomation_Pokemon_StoryLevelCheck_H +#define PokemonAutomation_Pokemon_StoryLevelCheck_H + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// How far below a level check's minimum a member may be and still pass. +// A minimum is a plan's estimate of what a fight needs, with margin: a +// member a level or three short wins it too, and stopping the run there +// costs more than the fight's risk (FRLG 17.04, console B, 2026-11-15: +// Giovanni's check stopped a Lv49 lead 3 times at "min 50"; the user: +// 49 is fine, stop at 46 or lower). +inline constexpr unsigned LEVEL_CHECK_TOLERANCE = 3; + +// What a level check makes of a member's level. +enum class LevelVerdict{ + // At least the minimum. + MET, + // Below the minimum by LEVEL_CHECK_TOLERANCE or less: passes, with a + // warning. + WITHIN_TOLERANCE, + // Further below: fails. + BELOW, +}; + +// The verdict on a member of level `level` against `minimum`. +inline LevelVerdict level_verdict(unsigned level, unsigned minimum){ + if (level >= minimum){ + return LevelVerdict::MET; + } + return level + LEVEL_CHECK_TOLERANCE >= minimum ? LevelVerdict::WITHIN_TOLERANCE : LevelVerdict::BELOW; +} + + + +} // namespace Pokemon +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/Pokemon/Options/Pokemon_StoryRunOptions.cpp b/SerialPrograms/Source/Pokemon/Options/Pokemon_StoryRunOptions.cpp index c1217c26fd..ceaed0b08c 100644 --- a/SerialPrograms/Source/Pokemon/Options/Pokemon_StoryRunOptions.cpp +++ b/SerialPrograms/Source/Pokemon/Options/Pokemon_StoryRunOptions.cpp @@ -14,15 +14,29 @@ namespace Pokemon{ const EnumDropdownDatabase& StoryCheckLevel_Database(){ static const EnumDropdownDatabase database({ {StoryCheckLevel::TESTING, "testing", "Testing: run each checkpoint 3 times to be sure it really passes"}, - {StoryCheckLevel::THOROUGH, "thorough", "Thorough: check everything for the user (Bag items, Pok\u00e9mon stats, preconditions)"}, - {StoryCheckLevel::DEFAULT, "default", "Default: check the most important things, assume the rest is fine"}, - {StoryCheckLevel::FAST, "fast", "Fast: minimal checks"}, - {StoryCheckLevel::SPEEDRUN, "speedrun", "Speedrun: almost no checks, as fast as possible"}, + {StoryCheckLevel::THOROUGH, "thorough", "Thorough: check everything for the user (Bag items, Pok\u00e9mon levels and stats before a fight)"}, + {StoryCheckLevel::DEFAULT, "default", "Default: check menu rows before pressing them; trust the Bag counts and levels the story keeps"}, + {StoryCheckLevel::FAST, "fast", "Fast: only the save and the start of each checkpoint"}, + {StoryCheckLevel::SPEEDRUN, "speedrun", "Speedrun: only the save and the start of each checkpoint, skipping optional errands"}, }); return database; } +namespace{ + +// The CHECKS option's label, with the check table (story_checks_help()), +// so what it says is what runs. +std::string checks_label(){ + return std::format( + "Checks:
How much each step reads the screen to confirm what it did, from Testing (the most) to Speedrun (almost none). " + "Each kind of check runs at these levels:{}", story_checks_help() + ); +} + +} // namespace + + const EnumDropdownDatabase& StorySaveMode_Database(){ static const EnumDropdownDatabase database({ {StorySaveMode::NONE, "none", "None: never save (testing a checkpoint; the start save stays)"}, @@ -94,7 +108,7 @@ StoryRunOptions::StoryRunOptions(const StringSelectDatabase& checkpoints, const 3, 1, 20 ) , CHECKS( - "Checks:
How much each step reads the screen to confirm what it did, from Testing (the most) to Speedrun (almost none).", + checks_label(), StoryCheckLevel_Database(), LockMode::LOCK_WHILE_RUNNING, StoryCheckLevel::DEFAULT diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.cpp index 4407654aea..d8c3606f06 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.cpp @@ -185,6 +185,12 @@ std::string_view pc_screen_name(PcScreen screen){ PcView read_pc_screen(Logger& logger, const ImageViewRGB32& screen){ const ImageViewRGB32 game = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + // The fade into or out of a box screen: black with a white line across + // the middle for over a second (console B, 2026-11-16). Its black has + // the PKMN DATA panel's hue, so it is told apart first. + if (image_stats(game).average.sum() < DARK_SCREEN){ + return {}; + } if (is_solid(extract_box_reference(game, DATA_PANEL_PATCH), {0.311, 0.319, 0.370}, 0.06, 80)){ return box_screen(logger, screen, game); } @@ -198,7 +204,7 @@ PcView read_pc_screen(Logger& logger, const ImageViewRGB32& screen){ if (is_white(extract_box_reference(game, MESSAGE_PATCH), 500, 40)){ return {.screen = PcScreen::TEXT}; } - if (StartMenuDetector(COLOR_RED).detect(screen) || image_stats(game).average.sum() < DARK_SCREEN){ + if (StartMenuDetector(COLOR_RED).detect(screen)){ return {}; } return {.screen = PcScreen::OVERWORLD}; @@ -278,6 +284,11 @@ void add_tests_PcScreenReader(UnitTestDatabase& database){ // Pokemon it points at. "WithdrawBox_box-grid_0_none.png", "ContinueWithdraw_yes-no_1_none.png", + // 20.01a at the Indigo Plateau, 2026-11-16: 0.8 s after A on + // WITHDRAW the fade is still black and must not read as the box; + // by 3 s the box is up, the hand on the Magikarp. + "WithdrawOpening_other_none_none.png", + "IndigoWithdrawBox_box-grid_0_none.png", "Overworld_overworld_none_none.png", "StartMenu_other_none_none.png", }){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.h index c0ec18899e..029d87f526 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Box/PokemonFRLG_PcScreenReader.h @@ -19,7 +19,8 @@ * box's name; "Continue BOX operations?" a YES/NO at (188, 85). * * A message box with nothing else is TEXT; a frame with none of these, no - * START menu and not dark is the OVERWORLD. A screen between two of them + * START menu and not dark is the OVERWORLD. A dark frame, as in the fade + * into and out of a box screen, is OTHER whatever else it matches. A screen between two of them * can read as the overworld: the caller confirms it on a later frame. * */ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.cpp new file mode 100644 index 0000000000..a24364fd1d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.cpp @@ -0,0 +1,69 @@ +/* Boulder Push Reader + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/ImageTools/ImageDiff.h" +#include "PokemonFRLG_OverworldRecoveryWalk.h" +#include "PokemonFRLG_BoulderPushReader.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr double GBA_WIDTH = 240; +constexpr double GBA_HEIGHT = 160; +constexpr double TILE = 16; +// The player's tile on the GBA screen while the camera follows them: column +// 7, row 4 of the 15 by 10 (PlayerFacingReader's sprite stands on it). +constexpr double PLAYER_X = 112; +constexpr double PLAYER_Y = 72; + +// How much the two tiles ahead change when a boulder moves a tile on: 76.5 +// for the boulder pushed south from Victory Road 1F's (7, 17) (console B, +// 2026-11-16, 19.04b), against 11.3 between two of the cave's floor tiles. +constexpr double BOULDER_MOVED_RMSD = 30.0; + +// The two tiles ahead of the player, `direction`, as a box of `game`: from +// the tile next to theirs to the one after it. +ImageFloatBox tiles_ahead(const ImageFloatBox& game, Direction direction){ + const TilePos next = TilePos{0, 0}.next(direction); + const bool across = next.x != 0; + const double x = PLAYER_X + (next.x < 0 ? 2 * next.x : next.x) * TILE; + const double y = PLAYER_Y + (next.y < 0 ? 2 * next.y : next.y) * TILE; + const double width = across ? 2 * TILE : TILE; + const double height = across ? TILE : 2 * TILE; + return ImageFloatBox( + game.x + game.width * x / GBA_WIDTH, + game.y + game.height * y / GBA_HEIGHT, + game.width * width / GBA_WIDTH, + game.height * height / GBA_HEIGHT + ); +} + +} // namespace + + +BoulderPressRead read_boulder_press( + const ImageViewRGB32& before, const ImageViewRGB32& after, const ImageFloatBox& game, Direction direction +){ + BoulderPressRead read; + read.scrolled = tap_scroll_change(before, after, game) > WALL_TAP_MOVED_RMSD; + if (!read.scrolled){ + const ImageFloatBox ahead = tiles_ahead(game, direction); + read.boulder_moved = ImageMatch::pixel_RMSD( + extract_box_reference(before, ahead), extract_box_reference(after, ahead) + ) > BOULDER_MOVED_RMSD; + } + return read; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h new file mode 100644 index 0000000000..7d042ff1b6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h @@ -0,0 +1,48 @@ +/* Boulder Push Reader + * + * From: https://github.com/PokemonAutomation/ + * + * What a step tap toward a Strength boulder did, read from the game screen + * before and after it. A tap into a boulder pushes it a tile while the + * player walks in place (pret/pokefirered field_player_avatar.c, + * DoBoulderDust: the player's WalkInPlaceNormal, the boulder's + * WalkSlower): the map stays, and only the two tiles ahead of the player + * change. The next tap walks the player onto the tile the boulder left, + * and the map scrolls a tile. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BoulderPushReader_H +#define PokemonAutomation_PokemonFRLG_BoulderPushReader_H + +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "PokemonFRLG_OverworldMap.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// What one step tap toward a boulder showed. +struct BoulderPressRead{ + // The map scrolled: the player walked a tile (tap_scroll_change() over + // WALL_TAP_MOVED_RMSD). + bool scrolled = false; + // The two tiles ahead of the player changed: a boulder left the first + // for the second, or for a hole there. Read only when the map stayed. + bool boulder_moved = false; +}; + +// Reads a tap `direction` from `before` and `after`, shots of the console +// screen with the GBA's 240x160 screen in `game`. +BoulderPressRead read_boulder_press( + const ImageViewRGB32& before, const ImageViewRGB32& after, const ImageFloatBox& game, Direction direction +); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.cpp new file mode 100644 index 0000000000..aca0fe9845 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.cpp @@ -0,0 +1,76 @@ +/* Overworld Gated Route + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "Pokemon/Navigation/Pokemon_GateState.h" +#include "Pokemon/Navigation/Pokemon_GateTiles.h" +#include "PokemonFRLG_OverworldGatedRoute.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +Pokemon::GateState gates_after_route(const Pokemon::GateState& before, const std::vector& route){ + Pokemon::GateState gates = before; + for (const RouteStep& step : route){ + Pokemon::apply_gate_change(gates, step.gate_change); + } + return gates; +} + +bool has_gates(const std::vector& maps){ + return std::ranges::any_of(maps, [](const MapData& map){ + return !map.gates.empty(); + }); +} + +std::vector resolve_maps(const std::vector& maps, const Pokemon::GateState& gates){ + std::vector resolved = maps; + for (MapData& map : resolved){ + if (map.gates.empty()){ + continue; + } + map.tiles = Pokemon::resolve_tiles(map, gates); + std::erase_if(map.objects, [&](const MapObject& object){ + const Pokemon::MapGate* gate = Pokemon::gate_at(map, TilePos{object.x, object.y}); + return gate != nullptr && Pokemon::gate_is_open(map, *gate, gates); + }); + } + return resolved; +} + +std::optional cut_gate_key(const std::vector& maps, const MapPosition& tree){ + for (const MapData& map : maps){ + if (map.name != tree.map || !map.tiles.contains(tree.point)){ + continue; + } + const Pokemon::MapGate* gate = Pokemon::gate_at(map, tree.point); + if (gate != nullptr && gate->kind == Pokemon::GateKind::CUT){ + return Pokemon::gate_key(map.name, gate->id); + } + } + return std::nullopt; +} + +void regrow_cut_gates(const std::vector& maps, Pokemon::GateState& gates){ + for (const MapData& map : maps){ + for (const auto& [id, gate] : map.gates){ + if (gate.kind == Pokemon::GateKind::CUT){ + gates.opened.erase(Pokemon::gate_key(map.name, id)); + } + } + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.cpp index 895d809f79..05232b4297 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.cpp @@ -163,6 +163,77 @@ class Test_OverworldLateBattle : public UnitTest{ LateBattleCase m_case; }; +struct BattleAfterWarpInput{ + // From the end of the ladder's fade to the battle's step. + Milliseconds delay{0}; +}; + +struct BattleAfterWarpExpectation{ + // The battle run from, and the route walked on 3F to here. + MapPosition end; +}; + +struct BattleAfterWarpCase{ + std::string name; + BattleAfterWarpInput input; + BattleAfterWarpExpectation expectation; +}; + +const MapPosition BELOW_LADDER{"VictoryRoad_2F", {34, 14}}; +const MapPosition ON_3F{"VictoryRoad_3F", {34, 5}}; + +// Console B, 2026-11-16 02:18, 19.04c ladder_3f: "north 5 (warp)" up +// Victory Road 2F's ladder reached 3F, then a wild battle started there. +// The walker took the ladder's fade for the battle's wipe, held on north +// toward a ladder it had passed, and failed with the player on 3F 2 tiles +// past the ladder. The new map's overworld showed between the fade and +// the battle: the warp was taken, and the player is found again on 3F. +class Test_OverworldBattleAfterWarp : public UnitTest{ +public: + explicit Test_OverworldBattleAfterWarp(BattleAfterWarpCase test_case) + : UnitTest("PokemonFRLG::OverworldBattleAfterWarp - " + test_case.name) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + return run_case(); + }catch (Exception& e){ + return std::string(e.name()) + ": " + e.message(); + } + } + +private: + UnitTestResult run_case() const{ + const std::optional> route = plan_overworld_route( + maps(), BELOW_LADDER, RouteGoal{m_case.expectation.end, std::nullopt}, default_route_costs(), Direction::NORTH + ); + if (!route){ + return std::format("No route from {} to {}.", to_string(BELOW_LADDER), to_string(m_case.expectation.end)); + } + SimScript script; + script.battle_after_warp = m_case.input.delay; + OverworldSim sim(maps(), BELOW_LADDER, Direction::NORTH, script); + OverworldSimWalker walker(sim, {}); + const RoutePlanning planning{.maps = &maps(), .costs = default_route_costs(), .start = BELOW_LADDER, .label = "Sim"}; + LateBattleRun run; + run.failure = walker.run(*route, planning); + run.state = sim.state(); + run.log = walker.log(); + const MapPosition& end = m_case.expectation.end; + if (!run.failure.empty() || !(run.state.position == end) || run.state.wild_battles != 1 || !run.state.violations.empty()){ + return std::format("Expected the battle on 3F run from and {} reached:{}", to_string(end), describe(run)); + } + return true; + } + + BattleAfterWarpCase m_case; +}; + +const BattleAfterWarpCase BATTLE_AFTER_WARP_CASES[] = { + {.name = "a battle 1 s after the ladder's fade", .input = {.delay = Milliseconds(1000)}, .expectation = {.end = ON_3F}}, + {.name = "a battle 3 s after the ladder's fade", .input = {.delay = Milliseconds(3000)}, .expectation = {.end = ON_3F}}, +}; + } // namespace @@ -185,6 +256,9 @@ void add_tests_OverworldLateBattle(UnitTestDatabase& database){ for (const LateBattleCase& item : LATE_BATTLE_CASES){ database.add(item); } + for (const BattleAfterWarpCase& item : BATTLE_AFTER_WARP_CASES){ + database.add(item); + } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index 748a4a40ff..42d683de31 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -252,6 +252,10 @@ class CheckedSteps{ size_t m_reholds = 0; }; +// How far on from a warp's tile a wild battle on the new map may leave the +// player (2 on Victory Road 3F: console B, 2026-11-16 02:18, 19.04c). +constexpr int WARP_ARRIVAL_DRIFT = 2; + // run_route()'s walk: the plan, as rejoined or planned again after a // stop, which step is next, where the player is and which way they face. class RouteRun{ @@ -318,6 +322,12 @@ class RouteRun{ continue; } m_walked.reset(); + if (outcome.end == StepEnd::WARPED){ + if (!after_warped(step)){ + return; + } + continue; + } if (!after_stop(step, outcome, start, crossing)){ return; } @@ -566,20 +576,30 @@ class RouteRun{ if (step.to_wall){ return after_wall_stop(step, outcome, start, crossing); } + // A hold on that took no warp left the player anywhere on the leg: + // found again there, as after any stop (console B, 2026-11-16 + // 02:13, 19.04c: a wild Onix on "north 5 (warp)" to Victory Road 3F). + bool held_on = false; if (outcome.end == StepEnd::STOPPED && step.warps && (!step.wild || by_wild_battle(step, start, outcome))){ - m_calls.hold_to_warp(step); - m_at = step.end; - m_facing = step.facing_after; - m_next++; - m_lines.end(step, m_at, EndBasis::ASSUMED, "stopped, then held on to the warp"); - return true; + const std::optional held = m_calls.hold_to_warp(step); + if (held == WarpBattle::AFTER){ + return after_warped(step); + } + if (held){ + m_at = step.end; + m_facing = step.facing_after; + m_next++; + m_lines.end(step, m_at, EndBasis::ASSUMED, "stopped, then held on to the warp"); + return true; + } + held_on = true; } - m_lines.end(step, std::nullopt, EndBasis::UNKNOWN, "stopped part-way"); + m_lines.end(step, std::nullopt, EndBasis::UNKNOWN, held_on ? "stopped, then held on with no warp" : "stopped part-way"); if (maps() == nullptr){ m_calls.fail("walk_overworld_route(): stopped part-way on " + to_string(step) + ", with no maps to find the player again."); return false; } - const WalkedTiles walked = outcome.walked.value_or(whole_leg(step)); + const WalkedTiles walked = held_on ? whole_leg(step) : outcome.walked.value_or(whole_leg(step)); if (!outcome.blocked){ return rejoin(step, candidates_on(step, start, walked), walked); } @@ -590,6 +610,30 @@ class RouteRun{ return rejoin(step, blocked_ahead(step, candidates_on(longer, start, walked)), walked); } + // `step`, m_plan[m_next], a warp, was taken, then a wild battle started on + // the new map (WarpBattle::AFTER): the player is up to WARP_ARRIVAL_DRIFT + // tiles on from the warp's tile, found again as on the step after it (its + // end, not the warp's tile, which warps again). False once failed. + bool after_warped(const RouteStep& step){ + m_lines.end(step, std::nullopt, EndBasis::UNKNOWN, "through the warp, then a wild battle on the new map"); + if (maps() == nullptr){ + m_calls.fail(std::format("walk_overworld_route(): a wild battle after the warp to {}, with no maps to find the player again.", step.end.map)); + return false; + } + RouteStep on; + on.direction = step.direction; + on.tiles = WARP_ARRIVAL_DRIFT; + on.end = step.end; + std::vector candidates; + for (const MapPosition& tile : leg_tiles(*maps(), step.end, on)){ + candidates.push_back(StopCandidate{.player = tile}); + } + if (m_next + 1 < m_plan.size()){ + m_next++; + } + return rejoin(m_plan[m_next], candidates, WalkedTiles{.min = 0, .max = WARP_ARRIVAL_DRIFT}); + } + // Of `candidates`, where a tap along `step` showed no step, those the maps block the way ahead of or past the // taps seen to move (10.05's Tower 6F column 16: not only its wall 3 tiles on); all of them if none. std::vector blocked_ahead(const RouteStep& step, std::vector candidates) const{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h index 6436600fc1..f958c4e311 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h @@ -53,6 +53,7 @@ #include "PokemonFRLG_OverworldRoute.h" #include "PokemonFRLG_OverworldTrainerCrossing.h" #include "PokemonFRLG_OverworldStepChecks.h" +#include "PokemonFRLG_OverworldWarpBattle.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -97,11 +98,12 @@ struct RoutePlanning{ }; // The console side. `walk` walks one step from `facing` (unknown after a -// stop); `hold_to_warp` holds on along a stopped leg until its warp; +// stop); `hold_to_warp` holds on along a stopped leg until its warp, and +// returns the warp's battle check, or nothing if no warp was reached; // `fail` throws. struct RouteCalls{ std::function facing)> walk; - std::function hold_to_warp; + std::function(const RouteStep& step)> hold_to_warp; std::function log; std::function fail; // Taps once more toward the wall a leg to a wall ended at, and says diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index 3213f47839..74ff64f0da 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -68,6 +68,8 @@ struct StepWalk{ // Stopped by a Bicycle tap that didn't move (StepOutcome::blocked). bool blocked = false; HoldMovement movement = HoldMovement::UNMEASURED; + // Through the warp, then a wild battle on the new map (WarpBattle::AFTER). + bool warped = false; }; // The four edge quarters of the game screen `game`: top, bottom, left and @@ -457,9 +459,17 @@ StepWalk walk_hold_step( } wait_out_warp(console, context, step, fade, before); static_assert(AFTER_WARP_BATTLE_WATCH >= AFTER_WARP); - if (run_from_battle_after_warp(console, context)){ - console.log("Route: a wild battle, not the warp to " + step.end.map + "; the player is on " + to_string(step) + " before the warp.", COLOR_ORANGE); + switch (run_from_battle_after_warp(console, context)){ + case WarpBattle::NONE: + break; + case WarpBattle::INSTEAD: + console.log(std::format("Route: a wild battle, not the warp to {}; the player is on {} before the warp.", step.end.map, to_string(step)), COLOR_ORANGE); out.stopped = walked_before_warp(step); + break; + case WarpBattle::AFTER: + console.log(std::format("Route: through the warp to {}, then a wild battle there: the player's tile isn't known.", step.end.map), COLOR_ORANGE); + out.warped = true; + break; } return out; } @@ -584,6 +594,9 @@ StepOutcome walk_and_watch( if (walked.stopped){ return StepOutcome{.end = StepEnd::STOPPED, .walked = walked.stopped, .blocked = walked.blocked}; } + if (walked.warped){ + return StepOutcome{.end = StepEnd::WARPED, .walked = std::nullopt}; + } if (step.action == RouteAction::FACE || step.action == RouteAction::OPEN_GATE || step.action == RouteAction::PRESS_SWITCH){ return StepOutcome{}; } @@ -606,6 +619,24 @@ StepOutcome walk_and_watch( return StepOutcome{.end = StepEnd::LATE, .walked = placed}; } +namespace{ + +// Whether a warp's black shows within WARP_TIMEOUT after a hold on toward +// it, as after a warp leg's hold. The black onto Victory Road 3F's ladder +// came a moment after a hold on's watch ended (console B, 2026-11-16 +// 02:13, 19.04c). +bool black_after_hold(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ + BlackScreenWatcher black(COLOR_RED); + context.wait_for_all_requests(); + if (wait_until(console, context, WARP_TIMEOUT, {black}) < 0){ + return false; + } + console.log(std::format("Route: the black onto the warp to {} showed after the hold.", step.end.map), COLOR_ORANGE); + return true; +} + +} // namespace + // Holds on along `step`, stopped part-way off the grass or by a wild // battle where no trainer may see the player, until its warp's fade. Off // the grass only a message stops a leg (a trainer who saw the player, a @@ -613,7 +644,10 @@ StepOutcome walk_and_watch( // after a wild battle, so holding on reaches the warp however far they // got (console B, 2026-11-01: Camper Liam stopped "south 9 (warp)" out of // Pewter Gym). After a trainer the player faces them, so this turns first. -void hold_to_warp( +// The warp's battle check (NONE or AFTER) once through it; nothing if no +// warp's black showed by the time a warp leg's end gives up: the player is +// somewhere on the leg. +std::optional hold_to_warp( ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, const OverworldInterrupts& interrupts, MoveSpeed speed ){ @@ -636,10 +670,9 @@ void hold_to_warp( }, callbacks ); - if (ret == 0){ + if (ret == 0 || (ret < 0 && black_after_hold(console, context, step))){ wait_out_warp(console, context, step, before); - check_warp_was_no_battle(console, context, step); - return; + return check_warp_was_no_battle(console, context, step); } if (ret < 0){ break; @@ -647,11 +680,8 @@ void hold_to_warp( console.log("Route: " + interrupts[ret - 1]->name() + " on the way to the warp.", COLOR_ORANGE); interrupts[ret - 1]->clear(console, context); } - OperationFailedExceptionWithScreenshot::fire( - ErrorReportMode::SEND_ERROR_REPORT, - "walk_overworld_route(): no fade holding on toward the warp to " + step.end.map + ".", - console - ); + console.log(std::format("Route: no fade holding on toward the warp to {}.", step.end.map), COLOR_ORANGE); + return std::nullopt; } // After `step`, which crosses the sight of a trainer not beaten @@ -859,9 +889,12 @@ void walk_overworld_route_with_recovery( return outcome; }; calls.hold_to_warp = [&](const RouteStep& step){ - hold_to_warp(console, context, step, step.wild ? interrupts.wild : interrupts.other, riding ? speed : on_foot(speed)); - riding = riding && warp_keeps_bike(step.end.map); - at = step.end; + const std::optional held = hold_to_warp(console, context, step, step.wild ? interrupts.wild : interrupts.other, riding ? speed : on_foot(speed)); + if (held){ + riding = riding && warp_keeps_bike(step.end.map); + } + at = held == WarpBattle::NONE ? std::optional(step.end) : std::nullopt; + return held; }; calls.landed_on = [&](const MapPosition&){ return stands_on_foot(console, context, player); }; calls.riding = [&](const RouteStep&){ return riding; }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery_Tests.cpp index cf8c08c530..f320220705 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery_Tests.cpp @@ -91,7 +91,10 @@ struct ScriptedRoute{ auto iter = ends.find(walked.size() - 1); return iter == ends.end() ? StepOutcome{} : iter->second; }; - calls.hold_to_warp = [this](const RouteStep& step){ held_to_warp.push_back(step); }; + calls.hold_to_warp = [this](const RouteStep& step){ + held_to_warp.push_back(step); + return std::optional(WarpBattle::NONE); + }; calls.log = [this](const std::string& message){ logs.push_back(message); }; calls.moved_past_wall = [this](const RouteStep&){ wall_taps++; @@ -183,7 +186,10 @@ UnitTestResult test_stop_recover_resume(){ const WalkedTiles walked = walked_near(step, step.tiles / 2, std::chrono::milliseconds(267)); ScriptedRoute script; script.ends[stopped] = StepOutcome{.end = StepEnd::STOPPED, .walked = walked}; - const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = std::nullopt, .label = "Route", .wall_check = WallCheck::TAP}; + // Open legs are trusted: once the player is found again, the rest of the + // route would also be checked at walls after its open legs (Route 1's + // "west 6" before "south 7 (to wall)"), which the open-leg tests cover. + const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = std::nullopt, .label = "Route", .wall_check = WallCheck::TAP, .open_leg_check = OpenLegCheck::TRUST}; if (script.run(*route, &planning)){ return "Failed: " + script.failure; } @@ -226,13 +232,17 @@ UnitTestResult test_open_water_legs(){ return "No route."; } // Routes now land on the sand bars and the shore instead of stopping - // on the water (RouteCost::OPEN_WATER_STOP). The leg to the - // first sand bar is made an open stop on the water, as legs were then, - // to keep the check covered. - for (RouteStep& step : *route){ - if (step.surfing && step.action == RouteAction::WALK && !step.warps){ + // on the water (RouteCost::OPEN_WATER_STOP), and hold the leg after + // one to a wall (RouteCost::OPEN_CHECK). The leg to the first sand bar + // is made an open stop on the water, and the walk after it an open + // leg, as legs were then, to keep the check covered. + for (size_t c = 0; c + 1 < route->size(); c++){ + RouteStep& step = (*route)[c]; + RouteStep& next = (*route)[c + 1]; + if (step.surfing && step.action == RouteAction::WALK && !step.warps && next.action == RouteAction::WALK && !next.warps){ step.to_wall = false; step.lands_after = 0; + next.to_wall = false; break; } } @@ -261,14 +271,15 @@ UnitTestResult test_open_water_legs(){ return true; } -// A corridor with a person at each end: nothing finds the player again. +// A corridor with a person who wanders at each end: neither stops a hold +// like a wall (one standing still would), so nothing finds the player again. const std::string TEST_CORRIDOR_JSON = R"({ "name": "Corridor", "source": {"decomp_file": "", "revision": "test", "date": "2026-10-31"}, - "tiles": ["#######", "#.....#", "#######"], - "elevation": ["3333333", "3333333", "3333333"], + "tiles": ["#########", "#.......#", "#########"], + "elevation": ["333333333", "333333333", "333333333"], "objects": [ - {"name": "youngster", "kind": "npc", "x": 1, "y": 1}, - {"name": "lass", "kind": "npc", "x": 5, "y": 1} + {"name": "youngster", "kind": "npc", "x": 1, "y": 1, "wander": {"x0": 1, "y0": 1, "x1": 2, "y1": 1}}, + {"name": "lass", "kind": "npc", "x": 7, "y": 1, "wander": {"x0": 6, "y0": 1, "x1": 7, "y1": 1}} ] })"; @@ -285,7 +296,7 @@ RouteStep walk(Direction direction, int tiles, MapPosition end){ // be on, a stop fails the route instead of guessing. UnitTestResult test_no_recovery(){ const std::vector maps{parse_map(TEST_CORRIDOR_JSON, "Corridor")}; - const std::vector route{walk(Direction::EAST, 2, {"Corridor", {4, 1}})}; + const std::vector route{walk(Direction::EAST, 2, {"Corridor", {5, 1}})}; ScriptedRoute without_maps; without_maps.ends[0] = stop_part_way(); if (!without_maps.run(route, nullptr) || without_maps.failure.find("no maps") == std::string::npos){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index bca12033ae..7e5f815338 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -27,34 +27,6 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -const RouteCosts& default_route_costs(){ - static const RouteCosts COSTS{ - {RouteCost::TILE, 1}, - {RouteCost::TURN, 2}, - {RouteCost::WARP, 30}, - {RouteCost::SURF, 40}, - {RouteCost::GRASS_TILE, 20}, - {RouteCost::OPEN_STOP, 8}, - {RouteCost::OPEN_WILD_STOP, 300}, - {RouteCost::SIGHT_TILE, 0}, - {RouteCost::SIGHT_OVERSHOOT, 0}, - {RouteCost::SIGN_OVERSHOOT, 3}, - {RouteCost::OPEN_WATER_STOP, 1000}, - {RouteCost::OPEN_CHECK, 10}, - }; - return COSTS; -} - -int route_cost(const RouteCosts& costs, RouteCost kind){ - auto iter = costs.find(kind); - if (iter == costs.end()){ - iter = default_route_costs().find(kind); - } - return iter->second; -} - - - namespace{ @@ -307,9 +279,12 @@ class StepModel{ using State = Located; using StateHash = LocatedHash; - StepModel(const std::vector& maps, const RouteCosts& costs) + // With `only_map`, no step leaves that map; the other maps still tell + // where a hold stops (an edge onto a wall, a door's warp). + StepModel(const std::vector& maps, const RouteCosts& costs, std::optional only_map = std::nullopt) : m_maps(maps) , m_costs(costs) + , m_only_map(only_map) {} std::optional> press(const State& state, Direction direction) const{ @@ -317,6 +292,9 @@ class StepModel{ if (!transition || (transition->action == RouteAction::SURF && route_cost(m_costs, RouteCost::SURF) < 0)){ return std::nullopt; } + if (m_only_map && transition->next.map != *m_only_map){ + return std::nullopt; + } Pokemon::Step step; step.next = transition->next; step.action = transition->action == RouteAction::SURF ? ACTION_SURF : 0; @@ -347,6 +325,9 @@ class StepModel{ if (seen_by_trainer(step.next)){ step.extra_cost += route_cost(m_costs, RouteCost::SIGHT_TILE); } + if (in_trainer_line(step.next)){ + step.extra_cost += route_cost(m_costs, RouteCost::LINE_TILE); + } return step; } bool held_at(const State& state, Direction direction) const{ @@ -423,9 +404,18 @@ class StepModel{ return trainer_may_see(map, object, state.state.position); }); } + // Whether a trainer who stands and looks one way sees `state`'s tile. + bool in_trainer_line(const State& state) const{ + const MapData& map = m_maps[state.map]; + return std::ranges::any_of(map.objects, [&](const MapObject& object){ + return object.trainer && !object.wander && object.trainer->looks.size() == 1 + && trainer_may_see(map, object, state.state.position); + }); + } const std::vector& m_maps; const RouteCosts& m_costs; + std::optional m_only_map; }; // The maps through each gate state a search reaches, resolved once. @@ -462,13 +452,14 @@ class GatedStepModel{ using State = Located; using StateHash = LocatedHash; - GatedStepModel(const GateMaps& maps, const RouteCosts& costs) + GatedStepModel(const GateMaps& maps, const RouteCosts& costs, std::optional only_map) : m_maps(maps) , m_costs(costs) + , m_only_map(only_map) {} std::optional> press(const State& state, Direction direction, const Pokemon::GateState& gates) const{ - return StepModel(m_maps.at(gates), m_costs).press(state, direction); + return StepModel(m_maps.at(gates), m_costs, m_only_map).press(state, direction); } bool held_at(const State& state, Direction direction, const Pokemon::GateState& gates) const{ return StepModel(m_maps.at(gates), m_costs).held_at(state, direction); @@ -489,6 +480,7 @@ class GatedStepModel{ private: const GateMaps& m_maps; const RouteCosts& m_costs; + std::optional m_only_map; }; Pokemon::LegCosts to_leg_costs(const RouteCosts& costs){ @@ -677,12 +669,16 @@ std::optional predict_overworld_press( }; } -std::optional> plan_overworld_route( +namespace{ + +// plan_overworld_route(), with no step off `only_map` if given. +std::optional> plan_route_on( const std::vector& maps, const MapPosition& start, const RouteGoal& goal, const RouteCosts& costs, - std::optional start_facing + std::optional start_facing, + std::optional only_map ){ const int start_map = find_map(maps, start.map); const int goal_map = find_map(maps, goal.position.map); @@ -695,7 +691,7 @@ std::optional> plan_overworld_route( first.state.elevation = elevation_at(maps[start_map], start.point); first.state.surfing = is_water(maps[start_map], start.point); - const StepModel model(maps, costs); + const StepModel model(maps, costs, only_map); const auto legs = Pokemon::plan_legs( model, first, start_facing, std::function([&](const Located& player){ @@ -715,51 +711,40 @@ std::optional> plan_overworld_route( return route; } - -bool has_gates(const std::vector& maps){ - return std::ranges::any_of(maps, [](const MapData& map){ - return !map.gates.empty(); - }); -} - -std::vector resolve_maps(const std::vector& maps, const Pokemon::GateState& gates){ - std::vector resolved = maps; - for (MapData& map : resolved){ - if (map.gates.empty()){ - continue; - } - map.tiles = Pokemon::resolve_tiles(map, gates); - std::erase_if(map.objects, [&](const MapObject& object){ - const Pokemon::MapGate* gate = Pokemon::gate_at(map, TilePos{object.x, object.y}); - return gate != nullptr && Pokemon::gate_is_open(map, *gate, gates); - }); +// The map a route from `start` to `goal` stays on if any route does: +// theirs, when they share it. The game resets a map's objects when the +// player leaves it: 19.04b's below_ladder went out of Victory Road 1F's +// cave mouth onto Route 23 and back in, and the boulder pushed onto the +// floor switch stood on (7, 18) again, where a leg ran into it (console +// B, 2026-11-16, run 3). The other maps stay loaded: planned on the map +// alone, an edge onto a wall or a door's warp read as no wall, and 12.03 +// planned a leg on the water into Cinnabar's north wall as open. +std::optional shared_map(const std::vector& maps, const MapPosition& start, const RouteGoal& goal){ + if (start.map != goal.position.map){ + return std::nullopt; } - return resolved; + const int map = find_map(maps, start.map); + return map < 0 ? std::nullopt : std::optional(map); } -std::optional cut_gate_key(const std::vector& maps, const MapPosition& tree){ - for (const MapData& map : maps){ - if (map.name != tree.map || !map.tiles.contains(tree.point)){ - continue; - } - const Pokemon::MapGate* gate = Pokemon::gate_at(map, tree.point); - if (gate != nullptr && gate->kind == Pokemon::GateKind::CUT){ - return Pokemon::gate_key(map.name, gate->id); - } - } - return std::nullopt; -} +} // namespace -void regrow_cut_gates(const std::vector& maps, Pokemon::GateState& gates){ - for (const MapData& map : maps){ - for (const auto& [id, gate] : map.gates){ - if (gate.kind == Pokemon::GateKind::CUT){ - gates.opened.erase(Pokemon::gate_key(map.name, id)); - } +std::optional> plan_overworld_route( + const std::vector& maps, + const MapPosition& start, + const RouteGoal& goal, + const RouteCosts& costs, + std::optional start_facing +){ + if (const std::optional map = shared_map(maps, start, goal)){ + if (std::optional> route = plan_route_on(maps, start, goal, costs, start_facing, map)){ + return route; } } + return plan_route_on(maps, start, goal, costs, start_facing, std::nullopt); } + namespace{ // `legs` as route steps, each read on the maps its gates make. @@ -780,35 +765,40 @@ std::vector gated_route_steps(const GateMaps& gate_maps, const std::v } // namespace -std::optional> plan_overworld_route_gated( +namespace{ + +// Where a gated route starts: the tile, the gates as they stand, and the +// way the player faces, if known. +struct GatedRouteStart{ + const MapPosition& position; + const Pokemon::GateState& gates; + std::optional facing; +}; + +// plan_overworld_route_gated() on maps with gates, with no step off +// `only_map` if given. +std::optional> plan_gated_route_on( const std::vector& maps, - const MapPosition& start, + const GatedRouteStart& from, const RouteGoal& goal, - const Pokemon::GateState& gates, const Pokemon::GateRules& rules, const RouteCosts& costs, - std::optional start_facing + std::optional only_map ){ - if (!has_gates(maps)){ - return plan_overworld_route(maps, start, goal, costs, start_facing); - } - const int start_map = find_map(maps, start.map); + const int start_map = find_map(maps, from.position.map); const int goal_map = find_map(maps, goal.position.map); if (start_map < 0 || goal_map < 0){ throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Route between maps that aren't loaded."); } const GateMaps gate_maps(maps); - const std::vector& first_maps = gate_maps.at(gates); + const std::vector& first_maps = gate_maps.at(from.gates); Pokemon::GatedStart first; first.state.map = start_map; - first.state.state.position = start.point; - first.state.state.elevation = elevation_at(first_maps[start_map], start.point); - first.state.state.surfing = is_water(first_maps[start_map], start.point); - first.gates = gates; - first.facing = start_facing; - + first.state.state = PlayerState{from.position.point, elevation_at(first_maps[start_map], from.position.point), is_water(first_maps[start_map], from.position.point)}; + first.gates = from.gates; + first.facing = from.facing; const Pokemon::ConnectedMaps world(maps); - const GatedStepModel model(gate_maps, costs); + const GatedStepModel model(gate_maps, costs, only_map); const auto legs = Pokemon::plan_gated_legs( model, world, rules, first, Pokemon::GatedGoal{ @@ -829,12 +819,26 @@ std::optional> plan_overworld_route_gated( return route; } -Pokemon::GateState gates_after_route(const Pokemon::GateState& before, const std::vector& route){ - Pokemon::GateState gates = before; - for (const RouteStep& step : route){ - Pokemon::apply_gate_change(gates, step.gate_change); +} // namespace + +std::optional> plan_overworld_route_gated( + const std::vector& maps, + const MapPosition& start, + const RouteGoal& goal, + const Pokemon::GateState& gates, + const Pokemon::GateRules& rules, + const RouteCosts& costs, + std::optional start_facing +){ + if (!has_gates(maps)){ + return plan_overworld_route(maps, start, goal, costs, start_facing); + } + if (const std::optional map = shared_map(maps, start, goal)){ + if (std::optional> route = plan_gated_route_on(maps, {start, gates, start_facing}, goal, rules, costs, map)){ + return route; + } } - return gates; + return plan_gated_route_on(maps, {start, gates, start_facing}, goal, rules, costs, std::nullopt); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h index f8c2ca5b85..5d998a23e5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h @@ -30,8 +30,10 @@ namespace PokemonFRLG{ // The cheapest route from `start`, surfing if it is on water, to // `goal`, or nothing if there is none. `maps` must hold every map the route -// may pass through; warps to other maps are not taken. Planned with -// Pokemon::plan_legs() on the game's step rules. +// may pass through; warps to other maps are not taken. A route between two +// tiles of one map stays on that map if any route does: leaving it resets +// its objects (pushed boulders). Planned with Pokemon::plan_legs() on the +// game's step rules. std::optional> plan_overworld_route( const std::vector& maps, const MapPosition& start, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.cpp new file mode 100644 index 0000000000..1729cbd6d3 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.cpp @@ -0,0 +1,45 @@ +/* Overworld Route Costs + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "PokemonFRLG_OverworldRouteCosts.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +const RouteCosts& default_route_costs(){ + static const RouteCosts COSTS{ + {RouteCost::TILE, 1}, + {RouteCost::TURN, 2}, + {RouteCost::WARP, 30}, + {RouteCost::SURF, 40}, + {RouteCost::GRASS_TILE, 20}, + {RouteCost::OPEN_STOP, 8}, + {RouteCost::OPEN_WILD_STOP, 300}, + {RouteCost::SIGHT_TILE, 0}, + {RouteCost::LINE_TILE, 0}, + {RouteCost::SIGHT_OVERSHOOT, 0}, + {RouteCost::SIGN_OVERSHOOT, 3}, + {RouteCost::OPEN_WATER_STOP, 1000}, + {RouteCost::OPEN_CHECK, 10}, + }; + return COSTS; +} + +int route_cost(const RouteCosts& costs, RouteCost kind){ + auto iter = costs.find(kind); + if (iter == costs.end()){ + iter = default_route_costs().find(kind); + } + return iter->second; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.h index 3fe9394aa2..24b50423cd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.h @@ -43,6 +43,11 @@ enum class RouteCost{ // cost, not a ban: a route walks past a trainer when the way round // is much longer. SIGHT_TILE, + // Extra again for one in the line of a trainer who stands and looks + // one way. The story weighs these only: one who wanders or looks + // around can't be planned round, and the walk watches for them, its + // legs across their sight held to walls. + LINE_TILE, // Extra for an open leg whose tile past its end is one a trainer may // see: a leg that runs a tile on starts the battle (console B, // 2026-11-11 15:03, Rocket Hideout B2F: a south 2 to (19, 5) went on @@ -77,12 +82,13 @@ enum class RouteCost{ using RouteCosts = std::map; // TILE 1, TURN 2, WARP 30, SURF 40, GRASS_TILE 20, OPEN_STOP 8, -// OPEN_WILD_STOP 300, SIGHT_TILE 0, SIGHT_OVERSHOOT 0, SIGN_OVERSHOOT 3, -// OPEN_WATER_STOP 1000, OPEN_CHECK 10. +// OPEN_WILD_STOP 300, SIGHT_TILE 0, LINE_TILE 0, SIGHT_OVERSHOOT 0, +// SIGN_OVERSHOOT 3, OPEN_WATER_STOP 1000, OPEN_CHECK 10. // The sight costs are // off by default until beaten trainers and battles a story step wants are // told apart: at 100 and 10 they moved Pewter City's and Pewter Gym's -// plans (the Gym's Camper is fought on the way to Brock). +// plans (the Gym's Camper is fought on the way to Brock). The story's +// routes weigh LINE_TILE (story_route_costs()). const RouteCosts& default_route_costs(); // `costs`'s cost for `kind`, or the default if it has none. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp index b5fa8b1fa9..295cfd4bcd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Common/Cpp/Exceptions.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "Pokemon/Navigation/Pokemon_LegWalker.h" @@ -149,6 +150,7 @@ OverworldSim::OverworldSim(std::vector maps, MapPosition start, Directi open_start_gates(); m_player = PlayerState{start.point, elevation_at(map(), start.point), false}; m_state.facing = facing; + m_state.strength_on = m_script.strength_on; m_state.on_bike = m_script.on_bike; m_frozen = m_script.message_open; show(m_frozen ? SimScreen::MESSAGE : m_script.start_menu_open ? SimScreen::START_MENU : SimScreen::OVERWORLD, m_now); @@ -378,11 +380,12 @@ bool OverworldSim::after_step(const Step& step, Milliseconds pressed){ note("the warp takes the player off the Bicycle."); } m_frozen = true; - schedule(pressed + timing.tile, m_script.lift_exit_dims && m_script.lift_floors.contains(m_state.warped_from.back()) ? SimScreen::OVERWORLD : SimScreen::FADE, false); - schedule(pressed + timing.tile + timing.fade, SimScreen::OVERWORLD, timing.fade_in == 0ms); + schedule(pressed + timing.tile + timing.warp_fade_delay, m_script.lift_exit_dims && m_script.lift_floors.contains(m_state.warped_from.back()) ? SimScreen::OVERWORLD : SimScreen::FADE, false); + schedule(pressed + timing.tile + timing.warp_fade_delay + timing.fade, SimScreen::OVERWORLD, timing.fade_in == 0ms); if (timing.fade_in > 0ms){ - schedule(pressed + timing.tile + timing.fade + timing.fade_in, SimScreen::OVERWORLD, true); + schedule(pressed + timing.tile + timing.warp_fade_delay + timing.fade + timing.fade_in, SimScreen::OVERWORLD, true); } + battle_after_warp(pressed + timing.tile + timing.warp_fade_delay + timing.fade + timing.fade_in); note("warped to " + to_string(m_state.position) + "."); return true; } @@ -469,6 +472,14 @@ bool OverworldSim::rolls_encounter(int rate){ // Blocked holding `direction` at `pressed`: a sign walked into moving north // or south shows its message. void OverworldSim::bump(Direction direction, Milliseconds pressed){ + if (m_state.strength_on && boulder_ahead()){ + // With Strength on, walking into a boulder pushes it, as A's + // push does: 19.04d's hold east "to wall" at Victory Road 3F's + // (33, 18) pushed it into the hole (34, 18) with Strength on from + // the save (console B, 2026-11-16). + push_boulder(); + return; + } const TilePos ahead = m_player.position.next(direction); const bool sign = tile_at(map(), ahead) == TileKind::SIGN && (direction == Direction::NORTH || direction == Direction::SOUTH); @@ -677,9 +688,6 @@ namespace{ using namespace MovementMechanics; using namespace OverworldWalkSteps; -// The console's wait for a warp's fade (wait_out_warp()). -constexpr Milliseconds WARP_TIMEOUT(8000); - // The detection delay of the walker's interrupt `index` in `interrupts`. Milliseconds delay_of(const OverworldInterrupts& interrupts, size_t index){ return interrupts[index]->detection_delay(); @@ -764,37 +772,6 @@ std::optional OverworldSimWalker::hold_watching(const RouteStep& step, return m_sim.hold(step.direction, hold, STEP_RELEASE, hold + STEP_RELEASE + m_rules.watch_past_hold, watchers(interrupts)); } -// Whether a warp's fade showed and was over between `from` and now. -// wait_out_warp(), then run_from_battle_after_warp(): false if the fade -// was a wild battle's, run from. wait_out_warp()'s watcher takes a wild -// battle's wipe for the fade (run 7; console B, 2026-11-03, Mt. Moon 1F): -// the battle screen stands in for the wipe. The fade is watched for from -// `watched_from`: a fade over by then is missed. No warp: a step more, -// twice: a hold ends up to two tiles short, and an arrow warp (stairs) -// fires on the press made standing on it. -bool OverworldSimWalker::after_warp(const RouteStep& step, int warps_before, Milliseconds watched_from){ - if (black_without_warp(step, warps_before, watched_from)){ - return true; - } - bool battle = false; - if (m_sim.state().warps == warps_before && !(battle = m_sim.watch({SimWatcher::BATTLE_SCREEN}, WARP_TIMEOUT).has_value())){ - for (int tap = 0; tap < 2 && m_sim.state().warps == warps_before; tap++){ - m_log.push_back("Route: no fade; one more step into the warp."); - watched_from = m_sim.state().time; - m_sim.tap(step.direction, STEP_TAP, STEP_TAP_RELEASE); - } - } - if (!battle && (m_sim.state().warps == warps_before || (!fade_over_since(watched_from) && !m_rules.scene_confirms_missed_fade && !m_sim.watch({SimWatcher::FADE}, WARP_TIMEOUT)))){ - fail("walk_overworld_route(): no fade in and out after walking onto the warp to " + step.end.map + "."); - } - m_sim.watch({}, AFTER_WARP); - if (!m_sim.watch(watchers({m_wild[1]}), AFTER_WARP_BATTLE_WATCH - AFTER_WARP)){ - return true; - } - m_sim.handle_battle(SimBattleChoice::RUN); - return false; -} - void OverworldSimWalker::turn_or_fail(const RouteStep& step){ const OverworldWalkSteps::UnreadTurn unread{ .at_known = m_at_known, .overworld_clear = true, .after = OverworldWalkSteps::UnreadTurn::then_for(step), @@ -878,6 +855,8 @@ StepOutcome OverworldSimWalker::walk_ridden(const RouteStep& step, std::optional } }else if (const std::optional walked = walk_step(step, facing)){ return StepOutcome{.end = StepEnd::STOPPED, .walked = walked}; + }else if (std::exchange(m_warped_into_battle, false)){ + return StepOutcome{.end = StepEnd::WARPED, .walked = std::nullopt}; } if (step.action == RouteAction::FACE || step.action == RouteAction::OPEN_GATE || step.action == RouteAction::PRESS_SWITCH){ return StepOutcome{}; @@ -934,31 +913,30 @@ size_t OverworldSimWalker::clear_unseen_battle(const RouteStep& step){ return clear_late(m_wild, UNSEEN_BATTLE_WATCH, MAX_INTERRUPTIONS_PER_LEG); } -void OverworldSimWalker::hold_to_warp(const RouteStep& step){ +std::optional OverworldSimWalker::hold_to_warp(const RouteStep& step){ // The warp it holds on to takes the player off the Bicycle. m_riding = m_riding && warp_keeps_bike(step.end.map); const std::vector& ints = interrupts(step); - std::vector fade_first{SimWatcher::FADE}; - for (const SimWatcher watcher : watchers(ints)){ - fade_first.push_back(watcher); - } + std::vector fade_first = watchers(ints); + fade_first.insert(fade_first.begin(), SimWatcher::FADE); const int warps_before = m_sim.state().warps; for (size_t count = 0; count <= MAX_INTERRUPTIONS_PER_LEG; count++){ m_sim.tap(step.direction); const Milliseconds hold = TILE_TIME * (step.tiles + 2); - const std::optional seen = m_sim.hold(step.direction, hold, STEP_RELEASE, hold + STEP_RELEASE, fade_first); + const std::optional seen = m_sim.hold(step.direction, hold, STEP_RELEASE, hold + STEP_RELEASE + WARP_TIMEOUT, fade_first); if (seen && seen->watcher == 0){ if (!after_warp(step, warps_before, m_sim.state().time)){ fail_off_route(step); } - return; + return std::exchange(m_warped_into_battle, false) ? WarpBattle::AFTER : WarpBattle::NONE; } if (!seen){ break; } clear(ints[seen->watcher - 1]); } - fail("walk_overworld_route(): no fade holding on toward the warp to " + step.end.map + "."); + m_log.push_back(std::format("Route: no fade holding on toward the warp to {}.", step.end.map)); + return std::nullopt; } StepEnd OverworldSimWalker::watch_for_trainer(const RouteStep& step, const TrainerCrossing& crossing){ @@ -982,7 +960,7 @@ bool OverworldSimWalker::moved_past_wall(const RouteStep& step){ RouteCalls OverworldSimWalker::calls(){ RouteCalls calls; calls.walk = [this](const RouteStep& step, std::optional facing){ return walk(step, facing); }; - calls.hold_to_warp = [this](const RouteStep& step){ hold_to_warp(step); }; + calls.hold_to_warp = [this](const RouteStep& step){ return hold_to_warp(step); }; calls.log = [this](const std::string& message){ m_log.push_back(message); }; calls.fail = [this](const std::string& message){ fail(message); }; calls.moved_past_wall = [this](const RouteStep& step){ return moved_past_wall(step); }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h index 5ed59f6a62..e567bde2cc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h @@ -196,6 +196,10 @@ class OverworldSim{ bool push_poster_switch(); // SimField::PUSH_BOULDER. (PokemonFRLG_OverworldSimField.cpp) bool push_boulder(); + // Whether a pushable_boulder stands on the tile the player faces. + bool boulder_ahead() const; + // SimField::STRENGTH. + bool use_strength(); // A boulder fell through `hole`: the boulder the game hid on the floor // below (a pushable_boulder with a hide_flag) is shown. void land_fallen_boulder(const MapPosition& hole); @@ -211,9 +215,13 @@ class OverworldSim{ // its tree cut, to come back after a warp as one cut_tree() cuts. void open_start_gates(); // The trees cut come back, as after a warp. + // A warp's ClearTempFieldEventData (pokefirered): the trees cut grow + // back and Strength wears off. void regrow_cut_trees(); bool after_step(const Step& step, Milliseconds pressed); bool wild_battle(Milliseconds pressed); + // SimScript::battle_after_warp, once, after a warp's fade ending at `fade_end`. + void battle_after_warp(Milliseconds fade_end); std::optional next_encounter(); bool rolls_encounter(int rate); bool drops_turn_tap(); @@ -246,6 +254,7 @@ class OverworldSim{ bool m_frozen = false; // A battle is on screen or about to show. bool m_battle_pending = false; + bool m_battle_after_warp_done = false; // The trainer (an object of the player's map) whose message is up or // about to show, and whose battle follows it. std::optional m_trainer_speaking; @@ -503,7 +512,7 @@ class OverworldSimWalker{ size_t clear_unseen_battle(const RouteStep& step); bool battle_on_its_way() const; void clear(const Interrupt& interrupt); - void hold_to_warp(const RouteStep& step); + std::optional hold_to_warp(const RouteStep& step); StepEnd watch_for_trainer(const RouteStep& step, const TrainerCrossing& crossing); bool moved_past_wall(const RouteStep& step); void check_overworld(const RouteStep& step); @@ -522,6 +531,8 @@ class OverworldSimWalker{ // and whether its map was dark then. Milliseconds m_leg_start{0}; bool m_leg_dark = false; + // The last warp was taken, then a wild battle on the new map (WarpBattle::AFTER). + bool m_warped_into_battle = false; // Whether the walker takes the player to ride the Bicycle, and the // speed of the step under way. bool m_riding = false; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp index f3bbc40b8e..9be8de624c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp @@ -10,6 +10,7 @@ #include #include +#include #include "Pokemon/Navigation/Pokemon_GateTiles.h" #include "PokemonFRLG_CodedRooms.h" #include "PokemonFRLG_FlyMap.h" @@ -32,6 +33,13 @@ namespace{ constexpr Milliseconds CUT_TIME(4000); // The boulder's slide, one tile. Not measured on the console. constexpr Milliseconds PUSH_TIME(500); +// A floor switch's script after the boulder lands on it (pokefirered +// VictoryRoad_1F_EventScript_FloorSwitch: lockall, the barrier's +// metatiles, SE_ICE_BREAK, waitse, releaseall): no text, but no step +// either until the sound ends. The step tap 0.9 s after the push tap was +// lost (console B, 2026-11-16, 19.04b push_onto_switch); the length is a +// guess on the long side. +constexpr Milliseconds SWITCH_SCRIPT_TIME(1500); } // namespace @@ -44,6 +52,8 @@ bool OverworldSim::use_field(SimField field, size_t floor){ return push_poster_switch(); case SimField::PUSH_BOULDER: return push_boulder(); + case SimField::STRENGTH: + return use_strength(); case SimField::LIFT_FLOOR: return choose_lift_floor(floor); case SimField::BIKE_SELECT: @@ -186,6 +196,30 @@ void OverworldSim::land_fallen_boulder(const MapPosition& hole){ } } +bool OverworldSim::boulder_ahead() const{ + const TilePos ahead = m_player.position.next(m_state.facing); + const std::vector& objects = map().objects; + return std::any_of(objects.begin(), objects.end(), [&](const MapObject& object){ + return object.name == "pushable_boulder" && object.x == ahead.x && object.y == ahead.y; + }); +} + +bool OverworldSim::use_strength(){ + if (!boulder_ahead() || m_state.screen != SimScreen::OVERWORLD || m_frozen){ + violation(std::format("no boulder {} of {}: A for Strength shows nothing.", direction_name(m_state.facing), to_string(m_state.position))); + return false; + } + if (m_state.strength_on){ + // EventScript_AlreadyUsedStrength: a message, no YES/NO for the + // console's answer to wait for. + violation(std::format("Strength is on already on {}: A shows a message, no YES/NO.", to_string(m_state.position))); + return false; + } + note("Strength is on."); + m_state.strength_on = true; + return true; +} + bool OverworldSim::push_boulder(){ std::vector& objects = m_maps[m_map].objects; const TilePos ahead = m_player.position.next(m_state.facing); @@ -228,6 +262,8 @@ bool OverworldSim::push_boulder(){ m_state.gates.switches_on.insert(Pokemon::switch_key(*pressed)); read_gates(); note(std::format("switch {} is on.", Pokemon::switch_key(*pressed))); + m_frozen = true; + schedule(m_now + SWITCH_SCRIPT_TIME, SimScreen::OVERWORLD, /*unfreeze=*/true); } return true; } @@ -414,6 +450,7 @@ void OverworldSim::open_start_gates(){ } void OverworldSim::regrow_cut_trees(){ + m_state.strength_on = false; for (auto& [index, tree] : m_cut_trees){ m_maps[index].objects.push_back(tree); } @@ -424,6 +461,19 @@ void OverworldSim::regrow_cut_trees(){ } } +void OverworldSim::battle_after_warp(Milliseconds fade_end){ + if (!m_script.battle_after_warp || std::exchange(m_battle_after_warp_done, true)){ + return; + } + const Milliseconds pressed = fade_end + *m_script.battle_after_warp; + m_state.wild_battles++; + m_wild_battle_from = pressed; + m_battle_pending = true; + schedule(pressed + m_script.timing.flash, SimScreen::BATTLE_FLASH, false); + schedule(pressed + m_script.timing.battle_screen, SimScreen::BATTLE, false); + note(std::format("a wild battle on {}, after the warp.", to_string(m_state.position))); +} + bool OverworldSim::push_poster_switch(){ std::vector& objects = m_maps[m_map].objects; const TilePos ahead = m_player.position.next(m_state.facing); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.h index ffaa1bd629..f940f58f60 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.h @@ -46,6 +46,11 @@ enum class SimField{ // and the player's next step takes the tile it left. Strength is the // console's: the sim does not ask for it. PUSH_BOULDER, + // A on the boulder the player faces, and YES: Strength is on until the + // next warp (SimState::strength_on). A violation if it is on already + // (the game shows a message, no YES/NO) or no boulder is there (A + // shows nothing). + STRENGTH, // Not A: Fly from the party menu to the town numbered `floor` in // kanto_fly_towns(), outdoors: the fade, then the player on its landing // tile facing south, still for SimTiming::fly. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimScreens.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimScreens.h index 5f0be8df11..87df82b339 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimScreens.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimScreens.h @@ -85,6 +85,10 @@ struct SimTiming{ // pokefirered field_specials.c), and its chime. Not measured on the console. Milliseconds lift_ride{1500}; Milliseconds fade{1000}; // from the step's end to the new map + // From the step onto a warp to its fade's black. 0: none. On console + // B (2026-11-16 02:13, Victory Road 2F's ladder up) the black showed + // after a hold on toward the ladder and its watch had ended. + Milliseconds warp_fade_delay{0}; // From the fade's end, the new map fades in this long, and the game // takes no input yet (fault-class sweep; BDSP's Center, lab-B // 2026-11-10). Not measured on FRLG: 0, none. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h index a4ad367d85..a422a50be7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h @@ -54,6 +54,15 @@ struct SimScript{ // don't mark as grass: Mt. Moon B2F's tiles closed on one side ('8') // are cave floor too (console B, 2026-11-03). std::set wild_floor_maps; + // A wild battle this long after the first warp's fade ends, on the new + // map: on the console the hold onto Victory Road 3F's ladder walked on + // there and set one off (2026-11-16 02:18, 19.04c). The sim leaves the + // player on the warp's tile. + std::optional battle_after_warp; + // Strength is on at the start: a save keeps it, as Continue + // (pokefirered CB2_ContinueSavedGame) doesn't clear + // FLAG_SYS_USE_STRENGTH; only a warp does. + bool strength_on = false; // Whether the game holds the player up a tile on a step onto a // connected map. It did north onto Nugget Bridge (console B, // 2026-11-03, rows 05.05 and 05.09), not south from Route 6 into @@ -193,6 +202,9 @@ struct SimState{ bool on_bike = false; // On the water (SimField::SURF). bool surfing = false; + // Strength in use (SimField::STRENGTH, SimScript::strength_on): a + // step into a boulder pushes it. A warp turns it off. + bool strength_on = false; // Bicycle taps the game dropped, too soon after the last one. int bike_taps_dropped = 0; // Step taps the game ignored, inside the lockout after the last one diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp index 432a02bb4f..51b72355ce 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp @@ -269,6 +269,41 @@ bool OverworldSimWalker::fade_over_since(Milliseconds from) const{ } +// Whether a warp's fade showed and was over between `from` and now. +// wait_out_warp(), then run_from_battle_after_warp(): false if the fade +// was a wild battle's, run from; true with m_warped_into_battle if the new +// map's overworld showed before a battle (WarpBattle::AFTER). wait_out_warp()'s watcher takes a wild +// battle's wipe for the fade (run 7; console B, 2026-11-03, Mt. Moon 1F): +// the battle screen stands in for the wipe. The fade is watched for from +// `watched_from`: a fade over by then is missed. No warp: a step more, +// twice: a hold ends up to two tiles short, and an arrow warp (stairs) +// fires on the press made standing on it. +bool OverworldSimWalker::after_warp(const RouteStep& step, int warps_before, Milliseconds watched_from){ + if (black_without_warp(step, warps_before, watched_from)){ + return true; + } + bool battle = false; + if (m_sim.state().warps == warps_before && !(battle = m_sim.watch({SimWatcher::BATTLE_SCREEN}, WARP_TIMEOUT).has_value())){ + for (int tap = 0; tap < 2 && m_sim.state().warps == warps_before; tap++){ + m_log.push_back("Route: no fade; one more step into the warp."); + watched_from = m_sim.state().time; + m_sim.tap(step.direction, STEP_TAP, STEP_TAP_RELEASE); + } + } + if (!battle && (m_sim.state().warps == warps_before || (!fade_over_since(watched_from) && !m_rules.scene_confirms_missed_fade && !m_sim.watch({SimWatcher::FADE}, WARP_TIMEOUT)))){ + fail("walk_overworld_route(): no fade in and out after walking onto the warp to " + step.end.map + "."); + } + // run_from_battle_after_warp(): the new map's overworld after the fade. + const bool arrived = m_sim.state().screen == SimScreen::OVERWORLD && fade_over_since(watched_from); + m_sim.watch({}, AFTER_WARP); + if (!m_sim.watch(watchers({m_wild[1]}), AFTER_WARP_BATTLE_WATCH - AFTER_WARP)){ + return true; + } + m_sim.handle_battle(SimBattleChoice::RUN); + m_warped_into_battle = arrived; + return arrived; +} + // A fade seen with no warp: the console's screen check // (warp_left_scene()) finds the scene from before the hold. bool OverworldSimWalker::black_without_warp(const RouteStep& step, int warps_before, Milliseconds watched_from){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp index 6a8ac2a474..0f407a76dd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp @@ -299,16 +299,12 @@ UnitTestResult test_forest_north_gate(){ return true; } -// Console B, 2026-11-03, Mt. Moon 1F (row 04.05): a wild battle whose -// flashes were missed started on the leg south onto the ladder; its wipe -// passed for the ladder's fade, and the walker stopped as off the route, -// on the leg a tile short of the ladder. Here on the leg through the -// forest's grass onto its north gate: a battle on the leg's first or -// second step is run from, the player found again on the leg, and the -// gate reached through its warp: the player is on the leg's line, and -// holds on to it. If that hold then ends well short of the warp (hold 2: -// the leg, then the hold on), the route still stops on no fade. Without the -// rule it stops as off the route, as on the console. +// Console B, 2026-11-03, Mt. Moon 1F (row 04.05): a missed battle's wipe +// passed for the ladder's fade, and the walker stopped as off the route. +// Here on the forest's north gate: a battle on the leg's step 1 or 2 is +// run from, and the player holds on to the warp; a hold on that sees no +// black (hold 2 short, or a late black: console B, 2026-11-16 02:13, +// 19.04c) finds them again on the leg. Without the rule: off the route. UnitTestResult test_battle_on_warp_leg(){ const SimCase c{.start = at("ViridianForest", 5, 20), .facing = Direction::NORTH, .goal = at("Route2_ViridianForest_NorthEntrance", 7, 9)}; for (size_t tile : {1, 2}){ @@ -320,11 +316,15 @@ UnitTestResult test_battle_on_warp_leg(){ return std::format("Expected the battle on step {} run from, then the gate reached:", tile) + describe(*now); } } - SimCase no_warp = c; - no_warp.script.short_holds[2] = 6; - const std::optional short_back = run_with_battle_on_warp_leg(no_warp, 1); - if (!short_back || !stopped_with(*short_back, "no fade holding on toward the warp") || short_back->state.warps != 0){ - return "Expected a stop on no fade when the walk back ends short of the warp:" + (short_back ? describe(*short_back) : ""); + SimCase late_fade = c; + late_fade.script.timing.warp_fade_delay = Milliseconds(2000); + SimCase short_back = c; + short_back.script.short_holds[2] = 6; + for (const SimCase& held : {late_fade, short_back}){ + const std::optional run = run_with_battle_on_warp_leg(held, 1); + if (!run || !arrived(*run, c.goal) || run->state.warps != 1){ + return "Expected the gate reached after a hold on that saw no black:" + (run ? describe(*run) : ""); + } } SimCase off = c; off.rules.find_player_after_warp_battle = false; @@ -716,8 +716,8 @@ UnitTestResult test_mt_moon_battle_on_ladder_leg(){ // walked again to its wall, and the route reaches B2F's ladder. Without // the rule the leg is taken as walked, and the run stops on no fade onto // the ladder down to B2F, as it did (the console's walker stopped on the -// leg; this one, which holds on toward a warp after a wild battle, stops -// holding on). +// leg; this one holds on toward the warp, finds the player again when that +// sees no black (6fdafbc24), and walks onto it with the battle still on). UnitTestResult test_mt_moon_battle_seen_after_wall_leg(){ SimCase c{.start = at("MtMoon_B1F", 3, 3), .facing = Direction::SOUTH, .goal = at("MtMoon_B2F", 26, 21)}; c.script.encounters = {{.grass_step = 13, .seen_late = true}}; @@ -738,7 +738,7 @@ UnitTestResult test_mt_moon_battle_seen_after_wall_leg(){ const bool taken_as_walked = std::any_of(old.log.begin(), old.log.end(), [](const std::string& line){ return line.find("south 15 (to wall): ended at MtMoon_B1F (3, 18) (walked)") != std::string::npos; }); - if (!taken_as_walked || !stopped_with(old, "no fade holding on toward the warp to MtMoon_B2F.")){ + if (!taken_as_walked || !stopped_with(old, "no fade in and out after walking onto the warp to MtMoon_B2F.")){ return "Expected the leg taken as walked and the run stopped on no fade, as on the console, without the rule:" + describe(old); } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldStepChecks.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldStepChecks.h index d3c5895436..62dc179550 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldStepChecks.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldStepChecks.h @@ -32,6 +32,9 @@ enum class StepEnd{ // started. The step before it may have stopped part-way: its // battle was seen too late (console B, 2026-11-03, Mt. Moon B2F). BATTLE_BEFORE, + // Through the warp, then a wild battle on the new map: where on it the + // player stands isn't known (WarpBattle::AFTER). + WARPED, }; // Whether the screen moved while a step's hold ran, as the walker saw it. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp index ed5265c02d..eece211400 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -43,8 +43,6 @@ using namespace OverworldWalkSteps; namespace{ -// From the end of the hold, through the fade out and in. -constexpr Milliseconds WARP_TIMEOUT = 8000ms; constexpr Milliseconds SURF_PROMPT_TIMEOUT = 5000ms; constexpr Milliseconds SURF_ANIMATION = 3000ms; // A card-key door's message, and the door opening after it. @@ -660,19 +658,24 @@ size_t clear_battle_before( // Route 1's grass, and the step meant for Oak's Lab's door set off a // battle; its flashes and wipe passed for the warp's fade, the route went // on as if inside, and the next screen was the battle's FIGHT menu. -bool run_from_battle_after_warp(ConsoleHandle& console, ProControllerContext& context){ +WarpBattle run_from_battle_after_warp(ConsoleHandle& console, ProControllerContext& context){ + const bool overworld = battle_on_its_way(console, context).empty(); BattleScreenWatcher battle(COLOR_RED); context.wait_for_all_requests(); if (wait_until(console, context, AFTER_WARP_BATTLE_WATCH, {battle}) < 0){ - return false; + return WarpBattle::NONE; } flee_battle(console, context); - return true; + return overworld ? WarpBattle::AFTER : WarpBattle::INSTEAD; } -void check_warp_was_no_battle(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ - if (!run_from_battle_after_warp(console, context)){ - return; +WarpBattle check_warp_was_no_battle(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ + const WarpBattle battle = run_from_battle_after_warp(console, context); + if (battle != WarpBattle::INSTEAD){ + if (battle == WarpBattle::AFTER){ + console.log(std::format("Route: through the warp to {}, then a wild battle there: the player's tile isn't known.", step.end.map), COLOR_ORANGE); + } + return battle; } OperationFailedExceptionWithScreenshot::fire( ErrorReportMode::SEND_ERROR_REPORT, @@ -883,7 +886,13 @@ void walk_step_leg( } wait_out_warp(console, context, step, fade, before); static_assert(AFTER_WARP_BATTLE_WATCH >= AFTER_WARP); - check_warp_was_no_battle(console, context, step); + if (check_warp_was_no_battle(console, context, step) == WarpBattle::AFTER){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::format("walk_overworld_route(): a wild battle on {} after the warp: the player's tile there isn't known.", step.end.map), + console + ); + } } // A WALK step from `from`: turned first, then its leg. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkBattles.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkBattles.h index cd6ac0e11b..b472dd092a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkBattles.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkBattles.h @@ -14,6 +14,7 @@ #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" #include "PokemonFRLG_OverworldRoute.h" +#include "PokemonFRLG_OverworldWarpBattle.h" #include "PokemonFRLG_OverworldWalkMoves.h" namespace PokemonAutomation{ @@ -46,9 +47,10 @@ size_t clear_battle_before( const OverworldInterrupts& wild, const RouteStep& step ); -// After a warp's fade: if it was a wild battle's, runs from the battle and -// returns true. -bool run_from_battle_after_warp(ConsoleHandle& console, ProControllerContext& context); +// After a warp's fade: whether a wild battle follows, and if one does, +// whether the new map's overworld showed before it (the screen right after +// the fade isn't black or a battle's). Runs from the battle. +WarpBattle run_from_battle_after_warp(ConsoleHandle& console, ProControllerContext& context); // Whether `screen` is the overworld of a cave dark without Flash (Rock // Tunnel): black around a lit circle on the player in the middle. The @@ -61,8 +63,8 @@ bool run_from_battle_after_warp(ConsoleHandle& console, ProControllerContext& co bool dark_cave_screen(const ImageViewRGB32& screen); // After `step`'s warp: fails, once the battle is fled, if its fade was a -// wild battle's. -void check_warp_was_no_battle(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step); +// wild battle's. Returns what the battle check found: NONE or AFTER. +WarpBattle check_warp_was_no_battle(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkTimes.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkTimes.h index 61b0560c33..c9ee2838fe 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkTimes.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkTimes.h @@ -34,6 +34,8 @@ namespace OverworldWalkSteps{ // on its own, and a leg started before that ends loses tiles (on the console a // 600ms wait cost 2 tiles). inline constexpr Milliseconds AFTER_WARP(1500); +// From the end of a hold onto a warp, through the fade out and in. +inline constexpr Milliseconds WARP_TIMEOUT(8000); } // namespace OverworldWalkSteps diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpBattle.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpBattle.h new file mode 100644 index 0000000000..485acff782 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpBattle.h @@ -0,0 +1,30 @@ +/* Overworld Warp Battle + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_OverworldWarpBattle_H +#define PokemonAutomation_PokemonFRLG_OverworldWarpBattle_H + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// What a wild battle after a warp's fade says about the warp. +enum class WarpBattle{ + NONE, // no battle: the warp was taken + INSTEAD, // the fade was the battle's wipe: no warp + // The new map's overworld showed before the battle: the warp was taken, + // and the battle started there, a step or more on. Victory Road 3F's + // ladder, then a wild battle on 3F (console B, 2026-11-16 02:18, 19.04c). + AFTER, +}; + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 04905bec4a..f3047bd791 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -54,6 +54,7 @@ #include "Programs/AutoStory/PokemonFRLG_AutoStoryPaceSim.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h" +#include "Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryPartyRoster.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h" @@ -208,6 +209,7 @@ static void add_tests_AutoStoryAll(UnitTestDatabase& database){ add_tests_AutoStoryCapture(database); add_tests_AutoStoryPcStorage(database); add_tests_AutoStoryAbilities(database); + add_tests_AutoStoryCheckLevel(database); } void add_tests(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/BattleData/moves.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/BattleData/moves.json index 6927368ca1..64aeebeb0b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/BattleData/moves.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/BattleData/moves.json @@ -1,103 +1,103 @@ { -"pound": ["normal", 1, 35], -"karate-chop": ["fighting", 1, 25], -"double-slap": ["normal", 1, 10], -"comet-punch": ["normal", 1, 15], -"mega-punch": ["normal", 1, 20], -"pay-day": ["normal", 1, 20], -"fire-punch": ["fire", 1, 15], -"ice-punch": ["ice", 1, 15], -"thunder-punch": ["electric", 1, 15], -"scratch": ["normal", 1, 35], -"vise-grip": ["normal", 1, 30], +"pound": ["normal", 40, 35], +"karate-chop": ["fighting", 50, 25], +"double-slap": ["normal", 15, 10], +"comet-punch": ["normal", 18, 15], +"mega-punch": ["normal", 80, 20], +"pay-day": ["normal", 40, 20], +"fire-punch": ["fire", 75, 15], +"ice-punch": ["ice", 75, 15], +"thunder-punch": ["electric", 75, 15], +"scratch": ["normal", 40, 35], +"vise-grip": ["normal", 55, 30], "guillotine": ["normal", 1, 5], -"razor-wind": ["normal", 1, 10], +"razor-wind": ["normal", 80, 10], "swords-dance": ["normal", 0, 30], -"cut": ["normal", 1, 30], -"gust": ["flying", 1, 35], -"wing-attack": ["flying", 1, 35], +"cut": ["normal", 50, 30], +"gust": ["flying", 40, 35], +"wing-attack": ["flying", 60, 35], "whirlwind": ["normal", 0, 20], -"fly": ["flying", 1, 15], -"bind": ["normal", 1, 20], -"slam": ["normal", 1, 20], -"vine-whip": ["grass", 1, 10], -"stomp": ["normal", 1, 20], -"double-kick": ["fighting", 1, 30], -"mega-kick": ["normal", 1, 5], -"jump-kick": ["fighting", 1, 25], -"rolling-kick": ["fighting", 1, 15], +"fly": ["flying", 70, 15], +"bind": ["normal", 15, 20], +"slam": ["normal", 80, 20], +"vine-whip": ["grass", 35, 10], +"stomp": ["normal", 65, 20], +"double-kick": ["fighting", 30, 30], +"mega-kick": ["normal", 120, 5], +"jump-kick": ["fighting", 70, 25], +"rolling-kick": ["fighting", 60, 15], "sand-attack": ["ground", 0, 15], -"headbutt": ["normal", 1, 15], -"horn-attack": ["normal", 1, 25], -"fury-attack": ["normal", 1, 20], +"headbutt": ["normal", 70, 15], +"horn-attack": ["normal", 65, 25], +"fury-attack": ["normal", 15, 20], "horn-drill": ["normal", 1, 5], -"tackle": ["normal", 1, 35], -"body-slam": ["normal", 1, 15], -"wrap": ["normal", 1, 20], -"take-down": ["normal", 1, 20], -"thrash": ["normal", 1, 20], -"double-edge": ["normal", 1, 15], +"tackle": ["normal", 35, 35], +"body-slam": ["normal", 85, 15], +"wrap": ["normal", 15, 20], +"take-down": ["normal", 90, 20], +"thrash": ["normal", 90, 20], +"double-edge": ["normal", 120, 15], "tail-whip": ["normal", 0, 30], -"poison-sting": ["poison", 1, 35], -"twineedle": ["bug", 1, 20], -"pin-missile": ["bug", 1, 20], +"poison-sting": ["poison", 15, 35], +"twineedle": ["bug", 25, 20], +"pin-missile": ["bug", 14, 20], "leer": ["normal", 0, 30], -"bite": ["dark", 1, 25], +"bite": ["dark", 60, 25], "growl": ["normal", 0, 40], "roar": ["normal", 0, 20], "sing": ["normal", 0, 15], "supersonic": ["normal", 0, 20], "sonic-boom": ["normal", 1, 20], "disable": ["normal", 0, 20], -"acid": ["poison", 1, 30], -"ember": ["fire", 1, 25], -"flamethrower": ["fire", 1, 15], +"acid": ["poison", 40, 30], +"ember": ["fire", 40, 25], +"flamethrower": ["fire", 95, 15], "mist": ["ice", 0, 30], -"water-gun": ["water", 1, 25], -"hydro-pump": ["water", 1, 5], -"surf": ["water", 1, 15], -"ice-beam": ["ice", 1, 10], -"blizzard": ["ice", 1, 5], -"psybeam": ["psychic", 1, 20], -"bubble-beam": ["water", 1, 20], -"aurora-beam": ["ice", 1, 20], -"hyper-beam": ["normal", 1, 5], -"peck": ["flying", 1, 35], -"drill-peck": ["flying", 1, 20], -"submission": ["fighting", 1, 25], +"water-gun": ["water", 40, 25], +"hydro-pump": ["water", 120, 5], +"surf": ["water", 95, 15], +"ice-beam": ["ice", 95, 10], +"blizzard": ["ice", 120, 5], +"psybeam": ["psychic", 65, 20], +"bubble-beam": ["water", 65, 20], +"aurora-beam": ["ice", 65, 20], +"hyper-beam": ["normal", 150, 5], +"peck": ["flying", 35, 35], +"drill-peck": ["flying", 80, 20], +"submission": ["fighting", 80, 25], "low-kick": ["fighting", 1, 20], "counter": ["fighting", 1, 20], "seismic-toss": ["fighting", 1, 20], -"strength": ["normal", 1, 15], -"absorb": ["grass", 1, 20], -"mega-drain": ["grass", 1, 10], +"strength": ["normal", 80, 15], +"absorb": ["grass", 20, 20], +"mega-drain": ["grass", 40, 10], "leech-seed": ["grass", 0, 10], "growth": ["normal", 0, 40], -"razor-leaf": ["grass", 1, 25], -"solar-beam": ["grass", 1, 10], +"razor-leaf": ["grass", 55, 25], +"solar-beam": ["grass", 120, 10], "poison-powder": ["poison", 0, 35], "stun-spore": ["grass", 0, 30], "sleep-powder": ["grass", 0, 15], -"petal-dance": ["grass", 1, 20], +"petal-dance": ["grass", 70, 20], "string-shot": ["bug", 0, 40], "dragon-rage": ["dragon", 1, 10], -"fire-spin": ["fire", 1, 15], -"thunder-shock": ["electric", 1, 30], -"thunderbolt": ["electric", 1, 15], +"fire-spin": ["fire", 15, 15], +"thunder-shock": ["electric", 40, 30], +"thunderbolt": ["electric", 95, 15], "thunder-wave": ["electric", 0, 20], -"thunder": ["electric", 1, 10], -"rock-throw": ["rock", 1, 15], -"earthquake": ["ground", 1, 10], +"thunder": ["electric", 120, 10], +"rock-throw": ["rock", 50, 15], +"earthquake": ["ground", 100, 10], "fissure": ["ground", 1, 5], -"dig": ["ground", 1, 10], +"dig": ["ground", 60, 10], "toxic": ["poison", 0, 10], -"confusion": ["psychic", 1, 25], -"psychic": ["psychic", 1, 10], +"confusion": ["psychic", 50, 25], +"psychic": ["psychic", 90, 10], "hypnosis": ["psychic", 0, 20], "meditate": ["psychic", 0, 40], "agility": ["psychic", 0, 30], -"quick-attack": ["normal", 1, 30], -"rage": ["normal", 1, 20], +"quick-attack": ["normal", 40, 30], +"rage": ["normal", 20, 20], "teleport": ["psychic", 0, 20], "night-shade": ["ghost", 1, 15], "mimic": ["normal", 0, 10], @@ -118,98 +118,98 @@ "bide": ["normal", 1, 10], "metronome": ["normal", 0, 10], "mirror-move": ["flying", 0, 20], -"self-destruct": ["normal", 1, 5], -"egg-bomb": ["normal", 1, 10], -"lick": ["ghost", 1, 30], -"smog": ["poison", 1, 20], -"sludge": ["poison", 1, 20], -"bone-club": ["ground", 1, 20], -"fire-blast": ["fire", 1, 5], -"waterfall": ["water", 1, 15], -"clamp": ["water", 1, 10], -"swift": ["normal", 1, 20], -"skull-bash": ["normal", 1, 15], -"spike-cannon": ["normal", 1, 15], -"constrict": ["normal", 1, 35], +"self-destruct": ["normal", 200, 5], +"egg-bomb": ["normal", 100, 10], +"lick": ["ghost", 20, 30], +"smog": ["poison", 20, 20], +"sludge": ["poison", 65, 20], +"bone-club": ["ground", 65, 20], +"fire-blast": ["fire", 120, 5], +"waterfall": ["water", 80, 15], +"clamp": ["water", 35, 10], +"swift": ["normal", 60, 20], +"skull-bash": ["normal", 100, 15], +"spike-cannon": ["normal", 20, 15], +"constrict": ["normal", 10, 35], "amnesia": ["psychic", 0, 20], "kinesis": ["psychic", 0, 15], "soft-boiled": ["normal", 0, 10], -"high-jump-kick": ["fighting", 1, 20], +"high-jump-kick": ["fighting", 85, 20], "glare": ["normal", 0, 30], -"dream-eater": ["psychic", 1, 15], +"dream-eater": ["psychic", 100, 15], "poison-gas": ["poison", 0, 40], -"barrage": ["normal", 1, 20], -"leech-life": ["bug", 1, 15], +"barrage": ["normal", 15, 20], +"leech-life": ["bug", 20, 15], "lovely-kiss": ["normal", 0, 10], -"sky-attack": ["flying", 1, 5], +"sky-attack": ["flying", 140, 5], "transform": ["normal", 0, 10], -"bubble": ["water", 1, 30], -"dizzy-punch": ["normal", 1, 10], +"bubble": ["water", 20, 30], +"dizzy-punch": ["normal", 70, 10], "spore": ["grass", 0, 15], "flash": ["normal", 0, 20], "psywave": ["psychic", 1, 15], "splash": ["normal", 0, 40], "acid-armor": ["poison", 0, 40], -"crabhammer": ["water", 1, 10], -"explosion": ["normal", 1, 5], -"fury-swipes": ["normal", 1, 15], -"bonemerang": ["ground", 1, 10], +"crabhammer": ["water", 90, 10], +"explosion": ["normal", 250, 5], +"fury-swipes": ["normal", 18, 15], +"bonemerang": ["ground", 50, 10], "rest": ["psychic", 0, 10], -"rock-slide": ["rock", 1, 10], -"hyper-fang": ["normal", 1, 15], +"rock-slide": ["rock", 75, 10], +"hyper-fang": ["normal", 80, 15], "sharpen": ["normal", 0, 30], "conversion": ["normal", 0, 30], -"tri-attack": ["normal", 1, 10], +"tri-attack": ["normal", 80, 10], "super-fang": ["normal", 1, 10], -"slash": ["normal", 1, 20], +"slash": ["normal", 70, 20], "substitute": ["normal", 0, 10], -"struggle": ["normal", 1, 1], +"struggle": ["normal", 50, 1], "sketch": ["normal", 0, 1], -"triple-kick": ["fighting", 1, 10], -"thief": ["dark", 1, 10], +"triple-kick": ["fighting", 10, 10], +"thief": ["dark", 40, 10], "spider-web": ["bug", 0, 10], "mind-reader": ["normal", 0, 5], "nightmare": ["ghost", 0, 15], -"flame-wheel": ["fire", 1, 25], -"snore": ["normal", 1, 15], +"flame-wheel": ["fire", 60, 25], +"snore": ["normal", 40, 15], "curse": ["mystery", 0, 10], "flail": ["normal", 1, 15], "conversion-2": ["normal", 0, 30], -"aeroblast": ["flying", 1, 5], +"aeroblast": ["flying", 100, 5], "cotton-spore": ["grass", 0, 40], "reversal": ["fighting", 1, 15], "spite": ["ghost", 0, 10], -"powder-snow": ["ice", 1, 25], +"powder-snow": ["ice", 40, 25], "protect": ["normal", 0, 10], -"mach-punch": ["fighting", 1, 30], +"mach-punch": ["fighting", 40, 30], "scary-face": ["normal", 0, 10], -"feint-attack": ["dark", 1, 20], +"feint-attack": ["dark", 60, 20], "sweet-kiss": ["normal", 0, 10], "belly-drum": ["normal", 0, 10], -"sludge-bomb": ["poison", 1, 10], -"mud-slap": ["ground", 1, 10], -"octazooka": ["water", 1, 10], +"sludge-bomb": ["poison", 90, 10], +"mud-slap": ["ground", 20, 10], +"octazooka": ["water", 65, 10], "spikes": ["ground", 0, 20], -"zap-cannon": ["electric", 1, 5], +"zap-cannon": ["electric", 100, 5], "foresight": ["normal", 0, 40], "destiny-bond": ["ghost", 0, 5], "perish-song": ["normal", 0, 5], -"icy-wind": ["ice", 1, 15], +"icy-wind": ["ice", 55, 15], "detect": ["fighting", 0, 5], -"bone-rush": ["ground", 1, 10], +"bone-rush": ["ground", 25, 10], "lock-on": ["normal", 0, 5], -"outrage": ["dragon", 1, 15], +"outrage": ["dragon", 90, 15], "sandstorm": ["rock", 0, 10], -"giga-drain": ["grass", 1, 5], +"giga-drain": ["grass", 60, 5], "endure": ["normal", 0, 10], "charm": ["normal", 0, 20], -"rollout": ["rock", 1, 20], -"false-swipe": ["normal", 1, 40], +"rollout": ["rock", 30, 20], +"false-swipe": ["normal", 40, 40], "swagger": ["normal", 0, 15], "milk-drink": ["normal", 0, 10], -"spark": ["electric", 1, 20], -"fury-cutter": ["bug", 1, 20], -"steel-wing": ["steel", 1, 25], +"spark": ["electric", 65, 20], +"fury-cutter": ["bug", 10, 20], +"steel-wing": ["steel", 70, 25], "mean-look": ["normal", 0, 5], "attract": ["normal", 0, 15], "sleep-talk": ["normal", 0, 10], @@ -219,51 +219,51 @@ "frustration": ["normal", 1, 20], "safeguard": ["normal", 0, 25], "pain-split": ["normal", 0, 20], -"sacred-fire": ["fire", 1, 5], +"sacred-fire": ["fire", 100, 5], "magnitude": ["ground", 1, 30], -"dynamic-punch": ["fighting", 1, 5], -"megahorn": ["bug", 1, 10], -"dragon-breath": ["dragon", 1, 20], +"dynamic-punch": ["fighting", 100, 5], +"megahorn": ["bug", 120, 10], +"dragon-breath": ["dragon", 60, 20], "baton-pass": ["normal", 0, 40], "encore": ["normal", 0, 5], -"pursuit": ["dark", 1, 20], -"rapid-spin": ["normal", 1, 40], +"pursuit": ["dark", 40, 20], +"rapid-spin": ["normal", 20, 40], "sweet-scent": ["normal", 0, 20], -"iron-tail": ["steel", 1, 15], -"metal-claw": ["steel", 1, 35], -"vital-throw": ["fighting", 1, 10], +"iron-tail": ["steel", 100, 15], +"metal-claw": ["steel", 50, 35], +"vital-throw": ["fighting", 70, 10], "morning-sun": ["normal", 0, 5], "synthesis": ["grass", 0, 5], "moonlight": ["normal", 0, 5], "hidden-power": ["normal", 1, 15], -"cross-chop": ["fighting", 1, 5], -"twister": ["dragon", 1, 20], +"cross-chop": ["fighting", 100, 5], +"twister": ["dragon", 40, 20], "rain-dance": ["water", 0, 5], "sunny-day": ["fire", 0, 5], -"crunch": ["dark", 1, 15], +"crunch": ["dark", 80, 15], "mirror-coat": ["psychic", 1, 20], "psych-up": ["normal", 0, 10], -"extreme-speed": ["normal", 1, 5], -"ancient-power": ["rock", 1, 5], -"shadow-ball": ["ghost", 1, 15], -"future-sight": ["psychic", 1, 15], -"rock-smash": ["fighting", 1, 15], -"whirlpool": ["water", 1, 15], -"beat-up": ["dark", 1, 10], -"fake-out": ["normal", 1, 10], -"uproar": ["normal", 1, 10], +"extreme-speed": ["normal", 80, 5], +"ancient-power": ["rock", 60, 5], +"shadow-ball": ["ghost", 80, 15], +"future-sight": ["psychic", 80, 15], +"rock-smash": ["fighting", 20, 15], +"whirlpool": ["water", 15, 15], +"beat-up": ["dark", 10, 10], +"fake-out": ["normal", 40, 10], +"uproar": ["normal", 50, 10], "stockpile": ["normal", 0, 10], -"spit-up": ["normal", 1, 10], +"spit-up": ["normal", 100, 10], "swallow": ["normal", 0, 10], -"heat-wave": ["fire", 1, 10], +"heat-wave": ["fire", 100, 10], "hail": ["ice", 0, 10], "torment": ["dark", 0, 15], "flatter": ["dark", 0, 15], "will-o-wisp": ["fire", 0, 15], "memento": ["dark", 0, 10], -"facade": ["normal", 1, 20], -"focus-punch": ["fighting", 1, 20], -"smelling-salts": ["normal", 1, 10], +"facade": ["normal", 70, 20], +"focus-punch": ["fighting", 150, 20], +"smelling-salts": ["normal", 60, 10], "follow-me": ["normal", 0, 20], "nature-power": ["normal", 0, 20], "charge": ["electric", 0, 20], @@ -274,83 +274,83 @@ "wish": ["normal", 0, 10], "assist": ["normal", 0, 20], "ingrain": ["grass", 0, 20], -"superpower": ["fighting", 1, 5], +"superpower": ["fighting", 120, 5], "magic-coat": ["psychic", 0, 15], "recycle": ["normal", 0, 10], -"revenge": ["fighting", 1, 10], -"brick-break": ["fighting", 1, 15], +"revenge": ["fighting", 60, 10], +"brick-break": ["fighting", 75, 15], "yawn": ["normal", 0, 10], -"knock-off": ["dark", 1, 20], +"knock-off": ["dark", 20, 20], "endeavor": ["normal", 1, 5], -"eruption": ["fire", 1, 5], +"eruption": ["fire", 150, 5], "skill-swap": ["psychic", 0, 10], "imprison": ["psychic", 0, 10], "refresh": ["normal", 0, 20], "grudge": ["ghost", 0, 5], "snatch": ["dark", 0, 10], -"secret-power": ["normal", 1, 20], -"dive": ["water", 1, 10], -"arm-thrust": ["fighting", 1, 20], +"secret-power": ["normal", 70, 20], +"dive": ["water", 60, 10], +"arm-thrust": ["fighting", 15, 20], "camouflage": ["normal", 0, 20], "tail-glow": ["bug", 0, 20], -"luster-purge": ["psychic", 1, 5], -"mist-ball": ["psychic", 1, 5], +"luster-purge": ["psychic", 70, 5], +"mist-ball": ["psychic", 70, 5], "feather-dance": ["flying", 0, 15], "teeter-dance": ["normal", 0, 20], -"blaze-kick": ["fire", 1, 10], +"blaze-kick": ["fire", 85, 10], "mud-sport": ["ground", 0, 15], -"ice-ball": ["ice", 1, 20], -"needle-arm": ["grass", 1, 15], +"ice-ball": ["ice", 30, 20], +"needle-arm": ["grass", 60, 15], "slack-off": ["normal", 0, 10], -"hyper-voice": ["normal", 1, 10], -"poison-fang": ["poison", 1, 15], -"crush-claw": ["normal", 1, 10], -"blast-burn": ["fire", 1, 5], -"hydro-cannon": ["water", 1, 5], -"meteor-mash": ["steel", 1, 10], -"astonish": ["ghost", 1, 15], -"weather-ball": ["normal", 1, 10], +"hyper-voice": ["normal", 90, 10], +"poison-fang": ["poison", 50, 15], +"crush-claw": ["normal", 75, 10], +"blast-burn": ["fire", 150, 5], +"hydro-cannon": ["water", 150, 5], +"meteor-mash": ["steel", 100, 10], +"astonish": ["ghost", 30, 15], +"weather-ball": ["normal", 50, 10], "aromatherapy": ["grass", 0, 5], "fake-tears": ["dark", 0, 20], -"air-cutter": ["flying", 1, 25], -"overheat": ["fire", 1, 5], +"air-cutter": ["flying", 55, 25], +"overheat": ["fire", 140, 5], "odor-sleuth": ["normal", 0, 40], -"rock-tomb": ["rock", 1, 10], -"silver-wind": ["bug", 1, 5], +"rock-tomb": ["rock", 50, 10], +"silver-wind": ["bug", 60, 5], "metal-sound": ["steel", 0, 40], "grass-whistle": ["grass", 0, 15], "tickle": ["normal", 0, 20], "cosmic-power": ["psychic", 0, 20], -"water-spout": ["water", 1, 5], -"signal-beam": ["bug", 1, 15], -"shadow-punch": ["ghost", 1, 20], -"extrasensory": ["psychic", 1, 30], -"sky-uppercut": ["fighting", 1, 15], -"sand-tomb": ["ground", 1, 15], +"water-spout": ["water", 150, 5], +"signal-beam": ["bug", 75, 15], +"shadow-punch": ["ghost", 60, 20], +"extrasensory": ["psychic", 80, 30], +"sky-uppercut": ["fighting", 85, 15], +"sand-tomb": ["ground", 15, 15], "sheer-cold": ["ice", 1, 5], -"muddy-water": ["water", 1, 10], -"bullet-seed": ["grass", 1, 30], -"aerial-ace": ["flying", 1, 20], -"icicle-spear": ["ice", 1, 30], +"muddy-water": ["water", 95, 10], +"bullet-seed": ["grass", 10, 30], +"aerial-ace": ["flying", 60, 20], +"icicle-spear": ["ice", 10, 30], "iron-defense": ["steel", 0, 15], "block": ["normal", 0, 5], "howl": ["normal", 0, 40], -"dragon-claw": ["dragon", 1, 15], -"frenzy-plant": ["grass", 1, 5], +"dragon-claw": ["dragon", 80, 15], +"frenzy-plant": ["grass", 150, 5], "bulk-up": ["fighting", 0, 20], -"bounce": ["flying", 1, 5], -"mud-shot": ["ground", 1, 15], -"poison-tail": ["poison", 1, 25], -"covet": ["normal", 1, 40], -"volt-tackle": ["electric", 1, 15], -"magical-leaf": ["grass", 1, 20], +"bounce": ["flying", 85, 5], +"mud-shot": ["ground", 55, 15], +"poison-tail": ["poison", 50, 25], +"covet": ["normal", 40, 40], +"volt-tackle": ["electric", 120, 15], +"magical-leaf": ["grass", 60, 20], "water-sport": ["water", 0, 15], "calm-mind": ["psychic", 0, 20], -"leaf-blade": ["grass", 1, 15], +"leaf-blade": ["grass", 70, 15], "dragon-dance": ["dragon", 0, 20], -"rock-blast": ["rock", 1, 10], -"shock-wave": ["electric", 1, 20], -"water-pulse": ["water", 1, 20], -"doom-desire": ["steel", 1, 5], -"psycho-boost": ["psychic", 1, 5] +"rock-blast": ["rock", 25, 10], +"shock-wave": ["electric", 60, 20], +"water-pulse": ["water", 60, 20], +"doom-desire": ["steel", 120, 5], +"psycho-boost": ["psychic", 140, 5] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp index c4670c692e..2b2ccb1e51 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp @@ -277,13 +277,16 @@ Pokemon::StoryGameHooks story_game(SingleSwitchProgramEnvironment& env, StoryEnv }; game.after_load = [&story](Pokemon::RunState&){ story.supplies = story.saved_supplies; + // The save's counts are the story's record, not a read of this + // bag: the next battle reads it first. + story.supplies.counts_read = false; // The save's party, which a catch or a gift since then changed. story.party.invalidate_species(); story.party.users() = story.saved_field_moves.users(); - // Until read in full, so each verify run starts from the bag as - // the save holds it, not from a count once read wrong or not at - // all (console B, 2026-11-03: 0 Potions in all 3 runs). Once - // read, a reload of the same save restores it. + // The Bag's check, once per save. It changes no count: a battle + // or recovery whose counts are a row's guess reads the pocket + // itself (console B, 2026-11-15: 19.01's rival fought with 0 + // Potions and no X item when Default skipped this read). try{ if (!story.bag_read){ read_bag_supplies(story, story.start_menu); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp index b832f421a7..70d8fa00fd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryAbilities_Tests.cpp @@ -155,7 +155,9 @@ std::vector step_cases(){ const Pokemon::StoryStep grind = grind_step("grind", "", {.member = 0, .level = 20, .max_encounters = 5, .pace = Pokemon::Direction::EAST, .heal_every = 0}, {}); return { {"level reached", none, level_step("check", "", {.slot = 0, .level = 16}), "unchanged"}, - {"level below", none, level_step("check", "", {.slot = 0, .level = 17}), "level_below"}, + {"level 3 below the minimum passes", [](StubGame& game){ game.level = 47; }, level_step("check", "", {.slot = 0, .level = 50}), "unchanged"}, + {"level 1 below the minimum passes", [](StubGame& game){ game.level = 49; }, level_step("check", "", {.slot = 0, .level = 50}), "unchanged"}, + {"level 4 below the minimum fails", [](StubGame& game){ game.level = 46; }, level_step("check", "", {.slot = 0, .level = 50}), "level_below"}, {"level unread", [](StubGame& game){ game.level.reset(); }, level_step("check", "", {.slot = 0, .level = 16}), "level_unread"}, {"a Mart purchase that fails", none, mart, "mart_failed"}, {"a move it knows already succeeds", none, teach_step("teach", "", {.item = "hm03", .move = "surf", .member = 0}), "unchanged"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp index 63e4f9c425..77b96f739f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp @@ -16,6 +16,7 @@ #include "CommonTools/Async/InferenceRoutines.h" #include "CommonTools/Images/SolidColorTest.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" #include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" #include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.h" @@ -32,6 +33,7 @@ #include "VideoGames/PokemonFRLG/Programs/PokemonFRLG_StartMenuNavigation.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryGenderMenu.h" +#include "PokemonFRLG_AutoStoryStartMenuOpening.h" #include "PokemonFRLG_AutoStoryStepInterrupts.h" #include "PokemonFRLG_AutoStoryTrainerMessage.h" @@ -157,10 +159,10 @@ bool move_start_cursor_to_save(ConsoleHandle& console, ProControllerContext& con } // Overlaps open_start_menu() and move_cursor_to_position() in PokemonFRLG_StartMenuNavigation.h. -// Ours wraps open_start_menu() and then moves the cursor by row for any START menu variant. +// Ours opens it on a quiet overworld (open_start_menu_settled()) and then moves the cursor by row for any START menu variant. // Could be unified with upstream if needed. void open_start_menu_row(ConsoleHandle& console, ProControllerContext& context, StartMenu menu, int row){ - open_start_menu(console, context); + open_start_menu_settled(console, context); if (!move_start_cursor(console, context, start_menu_rows(menu), row)){ OperationFailedExceptionWithScreenshot::fire( ErrorReportMode::SEND_ERROR_REPORT, "START menu: no cursor.", console @@ -788,7 +790,7 @@ void save_game( } std::string read_save_place(ConsoleHandle& console, ProControllerContext& context, Language language){ - open_start_menu(console, context); + open_start_menu_settled(console, context); if (!move_start_cursor_to_save(console, context)){ OperationFailedExceptionWithScreenshot::fire( ErrorReportMode::SEND_ERROR_REPORT, "START menu: no cursor.", console @@ -952,7 +954,7 @@ void buy_items( } cursor = order.row; mart_shot(console, context, std::format("row{}-list", order.row + 1)); - if (checks_screen(checks)){ + if (Pokemon::runs_check(checks, Pokemon::StoryCheckKind::MENU_ROW)){ check_mart_row(console, context, order, language); } // "How many?" drops presses while its text prints. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp index e40499b8e7..209b0bdbc0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp @@ -15,6 +15,7 @@ #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "Pokemon/AutoStory/Pokemon_ConsoleReadings.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" #include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" #include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h" @@ -29,11 +30,16 @@ #include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryBattleData.h" +#include "PokemonFRLG_AutoStoryBattleText.h" #include "PokemonFRLG_AutoStoryBattleDecisions.h" #include "PokemonFRLG_AutoStoryBattle.h" #include "PokemonFRLG_AutoStoryBagUse.h" +#include "PokemonFRLG_AutoStoryBattleBag.h" +#include "PokemonFRLG_AutoStoryBattleSwitch.h" #include "PokemonFRLG_AutoStoryHealing.h" #include "PokemonFRLG_AutoStoryHealingSteps.h" +#include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryLeadOut.h" #include "PokemonFRLG_AutoStoryPocketList.h" namespace PokemonAutomation{ @@ -147,75 +153,6 @@ void tap(ProControllerContext& context, DpadPosition position){ pbf_press_dpad(context, position, 160ms, 240ms); } -// In the bag, with the cursor on `row`: whether that row is `item`. FAST -// doesn't look. A row that can't be read (as in a language the reader has -// no names for) is taken by its position; only another item's name stops it. -bool bag_row_is( - ConsoleHandle& console, ProControllerContext& context, - int row, int shown, const std::string& item, Pokemon::StoryCheckLevel checks, Language language -){ - if (!checks_screen(checks)){ - return true; - } - context.wait_for_all_requests(); - VideoSnapshot screen = console.video().snapshot(); - const std::string read = screen ? read_item_list_name(console, language, screen, shown) : ""; - if (read == item){ - return true; - } - if (read.empty()){ - console.log(std::format("Bag: row {} unread, taking it as the {} by its position.", row + 1, item), COLOR_ORANGE); - return true; - } - console.log(std::format("Bag: row {} reads \"{}\", not {}: not using it.", row + 1, read, item), COLOR_RED); - dump_debug_image(console, "AutoStory/bag", std::format("row{}-not-{}", row + 1, item), screen); - return false; -} - -// What an item in battle is used on. -enum class ItemTarget{ - // A Potion or a cure: the party list opens, its cursor on the starter. - PARTY_MEMBER, - // An X item: the Pokemon out, with no party list. - POKEMON_OUT, -}; - -// From the battle menu: `item`, in `row` (from 0) of the Items pocket, on -// `target`. The bag opens on the pocket used last; Items is the first. -// Returns whether it was used; else (THOROUGH) backs out to the menu. -bool use_item( - ConsoleHandle& console, ProControllerContext& context, - const Supplies& supplies, const std::string& item, ItemTarget target, Pokemon::StoryCheckLevel checks, Language language -){ - const int row = item_row(supplies, item); - console.log(std::format("Battle: using the {} in row {} of the Items pocket.", item, row + 1)); - tap(context, DPAD_LEFT); - tap(context, DPAD_UP); - tap(context, DPAD_RIGHT); - pbf_press_button(context, BUTTON_A, 160ms, 1500ms); - for (int c = 0; c < 2; c++){ - pbf_press_dpad(context, DPAD_LEFT, 160ms, 500ms); - } - for (int c = 0; c < 12; c++){ - pbf_press_dpad(context, DPAD_UP, 100ms, 150ms); - } - for (int c = 0; c < row; c++){ - tap(context, DPAD_DOWN); - } - if (!bag_row_is(console, context, row, item_shown_row(supplies, row), item, checks, language)){ - pbf_press_button(context, BUTTON_B, 160ms, 1500ms); - return false; - } - // The item, USE, then the starter in the party list. An X item's USE - // goes straight to the battle's text, which the loop reads. - pbf_press_button(context, BUTTON_A, 160ms, 800ms); - pbf_press_button(context, BUTTON_A, 160ms, 1500ms); - if (target == ItemTarget::PARTY_MEMBER){ - pbf_press_button(context, BUTTON_A, 160ms, 1000ms); - } - return true; -} - // RUN, bottom right of the battle menu. // Overlaps flee_battle() in PokemonFRLG_Navigation.h. // Ours is one blind turn that resets the cursor first, since the battle loop reads the result itself; @@ -304,20 +241,6 @@ bool forget_move(ConsoleHandle& console, ProControllerContext& context, size_t s return true; } -TurnResult item_result(bool used){ - return used ? TurnResult::DONE : TurnResult::NOT_DONE; -} - -// The party list in battle opens on the lead: down to `slot`, then A, and -// SHIFT, the top of its menu. -void send_member(ProControllerContext& context, size_t slot){ - for (size_t c = 0; c < slot; c++){ - pbf_press_dpad(context, DPAD_DOWN, 160ms, 400ms); - } - pbf_press_button(context, BUTTON_A, 160ms, 800ms); - pbf_press_button(context, BUTTON_A, 160ms, 1500ms); -} - class BattleLoop{ public: @@ -402,6 +325,7 @@ class BattleLoop{ read_hp(screen); watch_for_faint(screen); check_run_refused(seen, screen); + read_policy_text(seen, screen, now); act(seen, screen, now); return false; } @@ -594,30 +518,70 @@ class BattleLoop{ m_last_press = now; } + // From the battle menu, before the first turn (battle_needs_bag_read()): the + // Items pocket through BAG, read whole and closed again, its counts + // taken as the battle's. With nothing read the battle stops rather + // than fight on counts it doesn't know. + void read_battle_bag(){ + m_console.log("Battle: the Items pocket's counts are not known; reading it before the first turn."); + // The pocket's rows as counted, and its CANCEL. + const std::vector rows = read_battle_pocket(m_console, m_context, m_language, m_supplies.pocket.size() + 1); + // A read ends with the cursor on the top row. + m_bag_cursor.row = 0; + if (rows.empty()){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + "Battle: couldn't read the Items pocket; not fighting on unknown item counts.", + m_console + ); + } + set_from_bag(m_supplies, rows); + } + void log_turn(const PartyStatus& status, const TurnAction& action){ m_console.log(std::format( - "Battle: turn {}, HP {} ({:.0f}% of the bar), {}, {} Potions, {} Antidotes, {} Parlyz Heals, {} Awakenings.", + "Battle: turn {}, HP {} ({:.0f}% of the bar), {}, {}.", m_decisions.turns(), status.hp_red ? "red" : status.hp_yellow ? "yellow" : "green", 100 * status.hp_fill, - status_name(status.status), m_supplies.potions, m_supplies.antidotes, m_supplies.parlyz_heals, m_supplies.awakenings + status_name(status.status), supply_line(m_supplies) )); if (!action.heal_reason.empty()){ m_console.log("Battle: " + action.heal_reason + "."); } } - void take_turn(const ImageViewRGB32& screen){ + // The Pokemon out on the battle menu: a wild battle's at its first + // menu, a trainer's and ours at each. + void read_battlers(const ImageViewRGB32& screen){ const bool trainer = m_kind == BattleKind::TRAINER; if (!trainer && m_decisions.turns() == 0){ m_supplies.wild_foes = read_wild_foes(m_console.logger(), m_language, screen); } if (trainer){ m_supplies.foe_out = read_trainer_foe(m_console.logger(), m_language, screen, m_supplies.foes); + m_supplies.own_out = read_own_battler(m_console.logger(), m_language, screen); + } + } + + // The lead's box, the foe's bar and the battle texts since the last turn. + PartyStatus turn_status(const ImageViewRGB32& screen){ + PartyStatus status = read_party_status(screen); + if (m_kind == BattleKind::TRAINER){ + status.foe_fill = read_opponent_hp_fill(screen); } + status.battle_texts = std::exchange(m_policy_texts, {}); + return status; + } + void take_turn(const ImageViewRGB32& screen){ + read_battlers(screen); if (m_refusal.refused(current_time())){ m_console.log("Battle: the move list came back without a turn (Disable?); choosing another move.", COLOR_ORANGE); m_decisions.turn_done(TurnChoice::MOVE, TurnResult::REFUSED); } - const PartyStatus status = read_party_status(screen); + if (m_decisions.turns() == 0 && battle_needs_bag_read(m_supplies, m_kind)){ + read_battle_bag(); + return; + } + const PartyStatus status = turn_status(screen); const TurnAction action = m_decisions.turn(status); m_evolution.turn_taken(action.choice); m_ran = action.choice == TurnChoice::RUN; @@ -629,19 +593,22 @@ class BattleLoop{ run_away(m_context); return; case TurnChoice::POTION: - m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, "potion", ItemTarget::PARTY_MEMBER, m_checks, m_language))); + m_decisions.turn_done(action.choice, use_item("potion", ItemTarget::PARTY_MEMBER)); return; case TurnChoice::ANTIDOTE: - m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, "antidote", ItemTarget::PARTY_MEMBER, m_checks, m_language))); + m_decisions.turn_done(action.choice, use_item("antidote", ItemTarget::PARTY_MEMBER)); return; case TurnChoice::AWAKENING: - m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, "awakening", ItemTarget::PARTY_MEMBER, m_checks, m_language))); + m_decisions.turn_done(action.choice, use_item("awakening", ItemTarget::PARTY_MEMBER)); return; case TurnChoice::MEDICINE: - m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, action.item, ItemTarget::PARTY_MEMBER, m_checks, m_language))); + m_decisions.turn_done(action.choice, use_item(action.item, ItemTarget::PARTY_MEMBER)); return; case TurnChoice::BATTLE_ITEM: - m_decisions.turn_done(action.choice, item_result(use_item(m_console, m_context, m_supplies, action.item, ItemTarget::POKEMON_OUT, m_checks, m_language))); + m_decisions.turn_done(action.choice, use_item(action.item, ItemTarget::POKEMON_OUT)); + return; + case TurnChoice::SWITCH_LEAD: + m_decisions.turn_done(action.choice, switch_lead_in(m_console, m_context, m_language, m_supplies.lead.species) ? TurnResult::DONE : TurnResult::NOT_DONE); return; case TurnChoice::MOVE: m_console.log(std::format("Battle: move {}.", action.slot + 1)); @@ -680,6 +647,27 @@ class BattleLoop{ m_decisions.turn_done(TurnChoice::RUN, TurnResult::REFUSED); } + // From the battle menu: `item` from the Items pocket on `target` + // (use_battle_item()); back at the menu if it wasn't used. + TurnResult use_item(const std::string& item, ItemTarget target){ + ConsoleBattleBag bag(m_console, m_context, target, m_checks, m_language, m_bag_cursor); + return use_battle_item(item, m_console.logger(), bag, m_supplies) ? TurnResult::DONE : TurnResult::NOT_DONE; + } + + // A League fight's battle texts, kept for the policy's next turn (PokemonSimulation #110). + void read_policy_text(BattleScreen seen, const ImageViewRGB32& screen, WallClock now){ + const bool text = seen == BattleScreen::ADVANCE || seen == BattleScreen::OTHER; + if (!text || m_supplies.policy.kind != BattlePolicyKind::BUDGETED_SETUP || now - m_last_policy_text < POLL){ + return; + } + m_last_policy_text = now; + std::optional letters = read_battle_text(m_language, screen); + if (letters && (m_policy_texts.empty() || m_policy_texts.back() != *letters)){ + m_console.log(std::format("Battle: text \"{}\".", *letters)); + m_policy_texts.push_back(std::move(*letters)); + } + } + ConsoleHandle& m_console; ProControllerContext& m_context; Supplies& m_supplies; @@ -692,11 +680,15 @@ class BattleLoop{ BattleKind m_kind; const Pokemon::StoryCheckLevel m_checks; const Language m_language; + // The bag's cursor in this battle. + BattleBagCursor m_bag_cursor; const WallClock m_start; WallClock m_last_battle; WallClock m_last_press; WallClock m_last_menu; WallClock m_last_overworld_check; + WallClock m_last_policy_text = WallClock{}; + std::vector m_policy_texts; BattleScreen m_last_seen = BattleScreen::NONE; bool m_seen_battle = false; bool m_confirmed = false; @@ -834,6 +826,10 @@ class StoryMessage : public OverworldInterrupt{ ConsoleItemUseActions bag(console, context, m_language, m_supplies.repel_menu); const ItemUseEnd end = renew_repel(console.logger(), bag, m_supplies.repel); console.log("Story: another Repel after the last wore off: " + item_use_end_name(end) + "."); + // Not counted: the last Repel takes its row with it. + if (end == ItemUseEnd::USED){ + m_supplies.counts_read = false; + } } } @@ -846,22 +842,6 @@ class StoryMessage : public OverworldInterrupt{ } // namespace -std::string_view status_name(StatusCondition status){ - switch (status){ - case StatusCondition::NONE: - return "no status"; - case StatusCondition::POISON: - return "PSN"; - case StatusCondition::PARALYSIS: - return "PAR"; - case StatusCondition::SLEEP: - return "SLP"; - case StatusCondition::OTHER: - return "a status"; - } - return "?"; -} - StatusCondition read_status_badge(const ImageViewRGB32& badge){ const ImageStats stats = image_stats(badge); const double r = stats.average.r; @@ -935,6 +915,13 @@ void recover_after_battle( ConsoleHandle& console, ProControllerContext& context, Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language ){ + // Counts a row guessed: the recovery reads the pocket itself first. + if (!supplies.counts_read && (supplies.hurt || supplies.status != StatusCondition::NONE)){ + const std::vector rows = read_items_pocket(console, context, language); + if (!rows.empty()){ + set_from_bag(supplies, rows); + } + } for (const std::string& item : recovery_items(supplies)){ use_recovery_item(console, context, item, checks, language, supplies); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h index 4d35ab056a..a6bdb6d528 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h @@ -77,6 +77,11 @@ struct PartyStatus{ // The HP bar's filled share of its width, 0 to 1, for the log. double hp_fill = 0; StatusCondition status = StatusCondition::NONE; + // The foe's HP bar's filled share, none if not read. + std::optional foe_fill = std::nullopt; + // The battle texts read since the last battle menu, in a League fight + // (read_battle_text()), for the policy's KO risk. + std::vector battle_texts = {}; }; // Reads current party health and status from battle screen. PartyStatus read_party_status(const ImageViewRGB32& screen); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.cpp new file mode 100644 index 0000000000..196495b75c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.cpp @@ -0,0 +1,151 @@ +/* AutoStory Battle Bag + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Common/Cpp/Color.h" +#include "CommonFramework/Tools/DebugDumper.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonFRLG_AutoStoryBattleBag.h" +#include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryPocketList.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +using namespace std::chrono_literals; + + +bool bag_row_is( + ConsoleHandle& console, ProControllerContext& context, + int row, int shown, const std::string& item, Pokemon::StoryCheckLevel checks, Language language +){ + if (!Pokemon::runs_check(checks, Pokemon::StoryCheckKind::MENU_ROW)){ + return true; + } + context.wait_for_all_requests(); + VideoSnapshot screen = console.video().snapshot(); + const std::string read = screen ? read_item_list_name(console, language, screen, shown) : ""; + if (read == item){ + return true; + } + if (read.empty()){ + console.log(std::format("Bag: row {} unread, taking it as the {} by its position.", row + 1, item), COLOR_ORANGE); + return true; + } + console.log(std::format("Bag: row {} reads \"{}\", not {}: not using it.", row + 1, read, item), COLOR_RED); + dump_debug_image(console, "AutoStory/bag", std::format("row{}-not-{}", row + 1, item), screen); + return false; +} + +namespace{ + +// `item` at its row as `supplies` has it, if it has one. +bool use_battle_item_row(const std::string& item, const Supplies& supplies, Logger& logger, BattleBag& bag){ + const int row = item_row(supplies, item); + if (row < 0){ + logger.log(std::format("Battle: no {} in the Items pocket.", item)); + return false; + } + logger.log(std::format("Battle: using the {} in row {} of the Items pocket.", item, row + 1)); + return bag.use_row(supplies, row, item_shown_row(supplies, row), item); +} + +// The UP presses that bring the cursor to the pocket's top: its rows as +// counted, and its CANCEL. +size_t rows_to_top(const Supplies& supplies){ + return supplies.pocket.size() + 1; +} + +} // namespace + +bool use_battle_item(const std::string& item, Logger& logger, BattleBag& bag, Supplies& supplies){ + if (use_battle_item_row(item, supplies, logger, bag)){ + return true; + } + logger.log(std::format("Battle: the {} isn't where the counts put it; reading the Items pocket again.", item)); + const std::vector rows = bag.read_pocket(supplies); + if (rows.empty()){ + return false; + } + set_from_bag(supplies, rows); + return use_battle_item_row(item, supplies, logger, bag); +} + +ConsoleBattleBag::ConsoleBattleBag( + ConsoleHandle& console, ProControllerContext& context, ItemTarget target, + Pokemon::StoryCheckLevel checks, Language language, BattleBagCursor& cursor +) + : m_console(console) + , m_context(context) + , m_target(target) + , m_checks(checks) + , m_language(language) + , m_cursor(cursor) +{} + +std::vector ConsoleBattleBag::read_pocket(const Supplies& supplies){ + std::vector rows = read_battle_pocket(m_console, m_context, m_language, rows_to_top(supplies)); + // A read ends with the cursor on the top row. + m_cursor.row = 0; + return rows; +} + +bool ConsoleBattleBag::use_row(const Supplies& supplies, int row, int shown, const std::string& item){ + int from = 0; + if (m_cursor.row){ + open_battle_items_pocket(m_context); + from = *m_cursor.row; + m_console.log(std::format("Bag: cursor from row {} to row {}.", from + 1, row + 1)); + }else{ + open_battle_bag(m_context, rows_to_top(supplies)); + m_console.log(std::format("Bag: cursor to the top, then to row {}.", row + 1)); + } + for (int c = from; c < row; c++){ + pbf_press_dpad(m_context, DPAD_DOWN, /*hold=*/160ms, /*release=*/240ms); + } + for (int c = row; c < from; c++){ + pbf_press_dpad(m_context, DPAD_UP, /*hold=*/160ms, /*release=*/240ms); + } + // Used or not, the bag keeps the cursor here; a used-up item's row + // goes, and the row below it moves up under the cursor. + m_cursor.row = row; + if (!bag_row_is(m_console, m_context, row, shown, item, m_checks, m_language)){ + pbf_press_button(m_context, BUTTON_B, /*hold=*/160ms, /*release=*/1500ms); + return false; + } + // The item, USE, then the starter in the party list. An X item's USE + // goes straight to the battle's text, which the loop reads. + pbf_press_button(m_context, BUTTON_A, /*hold=*/160ms, /*release=*/800ms); + pbf_press_button(m_context, BUTTON_A, /*hold=*/160ms, /*release=*/1500ms); + if (m_target == ItemTarget::PARTY_MEMBER){ + pbf_press_button(m_context, BUTTON_A, /*hold=*/160ms, /*release=*/1000ms); + } + return true; +} + +std::string supply_line(const Supplies& supplies){ + std::string line = std::format("{} Potions, {} Super Potions", supplies.potions, supplies.super_potions); + for (const auto& [item, count] : supplies.other_counts){ + if (count > 0 && medicine_hp(item) > 0){ + line += std::format(", {} {}", count, item); + } + } + line += std::format( + ", {} Antidotes, {} Parlyz Heals, {} Awakenings, {} Full Heals", + supplies.antidotes, supplies.parlyz_heals, supplies.awakenings, supplies.full_heals + ); + return line; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.h new file mode 100644 index 0000000000..a3cd66b016 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.h @@ -0,0 +1,113 @@ +/* AutoStory Battle Bag + * + * From: https://github.com/PokemonAutomation/ + * + * Items used from the Items pocket in battle, on the console or a test's + * bag: each found at its row, the pocket read again when the row holds + * another item. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryBattleBag_H +#define PokemonAutomation_PokemonFRLG_AutoStoryBattleBag_H + +#include +#include +#include +#include "Common/Cpp/Logging/AbstractLogger.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonFramework/Language.h" +#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.h" +#include "PokemonFRLG_AutoStorySupplies.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// In the bag, with the cursor on `row` (from 0), shown as row `shown`: +// whether that row is `item`, read when the check level runs MENU_ROW +// checks; taken as it otherwise. A row that can't be read (as in a +// language the reader has no names for) is taken by its position; only +// another item's name stops it. +bool bag_row_is( + ConsoleHandle& console, ProControllerContext& context, + int row, int shown, const std::string& item, Pokemon::StoryCheckLevel checks, Language language +); + +// The bag in battle, from the battle menu and back to it: the console's +// or a test's. +class BattleBag{ +public: + virtual ~BattleBag() = default; + // The Items pocket read whole (read_whole_pocket()). Empty if nothing + // could be read. + virtual std::vector read_pocket(const Supplies& supplies) = 0; + // The cursor on `row` (from 0) of the Items pocket, shown as row + // `shown`: if that row is `item`, it is used and true; else the bag + // closed with nothing used, and false. + virtual bool use_row(const Supplies& supplies, int row, int shown, const std::string& item) = 0; +}; + +// `item` from the Items pocket in battle, at its row as `supplies` has +// it. A row that reads as another item gets the pocket read again, its +// counts and order taken from it (set_from_bag()), and the item tried +// once more at its row there: one mismatch skipped the Route 22 rival's +// X Specials (console B, 2026-11-16). Returns whether it was used; the +// counts aren't spent here. +bool use_battle_item(const std::string& item, Logger& logger, BattleBag& bag, Supplies& supplies); + +// What an item in battle is used on. +enum class ItemTarget{ + // A Potion or a cure: the party list opens, its cursor on the starter. + PARTY_MEMBER, + // An X item: the Pokemon out, with no party list. + POKEMON_OUT, +}; + +// The Items pocket's cursor row in one battle, once the program has put +// it somewhere: the bag keeps it between uses, so the next use moves the +// cursor from there rather than back to the top first (the rows plus +// CANCEL in UP presses every time, before). Unknown at the battle's start. +struct BattleBagCursor{ + std::optional row = std::nullopt; +}; + +// The console's bag in battle, an item used on `target`. It opens on the +// pocket used last; Items is the first. +class ConsoleBattleBag : public BattleBag{ +public: + ConsoleBattleBag( + ConsoleHandle& console, ProControllerContext& context, ItemTarget target, + Pokemon::StoryCheckLevel checks, Language language, BattleBagCursor& cursor + ); + virtual std::vector read_pocket(const Supplies& supplies) override; + virtual bool use_row(const Supplies& supplies, int row, int shown, const std::string& item) override; + +private: + ConsoleHandle& m_console; + ProControllerContext& m_context; + ItemTarget m_target; + Pokemon::StoryCheckLevel m_checks; + Language m_language; + BattleBagCursor& m_cursor; +}; + +// The battle's supply line, for its turn log: the Potions and Super +// Potions, every other HP medicine the bag was read to hold, then the +// cures. 6 Super Potions went unlisted at the Route 22 rival (console B, +// 2026-11-16). +std::string supply_line(const Supplies& supplies); + + +// use_battle_item() on a made-up bag, and the supply line. +void add_tests_AutoStoryBattleBag(UnitTestDatabase& database); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag_Tests.cpp new file mode 100644 index 0000000000..20b6a886d7 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag_Tests.cpp @@ -0,0 +1,197 @@ +/* AutoStory Battle Bag Tests + * + * From: https://github.com/PokemonAutomation/ + * + * use_battle_item() on a made-up bag in battle, and the battle's supply + * line. + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Logging/AbstractLogger.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_AutoStoryBattleBag.h" +#include "PokemonFRLG_AutoStoryItemsPocket.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// 19.01b's Items pocket at the Route 22 rival (console B, 2026-11-16). +const std::vector ROUTE22_RIVAL_POCKET = { + {"moon-stone", 2}, {"potion", 3}, {"repel", 2}, {"escape-rope", 4}, {"super-repel", 4}, + {"rare-candy", 1}, {"x-special", 14}, {"x-speed", 6}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"elixir", 1}, {"super-potion", 6}, {"antidote", 1}, {"parlyz-heal", 2}, +}; + +// `rows` without `item`'s row: the pocket as counted before the item came +// or after the last one went, the rows below it one higher. +std::vector rows_without(const std::vector& rows, std::string_view item){ + std::vector kept; + for (const BagRow& row : rows){ + if (row.item != item){ + kept.push_back(row); + } + } + return kept; +} + +// A bag in battle on the sim: its Items pocket, a row used if it holds +// the item asked for. +class SimBattleBag : public BattleBag{ +public: + explicit SimBattleBag(std::vector rows) + : m_rows(std::move(rows)) + {} + virtual std::vector read_pocket(const Supplies&) override{ + m_reads++; + return m_rows; + } + virtual bool use_row(const Supplies&, int row, int, const std::string& item) override{ + m_tried.push_back(row); + return row >= 0 && static_cast(row) < m_rows.size() && m_rows[static_cast(row)].item == item; + } + int reads() const{ + return m_reads; + } + const std::vector& tried() const{ + return m_tried; + } + +private: + std::vector m_rows; + int m_reads = 0; + std::vector m_tried; +}; + +struct BattleItemInput{ + // The pocket as the story's counts have it. + std::vector counted; + // The pocket the bag really holds. + std::vector bag; + std::string item; +}; +struct BattleItemExpectation{ + bool used; + // The rows tried, from 0, in turn. + std::vector tried; + int reads; +}; +struct BattleItemCase{ + std::string name; + BattleItemInput input; + BattleItemExpectation expectation; +}; + +class Test_UseBattleItem : public UnitTest{ +public: + explicit Test_UseBattleItem(BattleItemCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryBattleBag - battle item: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + Supplies supplies; + set_from_bag(supplies, m_case.input.counted); + SimBattleBag bag(m_case.input.bag); + const bool used = use_battle_item(m_case.input.item, logger, bag, supplies); + const BattleItemExpectation& expected = m_case.expectation; + if (used != expected.used || bag.tried() != expected.tried || bag.reads() != expected.reads){ + return std::format( + "Used {} after {} rows tried and {} reads; expected {} after {} and {}.", + used, bag.tried().size(), bag.reads(), expected.used, expected.tried.size(), expected.reads + ); + } + return true; + } + +private: + BattleItemCase m_case; +}; + +const BattleItemCase BATTLE_ITEM_CASES[] = { + { + .name = "its row as counted: used, no read", + .input = {.counted = ROUTE22_RIVAL_POCKET, .bag = ROUTE22_RIVAL_POCKET, .item = "x-special"}, + .expectation = {.used = true, .tried = {6}, .reads = 0}, + }, + { + .name = "stale counts, the X Special a row lower: read again, then used", + .input = {.counted = rows_without(ROUTE22_RIVAL_POCKET, "escape-rope"), .bag = ROUTE22_RIVAL_POCKET, .item = "x-special"}, + .expectation = {.used = true, .tried = {5, 6}, .reads = 1}, + }, + { + .name = "none in the bag after the read: not used", + .input = {.counted = ROUTE22_RIVAL_POCKET, .bag = rows_without(ROUTE22_RIVAL_POCKET, "x-special"), .item = "x-special"}, + .expectation = {.used = false, .tried = {6}, .reads = 1}, + }, +}; + +struct SupplyLineInput{ + std::vector pocket; +}; +struct SupplyLineExpectation{ + std::string line; +}; +struct SupplyLineCase{ + std::string name; + SupplyLineInput input; + SupplyLineExpectation expectation; +}; + +class Test_SupplyLine : public UnitTest{ +public: + explicit Test_SupplyLine(SupplyLineCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryBattleBag - supply line: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + Supplies supplies; + set_from_bag(supplies, m_case.input.pocket); + const std::string line = supply_line(supplies); + if (line != m_case.expectation.line){ + return std::format("\"{}\"; expected \"{}\".", line, m_case.expectation.line); + } + return true; + } + +private: + SupplyLineCase m_case; +}; + +const SupplyLineCase SUPPLY_LINE_CASES[] = { + { + .name = "the Route 22 rival's bag lists its Super Potions", + .input = {.pocket = ROUTE22_RIVAL_POCKET}, + .expectation = {.line = "3 Potions, 6 Super Potions, 1 Antidotes, 2 Parlyz Heals, 0 Awakenings, 0 Full Heals"}, + }, + { + .name = "a Hyper Potion read from the bag is listed", + .input = {.pocket = {{"potion", 2}, {"hyper-potion", 4}, {"x-special", 3}}}, + .expectation = {.line = "2 Potions, 0 Super Potions, 4 hyper-potion, 0 Antidotes, 0 Parlyz Heals, 0 Awakenings, 0 Full Heals"}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryBattleBag(UnitTestDatabase& database){ + for (const BattleItemCase& test_case : BATTLE_ITEM_CASES){ + database.add(test_case); + } + for (const SupplyLineCase& test_case : SUPPLY_LINE_CASES){ + database.add(test_case); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.cpp index c07774c92d..0fc651dd06 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.cpp @@ -85,14 +85,15 @@ uint8_t byte_of(const JsonValue& value){ template using Table = std::map>; -// [type, damaging (0 or 1), pp] +// [type, power (0: no damage; 1: damage not from power), pp] const Table& moves(){ static const Table MOVES = []{ Table moves; for (const auto& [name, value] : file_json("moves").to_object_throw()){ const JsonArray& entry = value.to_array_throw(); + const uint8_t power = byte_of(entry[1]); moves.emplace(name, MoveData{ - .type = type_of(entry[0]), .damaging = entry[1].to_integer_throw() != 0, .pp = byte_of(entry[2]), + .type = type_of(entry[0]), .damaging = power != 0, .power = power, .pp = byte_of(entry[2]), }); } return moves; @@ -210,6 +211,14 @@ PokemonType ability_immunity(std::string_view species){ return PokemonType::NONE; } +bool may_have_thick_fat(std::string_view species){ + static constexpr std::string_view THICK_FAT[] = { + "seel", "dewgong", "snorlax", "marill", "azumarill", "miltank", + "makuhita", "hariyama", "spoink", "grumpig", "spheal", "sealeo", "walrein", + }; + return std::ranges::find(THICK_FAT, species) != std::end(THICK_FAT); +} + bool takes_two_turns(std::string_view move){ static constexpr std::string_view TWO_TURN_MOVES[] = {"dig", "fly", "solar-beam", "skull-bash", "razor-wind", "sky-attack"}; return std::ranges::find(TWO_TURN_MOVES, move) != std::end(TWO_TURN_MOVES); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h index 4e8e5e239d..554577c817 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h @@ -4,8 +4,7 @@ * * The game's data the story's attacks are chosen from when the plan has * none, built into the program from BattleData/: the type chart, each - * species' types, and each move's type, whether it does damage and its - * PP. A battle's foes come from its step in the checkpoint's plan. + * species' types, and each move's type, power (0: no damage) and PP. A battle's foes come from its step in the checkpoint's plan. * * Names are the program's slugs ("water-gun", "mr-mime"). * diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData_Tests.cpp index 206e201ddd..342624b22a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData_Tests.cpp @@ -2,7 +2,8 @@ * * From: https://github.com/PokemonAutomation/ * - * The battle data, and the attacks chosen against trainers' parties and wild Pokemon from it. + * The battle data, and the attacks chosen against trainers' parties and wild Pokemon from it; + * a status cured in a trainer's battle. * */ @@ -19,6 +20,7 @@ #include "PokemonFRLG_AutoStoryBattle.h" #include "PokemonFRLG_AutoStoryBattleData.h" #include "PokemonFRLG_AutoStoryBattleDecisions.h" +#include "PokemonFRLG_AutoStoryLeadOut.h" #include "PokemonFRLG_AutoStoryParty.h" namespace PokemonAutomation{ @@ -256,7 +258,236 @@ UnitTestResult test_wild_fallback(){ return true; } +// Victory Road's lead as it met Cooltrainer Colby (console B, 2026-11-16, +// 19.04d): Blastoise Lv51 with Bite, Strength, Surf and Blizzard. +PartyMember victory_road_blastoise(){ + return PartyMember{ + .species = "blastoise", + .moves = {{"bite", 25}, {"strength", 15}, {"surf", 15}, {"blizzard", 5}}, + .moves_through_level = 51, + .moves_read = true, + .level = 51, + }; +} + +// 19.04d (console B, 2026-11-16 03:34): against Colby's Water party the +// lead used Bite, as 1x as Strength and first in the plan's order, until +// its PP ran out. The best type matchup, then the most damage of the +// matchups that tie (power, half again for the lead's own type). +UnitTestResult test_matchup_then_power(){ + const PartyMember blastoise = victory_road_blastoise(); + const std::vector> cases = { + {"kingler", "strength"}, + {"tentacruel", "strength"}, + {"blastoise", "strength"}, + {"onix", "surf"}, + {"rhydon", "surf"}, + {"raticate", "surf"}, + {"dragonair", "blizzard"}, + {"pidgeot", "blizzard"}, + }; + for (const auto& [foe, expected] : cases){ + const std::optional slot = attack_slot_against(blastoise, {foe}); + const std::string chosen = slot ? blastoise.moves[*slot].move : "none"; + if (chosen != expected){ + return std::format("{}: expected {}, got {}.", foe, expected, chosen); + } + } + return true; +} + +// Lorelei (console B, 2026-11-16, 20.01): after four X Specials the lead +// used Strength on Dewgong for 11 turns. PokeGuy's Blastoise Lv51 +// (PokemonSimulation docs/battles/pokeguy-conditions.md, lorelei) and her +// foes' Defense and Sp. Def from the same table. +PartyMember lorelei_blastoise(){ + PartyMember blastoise = victory_road_blastoise(); + blastoise.stats = Stats{.hp = 159, .attack = 107, .defense = 108, .sp_attack = 123, .sp_defense = 124, .speed = 107}; + return blastoise; +} + +std::string pick(const PartyMember& member, std::string_view foe, const AttackContext& context){ + const std::optional slot = attack_slot_against(member, {std::string(foe)}, context); + return slot ? member.moves[*slot].move : "none"; +} + +constexpr FoeStats DEWGONG = {.defense = 103, .sp_defense = 119}; + +// Bite (Dark: special in Gen 3) at x3 hits ~83, Strength ~38. Surf would +// hit harder still, but Water on a Water foe is never chosen. +UnitTestResult test_dewgong_after_setup(){ + const std::string chosen = pick(lorelei_blastoise(), "dewgong", {.sp_attack_stage = 4, .foe = DEWGONG}); + return chosen == "bite" ? UnitTestResult(true) : UnitTestResult(std::format("Expected Bite at +4, got {}.", chosen)); +} + +// Strength ~38 against Bite ~29 and Blizzard ~7 (resisted twice, and +// Thick Fat halves its power). +UnitTestResult test_dewgong_without_setup(){ + const std::string chosen = pick(lorelei_blastoise(), "dewgong", {.foe = DEWGONG}); + return chosen == "strength" ? UnitTestResult(true) : UnitTestResult(std::format("Expected Strength at +0, got {}.", chosen)); +} + +// Jynx (Ice/Psychic): Defense 59, Sp. Def 135. Strength ~65, Surf ~57, +// Bite (2x) ~52: the matchup alone took Bite. +UnitTestResult test_jynx_physical(){ + const std::string chosen = pick(lorelei_blastoise(), "jynx", {.foe = FoeStats{.defense = 59, .sp_defense = 135}}); + return chosen == "strength" ? UnitTestResult(true) : UnitTestResult(std::format("Expected Strength on Jynx, got {}.", chosen)); +} + +// A Raticate with Defense and Sp. Def 80 (made up for the case): Surf +// ~99 at +0 beats Strength ~49; at Attack +3 (x2.5) Strength hits ~119. +UnitTestResult test_x_attack_physical(){ + const FoeStats even{.defense = 80, .sp_defense = 80}; + const std::string plain = pick(lorelei_blastoise(), "raticate", {.foe = even}); + const std::string boosted = pick(lorelei_blastoise(), "raticate", {.attack_stage = 3, .foe = even}); + if (plain != "surf" || boosted != "strength"){ + return std::format("Expected Surf at Attack +0 and Strength at +3, got {} and {}.", plain, boosted); + } + return true; +} + +// 19.04d (console B, 2026-11-16 03:36): paralysed by Colby's Kingler, the +// lead fought his four other Pokemon with PAR and 2 Parlyz Heals in the +// bag. A trainer's battle cures PAR with a Parlyz Heal once the HP needs +// no Super Potion first; a wild Pokemon is run from instead. +UnitTestResult test_paralysis_cured(){ + struct Input{ + BattleKind kind; + bool hp_yellow; + }; + struct Expectation{ + TurnChoice choice; + std::string item; + }; + struct Case{ + std::string name; + Input input; + Expectation expectation; + }; + const std::vector cases = { + {.name = "a trainer, HP green", .input = {BattleKind::TRAINER, false}, .expectation = {TurnChoice::MEDICINE, "parlyz-heal"}}, + {.name = "a trainer, HP yellow", .input = {BattleKind::TRAINER, true}, .expectation = {TurnChoice::MEDICINE, "super-potion"}}, + {.name = "a wild Pokemon", .input = {BattleKind::WILD_FIGHT, false}, .expectation = {TurnChoice::RUN, ""}}, + }; + for (const Case& c : cases){ + Supplies supplies; + supplies.lead = victory_road_blastoise(); + supplies.foe_out = "poliwhirl"; + supplies.super_potions = 4; + supplies.parlyz_heals = 2; + BattleDecisions decisions(supplies, c.input.kind); + const PartyStatus paralysed{.hp_seen = true, .hp_yellow = c.input.hp_yellow, .hp_red = false, .hp_fill = 0.5, .status = StatusCondition::PARALYSIS}; + const TurnAction action = decisions.turn(paralysed); + if (action.choice != c.expectation.choice || action.item != c.expectation.item){ + return std::format("{}: expected \"{}\", got choice {} \"{}\".", c.name, c.expectation.item, static_cast(action.choice), action.item); + } + } + return true; +} + +// A Parlyz Heal used: one fewer in the bag, and the lead counts as cured. +UnitTestResult test_parlyz_heal_used(){ + Supplies supplies; + supplies.lead = victory_road_blastoise(); + supplies.parlyz_heals = 2; + BattleDecisions decisions(supplies, BattleKind::TRAINER); + decisions.turn(PartyStatus{.hp_seen = true, .hp_yellow = false, .hp_red = false, .hp_fill = 0.7, .status = StatusCondition::PARALYSIS}); + decisions.turn_done(TurnChoice::MEDICINE, TurnResult::DONE); + if (supplies.parlyz_heals != 1 || supplies.status != StatusCondition::NONE){ + return std::format("{} Parlyz Heal(s) left, status {}; expected 1 left and no status.", supplies.parlyz_heals, status_name(supplies.status)); + } + return true; +} + +// Bruno's fight after the Roar: the lead's box went (the faint watch), our +// Lapras is out and nothing was sent. The turn switches Blastoise back in, +// the next is its own again; a real faint later still sends the next +// member that isn't protected (Magikarp, slot 2), never the lead's +// switch-in. +UnitTestResult test_dragged_out_lead_switched_back(){ + Supplies supplies; + supplies.lead = lorelei_blastoise(); + supplies.protected_slots = {1}; + const PartyStatus green{.hp_seen = true, .hp_fill = 1.0}; + BattleDecisions decisions(supplies, BattleKind::TRAINER); + supplies.own_out = "blastoise"; + decisions.turn(green); + decisions.lead_fainted(); + supplies.own_out = "lapras"; + const TurnAction action = decisions.turn(green); + if (action.choice != TurnChoice::SWITCH_LEAD || decisions.lost()){ + return "Expected the lead switched back in, and the battle not lost."; + } + decisions.turn_done(TurnChoice::SWITCH_LEAD, TurnResult::DONE); + supplies.own_out = "blastoise"; + if (decisions.turn(green).choice == TurnChoice::SWITCH_LEAD || decisions.lost()){ + return "Expected the lead's own turn after the switch back."; + } + if (decisions.next_member_slot() != std::optional(2)){ + return "Expected slot 3 sent after a real faint, past the protected slot 2."; + } + supplies.own_out = "lapras"; + if (decisions.turn(green).choice == TurnChoice::SWITCH_LEAD){ + return "Expected no switch back after a real faint."; + } + return true; +} + +// The switch back couldn't be made (the list didn't read the lead): the +// rule is off for the battle, and a lead that had lost its box is lost. +UnitTestResult test_switch_back_failed(){ + Supplies supplies; + supplies.lead = lorelei_blastoise(); + const PartyStatus green{.hp_seen = true, .hp_fill = 1.0}; + BattleDecisions decisions(supplies, BattleKind::TRAINER); + decisions.turn(green); + decisions.lead_fainted(); + supplies.own_out = "lapras"; + decisions.turn(green); + decisions.turn_done(TurnChoice::SWITCH_LEAD, TurnResult::NOT_DONE); + if (!decisions.lost() || decisions.turn(green).choice == TurnChoice::SWITCH_LEAD){ + return "Expected the battle lost and no second switch back."; + } + return true; +} + const AutoStoryBattleDataTestCase AUTO_STORY_BATTLE_DATA_CASES[] = { + { + .input = {.name = "Bruno's Roar: the lead switched back in", .body = test_dragged_out_lead_switched_back}, + .expectation = {.description = "SWITCH_LEAD, then the lead's own turn; a real faint later sends past the protected member"}, + }, + { + .input = {.name = "a switch back that couldn't be made", .body = test_switch_back_failed}, + .expectation = {.description = "the battle lost, the rule off"}, + }, + { + .input = {.name = "Victory Road's Blastoise: the best matchup, then the strongest move", .body = test_matchup_then_power}, + .expectation = {.description = "Strength on Kingler, Tentacruel and Blastoise; Surf on Onix, Rhydon and Raticate; Blizzard on Dragonair and Pidgeot"}, + }, + { + .input = {.name = "Lorelei's Dewgong at Sp. Atk +4", .body = test_dewgong_after_setup}, + .expectation = {.description = "Bite, the special move Water-on-Water leaves, over Strength"}, + }, + { + .input = {.name = "Lorelei's Dewgong at Sp. Atk +0", .body = test_dewgong_without_setup}, + .expectation = {.description = "Strength"}, + }, + { + .input = {.name = "Lorelei's Jynx, Defense 59", .body = test_jynx_physical}, + .expectation = {.description = "Strength over Surf and the super effective Bite"}, + }, + { + .input = {.name = "X Attack counted for a physical move", .body = test_x_attack_physical}, + .expectation = {.description = "Surf at Attack +0, Strength at +3"}, + }, + { + .input = {.name = "PAR with Parlyz Heals in the bag", .body = test_paralysis_cured}, + .expectation = {.description = "a Parlyz Heal against a trainer at green HP, a Super Potion first at yellow, RUN from a wild Pokemon"}, + }, + { + .input = {.name = "a Parlyz Heal used", .body = test_parlyz_heal_used}, + .expectation = {.description = "one fewer Parlyz Heal, the status cured"}, + }, { .input = {.name = "type chart, moves and species from pret", .body = test_data}, .expectation = {.description = "validates decompiled type charts, moves, and species"}, @@ -298,6 +529,7 @@ void add_tests_AutoStoryBattleData(UnitTestDatabase& database){ for (const auto& scenario : AUTO_STORY_BATTLE_DATA_CASES){ database.add(scenario); } + add_tests_AutoStoryLeadOut(database); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.cpp index 80943c4292..be17cfbc88 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.cpp @@ -13,6 +13,7 @@ #include "PokemonFRLG_AutoStoryBattleDecisions.h" #include "PokemonFRLG_AutoStoryHealing.h" #include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryLeadOut.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -32,6 +33,8 @@ constexpr int RUN_TRIES = 4; constexpr int FAINT_POLLS = 3; // PSN read at this many turns in a row before an Antidote. constexpr int PSN_READS = 2; +// The PP an Elixir restores to each move (pokefirered items.json). +constexpr uint8_t ELIXIR_PP = 10; // An evolution screen held this long was an evolution, not a text box // between two others. constexpr Milliseconds EVOLUTION_SEEN = std::chrono::milliseconds(5000); @@ -66,20 +69,38 @@ constexpr uint8_t MAX_LEVELS_IN_BATTLE = 3; // The HP a Potion heals (pret src/data/items.h). constexpr double POTION_HP = 20; -// A trainer's battle: the plan's attack, else the best type matchup -// (attack_slot_against()) against the foe out as read at the battle -// menu, else against the whole party its plan lists. -std::optional trainer_attack_slot(const PartyMember& usable, const Supplies& supplies){ - if (!supplies.foe_out.empty()){ - return attack_slot_against(usable, std::vector{supplies.foe_out}); +// A trainer's battle: the most damage (attack_slot_against()) against the +// foe out as read at the battle menu, with its stats when the plan has +// them (`foe_index` into its foes), else against the whole party its plan lists. +std::optional trainer_attack_slot( + const PartyMember& usable, const Supplies& supplies, AttackContext context, size_t foe_index +){ + if (supplies.foe_out.empty()){ + return attack_slot_against(usable, supplies.foes, context); + } + const std::vector& stats = supplies.policy.foe_stats; + if (foe_index < supplies.foes.size() && foe_index < stats.size() && supplies.foes[foe_index] == supplies.foe_out){ + context.foe = stats[foe_index]; + } + return attack_slot_against(usable, std::vector{supplies.foe_out}, context); +} + +// The X Attack or X Special `item` raised the lead's stage. +void count_stage(AttackContext& context, std::string_view item){ + constexpr int MAX_STAGE = 6; + if (item == "x-attack"){ + context.attack_stage = std::min(MAX_STAGE, context.attack_stage + 1); + }else if (item == "x-special"){ + context.sp_attack_stage = std::min(MAX_STAGE, context.sp_attack_stage + 1); } - return attack_slot_against(usable, supplies.foes); } // The item a turn uses, if any, and why one was or wasn't, for the log. struct ItemTurn{ TurnChoice choice = TurnChoice::MOVE; std::string reason = {}; + // A MEDICINE's item. + std::string item = {}; }; std::string_view bar_name(const PartyStatus& status){ @@ -88,17 +109,30 @@ std::string_view bar_name(const PartyStatus& status){ // The item this turn, from the bar and the badge as read (`seen_hit` the // HP the foe's last hit took, 0 if not seen): a Potion whenever the bar -// isn't green, unless the last hit took a Potion's worth or more; asleep, -// an Awakening unless the bar is red. -ItemTurn item_turn(const Supplies& supplies, const PartyStatus& status, double seen_hit, int awakenings){ +// isn't green, unless the last hit took a Potion's worth or more; with +// no Potion left, a Super Potion the same way; in a trainer's battle, +// unless the bar is red, an Awakening when asleep and a Parlyz Heal +// (cure_of()) when paralysed: a quarter of the turns lost for the rest of +// a long battle (console B, 2026-11-16, 19.04d: Colby's five Pokemon with +// PAR and 2 Parlyz Heals left in the bag). +ItemTurn item_turn(const Supplies& supplies, const PartyStatus& status, double seen_hit, bool trainer){ const bool hurt = status.hp_red || status.hp_yellow; const bool asleep = status.status == StatusCondition::SLEEP; + const bool paralysed = status.status == StatusCondition::PARALYSIS; + const int awakenings = trainer ? supplies.awakenings : 0; if (hurt && supplies.potions > 0 && seen_hit < POTION_HP){ return {TurnChoice::POTION, std::format("a Potion: HP {}, its last hit {:.0f} HP", bar_name(status), seen_hit)}; } + if (hurt && supplies.potions <= 0 && supplies.super_potions > 0 && seen_hit < medicine_hp("super-potion")){ + return {TurnChoice::MEDICINE, std::format("a Super Potion: HP {}, its last hit {:.0f} HP", bar_name(status), seen_hit), "super-potion"}; + } if (asleep && awakenings > 0 && !status.hp_red){ return {TurnChoice::AWAKENING, std::format("an Awakening: asleep at HP {}", bar_name(status))}; } + const std::string_view cure = cure_of(status.status); + if (paralysed && trainer && !status.hp_red && bag_count(supplies, cure) > 0){ + return {TurnChoice::MEDICINE, std::format("a Parlyz Heal: paralysed at HP {}", bar_name(status)), std::string(cure)}; + } if (!hurt){ return {}; } @@ -169,9 +203,18 @@ BattleDecisions::BattleDecisions(Supplies& supplies, BattleKind kind) m_level_cap = static_cast(std::min(battle_level(supplies.lead) + MAX_LEVELS_IN_BATTLE, 255)); } // The policy needs the lead's HP and Speed, which its stats give. - if (kind == BattleKind::TRAINER && supplies.policy.kind != BattlePolicyKind::NONE && supplies.lead.stats){ + if (kind == BattleKind::TRAINER && supplies.lead.stats){ + m_planned = planned_battle(supplies.trainer); + } + if (!m_planned && kind == BattleKind::TRAINER && supplies.policy.kind != BattlePolicyKind::NONE && supplies.lead.stats){ m_policy.emplace(supplies.policy); } + // A League fight spends its plan's budget and what the fights before + // left (end_trainer_battle() rolls it forward). + const LeagueFightPlan* league = supplies.league ? league_fight(supplies.league->plan, supplies.trainer) : nullptr; + if (kind == BattleKind::TRAINER && league != nullptr){ + supplies.budget = add_budgets(league->budget, supplies.league->carried); + } } TurnAction BattleDecisions::turn(const PartyStatus& status){ @@ -181,6 +224,20 @@ TurnAction BattleDecisions::turn(const PartyStatus& status){ m_before_forget.reset(); count_down_refused(); m_last_move_slot.reset(); + const LeadOnField lead = m_kind == BattleKind::TRAINER && !m_switch_off + ? lead_on_field({ + .box_gone = m_lost, .member_sent = !m_sent.empty(), + .own_out = m_supplies.own_out, .lead = m_supplies.lead.species, + }) + : LeadOnField::FAINTED; + if (lead == LeadOnField::FORCED_OUT){ + return switch_lead_back(); + } + // Read out, the lead is alive whatever its box did (the switch back's + // own animation hides it). + if (lead == LeadOnField::OUT && m_supplies.own_out == m_supplies.lead.species){ + m_lost = false; + } if (!m_lost){ return lead_turn(status); } @@ -211,14 +268,17 @@ TurnAction BattleDecisions::lead_turn(const PartyStatus& status){ return TurnAction{.choice = TurnChoice::RUN}; } see_hit(status); + if (m_planned){ + return planned_turn(status); + } if (m_policy){ return policy_turn(status, {}); } - // Awakenings are kept for trainers: a wild battle with a status is run from. - const int awakenings = m_kind == BattleKind::TRAINER ? m_supplies.awakenings : 0; - const ItemTurn items = m_items_off ? ItemTurn{} : item_turn(m_supplies, status, m_seen_hit, awakenings); + // Cures are kept for trainers: a wild battle with a status is run from. + const ItemTurn items = m_items_off ? ItemTurn{} : item_turn(m_supplies, status, m_seen_hit, m_kind == BattleKind::TRAINER); if (items.choice != TurnChoice::MOVE){ - return TurnAction{.choice = items.choice, .heal_reason = items.reason}; + m_planned_item = items.item; + return TurnAction{.choice = items.choice, .heal_reason = items.reason, .item = items.item}; } if (!m_items_off && m_psn_reads >= PSN_READS && !m_antidote_used && m_supplies.antidotes > 0){ m_antidote_used = true; @@ -233,6 +293,24 @@ TurnAction BattleDecisions::lead_turn(const PartyStatus& status){ return action; } +TurnAction BattleDecisions::switch_lead_back(){ + m_lost_before_switch = m_lost; + m_lost = false; + m_last_hp.reset(); + m_healed_hp = 0; + m_attack = {}; + if (m_policy){ + m_policy.emplace(m_supplies.policy); + } + if (m_planned){ + m_planned->lead_switched_in(); + } + return TurnAction{ + .choice = TurnChoice::SWITCH_LEAD, + .heal_reason = std::format("our {} is out, not sent: the lead was dragged out; switching it back", m_supplies.own_out), + }; +} + size_t BattleDecisions::track_foe(){ const std::vector& foes = m_supplies.foes; for (size_t index = m_foe_index; index < foes.size() && !m_supplies.foe_out.empty(); index++){ @@ -252,21 +330,61 @@ TurnAction BattleDecisions::policy_turn(const PartyStatus& status, std::string h .status = status.status, .speed = m_supplies.lead.stats->speed, .foe_index = track_foe(), + .foe_fill = status.foe_fill.value_or(1.0), + .battle_texts = status.battle_texts, }; - std::optional item = m_items_off ? std::nullopt : m_policy->choose(m_supplies, view); + // The League's policy logs every turn's state and choice on one line, + // for PokemonSimulation's log check. + const bool budgeted = m_supplies.policy.kind == BattlePolicyKind::BUDGETED_SETUP; + PolicyState::Turn turn = m_items_off ? PolicyState::Turn{} : m_policy->choose(m_supplies, view); + std::optional& item = turn.item; + const std::string state = budgeted ? m_policy->state_line(m_supplies, view) : std::string(); if (!item){ - TurnAction action = move_turn(); - action.heal_reason = std::move(heal_reason); + TurnAction action = move_turn(turn.move); + action.heal_reason = budgeted ? std::format("policy: {}; attack", state) : std::move(heal_reason); return action; } m_planned_item = item->item; return TurnAction{ .choice = item->party_member ? TurnChoice::MEDICINE : TurnChoice::BATTLE_ITEM, - .heal_reason = "policy: " + item->why, + .heal_reason = budgeted ? std::format("policy: {}; {}", state, item->why) : "policy: " + item->why, .item = std::move(item->item), }; } +TurnAction BattleDecisions::planned_turn(const PartyStatus& status){ + const PolicyView view{ + .hp = lead_hp(m_supplies, status).value_or(static_cast(m_supplies.lead.stats->hp)), + .max_hp = static_cast(m_supplies.lead.stats->hp), + .status = status.status, + .speed = m_supplies.lead.stats->speed, + .foe_index = track_foe(), + .foe_fill = status.foe_fill.value_or(1.0), + .battle_texts = status.battle_texts, + }; + // Items off (one read as another): the plan's moves only. + PlannedBattle::Turn turn = m_planned->choose(m_supplies, view); + if (turn.choice.item && m_items_off){ + turn.choice = PlannedChoice{.row = "items_off"}; + } + const std::string reason = std::format("planned: {}", turn.log); + if (turn.choice.item){ + m_planned_item = *turn.choice.item; + return TurnAction{ + // X items and Guard Spec go on the Pokemon out; the rest on the lead through the party list. + .choice = m_planned_item.starts_with("x-") || m_planned_item == "guard-spec" ? TurnChoice::BATTLE_ITEM : TurnChoice::MEDICINE, + .heal_reason = reason, + .item = m_planned_item, + }; + } + const std::optional slot = turn.choice.move_slot; + TurnAction action = move_turn(slot && *slot < m_supplies.lead.moves.size() + ? std::optional(m_supplies.lead.moves[*slot].move) + : std::nullopt); + action.heal_reason = reason; + return action; +} + void BattleDecisions::see_hit(const PartyStatus& status){ if (m_supplies.foe_out != m_hit_by){ m_seen_hit = 0; @@ -288,15 +406,22 @@ void BattleDecisions::see_hit(const PartyStatus& status){ // all four moves, the bottom left one (Bubble from Lv7), which the cursor // can't reach while that slot is empty, so before Bubble it stays on // Tackle. -TurnAction BattleDecisions::move_turn(){ +TurnAction BattleDecisions::move_turn(const std::optional& named){ PartyMember usable = m_supplies.lead; for (const auto& refused : m_refused){ if (refused.first < usable.moves.size()){ usable.moves[refused.first].pp = 0; } } + for (size_t index = 0; named && index < usable.moves.size(); index++){ + if (usable.moves[index].move == *named && usable.moves[index].pp > 0){ + spend_pp(m_supplies.lead, index); + m_last_move_slot = index; + return TurnAction{.choice = TurnChoice::MOVE, .slot = index}; + } + } const std::optional slot = m_kind == BattleKind::TRAINER - ? trainer_attack_slot(usable, m_supplies) + ? trainer_attack_slot(usable, m_supplies, m_attack, track_foe()) : attack_slot_against(usable, m_supplies.wild_foes); if (!slot){ return TurnAction{.choice = TurnChoice::MOVE, .slot = BOTTOM_LEFT_MOVE}; @@ -319,6 +444,7 @@ std::optional BattleDecisions::planned_item(const PartyStatus& stat } void BattleDecisions::planned_item_used(){ + count_stage(m_attack, m_planned_item); for (Pokemon::StoryItem& use : m_supplies.battle_items){ if (use.item == m_planned_item && use.quantity > 0){ use.quantity--; @@ -329,8 +455,34 @@ void BattleDecisions::planned_item_used(){ } void BattleDecisions::policy_item_used(){ + count_stage(m_attack, m_planned_item); spend_item(m_supplies, m_planned_item); - m_policy->item_used(m_planned_item); + // The story's own Super Potion or Parlyz Heal (item_turn()), with no + // policy to tell. + if (!m_policy && !m_planned){ + m_healed_hp = medicine_hp(m_planned_item); + if (m_healed_hp > 0){ + m_supplies.hurt = false; + m_supplies.hp_red = false; + } + if (m_planned_item == cure_of(m_supplies.status)){ + m_supplies.status = StatusCondition::NONE; + } + return; + } + if (m_planned){ + m_planned->item_used(m_planned_item); + }else{ + m_policy->item_used(m_planned_item); + } + if (m_supplies.budget){ + spend_budget(*m_supplies.budget, m_planned_item); + } + if (m_planned_item == "elixir"){ + add_pp(m_supplies.lead, ELIXIR_PP); + }else if (m_planned_item == "max-elixir"){ + restore_pp(m_supplies.lead); + } // A medicine heals up to the bar's end. const double room = static_cast(m_supplies.lead.stats->hp) - m_last_hp.value_or(0); m_healed_hp = std::min(medicine_hp(m_planned_item), std::max(0.0, room)); @@ -355,13 +507,8 @@ void BattleDecisions::move_refused(){ m_last_move_slot.reset(); } -void BattleDecisions::turn_done(TurnChoice choice, TurnResult result){ - if (result == TurnResult::REFUSED){ - refused(choice); - return; - } - const bool done = result == TurnResult::DONE; - if (!done && choice == TurnChoice::MOVE){ +void BattleDecisions::turn_not_done(TurnChoice choice){ + if (choice == TurnChoice::MOVE){ if (m_last_move_slot && !m_no_pp_read.insert(*m_last_move_slot).second){ no_pp_left(m_supplies.lead, *m_last_move_slot); }else{ @@ -369,8 +516,21 @@ void BattleDecisions::turn_done(TurnChoice choice, TurnResult result){ } return; } - if (!done){ - m_items_off = true; + if (choice == TurnChoice::SWITCH_LEAD){ + m_switch_off = true; + m_lost = m_lost_before_switch; + return; + } + m_items_off = true; +} + +void BattleDecisions::turn_done(TurnChoice choice, TurnResult result){ + if (result == TurnResult::REFUSED){ + refused(choice); + return; + } + if (result != TurnResult::DONE){ + turn_not_done(choice); return; } switch (choice){ @@ -391,7 +551,7 @@ void BattleDecisions::turn_done(TurnChoice choice, TurnResult result){ policy_item_used(); return; case TurnChoice::BATTLE_ITEM: - if (m_policy){ + if (m_policy || m_planned){ policy_item_used(); }else{ planned_item_used(); @@ -399,6 +559,7 @@ void BattleDecisions::turn_done(TurnChoice choice, TurnResult result){ return; case TurnChoice::RUN: case TurnChoice::MOVE: + case TurnChoice::SWITCH_LEAD: return; } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.h index 06e10490bd..4f1ad5f8bc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleDecisions.h @@ -31,6 +31,7 @@ #include "PokemonFRLG_AutoStoryBattle.h" #include "PokemonFRLG_AutoStoryBattlePolicy.h" #include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryPlannedBattle.h" #include "PokemonFRLG_AutoStoryBattleTurns.h" namespace PokemonAutomation{ @@ -80,7 +81,12 @@ class BattleDecisions{ private: TurnAction lead_turn(const PartyStatus& status); - TurnAction move_turn(); + // The lead was dragged out (LeadOnField::FORCED_OUT): alive, back in, + // its stages gone. + TurnAction switch_lead_back(); + // The move to attack with: `named` when the lead knows it with PP left + // and the game hasn't refused it, else the usual choice. + TurnAction move_turn(const std::optional& named = std::nullopt); // The next of the plan's battle items whose pocket row is known, for // a trainer's battle with the lead's HP not red; none otherwise. std::optional planned_item(const PartyStatus& status) const; @@ -92,6 +98,8 @@ class BattleDecisions{ // The battle policy's turn, with the lead's HP and speed known: its // item, or an attack. TurnAction policy_turn(const PartyStatus& status, std::string heal_reason); + // A League fight's turn: the planned policy's item or move. + TurnAction planned_turn(const PartyStatus& status); // The foe out, as an index into the step's foes. size_t track_foe(); // The HP the lead lost since the last turn, from the bar. @@ -101,6 +109,8 @@ class BattleDecisions{ // The game turned down `choice`: a move (Disable), or RUN in a // trainer's battle, which makes the battle a trainer's. void refused(TurnChoice choice); + // `choice` couldn't be made (TurnResult::NOT_DONE). + void turn_not_done(TurnChoice choice); Supplies& m_supplies; BattleKind m_kind; @@ -114,8 +124,17 @@ class BattleDecisions{ std::string m_planned_item; // The step's battle policy, if it has one and the lead's stats are read. std::optional m_policy; + // A League fight's planned policy (planned_battle()); the step's + // policy is not used then. + std::optional m_planned; + // The lead's Attack and Sp. Atk stages from the X items used, for its attack. + AttackContext m_attack; size_t m_foe_index = 0; bool m_lost = false; + // A switch back to the lead couldn't be made: the rule is off. + bool m_switch_off = false; + // The lead's box had gone before the switch back was chosen. + bool m_lost_before_switch = false; // NO was answered to "Delete a move?": "Stop learning?" comes next. bool m_declined_delete = false; // The move prompts since the last turn. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.cpp index d3583ec1c7..40390abe25 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.cpp @@ -5,12 +5,15 @@ */ #include +#include #include #include #include #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryBattleRisk.h" #include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryParty.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -23,8 +26,13 @@ namespace{ constexpr double THUNDER_BADGE = 1.1; // Guard Spec's Mist lasts this many turns, the one it is used on included. constexpr int MIST_TURNS = 5; +// Sunny Day's sun lasts five turns, the one it is used in included: our +// next four choices. +constexpr int SUN_TURNS = 4; constexpr int MAX_STAGE = 6; constexpr double WHOLE_HP = std::numeric_limits::infinity(); +// Gen 3's lowest damage roll: 85 of 100. +constexpr double LOWEST_ROLL = 0.85; // The HP medicines, smallest first (the doc's HEALS table). struct Medicine{ @@ -35,32 +43,50 @@ constexpr Medicine MEDICINES[] = { {"potion", 20}, {"super-potion", 50}, {"hyper-potion", 200}, {"max-potion", WHOLE_HP}, {"full-restore", WHOLE_HP}, }; -// The cure for a status, by the doc's CURES table; "" for none. -std::string_view cure_of(StatusCondition status){ - switch (status){ - case StatusCondition::SLEEP: - return "awakening"; - case StatusCondition::POISON: - return "antidote"; - case StatusCondition::PARALYSIS: - return "parlyz-heal"; - case StatusCondition::NONE: - case StatusCondition::OTHER: - return ""; - } - return ""; -} - // A Full Restore (a heal and a cure in one) is used only when it also heals // at least half of max HP; below that a cheap cure or a smaller medicine does. bool full_restore_worth_it(const PolicyView& view){ return view.max_hp - view.hp >= view.max_hp / 2; } -double stage_multiplier(int stage){ - return stage >= 0 ? (2.0 + stage) / 2.0 : 2.0 / (2.0 - stage); +// The battle HP bar's colour. +enum class HpBand{ + GREEN, + YELLOW, + RED, +}; + +HpBand hp_band(const PolicyView& view){ + if (view.hp * 5 <= view.max_hp){ + return HpBand::RED; + } + if (view.hp * 2 <= view.max_hp){ + return HpBand::YELLOW; + } + return HpBand::GREEN; } +// The heal by the fight's risk and the lead's HP band: the first of +// `items` in the bag. A row with none leaves it to the HP-against-the-hit +// rules (heal(), planning_heal()), which take the smallest medicine that +// clears the foe's hit: Potions and Super Potions. Against the Elite Four +// and the Champion that left Blastoise in the red for many turns and +// fainted it with 13 Full Restores in the bag (console B, 2026-11-16, +// Lorelei). +struct RiskHeal{ + BattleRisk risk; + HpBand band; + std::array items; +}; +constexpr RiskHeal RISK_HEALS[] = { + {BattleRisk::LOW, HpBand::GREEN, {}}, + {BattleRisk::LOW, HpBand::YELLOW, {}}, + {BattleRisk::LOW, HpBand::RED, {}}, + {BattleRisk::HIGH, HpBand::GREEN, {}}, + {BattleRisk::HIGH, HpBand::YELLOW, {"full-restore", "max-potion", "hyper-potion"}}, + {BattleRisk::HIGH, HpBand::RED, {"full-restore", "max-potion", "hyper-potion"}}, +}; + PolicyItem medicine_item(const std::string& item, std::string why){ return PolicyItem{.item = item, .party_member = true, .why = std::move(why)}; } @@ -69,6 +95,37 @@ PolicyItem setup_item_of(const std::string& item, std::string why){ return PolicyItem{.item = item, .party_member = false, .why = std::move(why)}; } +std::string_view band_name(HpBand band){ + switch (band){ + case HpBand::GREEN: + return "green"; + case HpBand::YELLOW: + return "yellow"; + case HpBand::RED: + return "red"; + } + return ""; +} + +// RISK_HEALS' item for the fight and the lead's HP, if the row names one in the bag. +std::optional risk_heal(const Supplies& supplies, const PolicyView& view){ + const HpBand band = hp_band(view); + for (const RiskHeal& row : RISK_HEALS){ + if (row.risk != supplies.risk || row.band != band){ + continue; + } + for (const std::string_view item : row.items){ + if (!item.empty() && bag_count(supplies, item) > 0){ + return medicine_item(std::string(item), std::format( + "{}: HP {:.0f}/{:.0f} ({}) in a {}-risk fight", + item, view.hp, view.max_hp, band_name(band), battle_risk_name(supplies.risk) + )); + } + } + } + return std::nullopt; +} + } // namespace @@ -79,14 +136,19 @@ std::optional battle_policy_kind(std::string_view word){ if (word == "goal-based-setup"){ return BattlePolicyKind::GOAL_BASED_SETUP; } + if (word == "budgeted-setup"){ + return BattlePolicyKind::BUDGETED_SETUP; + } return std::nullopt; } std::optional> foe_threats_of(const std::vector>& rows){ constexpr size_t COLUMNS = 7; + constexpr size_t WITH_PHAZES = 8; + constexpr size_t WITH_CHARGES = 9; std::vector foes; for (const std::vector& row : rows){ - if (row.size() != COLUMNS){ + if (row.size() < COLUMNS || row.size() > WITH_CHARGES){ return std::nullopt; } foes.push_back(FoeThreat{ @@ -97,17 +159,92 @@ std::optional> foe_threats_of(const std::vector(row[4]), .lowers_accuracy = row[5] != 0, .explodes = row[6] != 0, + .phazes = row.size() >= WITH_PHAZES && row[7] != 0, + .charges = row.size() == WITH_CHARGES && row[8] != 0, }); } return foes; } +namespace{ + +// A battle step's "foe_stats" rows, [defense, sp_defense] or [defense, +// sp_defense, hp] each; empty if there are none or a row isn't that. +std::vector foe_stats_of(const Pokemon::StoryActionArgs& args){ + constexpr size_t COLUMNS = 2; + constexpr size_t WITH_HP = 3; + std::vector foes; + for (const std::vector& row : Pokemon::story_arg>>(args, "foe_stats")){ + if (row.size() != COLUMNS && row.size() != WITH_HP){ + return {}; + } + FoeStats stats{.defense = static_cast(row[0]), .sp_defense = static_cast(row[1])}; + if (row.size() == WITH_HP){ + stats.hp = static_cast(row[2]); + } + foes.push_back(stats); + } + return foes; +} + +// The lead's best attack, at Sp. Atk `spa_stage` and its lowest roll, +// KOs the foe out from `fill` of its HP (1: full): the plan has the foe's HP. +bool attack_kos(const BattlePolicy& policy, const Supplies& supplies, const PolicyView& view, int spa_stage, double fill = 1.0){ + if (view.foe_index >= policy.foe_stats.size() || view.foe_index >= supplies.foes.size()){ + return false; + } + const FoeStats& stats = policy.foe_stats[view.foe_index]; + if (!stats.hp){ + return false; + } + const AttackContext context{.sp_attack_stage = spa_stage, .foe = stats}; + return most_damage_against(supplies.lead, supplies.foes[view.foe_index], context) * LOWEST_ROLL >= *stats.hp * fill; +} + +// The bag holds `item` and the battle's budget, if it has one, has some left. +bool within_budget(const Supplies& supplies, std::string_view item){ + if (bag_count(supplies, item) <= 0){ + return false; + } + if (!supplies.budget){ + return true; + } + return budget_left(*supplies.budget, item).value_or(1) > 0; +} + +// The lead's status's own cure, else a Full Heal, from the bag; none +// asleep (it attacks) or without a status. +std::optional status_cure(const Supplies& supplies, const PolicyView& view){ + if (view.status == StatusCondition::NONE || view.status == StatusCondition::SLEEP){ + return std::nullopt; + } + for (const std::string_view item : {cure_of(view.status), std::string_view("full-heal")}){ + if (!item.empty() && bag_count(supplies, item) > 0){ + return medicine_item(std::string(item), std::format("{} for {}", item, status_name(view.status))); + } + } + return std::nullopt; +} + +// The lead knows Surf and has no PP left for it. +bool surf_empty(const PartyMember& lead){ + for (const KnownMove& move : lead.moves){ + if (move.move == "surf"){ + return move.pp == 0; + } + } + return false; +} + +} // namespace + BattlePolicy battle_policy_of(const Pokemon::StoryActionArgs& args){ const std::optional kind = battle_policy_kind(Pokemon::story_arg(args, "policy")); + BattlePolicy policy; + policy.foe_stats = foe_stats_of(args); if (!kind){ - return {}; + return policy; } - BattlePolicy policy; policy.kind = *kind; policy.goals = SetupGoals{ .spa = static_cast(Pokemon::story_arg(args, "setup_spa")), @@ -124,6 +261,10 @@ BattlePolicy battle_policy_of(const Pokemon::StoryActionArgs& args){ } void end_trainer_battle(Supplies& supplies){ + if (supplies.league && supplies.budget){ + supplies.league->carried = *supplies.budget; + } + supplies.budget.reset(); supplies.foes.clear(); supplies.trainer.clear(); supplies.foe_out.clear(); @@ -159,7 +300,7 @@ PolicyState::Danger PolicyState::danger(const PolicyView& view) const{ // A poisoned lead also loses 1/8 of its HP to the poison each turn. const double residual = view.status == StatusCondition::POISON ? std::floor(view.max_hp / 8) : 0; const FoeThreat* threat = foe(view); - if (threat == nullptr){ + if (threat == nullptr || (threat->charges && !m_foe_charging && m_sun_turns <= 0)){ return {residual, residual, residual, residual}; } return { @@ -258,6 +399,14 @@ int PolicyState::setup_turns(const Supplies& supplies, const PolicyView& view, b } std::optional PolicyState::setup(const Supplies& supplies, const PolicyView& view) const{ + // Setup pays only while its stages last and the foe out needs more + // than one attack. Bruno's first Onix (console B, 2026-11-16, 20.02): + // four X Specials towards the Torrent stall's +4 while Surf KOs it at + // +0, then its Roar sent Blastoise out with them. + const FoeThreat* threat = foe(view); + if ((threat != nullptr && threat->phazes) || attack_kos(m_policy, supplies, view, m_spa)){ + return std::nullopt; + } const bool special = m_spa < spa_goal(view) && bag_count(supplies, "x-special") > 0; const bool speed = m_policy.goals.outspeed && bag_count(supplies, "x-speed") > 0 && m_speed < MAX_STAGE && !outsped(view); @@ -265,7 +414,6 @@ std::optional PolicyState::setup(const Supplies& supplies, const Pol if (!special && !speed && !accuracy){ return std::nullopt; } - const FoeThreat* threat = foe(view); if (m_policy.goals.guard_accuracy && bag_count(supplies, "guard-spec") > 0 && m_mist_turns <= 0 && threat != nullptr && threat->lowers_accuracy ){ @@ -331,13 +479,33 @@ std::optional PolicyState::planning_heal( )); } -std::optional PolicyState::choose(const Supplies& supplies, const PolicyView& view){ +PolicyState::Turn PolicyState::choose(const Supplies& supplies, const PolicyView& view){ if (m_mist_turns > 0){ m_mist_turns--; } + m_attack_reason.clear(); + for (const std::string& letters : view.battle_texts){ + note_battle_text(letters); + } + Turn turn = m_policy.kind == BattlePolicyKind::BUDGETED_SETUP + ? choose_budgeted(supplies, view) + : Turn{.item = choose_unbudgeted(supplies, view)}; + // The charged hit goes off this turn; the next charge has its own text. + m_foe_charging = false; + if (m_sun_turns > 0){ + m_sun_turns--; + } + return turn; +} + +std::optional PolicyState::choose_unbudgeted(const Supplies& supplies, const PolicyView& view){ if (m_policy.kind == BattlePolicyKind::NONE){ return std::nullopt; } + // A whole heal also cures, so it goes before a status's own cure. + if (std::optional item = risk_heal(supplies, view)){ + return item; + } const Danger risk = danger(view); if (std::optional item = cure(supplies, view, risk)){ return item; @@ -359,6 +527,276 @@ std::optional PolicyState::choose(const Supplies& supplies, const Po return planned; } +bool PolicyState::sure_ko_first(const Supplies& supplies, const PolicyView& view) const{ + const FoeThreat* threat = foe(view); + if (threat == nullptr || view.status == StatusCondition::SLEEP){ + return false; + } + // Paralysis quarters the lead's Speed. + const int speed = view.status == StatusCondition::PARALYSIS ? own_speed(view) / 4 : own_speed(view); + return speed > threat->speed && attack_kos(m_policy, supplies, view, m_spa, view.foe_fill); +} + +bool PolicyState::strength_kos(const Supplies& supplies, const PolicyView& view) const{ + if (view.foe_index >= m_policy.foe_stats.size() || view.foe_index >= supplies.foes.size()){ + return false; + } + const FoeStats& stats = m_policy.foe_stats[view.foe_index]; + if (!stats.hp){ + return false; + } + // The lead with Strength alone, for its damage. + PartyMember strength_only = supplies.lead; + std::erase_if(strength_only.moves, [](const KnownMove& move){ + return move.move != "strength"; + }); + const AttackContext context{.sp_attack_stage = m_spa, .foe = stats}; + const double lowest = most_damage_against(strength_only, supplies.foes[view.foe_index], context) * LOWEST_ROLL; + return lowest > 0 && lowest >= *stats.hp * view.foe_fill; +} + +std::optional PolicyState::ko_risk_heal(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + // A heal that gains less than the foe's best hit plus its mean hit + // only buys back the next hit: the bigger heal goes (Lorelei's + // Lapras, 2026-11-16: Super Potions of 50 against hits up to 39). + for (const Medicine& medicine : MEDICINES){ + if (std::isinf(medicine.hp) && medicine.item != "max-potion"){ + continue; + } + // Potions and Super Potions have no budget; Hyper and Max Potions do. + if (!within_budget(supplies, medicine.item)){ + continue; + } + const double gained = std::min(view.max_hp - view.hp, medicine.hp); + if (view.hp + gained > danger.normal_max && gained >= danger.normal_max + danger.mean){ + return medicine_item(std::string(medicine.item), std::format( + "{}: KO risk, HP {:.0f} <= the foe's best hit {:.0f}", medicine.item, view.hp, danger.normal_max + )); + } + } + for (const std::string_view item : {std::string_view("full-restore"), std::string_view("max-potion"), std::string_view("hyper-potion")}){ + if (bag_count(supplies, item) > 0){ + const bool over = supplies.budget && budget_left(*supplies.budget, item).value_or(1) <= 0; + return medicine_item(std::string(item), std::format( + "{}: KO risk, HP {:.0f} <= the foe's best hit {:.0f}{}", + item, view.hp, danger.normal_max, over ? " (over the fight's budget)" : "" + )); + } + } + return std::nullopt; +} + +std::optional PolicyState::reserve_heal( + const Supplies& supplies, const PolicyView& view, const Danger& danger, double reserve +) const{ + for (const Medicine& medicine : MEDICINES){ + if (!within_budget(supplies, medicine.item)){ + continue; + } + const double after = view.hp + std::min(view.max_hp - view.hp, medicine.hp); + const bool whole = std::isinf(medicine.hp); + // A part heal must hold the reserve after the mean hit; a whole + // heal is the most there is. + if ((whole && after - danger.mean > view.hp) || after - danger.mean >= reserve){ + return medicine_item(std::string(medicine.item), std::format( + "{}: HP {:.0f} under the setup reserve {:.0f}", medicine.item, view.hp, reserve + )); + } + } + return std::nullopt; +} + +std::optional PolicyState::budgeted_setup(const Supplies& supplies, const PolicyView& view) const{ + const FoeThreat* threat = foe(view); + if ((threat != nullptr && threat->phazes) || attack_kos(m_policy, supplies, view, m_spa, view.foe_fill)){ + return std::nullopt; + } + if (m_policy.goals.guard_accuracy && within_budget(supplies, "guard-spec") && m_mist_turns <= 0 + && threat != nullptr && threat->lowers_accuracy + ){ + return setup_item_of("guard-spec", "Guard Spec: the foe lowers accuracy"); + } + if (m_spa < spa_goal(view) && within_budget(supplies, "x-special")){ + return setup_item_of("x-special", std::format("X Special: Sp. Atk +{} of +{}", m_spa, spa_goal(view))); + } + if (m_policy.goals.outspeed && m_speed < MAX_STAGE && !outsped(view) && within_budget(supplies, "x-speed")){ + return setup_item_of("x-speed", std::format("X Speed: Speed {} against the foes left", own_speed(view))); + } + // The goal alone, not the foe's evasion: chasing Double Team with X + // Accuracy won less in the sim. + if (m_accuracy < m_policy.goals.accuracy && within_budget(supplies, "x-accuracy")){ + return setup_item_of("x-accuracy", std::format("X Accuracy: accuracy {:+} of {:+}", m_accuracy, m_policy.goals.accuracy)); + } + return std::nullopt; +} + +PolicyState::Turn PolicyState::choose_budgeted(const Supplies& supplies, const PolicyView& view){ + using Row = std::optional (PolicyState::*)(const Supplies&, const PolicyView&, const Danger&) const; + static constexpr Row ROWS[] = { + &PolicyState::row_sure_ko, + &PolicyState::row_strength_finisher, + &PolicyState::row_escalate, + &PolicyState::row_status_at_ko_risk, + &PolicyState::row_asleep, + &PolicyState::row_status_cure, + &PolicyState::row_ko_risk, + &PolicyState::row_surf_empty, + &PolicyState::row_setup, + }; + if (view.foe_index != m_streak_foe || view.foe_fill != m_streak_fill){ + m_medicine_streak = 0; + } + const Danger risk = danger(view); + Choice choice{.item = std::nullopt, .attack_reason = "attack"}; + for (const Row row : ROWS){ + if (std::optional chosen = (this->*row)(supplies, view, risk)){ + choice = std::move(*chosen); + break; + } + } + if (choice.item && choice.item->party_member){ + m_medicine_streak++; + m_streak_foe = view.foe_index; + m_streak_fill = view.foe_fill; + m_last_medicine = choice.item->item; + }else{ + m_medicine_streak = 0; + } + if (!choice.item){ + m_attack_reason = std::move(choice.attack_reason); + } + return Turn{.item = std::move(choice.item), .move = std::move(choice.move)}; +} + +std::optional PolicyState::row_sure_ko(const Supplies& supplies, const PolicyView& view, const Danger&) const{ + if (!sure_ko_first(supplies, view)){ + return std::nullopt; + } + if (strength_kos(supplies, view)){ + return Choice{.item = std::nullopt, .attack_reason = "attack: we move first and Strength KOs", .move = "strength"}; + } + return Choice{.item = std::nullopt, .attack_reason = "attack: we move first and the hit KOs"}; +} + +std::optional PolicyState::row_strength_finisher(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + if (view.status == StatusCondition::SLEEP || view.hp <= danger.normal_max || !strength_kos(supplies, view)){ + return std::nullopt; + } + return Choice{ + .item = std::nullopt, + .attack_reason = std::format("attack: Strength KOs and the foe's best hit {:.0f} doesn't KO first", danger.normal_max), + .move = "strength", + }; +} + +std::optional PolicyState::row_escalate(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + constexpr int MOST_MEDICINE_TURNS = 2; + if (m_medicine_streak < MOST_MEDICINE_TURNS){ + return std::nullopt; + } + const bool whole_last = std::isinf(medicine_hp(m_last_medicine)); + if (view.hp <= danger.normal_max && danger.normal_max < view.max_hp && !whole_last){ + for (const std::string_view item : {std::string_view("full-restore"), std::string_view("max-potion")}){ + if (bag_count(supplies, item) > 0){ + return Choice{.item = medicine_item(std::string(item), std::format( + "{}: {} medicine turns and the foe's bar hasn't moved; KO risk, HP {:.0f} <= {:.0f}", + item, m_medicine_streak, view.hp, danger.normal_max + ))}; + } + } + } + return Choice{ + .item = std::nullopt, + .attack_reason = std::format("attack: {} medicine turns and the foe's bar hasn't moved", m_medicine_streak), + }; +} + +std::optional PolicyState::row_status_at_ko_risk(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + if (view.status == StatusCondition::NONE || view.hp > danger.normal_max || danger.normal_max >= view.max_hp + || bag_count(supplies, "full-restore") <= 0 + ){ + return std::nullopt; + } + return Choice{.item = medicine_item("full-restore", std::format( + "full-restore: {} and KO risk, HP {:.0f} <= the foe's best hit {:.0f}", status_name(view.status), view.hp, danger.normal_max + ))}; +} + +std::optional PolicyState::row_asleep(const Supplies& supplies, const PolicyView& view, const Danger&) const{ + if (view.status != StatusCondition::SLEEP){ + return std::nullopt; + } + for (const std::string_view item : {cure_of(view.status), std::string_view("full-heal")}){ + if (!item.empty() && bag_count(supplies, item) > 0){ + return Choice{.item = medicine_item(std::string(item), std::format("{}: asleep", item))}; + } + } + return Choice{.item = std::nullopt, .attack_reason = "attack: asleep, no cure in the bag"}; +} + +std::optional PolicyState::row_status_cure(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + if (view.hp <= danger.normal_max){ + return std::nullopt; + } + if (std::optional item = status_cure(supplies, view)){ + return Choice{.item = std::move(item)}; + } + return std::nullopt; +} + +std::optional PolicyState::row_ko_risk(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + if (view.hp > danger.normal_max){ + return std::nullopt; + } + if (danger.normal_max >= view.max_hp){ + return Choice{.item = std::nullopt, .attack_reason = "attack: the foe's best hit KOs from full HP, no medicine helps"}; + } + if (std::optional item = ko_risk_heal(supplies, view, danger)){ + return Choice{.item = std::move(item)}; + } + return Choice{.item = std::nullopt, .attack_reason = "attack: KO risk and no medicine left"}; +} + +std::optional PolicyState::row_surf_empty(const Supplies& supplies, const PolicyView&, const Danger&) const{ + if (!surf_empty(supplies.lead)){ + return std::nullopt; + } + for (const std::string_view item : {std::string_view("elixir"), std::string_view("max-elixir")}){ + if (bag_count(supplies, item) > 0){ + return Choice{.item = medicine_item(std::string(item), std::format("{}: Surf has no PP left", item))}; + } + } + return std::nullopt; +} + +std::optional PolicyState::row_setup(const Supplies& supplies, const PolicyView& view, const Danger& danger) const{ + const std::optional planned = budgeted_setup(supplies, view); + if (!planned){ + return Choice{.item = std::nullopt, .attack_reason = "attack: no setup left in the goals or the budget, or the hit KOs"}; + } + const int turns = setup_turns(supplies, view, planned->item == "guard-spec"); + const double reserve = std::min(view.max_hp * 0.75, danger.normal_max + std::max(0, turns - 1) * danger.mean); + if (view.hp >= reserve){ + return Choice{.item = planned}; + } + if (std::optional item = reserve_heal(supplies, view, danger, reserve)){ + return Choice{.item = std::move(item)}; + } + return Choice{ + .item = std::nullopt, + .attack_reason = std::format("attack: HP {:.0f} under the setup reserve {:.0f} and no heal in the budget", view.hp, reserve), + }; +} + +std::string PolicyState::state_line(const Supplies& supplies, const PolicyView& view) const{ + return std::format( + "HP {:.0f}/{:.0f}, foe {} {:.0f}%, Sp. Atk {:+}, Speed {:+}, accuracy {:+}, budget {}{}{}", + view.hp, view.max_hp, supplies.foe_out.empty() ? "?" : supplies.foe_out, 100 * view.foe_fill, + m_spa, m_speed, m_accuracy, supplies.budget ? budget_text(*supplies.budget) : std::string("none"), + m_attack_reason.empty() ? "" : "; ", m_attack_reason + ); +} + void PolicyState::item_used(const std::string& item){ if (item == "x-special"){ m_spa = std::min(MAX_STAGE, m_spa + 1); @@ -371,6 +809,25 @@ void PolicyState::item_used(const std::string& item){ } } +void PolicyState::note_battle_text(std::string_view letters){ + const auto has = [letters](std::string_view word){ + return letters.find(word) != std::string_view::npos; + }; + // pokefirered's battle strings: "{foe} took\nin sunlight!", "{foe} hid\nunderwater!", + // "The sunlight got bright!", "The sunlight faded." + if ((has("took") && has("sunlight")) || has("underwater")){ + m_foe_charging = true; + return; + } + if (has("sunlight") && has("bright")){ + m_sun_turns = SUN_TURNS; + return; + } + if (has("sunlight") && has("faded")){ + m_sun_turns = 0; + } +} + void PolicyState::foe_evasion_raised(int stages){ m_foe_evasion = std::clamp(m_foe_evasion + stages, -MAX_STAGE, MAX_STAGE); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.h index 50d3fc51fa..47d1a581c0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.h @@ -14,12 +14,51 @@ * * The Torrent stall (target_torrent) is its extra X Specials only: the * doc's other stall, the weakest damaging move that can't KO the setup - * foe, needs the foe's HP. Not modelled: the foe's HP (so the doc's safe - * finishing hit is never taken early), Oran Berries and PP medicine in - * battle. Stage drops and evasion rises of the foe are + * foe, is not modelled. Setup pays only while its stages last and the + * foe out needs more than one attack: none against a foe that phazes + * (Roar, Whirlwind) or that the lead's best attack KOs from full HP at + * its lowest roll (the step's foe_stats with HP). Not modelled: the + * foe's HP as the fight goes, Oran Berries and PP medicine in battle. Stage drops and evasion rises of the foe are * not read off the battle text yet: foe_evasion_raised() and the like * take them once something does. * + * "budgeted-setup" (budgeted C2, the League's; design and sim: + * ~/BDSPLab/notes/frlg-e4-replica-policy.md). One state -> action table + * (choose_budgeted()'s rows), first row that applies, from the screen + * state each turn; D is the foe's best ordinary hit (foe_threats' + * normal_max, plus poison; for a foe whose hit charges a turn first, only + * while its charge text or Sunny Day's sun was read: PolicyView::battle_texts), + * "medicine" an item on the lead: + * 1. awake, we move first and our lowest roll KOs the foe at its HP + * bar: attack, at any HP (PokeGuy's Surf at 3/171), with Strength + * when its lowest roll KOs (Bite and Surf keep their PP); + * 2. Strength's lowest roll KOs and the foe can't KO first (HP > D): + * Strength (Bruno, console B, 2026-11-16: Surf on Hitmonchan at 4% + * and 2%); + * 3. the last two turns were medicine and the foe's bar didn't move: + * at KO risk a Full Restore (or Max Potion), unless the last was + * one; else attack. Never a third heal in a row (Lorelei's Lapras, + * console B, 2026-11-16: six turns of Super Potions and Parlyz + * Heals); + * 4. a status and HP <= D: a Full Restore, over the budget if need be; + * 5. asleep: an Awakening, else a Full Heal; with none, attack + * (Agatha's Gengar, 2026-11-16: two turns asleep, then Dream Eater); + * 6. a status with a cure and HP > D: the cure, else a Full Heal; + * 7. HP <= D (KO risk): the smallest medicine that lifts HP above D and + * heals at least D plus the foe's mean hit (a Hyper or Max Potion + * only within the budget), else a Full Restore, over the fight's + * budget if need be; none helps (D >= max HP): attack; + * 8. Surf out of PP: an Elixir, else a Max Elixir; + * 9. setup (Guard Spec, X Special, X Speed, X Accuracy towards the + * step's goals; accuracy goal without the foe's evasion), each item + * capped by the fight's budget (Supplies::budget), none when the + * next hit KOs the foe or the foe phazes; HP under C2's reserve + * min(75% max HP, D + (setup turns - 1) x mean hit) first heals + * within the budget, else the setup is dropped; + * 10. attack. + * The budget comes from the League plan (PokemonFRLG_AutoStoryLeaguePlan.h); + * every turn's state and choice is logged on one line (state_line()). + * */ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryBattlePolicy_H @@ -49,6 +88,13 @@ struct PolicyView{ int speed = 0; // The foe out, in the step's "foes" order; those before it have fainted. size_t foe_index = 0; + // The foe's HP bar's filled share, 1 when not read. + double foe_fill = 1.0; + // The battle texts read since the last choice, letters in lower case + // (read_battle_text()): the foe charging a hit (Solar Beam, Dive) + // makes its row a KO risk for this choice; Sunny Day's sun makes + // Solar Beam one for its turns. + std::vector battle_texts = {}; }; // An item the policy uses this turn. @@ -75,7 +121,8 @@ struct PolicyStages{ int mist_turns = 0; }; -// A trainer battle's plan is over: its party, items and policy go from `supplies`. +// A trainer battle's plan is over: its party, items and policy go from +// `supplies`; a League fight's budget left rolls forward to the next. void end_trainer_battle(Supplies& supplies); // The lead's side of the battle as the policy tracks it: the stages and @@ -84,8 +131,15 @@ class PolicyState{ public: explicit PolicyState(const BattlePolicy& policy); - // The item to use at a battle menu, or none to attack. - std::optional choose(const Supplies& supplies, const PolicyView& view); + // A turn's choice: the item to use, or none to attack, with the move + // the policy names for it ("strength"; none leaves it to the move choice). + struct Turn{ + std::optional item = std::nullopt; + std::optional move = std::nullopt; + }; + + // The choice at a battle menu. + Turn choose(const Supplies& supplies, const PolicyView& view); // `item` was used: its stage, or Mist, applies. void item_used(const std::string& item); @@ -96,6 +150,9 @@ class PolicyState{ PolicyStages stages() const{ return {.spa = m_spa, .speed = m_speed, .accuracy = m_accuracy, .mist_turns = m_mist_turns}; } + // The turn's state for the log: our HP, the foe and its bar, our + // stages and the budget left; after a choose() that attacks, why. + std::string state_line(const Supplies& supplies, const PolicyView& view) const; private: struct Danger{ @@ -106,6 +163,7 @@ class PolicyState{ }; Danger danger(const PolicyView& view) const; const FoeThreat* foe(const PolicyView& view) const; + void note_battle_text(std::string_view letters); int own_speed(const PolicyView& view) const; bool outsped(const PolicyView& view) const; int spa_goal(const PolicyView& view) const; @@ -118,6 +176,32 @@ class PolicyState{ const Supplies& supplies, const PolicyView& view, const Danger& danger, int turns, std::string_view waiting_on ) const; int setup_turns(const Supplies& supplies, const PolicyView& view, bool guard) const; + // BUDGETED_SETUP's table (the header): each row is the turn's choice + // when it applies, none when it doesn't. + struct Choice{ + std::optional item; + // An attack's reason, for the log, and its move if the row names one. + std::string attack_reason = {}; + std::optional move = std::nullopt; + }; + Turn choose_budgeted(const Supplies& supplies, const PolicyView& view); + std::optional choose_unbudgeted(const Supplies& supplies, const PolicyView& view); + std::optional row_sure_ko(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_strength_finisher(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_escalate(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_status_at_ko_risk(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_asleep(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_status_cure(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_ko_risk(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_surf_empty(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional row_setup(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + bool sure_ko_first(const Supplies& supplies, const PolicyView& view) const; + bool strength_kos(const Supplies& supplies, const PolicyView& view) const; + std::optional budgeted_setup(const Supplies& supplies, const PolicyView& view) const; + std::optional ko_risk_heal(const Supplies& supplies, const PolicyView& view, const Danger& danger) const; + std::optional reserve_heal( + const Supplies& supplies, const PolicyView& view, const Danger& danger, double reserve + ) const; const BattlePolicy m_policy; int m_spa = 0; @@ -125,6 +209,16 @@ class PolicyState{ int m_accuracy = 0; int m_foe_evasion = 0; int m_mist_turns = 0; + // The foe's charge text was read since the last choice; Sunny Day's turns left. + bool m_foe_charging = false; + int m_sun_turns = 0; + std::string m_attack_reason; + // The medicine turns in a row against the foe's bar m_streak_fill + // (foe m_streak_foe), and the last one's item. + int m_medicine_streak = 0; + size_t m_streak_foe = 0; + double m_streak_fill = 1.0; + std::string m_last_medicine; }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicyData.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicyData.h index 048dc705ba..566bf7df2d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicyData.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicyData.h @@ -16,6 +16,7 @@ #include #include #include "Pokemon/AutoStory/Types/Pokemon_StoryActionArg.h" +#include "PokemonFRLG_AutoStoryStats.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -23,11 +24,13 @@ namespace PokemonFRLG{ // How a battle's items are chosen: not by the policy, PokeGuy's B (cure, -// heal) or C2 (B, then setup towards goals). +// heal), C2 (B, then setup towards goals) or budgeted C2 (the League's: +// heal on KO risk, setup capped by the League plan's budget). enum class BattlePolicyKind{ NONE, SOLO_RECOVERY, GOAL_BASED_SETUP, + BUDGETED_SETUP, }; // The doc's setup goals for one fight. @@ -61,6 +64,12 @@ struct FoeThreat{ bool lowers_accuracy = false; // Self-Destruct, Explosion. bool explodes = false; + // Roar, Whirlwind: the lead forced out loses its stages. + bool phazes = false; + // Its only hit charges a turn first (Solar Beam without sun, Dive): no + // hit on the turn it charges, so the row is a KO risk only while the + // foe is charging or, for Solar Beam, the sun is out. + bool charges = false; }; // A step's policy: the kind, its goals and the foes' threat rows. @@ -69,17 +78,24 @@ struct BattlePolicy{ SetupGoals goals = {}; // In the step's "foes" order. std::vector foes = {}; + // The foes' Defense, Sp. Def and HP in the same order (the step's + // "foe_stats"), for the damage the lead's attacks would do, whatever + // the policy kind, and whether the best one KOs; empty when the plan + // doesn't carry them. + std::vector foe_stats = {}; }; // The policy a step's "policy" word names; none for an empty or unknown one. std::optional battle_policy_kind(std::string_view word); // The battle policy a step's args name, with its setup goals and foe data: -// none when they name none. +// NONE when they name none, with the foes' stats all the same. BattlePolicy battle_policy_of(const Pokemon::StoryActionArgs& args); // The step's "foe_threats" rows, [speed, likely, mean, max, normal_max, -// lowers_accuracy, explodes] each; none if a row isn't that. +// lowers_accuracy, explodes] each, with phazes as an eighth column where +// the foe has Roar or Whirlwind and charges as a ninth where its hit +// charges a turn first; none if a row isn't that. std::optional> foe_threats_of(const std::vector>& rows); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp index 7939e4fb53..5be0f43524 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp @@ -8,6 +8,7 @@ * */ +#include #include #include #include @@ -18,6 +19,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "PokemonFRLG_AutoStoryBattleDecisions.h" #include "PokemonFRLG_AutoStoryBattlePolicy.h" #include "PokemonFRLG_AutoStoryHealing.h" #include "PokemonFRLG_AutoStoryItemsPocket.h" @@ -62,7 +64,7 @@ Supplies koga_bag(){ // What the policy uses, or "" for an attack; the item is used, too. std::string use(PolicyState& state, Supplies& supplies, const PolicyView& view){ - const std::optional item = state.choose(supplies, view); + const std::optional item = state.choose(supplies, view).item; if (!item){ return ""; } @@ -202,6 +204,83 @@ UnitTestResult test_low_hp_heals(){ return true; } +// The 2026-11-16 loss to Lorelei (console B, 20.01): Blastoise Lv51 at +// 162 HP against her Dewgong (the plan's threat row), Sp. Atk +4 after +// four X Specials, the bag as the battle read it. It healed at red with a +// Super Potion or the Potion, never one of the 13 Full Restores. +BattlePolicy lorelei_policy(){ + return BattlePolicy{ + .kind = BattlePolicyKind::GOAL_BASED_SETUP, + .goals = {.spa = 4, .accuracy = 0, .outspeed = true, .guard_accuracy = true}, + .foes = {{.speed = 93, .likely = 21, .mean = 13, .max = 45, .normal_max = 30}}, + }; +} + +Supplies lorelei_bag(BattleRisk risk){ + Supplies supplies; + set_from_bag(supplies, { + {"potion", 1}, {"super-potion", 6}, {"full-restore", 13}, {"antidote", 1}, + {"parlyz-heal", 2}, {"full-heal", 2}, {"x-special", 4}, + }); + supplies.risk = risk; + return supplies; +} + +// The medicine the policy picks for the lead at `hp` of 162, Sp. Atk +4. +std::string lorelei_heal(BattleRisk risk, double hp){ + PolicyState state(lorelei_policy()); + for (int stage = 0; stage < 4; stage++){ + state.item_used("x-special"); + } + Supplies supplies = lorelei_bag(risk); + return use(state, supplies, PolicyView{.hp = hp, .max_hp = 162, .status = StatusCondition::NONE, .speed = 100, .foe_index = 0}); +} + +UnitTestResult test_high_risk_red_full_restore(){ + const std::string heal = lorelei_heal(BattleRisk::HIGH, /*hp=*/6); + if (heal != "full-restore"){ + return std::format("Expected a Full Restore at 6/162 against an Elite Four, got \"{}\".", heal); + } + return true; +} + +UnitTestResult test_high_risk_yellow_full_restore(){ + const std::string heal = lorelei_heal(BattleRisk::HIGH, /*hp=*/66); + if (heal != "full-restore"){ + return std::format("Expected a Full Restore at 66/162 (yellow) against an Elite Four, got \"{}\".", heal); + } + return true; +} + +UnitTestResult test_high_risk_green_attacks(){ + const std::string item = lorelei_heal(BattleRisk::HIGH, /*hp=*/84); + if (!item.empty()){ + return std::format("Expected an attack at 84/162 (green) once set up, got \"{}\".", item); + } + return true; +} + +UnitTestResult test_low_risk_red_super_potion(){ + const std::string heal = lorelei_heal(BattleRisk::LOW, /*hp=*/6); + if (heal != "super-potion"){ + return std::format("Expected a Super Potion at 6/162 in a low-risk fight, got \"{}\".", heal); + } + return true; +} + +// The battle's bag line prints the pocket's key, "full-restore": it is +// the key the medicine table and the pocket's rows use. +UnitTestResult test_full_restore_key_resolves(){ + const Supplies supplies = lorelei_bag(BattleRisk::HIGH); + if (bag_count(supplies, "full-restore") != 13 || item_row(supplies, "full-restore") != 2){ + return "Expected 13 Full Restores in row 3 of the Items pocket."; + } + if (!std::isinf(medicine_hp("full-restore"))){ + return "Expected the Full Restore to heal all HP."; + } + return true; +} + // The 2026-11-12 loss to Koga (console B, 12.02 from the save in front of // him): Blastoise at 128 HP, a thin bag (6 Potions, 1 Super Potion, no // Antidote, the Full Restore used on the first poisoning), Sp. Atk +1. @@ -268,13 +347,13 @@ UnitTestResult test_heal_log_names_the_setup(){ PolicyState state(koga_policy()); Supplies supplies = thin_bag(1); // Setup still pending (X Special): the heal's reason says what it waits on. - const std::optional heal = state.choose(supplies, lost_view(85, StatusCondition::POISON)); + const std::optional heal = state.choose(supplies, lost_view(85, StatusCondition::POISON)).item; if (!heal || heal->why.find("x-special") == std::string::npos){ return std::format("Expected the heal's reason to name the pending X Special, got \"{}\".", heal ? heal->why : "an attack"); } // Goals met: no setup is waited on, and the reason says so. state.item_used("x-special"); - const std::optional later = state.choose(supplies, lost_view(85, StatusCondition::POISON)); + const std::optional later = state.choose(supplies, lost_view(85, StatusCondition::POISON)).item; if (!later || later->why.find("no setup pending") == std::string::npos){ return std::format("Expected \"no setup pending\" once the goals are met, got \"{}\".", later ? later->why : "an attack"); } @@ -418,6 +497,10 @@ UnitTestResult test_foe_rows(){ if (!rows || rows->size() != 1 || (*rows)[0].speed != 30 || !(*rows)[0].lowers_accuracy || !(*rows)[0].explodes){ return "Expected the row to read."; } + const std::optional> charging = foe_threats_of({{125, 194, 182, 396, 198, 0, 0, 0, 1}}); + if (!charging || charging->size() != 1 || !(*charging)[0].charges || (*charging)[0].phazes){ + return "Expected a row of 9 to read as a foe whose hit charges a turn first."; + } if (battle_policy_kind("goal-based-setup") != BattlePolicyKind::GOAL_BASED_SETUP || battle_policy_kind("x")){ return "Expected the policy words to read."; } @@ -452,15 +535,15 @@ std::optional arg_of(const StoryStep& step, std::string_view key){ } // The step names the policy, its goals, and one threat row per foe. -UnitTestResult check_policy_step(std::string_view id, std::string_view name, const SetupGoals& goals){ +UnitTestResult check_policy_step(std::string_view id, std::string_view name, const SetupGoals& goals, std::string_view policy = "goal-based-setup"){ const int64_t spa = goals.spa; const int64_t accuracy = goals.accuracy; const bool outspeed = goals.outspeed; const bool guard = goals.guard_accuracy; const bool torrent = goals.torrent_power; const StoryStep& step = battle_step(id, name); - if (arg_of(step, "policy") != "goal-based-setup"){ - return std::format("{} {}: expected policy goal-based-setup.", id, name); + if (arg_of(step, "policy") != policy){ + return std::format("{} {}: expected policy {}.", id, name, policy); } if (arg_of(step, "setup_spa") != spa || arg_of(step, "setup_outspeed").value_or(false) != outspeed || arg_of(step, "setup_guard_accuracy").value_or(false) != guard @@ -515,12 +598,12 @@ UnitTestResult test_plan_blaine(){ } UnitTestResult test_plan_bruno(){ - const UnitTestResult result = check_policy_step("20.02", "bruno", {.spa = 2, .outspeed = true, .guard_accuracy = true}); + const UnitTestResult result = check_policy_step("20.01", "bruno", {.spa = 2, .outspeed = true, .guard_accuracy = true}, /*policy=*/"budgeted-setup"); if (result.result != UnitTestResult::PASSED){ return result; } - if (arg_of(battle_step("20.02", "bruno"), "setup_target_torrent") != true){ - return "20.02 bruno: expected the doc's target_torrent."; + if (arg_of(battle_step("20.01", "bruno"), "setup_target_torrent") != true){ + return "20.01 bruno: expected the doc's target_torrent."; } return true; } @@ -599,6 +682,140 @@ UnitTestResult test_plan_giovanni_gym(){ }); } +// A battle whose item counts are a row's guess reads the Items pocket +// before its first turn, unless it only runs; once read, it doesn't. +UnitTestResult test_unknown_counts_read_before_first_turn(){ + Supplies guessed; + if (!battle_needs_bag_read(guessed, BattleKind::TRAINER) || !battle_needs_bag_read(guessed, BattleKind::WILD_FIGHT)){ + return "Expected a trainer's or a wild fight's battle to read a guessed bag first."; + } + if (battle_needs_bag_read(guessed, BattleKind::WILD_RUN)){ + return "Expected a battle that only runs not to read the bag."; + } + Supplies read; + set_from_bag(read, {{"potion", 3}}); + if (battle_needs_bag_read(read, BattleKind::TRAINER)){ + return "Expected no read once the pocket was read."; + } + return true; +} + +// 19.01's rival at Default checks (console B, 2026-11-15): the load's Bag +// check skipped, the row's guess has no X item, so the policy attacked +// from turn 1. The battle reads the pocket itself, and the policy sets up +// from what it read. +UnitTestResult test_rival_route22_sets_up_from_its_own_read(){ + const BattlePolicy policy = battle_policy_of(battle_step("19.01", "rival_route22").args); + if (policy.kind != BattlePolicyKind::GOAL_BASED_SETUP){ + return "19.01 rival_route22: expected goal-based-setup."; + } + Supplies supplies; + supplies.policy = policy; + if (!battle_needs_bag_read(supplies, BattleKind::TRAINER)){ + return "Expected the rival's battle to read the bag, its counts a guess."; + } + set_from_bag(supplies, { + {"potion", 5}, {"super-potion", 6}, {"full-heal", 2}, + {"x-special", 10}, {"x-speed", 4}, {"x-accuracy", 4}, {"guard-spec", 2}, + }); + PolicyState state(policy); + const PolicyView view{.hp = 150, .max_hp = 150, .status = StatusCondition::NONE, .speed = 100, .foe_index = 0}; + const std::string first = use(state, supplies, view); + if (first.rfind("x-", 0) != 0 && first != "guard-spec"){ + return std::format("Expected a setup item at turn 1 from the read bag, got \"{}\".", first); + } + return true; +} + + +// The lead into Bruno (console B, 2026-11-16, 20.02): Blastoise Lv52, HP +// 165, Sp. Atk 114, Speed 113; the bag and foes as the League's steps. +Supplies league_supplies(const StoryStep& step){ + Supplies supplies; + set_from_bag(supplies, { + {"full-restore", 10}, {"x-special", 10}, {"x-speed", 4}, {"x-accuracy", 3}, {"guard-spec", 2}, + }); + supplies.lead = PartyMember{ + .species = "blastoise", + .moves = {{"bite", 25}, {"strength", 15}, {"surf", 14}, {"blizzard", 5}}, + .moves_through_level = 52, + .moves_read = true, + .level = 52, + .stats = Stats{.hp = 165, .attack = 99, .defense = 129, .sp_attack = 114, .sp_defense = 144, .speed = 113}, + }; + supplies.foes = Pokemon::story_arg>(step.args, "foes"); + supplies.policy = battle_policy_of(step.args); + return supplies; +} + +PolicyView league_view(double hp, size_t foe_index){ + return PolicyView{.hp = hp, .max_hp = 165, .status = StatusCondition::NONE, .speed = 113, .foe_index = foe_index}; +} + +// A League fight's foe and the lead's Sp. Atk stage (X Specials used). +struct LeagueTurnInput{ + std::string_view id; + std::string_view battle; + size_t foe_index; + int spa_stage; + double hp; +}; + +// The policy's item ("" for an attack) and, for an attack, the move. +struct LeagueTurnExpectation{ + std::string_view item; + std::string_view move; +}; + +struct LeagueTurnCase{ + std::string_view name; + LeagueTurnInput input; + LeagueTurnExpectation expectation; +}; + +// Bruno's first Onix (console B, 2026-11-16, 20.02): four X Specials +// towards +4 while Surf (4x) KOs it at +0, then its Roar sent Blastoise +// out. Setup only where it pays: not against a foe the best attack KOs, +// nor one that phazes; still against Lorelei's Dewgong. +const LeagueTurnCase LEAGUE_TURN_CASES[] = { + {"Bruno's Onix at +0, 71% HP: Surf", {"20.01", "bruno", 0, 0, 117}, {"", "surf"}}, + {"Bruno's Onix at +2: Surf", {"20.01", "bruno", 0, 2, 165}, {"", "surf"}}, + {"Bruno's Onix at +4: Surf", {"20.01", "bruno", 0, 4, 165}, {"", "surf"}}, + {"Bruno's second Onix at +0: Surf", {"20.01", "bruno", 3, 0, 165}, {"", "surf"}}, + {"Bruno's Hitmonchan at +0: X Special", {"20.01", "bruno", 1, 0, 165}, {"x-special", ""}}, + {"Lorelei's Dewgong at +0: X Special", {"20.01", "lorelei", 0, 0, 165}, {"x-special", ""}}, + {"the Champion's Pidgeot (Whirlwind): no X item", {"20.01", "champion", 0, 0, 165}, {"", ""}}, + {"the Champion's Arcanine (Roar): no X item", {"20.01", "champion", 4, 0, 165}, {"", ""}}, +}; + +UnitTestResult test_league_turns(){ + for (const LeagueTurnCase& test : LEAGUE_TURN_CASES){ + const LeagueTurnInput& input = test.input; + const StoryStep& step = battle_step(input.id, input.battle); + Supplies supplies = league_supplies(step); + PolicyState state(supplies.policy); + for (int used = 0; used < input.spa_stage; used++){ + state.item_used("x-special"); + } + const std::string item = use(state, supplies, league_view(input.hp, input.foe_index)); + if (item != test.expectation.item){ + return std::format("{}: expected \"{}\", got \"{}\".", test.name, test.expectation.item, item); + } + if (test.expectation.move.empty()){ + continue; + } + const AttackContext context{ + .sp_attack_stage = input.spa_stage, .foe = supplies.policy.foe_stats.at(input.foe_index), + }; + const std::optional slot = attack_slot_against(supplies.lead, {supplies.foes.at(input.foe_index)}, context); + const std::string move = slot ? supplies.lead.moves[*slot].move : "none"; + if (move != test.expectation.move){ + return std::format("{}: expected {}, got {}.", test.name, test.expectation.move, move); + } + } + return true; +} + struct AutoStoryBattlePolicyInput{ std::string name; @@ -657,6 +874,26 @@ const std::vector AUTO_STORY_BATTLE_POLICY_CASES = { .input = {.name = "low HP heals; no medicine attacks", .body = test_low_hp_heals}, .expectation = {.description = "a heal at low HP, an attack with none"}, }, + { + .input = {.name = "Lorelei, high risk, red HP", .body = test_high_risk_red_full_restore}, + .expectation = {.description = "a Full Restore, not a Super Potion"}, + }, + { + .input = {.name = "Lorelei, high risk, yellow HP", .body = test_high_risk_yellow_full_restore}, + .expectation = {.description = "a Full Restore"}, + }, + { + .input = {.name = "Lorelei, high risk, green HP after setup", .body = test_high_risk_green_attacks}, + .expectation = {.description = "an attack"}, + }, + { + .input = {.name = "Lorelei's HP in a low-risk fight, red HP", .body = test_low_risk_red_super_potion}, + .expectation = {.description = "a Super Potion; Full Restores are kept"}, + }, + { + .input = {.name = "the bag's full-restore key", .body = test_full_restore_key_resolves}, + .expectation = {.description = "13 in row 3, a whole-HP medicine"}, + }, { .input = {.name = "a heal that loses ground to poison and the foe's hits is not repeated", .body = test_futile_potions_attack}, .expectation = {.description = "Potions against a hit of 100 are skipped for an attack"}, @@ -686,7 +923,7 @@ const std::vector AUTO_STORY_BATTLE_POLICY_CASES = { .expectation = {.description = "4 in the opening, 2 with Torrent, on a later foe or a lone one"}, }, { - .input = {.name = "plan: 20.02 bruno names the policy, goals and target_torrent", .body = test_plan_bruno}, + .input = {.name = "plan: 20.01 bruno names budgeted-setup, its goals and target_torrent", .body = test_plan_bruno}, .expectation = {.description = "the policy, goals, target_torrent and 5 foe rows"}, }, { @@ -729,6 +966,18 @@ const std::vector AUTO_STORY_BATTLE_POLICY_CASES = { .input = {.name = "plan: 17.04 giovanni resolves to the doc's B", .body = test_plan_giovanni_gym}, .expectation = {.description = "solo-recovery, 5 generator rows"}, }, + { + .input = {.name = "guessed item counts: the battle reads the bag first", .body = test_unknown_counts_read_before_first_turn}, + .expectation = {.description = "a read before a trainer's or a wild fight, none to run or once read"}, + }, + { + .input = {.name = "19.01 rival at Default checks: sets up from the battle's own read", .body = test_rival_route22_sets_up_from_its_own_read}, + .expectation = {.description = "a bag read, then an X item or Guard Spec at turn 1"}, + }, + { + .input = {.name = "League: setup only where it pays (Bruno's Onix, Lorelei, the Champion's phazers)", .body = test_league_turns}, + .expectation = {.description = "Surf on a foe it KOs at any stage, no X item on Roar or Whirlwind, X Specials on the rest"}, + }, }; } // namespace diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.cpp new file mode 100644 index 0000000000..20a496c068 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.cpp @@ -0,0 +1,68 @@ +/* AutoStory Battle Switch + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_PartyMenuDetector.h" +#include "PokemonFRLG_AutoStoryBattleSwitch.h" +#include "PokemonFRLG_AutoStoryLeadOut.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using namespace std::chrono_literals; + + +namespace{ + +void tap(ProControllerContext& context, DpadPosition position){ + pbf_press_dpad(context, position, /*hold=*/160ms, /*release=*/240ms); +} + +// POKEMON, bottom left of the battle menu, and time for the party list to show. +void open_party_list(ProControllerContext& context){ + tap(context, DPAD_RIGHT); + tap(context, DPAD_UP); + tap(context, DPAD_LEFT); + tap(context, DPAD_DOWN); + pbf_press_button(context, BUTTON_A, /*hold=*/160ms, /*release=*/1500ms); +} + +} // namespace + + +void send_member(ProControllerContext& context, size_t slot){ + for (size_t c = 0; c < slot; c++){ + pbf_press_dpad(context, DPAD_DOWN, /*hold=*/160ms, /*release=*/400ms); + } + pbf_press_button(context, BUTTON_A, /*hold=*/160ms, /*release=*/800ms); + pbf_press_button(context, BUTTON_A, /*hold=*/160ms, /*release=*/1500ms); +} + +bool switch_lead_in(ConsoleHandle& console, ProControllerContext& context, Language language, std::string_view lead){ + open_party_list(context); + VideoSnapshot screen = console.video().snapshot(); + const std::optional slot = screen && PartyMenuDetector(COLOR_RED).detect(screen) + ? party_slot_of(console.logger(), language, screen, lead) + : std::nullopt; + if (!slot || *slot == 0){ + console.log("Battle: the lead isn't in the party list off the field; fighting on.", COLOR_RED); + pbf_press_button(context, BUTTON_B, /*hold=*/160ms, /*release=*/1000ms); + return false; + } + console.log(std::format("Battle: the lead back in from party list slot {}.", *slot + 1), COLOR_ORANGE); + send_member(context, *slot); + return true; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.h new file mode 100644 index 0000000000..7d00e0d9d5 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.h @@ -0,0 +1,40 @@ +/* AutoStory Battle Switch + * + * From: https://github.com/PokemonAutomation/ + * + * Sending a party member out from the battle menu through POKEMON and + * SHIFT. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryBattleSwitch_H +#define PokemonAutomation_PokemonFRLG_AutoStoryBattleSwitch_H + +#include +#include +#include "CommonFramework/Language.h" +#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The party list in battle opens on the lead: down to `slot`, then A, and +// SHIFT, the top of its menu. +void send_member(ProControllerContext& context, size_t slot); + +// Switches the lead dragged out back in from the battle menu: POKEMON, +// the party list's slot that reads `lead`, SHIFT. Not the slot out (the +// top-left one), so never a member the loop didn't mean to send. False, +// and back at the menu, if the list doesn't show or no other slot reads +// the lead. +bool switch_lead_in(ConsoleHandle& console, ProControllerContext& context, Language language, std::string_view lead); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.cpp new file mode 100644 index 0000000000..c5658e8137 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.cpp @@ -0,0 +1,53 @@ +/* AutoStory Battle Text + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonTools/Images/ImageFilter.h" +#include "CommonTools/OCR/OCR_Routines.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_OcrPreprocessing.h" +#include "PokemonFRLG_AutoStoryBattleText.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The battle text box's two lines, as a fraction of the game screen. +const ImageFloatBox BATTLE_TEXT_BOX(0.04, 0.755, 0.9, 0.2); +// Fewer letters than this is no text. +constexpr size_t MIN_LETTERS = 5; + +} // namespace + +std::optional read_battle_text(Language language, const ImageViewRGB32& screen){ + if (language != Language::English){ + return std::nullopt; + } + const ImageViewRGB32 game = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + const ImageRGB32 text_image = preprocess_for_ocr(extract_box_reference(game, BATTLE_TEXT_BOX), 3, 1); + for (const OCR::TextColorRange& filter : BRIGHT_TEXT_FILTERS()){ + size_t text_pixels = 0; + const ImageRGB32 filtered = to_blackwhite_rgb32_range(text_pixels, text_image, true, filter.mins, filter.maxs); + std::string text = text_pixels == 0 ? "" : OCR::ocr_read(language, filtered, OCR::PageSegMode::SINGLE_BLOCK); + std::erase_if(text, [](char c){ return !std::isalpha(static_cast(c)); }); + if (text.size() >= MIN_LETTERS){ + std::ranges::transform(text, text.begin(), [](char c){ return static_cast(std::tolower(static_cast(c))); }); + return text; + } + } + return std::nullopt; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.h new file mode 100644 index 0000000000..c901c8cfbe --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.h @@ -0,0 +1,34 @@ +/* AutoStory Battle Text + * + * From: https://github.com/PokemonAutomation/ + * + * The battle text box read as letters, for the battle policy's KO risk + * (PolicyView::battle_texts): a foe charging Solar Beam or Dive, Sunny + * Day's sun. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryBattleText_H +#define PokemonAutomation_PokemonFRLG_AutoStoryBattleText_H + +#include +#include +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "CommonFramework/Language.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The battle text box's two lines on `screen` as letters, lower case +// ("foevenusaurtookinsunlight"). English only: none in another language +// or with no text. +std::optional read_battle_text(Language language, const ImageViewRGB32& screen); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.cpp new file mode 100644 index 0000000000..9ef943520c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.cpp @@ -0,0 +1,280 @@ +/* AutoStory Battle Track + * + * From: https://github.com/PokemonAutomation/ + * + * The texts are pokefirered's (src/battle_message.c), read as letters: + * "Foe VENUSAUR's SP. ATK rose!" is "foevenusaursspatkrose". + * + */ + +#include +#include +#include "PokemonFRLG_AutoStoryBattleTrack.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// Guard Spec's Mist lasts 5 turns (pret). +constexpr int MIST_TURNS = 5; +// Sunny Day and Rain Dance last 5 turns, the one they start in included: +// the choices of the 4 after it. +constexpr int WEATHER_TURNS = 4; +// The fewest turns a sleep lasts (pret: 2 to 5), and Rest's. +constexpr int MIN_SLEEP_TURNS = 2; +constexpr int REST_SLEEP_TURNS = 3; +constexpr int MAX_STAGE = 6; + +bool has(std::string_view letters, std::string_view word){ + return letters.find(word) != std::string_view::npos; +} + +// A stat stage change: whose, which, by how much. +struct StatChange{ + bool foe = false; + int StatStages::* stat = nullptr; + int stages = 0; + + bool operator==(const StatChange&) const = default; +}; + +struct StatWord{ + std::string_view word; + int StatStages::* stat; +}; +constexpr std::array STAT_WORDS{{ + {"spatk", &StatStages::sp_attack}, {"spdef", &StatStages::sp_defense}, {"attack", &StatStages::attack}, + {"defense", &StatStages::defense}, {"speed", &StatStages::speed}, {"accuracy", &StatStages::accuracy}, + {"evasiveness", &StatStages::evasion}, +}}; +struct StageWord{ + std::string_view word; + int stages; +}; +// "harshly fell" before "fell", "sharply rose" before "rose". +constexpr std::array STAGE_WORDS{{ + {"sharplyrose", 2}, {"rose", 1}, {"harshlyfell", -2}, {"fell", -1}, +}}; + +// The stages "[sharply ]rose!" or "[harshly ]fell!" at the start of `after`. +std::optional stages_at(std::string_view after){ + for (const StageWord& stage : STAGE_WORDS){ + if (after.starts_with(stage.word)){ + return stage.stages; + } + } + return std::nullopt; +} + +// "'s [sharply ]rose!" or "[harshly ]fell!". +std::optional stat_change(std::string_view letters){ + for (const StatWord& stat : STAT_WORDS){ + for (size_t at = letters.find(stat.word); at != std::string_view::npos; at = letters.find(stat.word, at + 1)){ + if (const std::optional stages = stages_at(letters.substr(at + stat.word.size()))){ + return StatChange{.foe = letters.starts_with("foe"), .stat = stat.stat, .stages = *stages}; + } + } + } + return std::nullopt; +} + +enum class FoeStatusText{ + ASLEEP, + RESTED, + SLEPT_THROUGH, + WOKE, + FROZEN, + PARALYZED, + BURNED, + POISONED, + CURED, +}; + +// The foe's status texts; none for ours or another text. +std::optional foe_status_text(std::string_view letters){ + if (!letters.starts_with("foe")){ + return std::nullopt; + } + struct Word{ + std::string_view word; + FoeStatusText status; + }; + static constexpr std::array WORDS{{ + {"cured", FoeStatusText::CURED}, {"wokeup", FoeStatusText::WOKE}, {"defrosted", FoeStatusText::CURED}, + {"fellasleep", FoeStatusText::ASLEEP}, {"wenttosleep", FoeStatusText::RESTED}, + {"sleptandbecamehealthy", FoeStatusText::RESTED}, {"fastasleep", FoeStatusText::SLEPT_THROUGH}, + {"frozensolid", FoeStatusText::FROZEN}, {"paralyzed", FoeStatusText::PARALYZED}, + {"wasburned", FoeStatusText::BURNED}, {"poisoned", FoeStatusText::POISONED}, + }}; + for (const Word& word : WORDS){ + if (has(letters, word.word)){ + return word.status; + } + } + return std::nullopt; +} + +void apply_status(FoeStatusText text, BattleTrackState& state){ + switch (text){ + case FoeStatusText::ASLEEP: + state.foe_status = PlannedStatus::SLEEP; + state.foe_sleep_turns = MIN_SLEEP_TURNS; + return; + case FoeStatusText::RESTED: + state.foe_status = PlannedStatus::SLEEP; + state.foe_sleep_turns = REST_SLEEP_TURNS; + return; + case FoeStatusText::SLEPT_THROUGH: + state.foe_status = PlannedStatus::SLEEP; + state.foe_sleep_turns = std::max(1, state.foe_sleep_turns - 1); + return; + case FoeStatusText::FROZEN: + state.foe_status = PlannedStatus::FREEZE; + return; + case FoeStatusText::PARALYZED: + state.foe_status = PlannedStatus::PARALYSIS; + return; + case FoeStatusText::BURNED: + state.foe_status = PlannedStatus::BURN; + return; + case FoeStatusText::POISONED: + state.foe_status = PlannedStatus::POISON; + return; + case FoeStatusText::WOKE: + case FoeStatusText::CURED: + state.foe_status = PlannedStatus::NONE; + state.foe_sleep_turns = 0; + return; + } +} + +void set_weather(FieldWeather weather, int turns, BattleTrackState& state){ + state.weather = weather; + state.weather_turns = turns; +} + +// Sunny Day's and Rain Dance's start, their end-of-turn reminder (when +// the start was missed) and their end. +void read_weather(std::string_view letters, BattleTrackState& state){ + if (has(letters, "sunlightgotbright")){ + set_weather(FieldWeather::SUN, WEATHER_TURNS, state); + }else if (has(letters, "sunlightisstrong")){ + set_weather(FieldWeather::SUN, std::max(1, state.weather == FieldWeather::SUN ? state.weather_turns : 0), state); + }else if (has(letters, "startedtorain")){ + set_weather(FieldWeather::RAIN, WEATHER_TURNS, state); + }else if (has(letters, "raincontinuestofall")){ + set_weather(FieldWeather::RAIN, std::max(1, state.weather == FieldWeather::RAIN ? state.weather_turns : 0), state); + }else if (has(letters, "sunlightfaded") || has(letters, "rainstopped")){ + set_weather(FieldWeather::NONE, /*turns=*/0, state); + } +} + +// The foe's moves that take a turn of charging, by their charge text. +void read_charge(std::string_view letters, BattleTrackState& state){ + if (has(letters, "tookinsunlight")){ + state.foe_charging = "solar-beam"; + }else if (has(letters, "underwater")){ + state.foe_charging = "dive"; + } +} + +void apply_stat(const StatChange& change, BattleTrackState& state){ + // Ours rise from our items only (item_used()). + if (!change.foe && change.stages > 0){ + return; + } + int& stage = (change.foe ? state.foe : state.own).*change.stat; + stage = std::clamp(stage + change.stages, -MAX_STAGE, MAX_STAGE); +} + +void raise(int& stage){ + stage = std::min(MAX_STAGE, stage + 1); +} + +} // namespace + + +void BattleTrack::read_turn(const std::vector& texts){ + m_state.foe_recharging = false; + m_state.foe_charging.reset(); + bool restored = false; + // A text read twice (the box polled again, the name misread) is one + // change: one side can't change one stat twice in a row in a turn. + std::optional last_stat; + std::optional last_status; + for (const std::string& letters : texts){ + // pokefirered: "{trainer} used\nFULL RESTORE!"; the player's own + // medicine shows no such text. It cures the foe's status. + if (!restored && has(letters, "usedfullrestore")){ + restored = true; + m_state.trainer_full_restores++; + apply_status(FoeStatusText::CURED, m_state); + } + m_state.foe_recharging = m_state.foe_recharging || has(letters, "usedhyperbeam"); + read_charge(letters, m_state); + read_weather(letters, m_state); + const std::optional stat = stat_change(letters); + if (stat && stat != last_stat){ + apply_stat(*stat, m_state); + } + last_stat = stat; + const std::optional status = foe_status_text(letters); + if (status && status != last_status){ + apply_status(*status, m_state); + } + last_status = status; + } +} + +void BattleTrack::item_used(std::string_view item){ + if (item == "x-special"){ + raise(m_state.own.sp_attack); + }else if (item == "x-speed"){ + raise(m_state.own.speed); + }else if (item == "x-accuracy"){ + raise(m_state.own.accuracy); + }else if (item == "x-attack"){ + raise(m_state.own.attack); + }else if (item == "x-defend"){ + raise(m_state.own.defense); + }else if (item == "guard-spec"){ + m_state.mist_turns = MIST_TURNS; + } +} + +void BattleTrack::foe_out(size_t slot, std::string_view ability){ + if (m_foe_slot && *m_foe_slot != slot){ + m_state.foe = StatStages{}; + apply_status(FoeStatusText::CURED, m_state); + } + m_foe_slot = slot; + if (m_intimidated_by == slot){ + return; + } + m_intimidated_by = slot; + if (ability == "intimidate" && m_state.mist_turns == 0){ + m_state.own.attack = std::max(-MAX_STAGE, m_state.own.attack - 1); + } +} + +void BattleTrack::lead_switched_in(){ + m_state.own = StatStages{}; +} + +void BattleTrack::turn_chosen(){ + if (m_state.mist_turns > 0){ + m_state.mist_turns--; + } + if (m_state.weather_turns > 0 && --m_state.weather_turns == 0){ + m_state.weather = FieldWeather::NONE; + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.h new file mode 100644 index 0000000000..ac14ed49e7 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.h @@ -0,0 +1,104 @@ +/* AutoStory Battle Track + * + * From: https://github.com/PokemonAutomation/ + * + * What a League fight's screen doesn't show, kept as PokemonSimulation's + * engine has it, from the items we used and the battle texts + * (read_battle_text(): lower-case letters only): both sides' stat stages, + * the foe's status, the sun or rain, the foe's Hyper Beam recharge and + * two-turn charge, Guard Spec's Mist and the trainer's Full Restores. + * Our stages rise from our X items only; the texts lower them. The texts + * move the foe's both ways. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryBattleTrack_H +#define PokemonAutomation_PokemonFRLG_AutoStoryBattleTrack_H + +#include +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "PokemonFRLG_AutoStoryPlannedState.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// One side's stat stages, -6 to +6. +struct StatStages{ + int attack = 0; + int defense = 0; + int sp_attack = 0; + int sp_defense = 0; + int speed = 0; + int accuracy = 0; + int evasion = 0; +}; + +// The weather that changes damage (Sunny Day, Rain Dance). +enum class FieldWeather{ + NONE, + SUN, + RAIN, +}; + +// The fight's state as tracked. +struct BattleTrackState{ + StatStages own = {}; + int mist_turns = 0; + StatStages foe = {}; + PlannedStatus foe_status = PlannedStatus::NONE; + // The fewest turns the foe's sleep has left: 3 after Rest, else 2, + // one less for each turn it sleeps through ("is fast asleep"). + int foe_sleep_turns = 0; + bool foe_recharging = false; + // The two-turn move the foe is charging. + std::optional foe_charging = std::nullopt; + FieldWeather weather = FieldWeather::NONE; + // The choices the weather still lasts for. + int weather_turns = 0; + int trainer_full_restores = 0; +}; + +// A League fight's tracked state, turn by turn. +class BattleTrack{ +public: + // The battle texts since the last choice, in order. + void read_turn(const std::vector& texts); + // An X item or Guard Spec we used. + void item_used(std::string_view item); + // The foe out is the one at its trainer's `slot`: a new one starts at + // stage 0 with no status, and its Intimidate cuts our Attack unless + // Mist is up. + void foe_out(size_t slot, std::string_view ability); + // Our lead back in after Roar or Whirlwind: its stages are gone, the + // side's Mist stays, and the foe out doesn't Intimidate it again + // (pret: Intimidate acts on its holder's entry only). + void lead_switched_in(); + // A choice made: Mist and the weather count down. + void turn_chosen(); + const BattleTrackState& state() const{ + return m_state; + } + +private: + BattleTrackState m_state; + std::optional m_foe_slot; + // The foe whose Intimidate our lead has met. + std::optional m_intimidated_by; +}; + + +// Registers the battle track tests. +void add_tests_AutoStoryBattleTrack(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack_Tests.cpp new file mode 100644 index 0000000000..6695dd4fc6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack_Tests.cpp @@ -0,0 +1,234 @@ +/* AutoStory Battle Track Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The League fight's tracked state from battle texts as + * read_battle_text() gives them (letters, lower case), turn by turn. + * + */ + +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_AutoStoryBattleTrack.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// One turn: the texts since the last choice, and the foe out after them +// with its ability; our lead came back in after Roar or Whirlwind first. +struct TrackTurn{ + std::vector texts = {}; + size_t foe_slot = 0; + std::string foe_ability = {}; + bool lead_back_in = false; +}; +struct TrackInput{ + std::vector turns = {}; +}; +// The state at the last turn's choice. +struct TrackExpectation{ + StatStages own = {}; + StatStages foe = {}; + PlannedStatus foe_status = PlannedStatus::NONE; + int foe_sleep_turns = 0; + FieldWeather weather = FieldWeather::NONE; + int trainer_full_restores = 0; +}; +struct TrackCase{ + std::string name; + TrackInput input; + TrackExpectation expectation; +}; + +bool same(const StatStages& a, const StatStages& b){ + return a.attack == b.attack && a.defense == b.defense && a.sp_attack == b.sp_attack && a.sp_defense == b.sp_defense + && a.speed == b.speed && a.accuracy == b.accuracy && a.evasion == b.evasion; +} + +std::string describe(const StatStages& stages){ + return std::format("atk {} def {} spa {} spd {} spe {} acc {} eva {}", + stages.attack, stages.defense, stages.sp_attack, stages.sp_defense, stages.speed, stages.accuracy, stages.evasion); +} + +class Test_BattleTrack : public UnitTest{ +public: + explicit Test_BattleTrack(TrackCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryBattleTrack - {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + BattleTrack track; + for (size_t turn = 0; turn < m_case.input.turns.size(); turn++){ + if (turn > 0){ + track.turn_chosen(); + } + const TrackTurn& input = m_case.input.turns[turn]; + if (input.lead_back_in){ + track.lead_switched_in(); + } + track.read_turn(input.texts); + track.foe_out(input.foe_slot, input.foe_ability); + } + const BattleTrackState& got = track.state(); + const TrackExpectation& want = m_case.expectation; + if (!same(got.own, want.own) || !same(got.foe, want.foe) || got.foe_status != want.foe_status + || got.foe_sleep_turns != want.foe_sleep_turns || got.weather != want.weather + || got.trainer_full_restores != want.trainer_full_restores){ + return std::format("Ours {}; the foe's {}, status {}, sleep {}; weather {}; Full Restores {}.", + describe(got.own), describe(got.foe), static_cast(got.foe_status), got.foe_sleep_turns, + static_cast(got.weather), got.trainer_full_restores); + } + return true; + } + +private: + TrackCase m_case; +}; + +const TrackCase TRACK_CASES[] = { + { + .name = "Growth raises the foe's Sp. Atk", + .input = {.turns = {{.texts = {"foevenusaurusedgrowth", "foevenusaursspatkrose"}}}}, + .expectation = {.foe = {.sp_attack = 1}}, + }, + { + .name = "Amnesia sharply raises the foe's Sp. Def", + .input = {.turns = {{.texts = {"foeslowbrousedamnesia", "foeslowbrosspdefsharplyrose"}}}}, + .expectation = {.foe = {.sp_defense = 2}}, + }, + { + .name = "Double Team read twice, the name misread once: one stage", + .input = {.turns = {{.texts = {"foegengarsevasivenessrose", "foegengersevasivenessrose"}}}}, + .expectation = {.foe = {.evasion = 1}}, + }, + { + .name = "Double Team on two turns: two stages", + .input = {.turns = {{.texts = {"foegengarsevasivenessrose"}}, {.texts = {"foegengarsevasivenessrose"}}}}, + .expectation = {.foe = {.evasion = 2}}, + }, + { + .name = "Screech harshly lowers our Defense", + .input = {.turns = {{.texts = {"foearbokusedscreech", "blastoisesdefenseharshlyfell"}}}}, + .expectation = {.own = {.defense = -2}}, + }, + { + .name = "Scary Face and Rock Tomb lower our Speed", + .input = {.turns = {{.texts = {"blastoisesspeedharshlyfell"}}, {.texts = {"blastoisesspeedfell"}}}}, + .expectation = {.own = {.speed = -3}}, + }, + { + .name = "our X Special's text: counted from the item, not the text", + .input = {.turns = {{.texts = {"kosmosusedxspecial", "blastoisesspatkrose"}}}}, + .expectation = {}, + }, + { + .name = "a new foe starts at stage 0", + .input = {.turns = {{.texts = {"foevenusaursspatkrose"}, .foe_slot = 4}, {.texts = {}, .foe_slot = 5}}}, + .expectation = {}, + }, + { + .name = "Arcanine's Intimidate cuts our Attack once", + .input = {.turns = { + {.texts = {}, .foe_slot = 4, .foe_ability = "intimidate"}, + {.texts = {}, .foe_slot = 4, .foe_ability = "intimidate"}, + }}, + .expectation = {.own = {.attack = -1}}, + }, + { + // pret AbilityBattleEffects: Intimidate acts on its holder's entry + // only (STATUS3_INTIMIDATE_POKES), not on ours. + .name = "back in after Arcanine's Roar: our stages gone, no second Intimidate", + .input = {.turns = { + {.texts = {}, .foe_slot = 4, .foe_ability = "intimidate"}, + {.texts = {}, .foe_slot = 4, .foe_ability = "intimidate", .lead_back_in = true}, + }}, + .expectation = {}, + }, + { + .name = "our lead falls asleep: not the foe's status", + .input = {.turns = {{.texts = {"foejynxusedlovelykiss", "blastoisefellasleep"}}}}, + .expectation = {}, + }, + { + .name = "Rest: 3 turns, one less per turn slept through", + .input = {.turns = {{.texts = {"foelaprassleptandbecamehealthy"}}, {.texts = {"foelaprasisfastasleep", "foelaprasisfastasleep"}}}}, + .expectation = {.foe_status = PlannedStatus::SLEEP, .foe_sleep_turns = 2}, + }, + { + .name = "another sleep: 2 turns at least", + .input = {.turns = {{.texts = {"foejynxfellasleep"}}, {.texts = {"foejynxisfastasleep"}}}}, + .expectation = {.foe_status = PlannedStatus::SLEEP, .foe_sleep_turns = 1}, + }, + { + .name = "the foe wakes up", + .input = {.turns = {{.texts = {"foejynxfellasleep"}}, {.texts = {"foejynxwokeup"}}}}, + .expectation = {}, + }, + { + .name = "Blizzard freezes the foe", + .input = {.turns = {{.texts = {"foedragonitewasfrozensolid"}}}}, + .expectation = {.foe_status = PlannedStatus::FREEZE}, + }, + { + .name = "the trainer's Full Restore cures the foe", + .input = {.turns = {{.texts = {"foedragonitewasfrozensolid"}}, {.texts = {"lanceusedfullrestore", "lanceusedfullrestore"}}}}, + .expectation = {.trainer_full_restores = 1}, + }, + { + .name = "a paralyzed foe", + .input = {.turns = {{.texts = {"foedragonairisparalyzeditmaybeunabletomove"}}}}, + .expectation = {.foe_status = PlannedStatus::PARALYSIS}, + }, + { + .name = "Sunny Day's sun on the 4th choice after", + .input = {.turns = {{.texts = {"foevenusaurusedsunnyday", "thesunlightgotbright"}}, {}, {}, {}}}, + .expectation = {.weather = FieldWeather::SUN}, + }, + { + .name = "Sunny Day's sun gone by the 5th choice after", + .input = {.turns = {{.texts = {"thesunlightgotbright"}}, {}, {}, {}, {}}}, + .expectation = {}, + }, + { + .name = "the sunlight faded", + .input = {.turns = {{.texts = {"thesunlightgotbright"}}, {.texts = {"thesunlightfaded"}}}}, + .expectation = {}, + }, + { + .name = "Solar Beam's charge is no sun", + .input = {.turns = {{.texts = {"foevenusaurtookinsunlight"}}}}, + .expectation = {}, + }, + { + .name = "the sun's reminder after a missed start", + .input = {.turns = {{.texts = {"thesunlightisstrong"}}}}, + .expectation = {.weather = FieldWeather::SUN}, + }, + { + .name = "Rain Dance's rain", + .input = {.turns = {{.texts = {"itstartedtorain"}}}}, + .expectation = {.weather = FieldWeather::RAIN}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryBattleTrack(UnitTestDatabase& database){ + for (const TrackCase& test_case : TRACK_CASES){ + database.add(test_case); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTurns.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTurns.h index 38ac3de5c9..3b546c0c00 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTurns.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTurns.h @@ -37,8 +37,19 @@ enum class TurnChoice{ // on the lead through the party list. MEDICINE, MOVE, + // The lead back in through POKEMON and SHIFT: a Roar or Whirlwind + // dragged it out (lead_on_field()). + SWITCH_LEAD, }; +// Before a battle of `kind`'s first turn: whether it reads the Items pocket +// itself, its counts a row's guess (Supplies::counts_read), unless it only +// runs. Console B, 2026-11-15, 19.01: the rival was fought with 0 Potions +// and no X item from the counts a skipped check left. +inline bool battle_needs_bag_read(const Supplies& supplies, BattleKind kind){ + return !supplies.counts_read && kind != BattleKind::WILD_RUN; +} + // Decided battle action including slot or item index. struct TurnAction{ TurnChoice choice = TurnChoice::MOVE; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.cpp new file mode 100644 index 0000000000..fa45c9b267 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.cpp @@ -0,0 +1,136 @@ +/* AutoStory Boulder Presses + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/ImageTools/ImageDiff.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" +#include "PokemonFRLG_AutoStoryBoulderPresses.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_MovementStepPresses.h" +#include "PokemonFRLG_AutoStoryPresses.h" +#include "PokemonFRLG_AutoStoryQuietOverworld.h" +#include "PokemonFRLG_AutoStoryStepInterrupts.h" +#include "PokemonFRLG_AutoStoryTrainerMessage.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// How long the screen is watched, a shot every BOULDER_STILL_POLL, for +// two shots alike after a tap toward a boulder: the push's slow slide +// ends by the tap's release (MovementMechanics::STEP_TAP_RELEASE), so +// this only waits out a late frame. +constexpr Milliseconds BOULDER_STILL_POLL(100); +constexpr int BOULDER_STILL_POLLS = 5; +// How much two shots of a still screen may differ. +constexpr double BOULDER_STILL_RMSD = 6.0; +// How long a box that stopped a push may take to close. +constexpr Milliseconds BOX_TIMEOUT(20000); +// After A, the overworld this long quiet with nothing showing means A +// found nothing to use: Strength's question shows well within it. Looked +// for at most NOTHING_LOOK_TIMEOUT. +constexpr Milliseconds NOTHING_QUIET(1000); +constexpr Milliseconds NOTHING_LOOK_TIMEOUT(3000); +// How long Strength's YES/NO, and then its message, may take. +constexpr Milliseconds YES_NO_TIMEOUT(60000); +constexpr Milliseconds MESSAGE_TIMEOUT(300000); + +std::string_view describe(const BoulderPressRead& read){ + if (read.scrolled){ + return "the player walked a tile"; + } + return read.boulder_moved ? "the boulder moved, the player in place" : "nothing moved"; +} + +} // namespace + + +std::optional use_strength(ConsoleHandle& console, ProControllerContext& context, const MapPosition& here, Direction direction){ + pbf_press_button(context, BUTTON_A, /*hold=*/160ms, /*release=*/800ms); + context.wait_for_all_requests(); + ConsoleScreenLook eyes(console, context); + const Pokemon::ScreenLookFunction look = [&eyes](bool fresh){ return eyes.look(fresh); }; + const Pokemon::ScreenSettle settle = wait_for_quiet_overworld(look, NOTHING_QUIET, NOTHING_LOOK_TIMEOUT); + console.log(std::format("Boulder: after A for Strength, {}.", Pokemon::describe(settle))); + if (quiet_overworld(settle, NOTHING_QUIET)){ + return std::format("no boulder {} of {}: A for Strength showed nothing.", direction_name(direction), to_string(here)); + } + answer_yes_no(console, context, /*yes=*/true, BUTTON_B, YES_NO_TIMEOUT); + mash_until_overworld(console, context, MESSAGE_TIMEOUT); + return std::nullopt; +} + +ConsoleBoulderPresses::ConsoleBoulderPresses(ConsoleHandle& console, ProControllerContext& context, PlayerGender player) + : m_console(console) + , m_context(context) + , m_player(player) +{} + +BoulderPressRead ConsoleBoulderPresses::press(Direction direction){ + m_context.wait_for_all_requests(); + const VideoSnapshot before = m_console.video().snapshot(); + step_once(m_console, m_context, direction, direction, m_player); + const VideoSnapshot after = still_shot(); + if (!before || !after){ + m_console.log("Boulder: no shot of the screen around the tap: read as nothing moved.", COLOR_ORANGE); + return {}; + } + const BoulderPressRead read = read_boulder_press(*before.frame, *after.frame, GameSettings::instance().GAME_BOX, direction); + m_console.log(std::format("Boulder: tap {}: {}.", direction_name(direction), describe(read))); + return read; +} + +bool ConsoleBoulderPresses::clear_interrupt(){ + m_context.wait_for_all_requests(); + ConsoleScreenLook eyes(m_console, m_context); + const Pokemon::ScreenLookFunction look = [&eyes](bool fresh){ return eyes.look(fresh); }; + Pokemon::ScreenSettle settle = wait_for_quiet_overworld(look, MovementMechanics::AFTER_BATTLE_QUIET, BATTLE_EXIT_TIMEOUT); + if (settle.showing.has(ScreenEvent::BATTLE_STARTED)){ + m_console.log("Boulder: a wild battle stopped the push; running from it.", COLOR_ORANGE); + flee_battle(m_console, m_context); + wait_out_battle_exit(m_console, m_context); + settle = wait_for_quiet_overworld(look, MovementMechanics::AFTER_BATTLE_QUIET, BATTLE_EXIT_TIMEOUT); + }else if (settle.showing.has(ScreenEvent::DIALOG_BOX) || settle.showing.has(ScreenEvent::CHOICE_BOX)){ + m_console.log("Boulder: a box stopped the push; closing it.", COLOR_ORANGE); + mash_until_overworld(m_console, m_context, BOX_TIMEOUT); + settle = wait_for_quiet_overworld(look, MovementMechanics::AFTER_BATTLE_QUIET, BATTLE_EXIT_TIMEOUT); + } + const bool quiet = quiet_overworld(settle, MovementMechanics::AFTER_BATTLE_QUIET); + m_console.log(std::format("Boulder: after the tap, {}{}.", Pokemon::describe(settle), quiet ? "; tapping again" : ""), quiet ? COLOR_BLACK : COLOR_RED); + return quiet; +} + +VideoSnapshot ConsoleBoulderPresses::still_shot(){ + const ImageFloatBox& game = GameSettings::instance().GAME_BOX; + VideoSnapshot last = m_console.video().snapshot(); + for (int poll = 0; last && poll < BOULDER_STILL_POLLS; poll++){ + m_context.wait_for(BOULDER_STILL_POLL); + VideoSnapshot now = m_console.video().snapshot(); + if (!now){ + break; + } + const bool still = ImageMatch::pixel_RMSD( + extract_box_reference(*last.frame, game), extract_box_reference(*now.frame, game) + ) <= BOULDER_STILL_RMSD; + last = std::move(now); + if (still){ + break; + } + } + return last; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.h new file mode 100644 index 0000000000..0938675872 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.h @@ -0,0 +1,60 @@ +/* AutoStory Boulder Presses + * + * From: https://github.com/PokemonAutomation/ + * + * A boulder push's taps on the console (push_boulder_tiles()), each read + * from shots of the screen before and after it (read_boulder_press()). + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryBoulderPresses_H +#define PokemonAutomation_PokemonFRLG_AutoStoryBoulderPresses_H + +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include +#include +#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h" +#include "PokemonFRLG_AutoStoryBoulders.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Strength on, at the boulder `direction` of the player on `here`: A, +// YES to "Would you like to use STRENGTH?", its message closed. If A +// shows nothing (the overworld stays quiet), no boulder is there: returns +// that failure at once, not after the YES/NO's timeout. 19.04d's +// push_into_hole pressed A at the hole the boulder had already fallen +// into and waited 60 s for a YES/NO (console B, 2026-11-16). +std::optional use_strength(ConsoleHandle& console, ProControllerContext& context, const MapPosition& here, Direction direction); + +// A boulder push's taps on the console: step taps, each read from shots of +// the screen before it and once still after it. +class ConsoleBoulderPresses : public BoulderPresses{ +public: + ConsoleBoulderPresses(ConsoleHandle& console, ProControllerContext& context, PlayerGender player); + + // A step tap (step_once()), read once the screen is still. + BoulderPressRead press(Direction direction) override; + // The settle rule: looks until the overworld is quiet for + // MovementMechanics::AFTER_BATTLE_QUIET; a battle that shows is run + // from, a box closed, and the overworld waited for again. + bool clear_interrupt() override; + +private: + VideoSnapshot still_shot(); + + ConsoleHandle& m_console; + ProControllerContext& m_context; + PlayerGender m_player; +}; + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp index 2e55a8b941..4d10740719 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp @@ -5,11 +5,13 @@ */ #include +#include #include #include "Pokemon/AutoStory/Pokemon_StoryActions.h" #include "Pokemon/Navigation/Pokemon_GateTiles.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h" #include "PokemonFRLG_AutoStoryBoulders.h" +#include "PokemonFRLG_AutoStoryMovedBoulders.h" #include "PokemonFRLG_AutoStoryPoses.h" namespace PokemonAutomation{ @@ -28,6 +30,7 @@ Pokemon::Outcome boulder_pushed(Pokemon::RunState& state, const StoryStep& step, for (int64_t c = 0; c < tiles; c++){ at.tile = at.tile.next(direction); } + note_boulder_pushed(MapPosition{here->map, here->tile}, direction, tiles, state.flags); // The boulder stands a tile ahead; on a floor switch's button, the // switch is on for good and its barrier open. const auto map = std::find_if(maps.begin(), maps.end(), [&](const MapData& item){ @@ -40,6 +43,66 @@ Pokemon::Outcome boulder_pushed(Pokemon::RunState& state, const StoryStep& step, return Pokemon::outcome_ok(to_pose(at)); } +namespace{ + +// A tap, and once more if it did not do what `wanted` asks and something +// that stopped it was cleared. +BoulderPressRead press_for(Direction direction, bool (*wanted)(const BoulderPressRead&), BoulderPresses& presses){ + const BoulderPressRead read = presses.press(direction); + if (wanted(read) || !presses.clear_interrupt()){ + return read; + } + return presses.press(direction); +} + +bool pushed(const BoulderPressRead& read){ + return !read.scrolled && read.boulder_moved; +} + +bool walked(const BoulderPressRead& read){ + return read.scrolled; +} + +} // namespace + +BoulderPush push_boulder_tiles(Direction direction, int64_t tiles, BoulderPresses& presses){ + BoulderPush push; + for (int64_t tile = 1; tile <= tiles; tile++){ + const BoulderPressRead push_read = press_for(direction, pushed, presses); + if (push_read.scrolled){ + push.walked++; + push.failure = std::format("tile {} of {}: the tap to push walked the player a tile: no boulder ahead.", tile, tiles); + return push; + } + if (!push_read.boulder_moved){ + push.failure = std::format("tile {} of {}: the tap to push moved nothing: the boulder is stuck, or Strength is off.", tile, tiles); + return push; + } + if (!walked(press_for(direction, walked, presses))){ + push.failure = std::format("tile {} of {}: the tap onto the tile the boulder left did not move the player.", tile, tiles); + return push; + } + push.walked++; + } + return push; +} + +Pokemon::Outcome boulder_push_outcome(const StoryStep& step, const std::vector& maps, const BoulderPush& push, Pokemon::RunState& state){ + if (!push.failure){ + return boulder_pushed(state, step, maps); + } + Pokemon::Outcome outcome = Pokemon::outcome_failed("boulder_push", *push.failure); + if (const std::optional here = story_pose(state.pose)){ + const Direction direction = Pokemon::story_arg(step.args, "direction"); + StoryPose at{here->map, here->tile, direction}; + for (int64_t c = 0; c < push.walked; c++){ + at.tile = at.tile.next(direction); + } + outcome.pose = to_pose(at); + } + return outcome; +} + Pokemon::Outcome tree_cut(Pokemon::RunState& state, const StoryStep& step, const std::vector& maps){ const std::optional here = story_pose(state.pose); if (!here){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h index 0263eb8166..ca395b1546 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h @@ -11,10 +11,14 @@ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryBoulders_H #define PokemonAutomation_PokemonFRLG_AutoStoryBoulders_H +#include #include +#include +#include #include #include "Pokemon/AutoStory/Pokemon_StoryOutcome.h" #include "Pokemon/AutoStory/Pokemon_StoryPose.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" #include "PokemonFRLG_AutoStoryCheckpoints.h" @@ -28,6 +32,42 @@ namespace PokemonFRLG{ // switch's button turns that switch on in `state.gates`. Pokemon::Outcome boulder_pushed(Pokemon::RunState& state, const StoryStep& step, const std::vector& maps); + +// The step taps of a boulder push, on the console or the sim. +class BoulderPresses{ +public: + virtual ~BoulderPresses() = default; + // A step tap `direction`, and what it did. + virtual BoulderPressRead press(Direction direction) = 0; + // After a tap that did not do what the push needs: waits for the + // overworld to be quiet and in the player's control again, past what + // stopped the tap: a floor switch's script lock, a box (closed), a + // wild battle the step before set off (run from). Whether it is, so + // the tap may be tried again. + virtual bool clear_interrupt() = 0; +}; + +// How far a push got. +struct BoulderPush{ + // The tiles the player walked on, each read off the screen. + int64_t walked = 0; + // Why the push stopped short, if it did. + std::optional failure; +}; + +// Pushes the boulder ahead of the player `tiles` tiles `direction`. In +// FRLG a tap into a boulder pushes it while the player walks in place +// (PokemonFRLG_BoulderPushReader.h), so each tile takes two taps: one +// that pushes it (the map stays, the boulder moves) and one onto the tile +// it left (the map scrolls). A tap a tile left the player a tile short of +// where the plan has them (console B, 2026-11-16, 19.04b push_south). +BoulderPush push_boulder_tiles(Direction direction, int64_t tiles, BoulderPresses& presses); + +// A PUSH_BOULDER_VARIANT step's outcome after `push`: boulder_pushed() +// if it went the whole way, else failed, with the player where the taps +// put them, `push.walked` tiles on. +Pokemon::Outcome boulder_push_outcome(const StoryStep& step, const std::vector& maps, const BoulderPush& push, Pokemon::RunState& state); + // Where a CUT_TREE_VARIANT step leaves the player: on the tree's tile, a // tile on in its direction, facing that way. The tree's gate, if the map // has one, is open in `state.gates` until the next warp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp index f4145e34ee..36bf0e7772 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp @@ -23,10 +23,16 @@ #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldTiles.h" +#include "PokemonFRLG_AutoStoryBoulders.h" #include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryMovedBoulders.h" +#include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryPoses.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryRows19_Tests.h" @@ -172,7 +178,7 @@ UnitTestResult test_sim_pushes_a_boulder(){ } sim_step_once(sim, Direction::NORTH); if (!(sim.state().position == MapPosition{"VictoryRoad_1F", {7, 18}})){ - return "after the push, the player is on " + to_string(sim.state().position) + ", not (7, 18)."; + return std::format("after the push, the player is on {}, not (7, 18).", to_string(sim.state().position)); } // The boulder is in the way again one tile further on. if (!sim.use_field(SimField::PUSH_BOULDER)){ @@ -259,7 +265,394 @@ UnitTestResult test_push_boulder_step_on_sim(){ return true; } +bool boulder_on(const OverworldSim& sim, TilePos tile){ + return std::any_of(sim.objects().begin(), sim.objects().end(), [&](const MapObject& object){ + return object.name == "pushable_boulder" && object.x == tile.x && object.y == tile.y; + }); +} + +// A PUSH_BOULDER_VARIANT step of `tiles` tiles `direction`, Strength +// already on. +StoryStep push_step(Direction direction, int64_t tiles){ + StoryStep step; + step.kind = Pokemon::StoryStepKind::GAME; + step.name = "push"; + step.action = PUSH_BOULDER_VARIANT; + step.args = {{"direction", direction}, {"tiles", tiles}, {"activate", false}}; + return step; +} + +// 19.04b push_south (console B, 2026-11-16): from (7, 17) the boulder on +// (7, 18) goes to (7, 19), and the player ends on (7, 18), where the +// plan's next walk starts. +UnitTestResult test_one_tile_push_on_sim(){ + OverworldSim sim(story_maps(), MapPosition{"VictoryRoad_1F", {7, 17}}, Direction::SOUTH); + StoryPose at{"VictoryRoad_1F", {7, 17}, Direction::SOUTH}; + if (const std::string failure = row_step_on_sim(sim, at, push_step(Direction::SOUTH, /*tiles=*/1), "19.04b"); !failure.empty()){ + return failure; + } + if (!(sim.state().position == MapPosition{"VictoryRoad_1F", {7, 18}})){ + return std::format("after the push, the player is on {}, not (7, 18).", to_string(sim.state().position)); + } + if (!boulder_on(sim, {7, 19})){ + return "no boulder on (7, 19)."; + } + return true; +} + +// With no boulder ahead the tap to push walks the player: the step fails +// where the player walked to. +UnitTestResult test_push_with_no_boulder_on_sim(){ + OverworldSim sim(story_maps(), MapPosition{"VictoryRoad_1F", {11, 19}}, Direction::NORTH); + StoryPose at{"VictoryRoad_1F", {11, 19}, Direction::NORTH}; + if (row_step_on_sim(sim, at, push_step(Direction::NORTH, /*tiles=*/1), "19.04b").empty()){ + return "a push with no boulder ahead succeeded."; + } + if (!(sim.state().position == MapPosition{"VictoryRoad_1F", {11, 18}})){ + return std::format("the player is on {}, not (11, 18).", to_string(sim.state().position)); + } + return true; +} + +// A boulder against a wall doesn't move: the step fails with the player +// where they stood. +UnitTestResult test_stuck_boulder_on_sim(){ + OverworldSim sim(story_maps(), MapPosition{"VictoryRoad_1F", {6, 18}}, Direction::EAST); + StoryPose at{"VictoryRoad_1F", {6, 18}, Direction::EAST}; + if (row_step_on_sim(sim, at, push_step(Direction::EAST, /*tiles=*/1), "19.04b").empty()){ + return "a boulder against a wall was pushed."; + } + if (!(sim.state().position == MapPosition{"VictoryRoad_1F", {6, 18}})){ + return std::format("the player is on {}, not (6, 18).", to_string(sim.state().position)); + } + return true; +} + +// Taps that read as `reads` in turn, and `interrupts` cleared in turn. +class ScriptedPresses : public BoulderPresses{ +public: + ScriptedPresses(std::vector reads, std::vector interrupts) + : m_reads(std::move(reads)), m_interrupts(std::move(interrupts)) + {} + BoulderPressRead press(Direction) override{ + return m_taps < m_reads.size() ? m_reads[m_taps++] : BoulderPressRead{}; + } + bool clear_interrupt() override{ + return m_cleared < m_interrupts.size() && m_interrupts[m_cleared++]; + } + size_t taps() const{ + return m_taps; + } + +private: + std::vector m_reads; + std::vector m_interrupts; + size_t m_taps = 0; + size_t m_cleared = 0; +}; + +// 19.04b (console B, 2026-11-16, attempts 1 and 2 after the two-tap fix): +// push_south from (7, 17) leaves the boulder on (7, 19) and the player on +// (7, 18); by_boulder_2_corner's walk to (6, 18) must go round the boulder +// where it stands now. Planned on the boulder's map tile, its first leg +// went south onto (7, 19), bumped the boulder, and the walk ended a row off. +UnitTestResult test_walk_after_a_push_goes_round_the_boulder(){ + OverworldSim sim(story_maps(), MapPosition{"VictoryRoad_1F", {7, 17}}, Direction::SOUTH); + StoryPose at{"VictoryRoad_1F", {7, 17}, Direction::SOUTH}; + std::set flags; + if (const std::string failure = row_step_carrying_flags(sim, at, push_step(Direction::SOUTH, /*tiles=*/1), "19.04b", flags); !failure.empty()){ + return failure; + } + StoryStep corner; + corner.kind = Pokemon::StoryStepKind::ROUTE; + corner.name = "by_boulder_2_corner"; + const Pokemon::GridPose target{"VictoryRoad_1F", {{6, 18}}, std::nullopt}; + corner.args = {{"target", target}, {"fight_wild", false}}; + const std::string failure = row_step_carrying_flags(sim, at, corner, "19.04b", flags); + if (!failure.empty() || !(sim.state().position == MapPosition{"VictoryRoad_1F", {6, 18}})){ + return std::format("the walk to (6, 18) ended on {}: {}", to_string(sim.state().position), failure); + } + return true; +} + +// A boulder pushed twice keeps its map tile in its one flag, and the maps +// planned on show it where it stands; leaving the map puts it back. +UnitTestResult test_boulder_flags_follow_the_boulder(){ + std::set flags; + note_boulder_pushed(MapPosition{"VictoryRoad_1F", {6, 19}}, Direction::EAST, /*tiles=*/2, flags); + note_boulder_pushed(MapPosition{"VictoryRoad_1F", {8, 19}}, Direction::EAST, /*tiles=*/3, flags); + const std::set expected{"boulder_at:VictoryRoad_1F@7,19=12,19"}; + if (flags != expected){ + return std::format("{} flag(s), not the one for (7, 19) to (12, 19).", flags.size()); + } + const std::vector moved = moved_boulders(flags); + const std::vector maps = with_boulders_moved(story_maps(), moved); + for (const MapData& map : maps){ + if (map.name != "VictoryRoad_1F"){ + continue; + } + const bool there = std::any_of(map.objects.begin(), map.objects.end(), [](const MapObject& object){ + return object.name == "pushable_boulder" && object.x == 12 && object.y == 19; + }); + if (!there){ + return "no boulder on (12, 19) in the maps."; + } + } + boulders_back_after_map_change("VictoryRoad_1F", "VictoryRoad_2F", flags); + if (!flags.empty()){ + return "a boulder flag stayed after leaving the map."; + } + return true; +} + +// Victory Road 1F's floor switch script copies the boulder's place to its +// saved one (copyobjectxytoperm): leaving the floor and coming back finds +// it still on the switch (20, 16), and its barrier open. +UnitTestResult test_boulder_on_a_switch_stays_after_leaving(){ + std::set flags{"boulder_at:VictoryRoad_1F@7,18=20,16"}; + boulders_back_after_map_change("VictoryRoad_1F", "Route23", flags); + if (moved_boulders(flags).size() != 1){ + return "the boulder on the switch went back to (7, 18)."; + } + return true; +} + +// 19.04b push_onto_switch (console B, 2026-11-16 01:28): the boulder +// lands on 1F's switch (20, 16), whose script locks the player until its +// sound ends, and the step tap after the push was lost. The step tap is +// tried again once the overworld is quiet, and the player ends on (20, 15). +UnitTestResult test_push_onto_a_switch_waits_out_its_script(){ + const std::vector maps = with_boulders_moved(story_maps(), {BoulderMove{.map = "VictoryRoad_1F", .from = {7, 18}, .at = {20, 15}}}); + OverworldSim sim(maps, MapPosition{"VictoryRoad_1F", {20, 14}}, Direction::SOUTH); + sim.change_gates({}); + StoryPose at{"VictoryRoad_1F", {20, 14}, Direction::SOUTH}; + if (const std::string failure = row_step_on_sim(sim, at, push_step(Direction::SOUTH, /*tiles=*/1), "19.04b"); !failure.empty()){ + return failure; + } + if (!(sim.state().position == MapPosition{"VictoryRoad_1F", {20, 15}})){ + return std::format("after the push, the player is on {}, not (20, 15).", to_string(sim.state().position)); + } + if (sim.state().gates.switches_on.empty()){ + return "no switch on."; + } + return true; +} + +// 19.04b below_ladder (console B, 2026-11-16 01:40, run 3): from (19, 15), +// the boulder on the switch (20, 16) and the switch on, to (4, 7) below the +// ladder. The plan went out of the cave mouth onto Route 23 and back in, +// which put the boulder back on (7, 18), where a leg then ran into it. The +// route stays on Victory Road 1F. +UnitTestResult test_below_ladder_stays_on_the_floor(){ + const std::set flags{"boulder_at:VictoryRoad_1F@7,18=20,16"}; + Pokemon::GateState gates; + gates.switches_on.insert("VictoryRoad_1F/floor_switch_1"); + const std::optional> route = plan_overworld_route_gated( + run_story_maps(flags), MapPosition{"VictoryRoad_1F", {19, 15}}, + RouteGoal{MapPosition{"VictoryRoad_1F", {4, 7}}, Direction::NORTH}, gates, Pokemon::GateRules{} + ); + if (!route){ + return "no route from (19, 15) to (4, 7)."; + } + for (const RouteStep& step : *route){ + if (step.end.map != "VictoryRoad_1F"){ + return std::format("the route leaves Victory Road 1F for {}.", to_string(step.end)); + } + } + return true; +} + +// 19.04d drop_to_2f (console B, 2026-11-16 03:33): push_into_hole pushed +// 3F's boulder (33, 18) east into the hole (34, 18), where it fell to 2F. +// The maps planned on kept it standing on the hole, so the walk from +// (33, 18) to 2F's (34, 19) went round by 3F's west room and the ladder +// (34, 9), into Cooltrainer Colby's line (10, 17), and lost his battle. +// The boulder is gone from 3F: the walk is one step east, down the hole. +UnitTestResult test_boulder_down_a_hole_leaves_it_open(){ + const std::set flags{"boulder_at:VictoryRoad_3F@33,18=34,18"}; + Pokemon::GateState gates; + gates.switches_on.insert("VictoryRoad_3F/floor_switch_1"); + const std::optional> route = plan_overworld_route_gated( + run_story_maps(flags), MapPosition{"VictoryRoad_3F", {33, 18}}, + RouteGoal{MapPosition{"VictoryRoad_2F", {34, 19}}, std::nullopt}, gates, Pokemon::GateRules{} + ); + if (!route || route->empty()){ + return "no route from 3F (33, 18) to 2F (34, 19)."; + } + if (route->size() != 1 || route->front().direction != Direction::EAST){ + return std::format("{} leg(s), the first ending on {}, not one leg east down the hole.", route->size(), to_string(route->front().end)); + } + return true; +} + +const BoulderPressRead PUSHED{.scrolled = false, .boulder_moved = true}; +const BoulderPressRead WALKED{.scrolled = true, .boulder_moved = false}; + +// A tile pushed is two taps: one pushes the boulder, the player in place, +// and one walks onto the tile it left. A tap a tile pushed the boulder of +// 19.04b push_south but left the player a tile short (console B, +// 2026-11-16). +UnitTestResult test_push_taps_twice_a_tile(){ + ScriptedPresses presses({PUSHED, WALKED, PUSHED, WALKED}, {}); + const BoulderPush push = push_boulder_tiles(Direction::SOUTH, /*tiles=*/2, presses); + if (push.failure){ + return *push.failure; + } + if (push.walked != 2 || presses.taps() != 4){ + return std::format("{} tile(s) walked in {} taps, not 2 in 4.", push.walked, presses.taps()); + } + return true; +} + +// A tap to push that walks the player stops the push, with the tile +// walked counted. +UnitTestResult test_walk_instead_of_push_is_counted(){ + ScriptedPresses presses({PUSHED, WALKED, WALKED}, {false}); + const BoulderPush push = push_boulder_tiles(Direction::SOUTH, /*tiles=*/2, presses); + if (!push.failure || push.walked != 2){ + return std::format("failed {}, {} tile(s) walked, not failed with 2.", push.failure.has_value(), push.walked); + } + return true; +} + +// A wild battle set off by the step onto the boulder's old tile eats the +// next tap to push; once it is cleared, the tap is tried again. +UnitTestResult test_cleared_interrupt_repeats_the_tap(){ + ScriptedPresses presses({PUSHED, WALKED, BoulderPressRead{}, PUSHED, WALKED}, {true}); + const BoulderPush push = push_boulder_tiles(Direction::EAST, /*tiles=*/2, presses); + if (push.failure){ + return *push.failure; + } + if (push.walked != 2 || presses.taps() != 5){ + return std::format("{} tile(s) walked in {} taps, not 2 in 5.", push.walked, presses.taps()); + } + return true; +} + +// A screen of 240x160 cave floor, scrolled `scroll_x` pixels east, the +// player on their tile, and a boulder at (`boulder_x`, `boulder_y`). +ImageRGB32 cave_screen(size_t scroll_x, size_t boulder_x, size_t boulder_y){ + ImageRGB32 image(240, 160); + for (size_t y = 0; y < 160; y++){ + for (size_t x = 0; x < 240; x++){ + const size_t tile = (x + scroll_x) / 16 * 7 + (y + 8) / 16 * 13; + const uint32_t level = 0x80 + (uint32_t)(tile % 5) * 0x18; + uint32_t pixel = 0xff000000 | (level << 16) | (level << 8) | 0x40; + if (x >= 112 && x < 128 && y >= 72 && y < 88){ + pixel = 0xffd02020; + } + if (x >= boulder_x && x < boulder_x + 16 && y >= boulder_y && y < boulder_y + 16){ + pixel = 0xff304010; + } + image.pixel(x, y) = pixel; + } + } + return image; +} + +// A boulder pushed a tile, each way, with the map still: the two tiles +// ahead of the player changed. +UnitTestResult test_reader_sees_the_boulder_move(){ + struct Push{ + Direction direction; + size_t from_x; + size_t from_y; + size_t to_x; + size_t to_y; + }; + const Push pushes[] = { + {Direction::NORTH, 112, 56, 112, 40}, + {Direction::SOUTH, 112, 88, 112, 104}, + {Direction::WEST, 96, 72, 80, 72}, + {Direction::EAST, 128, 72, 144, 72}, + }; + const ImageFloatBox game(0, 0, 1, 1); + for (const Push& push : pushes){ + const BoulderPressRead read = read_boulder_press( + cave_screen(/*scroll_x=*/0, push.from_x, push.from_y), cave_screen(/*scroll_x=*/0, push.to_x, push.to_y), game, push.direction + ); + if (read.scrolled || !read.boulder_moved){ + return std::format("a push {} read as scrolled {}, boulder moved {}.", direction_name(push.direction), read.scrolled, read.boulder_moved); + } + } + return true; +} + +// A step scrolls the map: read as a walk. A tap that moved nothing reads +// as nothing. +UnitTestResult test_reader_sees_a_walk_and_a_still_screen(){ + const ImageFloatBox game(0, 0, 1, 1); + const ImageRGB32 at_rest = cave_screen(/*scroll_x=*/0, /*boulder_x=*/0, /*boulder_y=*/0); + const ImageRGB32 stepped = cave_screen(/*scroll_x=*/16, /*boulder_x=*/0, /*boulder_y=*/0); + const BoulderPressRead step = read_boulder_press(at_rest, stepped, game, Direction::EAST); + if (!step.scrolled){ + return "a step east read as no scroll."; + } + const ImageRGB32 boulder_east = cave_screen(/*scroll_x=*/0, /*boulder_x=*/144, /*boulder_y=*/72); + const BoulderPressRead still = read_boulder_press(boulder_east, boulder_east, game, Direction::EAST); + if (still.scrolled || still.boulder_moved){ + return "a screen that didn't change read as a move."; + } + return true; +} + const AutoStoryBouldersCase AUTO_STORY_BOULDERS_CASES[] = { + { + .input = {.name = "19.04b's one-tile push south from (7, 17) on the sim", .body = test_one_tile_push_on_sim}, + .expectation = {.description = "the boulder on (7, 19), the player on (7, 18)"}, + }, + { + .input = {.name = "a push step with no boulder ahead on the sim", .body = test_push_with_no_boulder_on_sim}, + .expectation = {.description = "failed, the player a tile on"}, + }, + { + .input = {.name = "a push step of a boulder against a wall on the sim", .body = test_stuck_boulder_on_sim}, + .expectation = {.description = "failed, the player in place"}, + }, + { + .input = {.name = "19.04b's walk to (6, 18) after the push south", .body = test_walk_after_a_push_goes_round_the_boulder}, + .expectation = {.description = "round the boulder on (7, 19), on (6, 18)"}, + }, + { + .input = {.name = "the run flags of a boulder pushed twice, then left", .body = test_boulder_flags_follow_the_boulder}, + .expectation = {.description = "one flag, (7, 19) to (12, 19); none after leaving"}, + }, + { + .input = {.name = "19.04b's push onto 1F's switch", .body = test_push_onto_a_switch_waits_out_its_script}, + .expectation = {.description = "the lost step tap tried again after the switch's script: on (20, 15), the switch on"}, + }, + { + .input = {.name = "a boulder on a floor switch, then the player leaves", .body = test_boulder_on_a_switch_stays_after_leaving}, + .expectation = {.description = "the boulder stays on the switch"}, + }, + { + .input = {.name = "19.04b's below_ladder after the switch", .body = test_below_ladder_stays_on_the_floor}, + .expectation = {.description = "a route that never leaves Victory Road 1F"}, + }, + { + .input = {.name = "19.04d's drop_to_2f after the boulder fell down the hole", .body = test_boulder_down_a_hole_leaves_it_open}, + .expectation = {.description = "one leg east, onto the hole (34, 18)"}, + }, + { + .input = {.name = "a push of two tiles", .body = test_push_taps_twice_a_tile}, + .expectation = {.description = "four taps: push, walk, push, walk"}, + }, + { + .input = {.name = "a push whose second tap to push walks", .body = test_walk_instead_of_push_is_counted}, + .expectation = {.description = "failed, two tiles walked"}, + }, + { + .input = {.name = "a push whose tap a wild battle took", .body = test_cleared_interrupt_repeats_the_tap}, + .expectation = {.description = "the battle cleared, the tap repeated, both tiles pushed"}, + }, + { + .input = {.name = "the reader on a boulder pushed each way", .body = test_reader_sees_the_boulder_move}, + .expectation = {.description = "the boulder moved, no scroll"}, + }, + { + .input = {.name = "the reader on a step and on a still screen", .body = test_reader_sees_a_walk_and_a_still_screen}, + .expectation = {.description = "a scroll, then nothing"}, + }, { .input = {.name = "a push_boulder step on the sim", .body = test_push_boulder_step_on_sim}, .expectation = {.description = "two tiles pushed, the player behind the boulder"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp index fe374ac8c6..88da789e42 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp @@ -1,620 +1,363 @@ -/* AutoStory Capture - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include -#include "CommonFramework/Exceptions/OperationFailedException.h" -#include "CommonFramework/Exceptions/ProgramFinishedException.h" -#include "CommonFramework/Tools/DebugDumper.h" -#include "CommonFramework/VideoPipeline/VideoFeed.h" -#include "CommonTools/Async/InferenceRoutines.h" -#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" -#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" -#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" -#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h" -#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.h" -#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h" -#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleScreenDetector.h" -#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_WildEncounterReader.h" -#include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" -#include "VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMenuNavigation.h" -#include "PokemonFRLG_AutoStoryActions.h" -#include "PokemonFRLG_AutoStoryCapture.h" -#include "PokemonFRLG_AutoStoryGameArgs.h" -#include "PokemonFRLG_AutoStoryPacing.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - -using namespace std::chrono_literals; -using Pokemon::Direction; - - -namespace{ - -constexpr size_t PARTY_SIZE = 6; -constexpr size_t MOVE_COUNT = 4; - -Direction opposite(Direction direction){ - switch (direction){ - case Direction::NORTH: return Direction::SOUTH; - case Direction::EAST: return Direction::WEST; - case Direction::SOUTH: return Direction::NORTH; - case Direction::WEST: return Direction::EAST; - } - return direction; -} - -} // namespace - - -std::string_view destination_name(CatchDestination destination){ - switch (destination){ - case CatchDestination::PARTY: return "party"; - case CatchDestination::PC: return "PC"; - } - return "?"; -} - -std::string_view capture_end_name(CaptureEnd end){ - switch (end){ - case CaptureEnd::CAUGHT: return "caught"; - case CaptureEnd::OUT_OF_ENCOUNTERS: return "out_of_encounters"; - case CaptureEnd::OUT_OF_BALLS: return "out_of_balls"; - case CaptureEnd::NO_ENCOUNTER: return "no_encounter"; - case CaptureEnd::SHINY: return "shiny"; - case CaptureEnd::PLAYER_FAINTED: return "player_fainted"; - case CaptureEnd::FAILED: return "failed"; - } - return "?"; -} - - -Pokemon::StoryActionArgs capture_args(const CapturePlan& plan){ - Pokemon::StoryActionArgs args{ - {"species", plan.species}, - {"catches", int64_t(plan.catches)}, - {"encounters", int64_t(plan.max_encounters)}, - {"balls", int64_t(plan.max_balls)}, - {"pace", plan.pace}, - {"turns", int64_t(plan.max_weaken_turns)}, - }; - if (plan.weaken_move){ - args.emplace("move", int64_t(*plan.weaken_move + 1)); - } - return args; -} - -std::optional capture_plan_of(const Pokemon::StoryActionArgs& args){ - const std::string* species = game_arg(args, "species"); - const std::optional catches = number_arg(args, "catches", 1, 999); - const std::optional encounters = number_arg(args, "encounters", 1, 9999); - const std::optional balls = number_arg(args, "balls", 1, 999); - const std::optional turns = number_arg(args, "turns", 0, 99); - const Direction* pace = game_arg(args, "pace"); - if (species == nullptr || species->empty() || !catches || !encounters || !balls || !turns || pace == nullptr){ - return std::nullopt; - } - CapturePlan plan{ - .species = *species, .catches = *catches, .max_encounters = *encounters, .max_balls = *balls, - .pace = *pace, .max_weaken_turns = *turns, - }; - if (args.contains("move")){ - plan.weaken_move = counted_arg(args, "move", MOVE_COUNT); - if (!plan.weaken_move){ - return std::nullopt; - } - } - return plan; -} - -Pokemon::StoryStep capture_step(std::string name, std::string why, const CapturePlan& plan){ - Pokemon::StoryStep step; - step.kind = Pokemon::StoryStepKind::GAME; - step.name = std::move(name); - step.why = std::move(why); - step.action = CAPTURE_ACTION; - step.args = capture_args(plan); - return step; -} - -Pokemon::StoryStep pc_step(std::string name, std::string why, const PcTransfer& transfer){ - Pokemon::StoryStep step; - step.kind = Pokemon::StoryStepKind::GAME; - step.name = std::move(name); - step.why = std::move(why); - step.action = PC_ACTION; - step.args = pc_args(transfer); - return step; -} - - -namespace{ - -// What a turn of the target's battle left. -enum class Turn{ - AGAIN, - // The battle is over; the capture goes on. - BATTLE_OVER, - // The capture is over: its result is set. - CAPTURE_OVER, -}; - -// One capture under way: its counts, and the battles it plays. -class CaptureRun{ -public: - CaptureRun(Logger& logger, CaptureActions& actions, const CapturePlan& plan, size_t party_size) - : m_logger(logger) - , m_actions(actions) - , m_plan(plan) - , m_party(party_size) - {} - - CaptureResult run(){ - m_logger.log(std::format("Capture: {} {}, party of {}.", m_plan.catches, m_plan.species, m_party)); - while (m_result.caught.size() < m_plan.catches){ - if (!next_encounter() || !battle()){ - return m_result; - } - } - m_result.end = CaptureEnd::CAUGHT; - return m_result; - } - -private: - // Ends the capture as `end`. False, for the caller to return. - bool end(CaptureEnd end, std::string detail = ""){ - m_result.end = end; - m_result.detail = std::move(detail); - return false; - } - // RUN, then ends the capture as `end`. - bool run_and_end(CaptureEnd end, std::string detail = ""){ - if (!m_actions.flee()){ - return this->end(CaptureEnd::FAILED, "couldn't run from " + m_plan.species); - } - return this->end(end, std::move(detail)); - } - - // Into the next wild battle, if the bounds allow one. False if the - // capture ends. - bool next_encounter(){ - if (m_result.encounters >= m_plan.max_encounters){ - return end(CaptureEnd::OUT_OF_ENCOUNTERS); - } - if (m_result.balls_thrown >= m_plan.max_balls){ - return end(CaptureEnd::OUT_OF_BALLS); - } - if (!m_actions.find_encounter(m_plan.pace)){ - return end(CaptureEnd::NO_ENCOUNTER); - } - m_result.encounters++; - return true; - } - - // One wild battle, from its start to the overworld. False if the - // capture ends. - bool battle(){ - const EncounterSeen seen = m_actions.read_encounter(); - if (seen.shiny){ - // Nothing more is pressed: a person decides. - m_logger.log("Capture: a shiny! Stopping in its battle.", COLOR_BLUE); - return end(CaptureEnd::SHINY, seen.species); - } - if (seen.species == m_plan.species){ - m_logger.log(std::format("Capture: encounter {}: {}.", m_result.encounters, seen.species)); - return target_battle(); - } - const std::string species = seen.species.empty() ? "an unread species" : seen.species; - m_logger.log(std::format("Capture: encounter {}: {}, running.", m_result.encounters, species)); - if (!m_actions.flee()){ - return end(CaptureEnd::FAILED, "couldn't run from " + species); - } - return true; - } - - // The target's battle, from the battle menu: the weakening move while - // its HP bar is green, so the move can't knock it out, then balls. - // False if the capture ends. - bool target_battle(){ - size_t weakened = 0; - for (size_t turn = 0; turn < CAPTURE_MAX_TURNS; turn++){ - if (m_result.balls_thrown >= m_plan.max_balls){ - return run_and_end(CaptureEnd::OUT_OF_BALLS); - } - const bool weaken = m_plan.weaken_move && weakened < m_plan.max_weaken_turns - && m_actions.read_foe_hp() == FoeHp::GREEN; - weakened += weaken ? 1 : 0; - const Turn end = weaken ? attack() : throw_ball(); - if (end != Turn::AGAIN){ - return end == Turn::BATTLE_OVER; - } - } - return run_and_end(CaptureEnd::FAILED, std::format("not caught in {} turns", CAPTURE_MAX_TURNS)); - } - - Turn attack(){ - switch (m_actions.attack(*m_plan.weaken_move)){ - case TurnEnd::MENU: - return Turn::AGAIN; - case TurnEnd::FOE_FAINTED: - m_logger.log("Capture: the target fainted.", COLOR_RED); - return Turn::BATTLE_OVER; - case TurnEnd::PLAYER_FAINTED: - end(CaptureEnd::PLAYER_FAINTED); - return Turn::CAPTURE_OVER; - case TurnEnd::FAILED: - break; - } - end(CaptureEnd::FAILED, "the turn didn't end at the battle menu"); - return Turn::CAPTURE_OVER; - } - - Turn throw_ball(){ - switch (m_actions.throw_ball()){ - case ThrowEnd::CAUGHT: - m_result.balls_thrown++; - return caught(); - case ThrowEnd::BROKE_FREE: - m_result.balls_thrown++; - return Turn::AGAIN; - case ThrowEnd::NO_BALLS: - run_and_end(CaptureEnd::OUT_OF_BALLS, "the bag has no Poke Ball"); - return Turn::CAPTURE_OVER; - case ThrowEnd::PLAYER_FAINTED: - end(CaptureEnd::PLAYER_FAINTED); - return Turn::CAPTURE_OVER; - case ThrowEnd::FAILED: - break; - } - end(CaptureEnd::FAILED, "the throw didn't end in a catch or at the battle menu"); - return Turn::CAPTURE_OVER; - } - - // To the party, or to the PC when the party is full. - Turn caught(){ - const CatchDestination destination = m_party < PARTY_SIZE ? CatchDestination::PARTY : CatchDestination::PC; - if (!m_actions.finish_catch(destination)){ - end(CaptureEnd::FAILED, "the overworld didn't come back after the catch"); - return Turn::CAPTURE_OVER; - } - m_party += destination == CatchDestination::PARTY ? 1 : 0; - m_result.caught.push_back(destination); - m_logger.log(std::format("Capture: caught {}, to the {}.", m_plan.species, destination_name(destination))); - return Turn::BATTLE_OVER; - } - - Logger& m_logger; - CaptureActions& m_actions; - const CapturePlan& m_plan; - size_t m_party; - CaptureResult m_result; -}; - -} // namespace - -CaptureResult run_capture(Logger& logger, CaptureActions& actions, const CapturePlan& plan, size_t party_size){ - return CaptureRun(logger, actions, plan, party_size).run(); -} - - -std::string capture_message(const CapturePlan& plan, const CaptureResult& result){ - const std::string tally = std::format( - "{} encounters, {} balls thrown, {} of {} caught", - result.encounters, result.balls_thrown, result.caught.size(), plan.catches - ); - switch (result.end){ - case CaptureEnd::CAUGHT:{ - std::string where; - for (CatchDestination destination : result.caught){ - where += (where.empty() ? "" : ", ") + std::string(destination_name(destination)); - } - return std::format("Capture: caught {} {} ({}): {}.", plan.catches, plan.species, where, tally); - } - case CaptureEnd::SHINY: - return std::format( - "Capture: a shiny {} in encounter {}. Stopped in its battle without running, for you to decide: " - "catch it or run by hand, then save.", - result.detail.empty() ? "Pokemon" : result.detail, result.encounters - ); - case CaptureEnd::OUT_OF_ENCOUNTERS: - return std::format("Capture of {}: out of encounters: {}.", plan.species, tally); - case CaptureEnd::OUT_OF_BALLS: - return std::format( - "Capture of {}: out of balls{}: {}.", - plan.species, result.detail.empty() ? "" : " (" + result.detail + ")", tally - ); - case CaptureEnd::NO_ENCOUNTER: - return std::format("Capture of {}: no wild battle started: {}.", plan.species, tally); - case CaptureEnd::PLAYER_FAINTED: - return std::format("Capture of {}: the player's Pokemon fainted: {}.", plan.species, tally); - case CaptureEnd::FAILED: - return std::format("Capture of {}: {}: {}.", plan.species, result.detail, tally); - } - return "Capture: ?"; -} - - -std::optional run_storage_game_step( - Logger& logger, VideoStream* stream, const Pokemon::StoryStep& step, - CaptureActions& capture, PcStorageActions& pc -){ - if (step.action == CAPTURE_ACTION){ - const std::optional plan = capture_plan_of(step.args); - if (!plan){ - return Pokemon::outcome_failed("bad_args", step.action); - } - const CaptureResult result = run_capture(logger, capture, *plan, pc.read_party().size()); - const std::string message = capture_message(*plan, result); - logger.log(message, result.end == CaptureEnd::CAUGHT ? COLOR_BLACK : COLOR_RED); - if (result.end == CaptureEnd::SHINY){ - // Not a failed Outcome, which would reload the save. - if (stream != nullptr){ - throw ProgramFinishedException(message, *stream); - } - throw ProgramFinishedException(message); - } - if (result.end == CaptureEnd::CAUGHT){ - return Pokemon::outcome_ok(); - } - return Pokemon::outcome_failed(std::string("capture_") + std::string(capture_end_name(result.end)), message); - } - if (step.action == PC_ACTION){ - const std::optional transfer = pc_transfer_of(step.args); - if (!transfer){ - return Pokemon::outcome_failed("bad_args", step.action); - } - const PcResult result = run_pc_transfer(logger, pc, *transfer); - switch (result.end){ - case PcEnd::DONE: - case PcEnd::SKIPPED: - return Pokemon::outcome_ok(); - case PcEnd::REFUSED: - return Pokemon::outcome_failed("pc_refused", result.detail); - case PcEnd::FAILED: - return Pokemon::outcome_failed("pc_failed", result.detail); - } - } - return std::nullopt; -} - - -bool pace_until_battle(Logger& logger, PatchSteps& steps, size_t max_steps){ - for (size_t c = 0; c < max_steps; c++){ - if (steps.step()){ - return true; - } - // The flash can be missed (console B, 2026-11-03): the battle's - // first text then waits for A, and the D-pad does nothing. Found a - // step late, the player stays where the battle started, but the - // step after it still counts as taken. - if (steps.battle_shows()){ - logger.log(std::format("Pacing: a battle shows after step {}; its flash was missed.", c + 1), COLOR_ORANGE); - return true; - } - // Console B, 2026-11-03 (m63): Camper Shane on Route 24 saw the - // player pace in his sight and walked up; his message stayed up - // while the rest of the steps paced in vain. - if (steps.message_shows()){ - const std::string trainer = steps.fight_trainer(); - logger.log(std::format("Pacing: trainer battle during pacing: {}, after step {}.", trainer, c + 1), COLOR_ORANGE); - } - } - if (steps.overworld_shows()){ - return false; - } - if (steps.battle_shows()){ - logger.log(std::format("Pacing: a battle shows after the last of {} steps; its flash was missed.", max_steps), COLOR_ORANGE); - return true; - } - logger.log(std::format("Pacing: no battle in {} steps, and the overworld doesn't show.", max_steps), COLOR_RED); - steps.dump_screen("no-battle-not-overworld"); - return false; -} - - -ConsolePatchSteps::ConsolePatchSteps( - ConsoleHandle& console, ProControllerContext& context, PlayerGender player, Direction pace, PaceSpot& spot, - const PaceTrainerBattle& trainer_battle -) - : m_console(console) - , m_context(context) - , m_player(player) - , m_pace(pace) - , m_spot(spot) - , m_trainer_battle(trainer_battle) -{} - -bool ConsolePatchSteps::step(){ - const Direction way = m_spot.displaced ? opposite(m_pace) : m_pace; - BattleFlashWatcher battle(COLOR_RED); - const int ret = run_until( - m_console, m_context, - [&](ProControllerContext& context){ - step_once(m_console, context, way, m_spot.facing, m_player); - }, - {battle} - ); - m_spot = {.displaced = !m_spot.displaced, .facing = way}; - return ret == 0; -} - -bool ConsolePatchSteps::battle_shows(){ - m_context.wait_for_all_requests(); - VideoSnapshot screen = m_console.video().snapshot(); - return screen && BattleScreenDetector(COLOR_RED).detect(screen); -} - -bool ConsolePatchSteps::overworld_shows(){ - return PokemonFRLG::overworld_shows(m_console, m_context); -} - -bool ConsolePatchSteps::message_shows(){ - m_context.wait_for_all_requests(); - VideoSnapshot screen = m_console.video().snapshot(); - return screen && WhiteDialogDetector(COLOR_RED).detect(screen); -} - -std::string ConsolePatchSteps::fight_trainer(){ - m_trainer_battle(); - // Back on the patch's tile, facing as the walk back left it. - m_spot = {}; - return "a trainer"; -} - -void ConsolePatchSteps::dump_screen(std::string_view label){ - m_context.wait_for_all_requests(); - dump_debug_image(m_console, "AutoStory/pace", std::string(label), m_console.video().snapshot()); -} - - -ConsoleCaptureActions::ConsoleCaptureActions( - ConsoleHandle& console, ProControllerContext& context, Language language, PlayerGender player, - PaceTrainerBattle trainer_battle -) - : m_console(console) - , m_context(context) - , m_language(language) - , m_player(player) - , m_trainer_battle(std::move(trainer_battle)) -{} - -bool ConsoleCaptureActions::find_encounter(Direction pace){ - ConsolePatchSteps steps(m_console, m_context, m_player, pace, m_spot, m_trainer_battle); - return find_paced_encounter(m_console.logger(), console_bike_select(m_console, m_context, m_player), steps); -} - -EncounterSeen ConsoleCaptureActions::read_encounter(){ - EncounterSeen seen; - // The shiny sound plays as the wild Pokemon slides in; the lead is - // sent out only if none was heard. - seen.shiny = handle_encounter(m_console, m_context, true); - if (seen.shiny){ - return seen; - } - m_context.wait_for_all_requests(); - VideoSnapshot screen = m_console.video().snapshot(); - seen.species = WildEncounterReader(COLOR_RED).read_encounter(m_console.logger(), m_language, screen, {}).name; - return seen; -} - -bool ConsoleCaptureActions::flee(){ - try{ - flee_battle(m_console, m_context); - // The pacing counts its taps: one lost to the battle's exit - // would put it a tile off. - wait_out_battle_exit(m_console, m_context); - return true; - }catch (OperationFailedException& e){ - m_console.log("Capture: " + e.message(), COLOR_RED); - return false; - } -} - -FoeHp ConsoleCaptureActions::read_foe_hp(){ - // No reader for the wild Pokemon's HP bar yet. - return FoeHp::UNKNOWN; -} - -TurnEnd ConsoleCaptureActions::attack(size_t move){ - // Only called with the HP bar read green, which the console can't read - // yet (read_foe_hp()): not run on the console. - if (!move_cursor_to_option(m_console, m_context, BattleMenuOption::FIGHT)){ - return TurnEnd::FAILED; - } - pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); - if (!move_cursor_to_option(m_console, m_context, BattleMoveOption(move))){ - return TurnEnd::FAILED; - } - pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); - BattleMenuWatcher menu(COLOR_RED); - const int ret = run_until( - m_console, m_context, - [](ProControllerContext& context){ - pbf_mash_button(context, BUTTON_B, 30000ms); - }, - {menu} - ); - return ret == 0 ? TurnEnd::MENU : TurnEnd::FAILED; -} - -ThrowEnd ConsoleCaptureActions::throw_ball(){ - if (!move_cursor_to_option(m_console, m_context, BattleMenuOption::BAG)){ - return ThrowEnd::FAILED; - } - pbf_press_button(m_context, BUTTON_A, 160ms, 1200ms); - m_context.wait_for_all_requests(); - if (!open_ball_pocket()){ - m_console.log("Capture: no Poke Ball found in the bag.", COLOR_RED); - pbf_mash_button(m_context, BUTTON_B, 2000ms); - m_context.wait_for_all_requests(); - return ThrowEnd::NO_BALLS; - } - // The top row, USE, the throw. - pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); - pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); - m_context.wait_for_all_requests(); - return wait_for_throw(); -} - -bool ConsoleCaptureActions::open_ball_pocket(){ - // The bag opens on the pocket used last: Items, Key Items and Poke - // Balls, RIGHT from one to the next. - for (size_t c = 0; c < 3; c++){ - VideoSnapshot screen = m_console.video().snapshot(); - const std::vector rows = read_bag_pocket(m_console.logger(), m_language, screen); - if (!rows.empty() && rows.front().item == "poke-ball"){ - return true; - } - pbf_press_dpad(m_context, DPAD_RIGHT, 160ms, 640ms); - m_context.wait_for_all_requests(); - } - return false; -} - -ThrowEnd ConsoleCaptureActions::wait_for_throw(){ - // Either the battle menu (it broke free) or, after "Gotcha!" and the - // Pokedex page, "Give a nickname?". B moves the messages on; one that - // answers the nickname NO leads to the overworld. - const WallClock deadline = current_time() + 60000ms; - for (size_t polls = 1; current_time() < deadline; polls++){ - m_context.wait_for_all_requests(); - VideoSnapshot screen = m_console.video().snapshot(); - if (screen && yes_no_cursor(screen)){ - return ThrowEnd::CAUGHT; - } - if (screen && BattleMenuDetector(COLOR_RED).detect(screen)){ - return ThrowEnd::BROKE_FREE; - } - if (polls % 4 != 0){ - pbf_wait(m_context, 500ms); - continue; - } - if (overworld_shows(m_console, m_context)){ - return ThrowEnd::CAUGHT; - } - pbf_press_button(m_context, BUTTON_B, 160ms, 340ms); - } - return ThrowEnd::FAILED; -} - -bool ConsoleCaptureActions::finish_catch(CatchDestination destination){ - m_console.log(std::string("Capture: no nickname; it goes to the ") + std::string(destination_name(destination)) + "."); - try{ - // B answers the nickname NO and moves the messages on. - mash_until_overworld(m_console, m_context, 30000ms); - return true; - }catch (OperationFailedException& e){ - m_console.log("Capture: " + e.message(), COLOR_RED); - return false; - } -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +/* AutoStory Capture Logic + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/Exceptions/ProgramFinishedException.h" +#include "PokemonFRLG_AutoStoryCapture.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" +#include "PokemonFRLG_AutoStoryPacing.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using namespace std::chrono_literals; +using Pokemon::Direction; + + +namespace{ + +constexpr size_t PARTY_SIZE = 6; +constexpr size_t MOVE_COUNT = 4; + +Direction opposite(Direction direction){ + switch (direction){ + case Direction::NORTH: return Direction::SOUTH; + case Direction::EAST: return Direction::WEST; + case Direction::SOUTH: return Direction::NORTH; + case Direction::WEST: return Direction::EAST; + } + return direction; +} + +} // namespace + + +std::string_view destination_name(CatchDestination destination){ + switch (destination){ + case CatchDestination::PARTY: return "party"; + case CatchDestination::PC: return "PC"; + } + return "?"; +} + +std::string_view capture_end_name(CaptureEnd end){ + switch (end){ + case CaptureEnd::CAUGHT: return "caught"; + case CaptureEnd::OUT_OF_ENCOUNTERS: return "out_of_encounters"; + case CaptureEnd::OUT_OF_BALLS: return "out_of_balls"; + case CaptureEnd::NO_ENCOUNTER: return "no_encounter"; + case CaptureEnd::SHINY: return "shiny"; + case CaptureEnd::PLAYER_FAINTED: return "player_fainted"; + case CaptureEnd::FAILED: return "failed"; + } + return "?"; +} + + +Pokemon::StoryActionArgs capture_args(const CapturePlan& plan){ + Pokemon::StoryActionArgs args{ + {"species", plan.species}, + {"catches", int64_t(plan.catches)}, + {"encounters", int64_t(plan.max_encounters)}, + {"balls", int64_t(plan.max_balls)}, + {"pace", plan.pace}, + {"turns", int64_t(plan.max_weaken_turns)}, + }; + if (plan.weaken_move){ + args.emplace("move", int64_t(*plan.weaken_move + 1)); + } + return args; +} + +std::optional capture_plan_of(const Pokemon::StoryActionArgs& args){ + const std::string* species = game_arg(args, "species"); + const std::optional catches = number_arg(args, "catches", 1, 999); + const std::optional encounters = number_arg(args, "encounters", 1, 9999); + const std::optional balls = number_arg(args, "balls", 1, 999); + const std::optional turns = number_arg(args, "turns", 0, 99); + const Direction* pace = game_arg(args, "pace"); + if (species == nullptr || species->empty() || !catches || !encounters || !balls || !turns || pace == nullptr){ + return std::nullopt; + } + CapturePlan plan{ + .species = *species, .catches = *catches, .max_encounters = *encounters, .max_balls = *balls, + .pace = *pace, .max_weaken_turns = *turns, + }; + if (args.contains("move")){ + plan.weaken_move = counted_arg(args, "move", MOVE_COUNT); + if (!plan.weaken_move){ + return std::nullopt; + } + } + return plan; +} + +Pokemon::StoryStep capture_step(std::string name, std::string why, const CapturePlan& plan){ + Pokemon::StoryStep step; + step.kind = Pokemon::StoryStepKind::GAME; + step.name = std::move(name); + step.why = std::move(why); + step.action = CAPTURE_ACTION; + step.args = capture_args(plan); + return step; +} + +Pokemon::StoryStep pc_step(std::string name, std::string why, const PcTransfer& transfer){ + Pokemon::StoryStep step; + step.kind = Pokemon::StoryStepKind::GAME; + step.name = std::move(name); + step.why = std::move(why); + step.action = PC_ACTION; + step.args = pc_args(transfer); + return step; +} + + +namespace{ + +// What a turn of the target's battle left. +enum class Turn{ + AGAIN, + // The battle is over; the capture goes on. + BATTLE_OVER, + // The capture is over: its result is set. + CAPTURE_OVER, +}; + +// One capture under way: its counts, and the battles it plays. +class CaptureRun{ +public: + CaptureRun(Logger& logger, CaptureActions& actions, const CapturePlan& plan, size_t party_size) + : m_logger(logger) + , m_actions(actions) + , m_plan(plan) + , m_party(party_size) + {} + + CaptureResult run(){ + m_logger.log(std::format("Capture: {} {}, party of {}.", m_plan.catches, m_plan.species, m_party)); + while (m_result.caught.size() < m_plan.catches){ + if (!next_encounter() || !battle()){ + return m_result; + } + } + m_result.end = CaptureEnd::CAUGHT; + return m_result; + } + +private: + // Ends the capture as `end`. False, for the caller to return. + bool end(CaptureEnd end, std::string detail = ""){ + m_result.end = end; + m_result.detail = std::move(detail); + return false; + } + // RUN, then ends the capture as `end`. + bool run_and_end(CaptureEnd end, std::string detail = ""){ + if (!m_actions.flee()){ + return this->end(CaptureEnd::FAILED, "couldn't run from " + m_plan.species); + } + return this->end(end, std::move(detail)); + } + + // Into the next wild battle, if the bounds allow one. False if the + // capture ends. + bool next_encounter(){ + if (m_result.encounters >= m_plan.max_encounters){ + return end(CaptureEnd::OUT_OF_ENCOUNTERS); + } + if (m_result.balls_thrown >= m_plan.max_balls){ + return end(CaptureEnd::OUT_OF_BALLS); + } + if (!m_actions.find_encounter(m_plan.pace)){ + return end(CaptureEnd::NO_ENCOUNTER); + } + m_result.encounters++; + return true; + } + + // One wild battle, from its start to the overworld. False if the + // capture ends. + bool battle(){ + const EncounterSeen seen = m_actions.read_encounter(); + if (seen.shiny){ + // Nothing more is pressed: a person decides. + m_logger.log("Capture: a shiny! Stopping in its battle.", COLOR_BLUE); + return end(CaptureEnd::SHINY, seen.species); + } + if (seen.species == m_plan.species){ + m_logger.log(std::format("Capture: encounter {}: {}.", m_result.encounters, seen.species)); + return target_battle(); + } + const std::string species = seen.species.empty() ? "an unread species" : seen.species; + m_logger.log(std::format("Capture: encounter {}: {}, running.", m_result.encounters, species)); + if (!m_actions.flee()){ + return end(CaptureEnd::FAILED, "couldn't run from " + species); + } + return true; + } + + // The target's battle, from the battle menu: the weakening move while + // its HP bar is green, so the move can't knock it out, then balls. + // False if the capture ends. + bool target_battle(){ + size_t weakened = 0; + for (size_t turn = 0; turn < CAPTURE_MAX_TURNS; turn++){ + if (m_result.balls_thrown >= m_plan.max_balls){ + return run_and_end(CaptureEnd::OUT_OF_BALLS); + } + const bool weaken = m_plan.weaken_move && weakened < m_plan.max_weaken_turns + && m_actions.read_foe_hp() == FoeHp::GREEN; + weakened += weaken ? 1 : 0; + const Turn end = weaken ? attack() : throw_ball(); + if (end != Turn::AGAIN){ + return end == Turn::BATTLE_OVER; + } + } + return run_and_end(CaptureEnd::FAILED, std::format("not caught in {} turns", CAPTURE_MAX_TURNS)); + } + + Turn attack(){ + switch (m_actions.attack(*m_plan.weaken_move)){ + case TurnEnd::MENU: + return Turn::AGAIN; + case TurnEnd::FOE_FAINTED: + m_logger.log("Capture: the target fainted.", COLOR_RED); + return Turn::BATTLE_OVER; + case TurnEnd::PLAYER_FAINTED: + end(CaptureEnd::PLAYER_FAINTED); + return Turn::CAPTURE_OVER; + case TurnEnd::FAILED: + break; + } + end(CaptureEnd::FAILED, "the turn didn't end at the battle menu"); + return Turn::CAPTURE_OVER; + } + + Turn throw_ball(){ + switch (m_actions.throw_ball()){ + case ThrowEnd::CAUGHT: + m_result.balls_thrown++; + return caught(); + case ThrowEnd::BROKE_FREE: + m_result.balls_thrown++; + return Turn::AGAIN; + case ThrowEnd::NO_BALLS: + run_and_end(CaptureEnd::OUT_OF_BALLS, "the bag has no Poke Ball"); + return Turn::CAPTURE_OVER; + case ThrowEnd::PLAYER_FAINTED: + end(CaptureEnd::PLAYER_FAINTED); + return Turn::CAPTURE_OVER; + case ThrowEnd::FAILED: + break; + } + end(CaptureEnd::FAILED, "the throw didn't end in a catch or at the battle menu"); + return Turn::CAPTURE_OVER; + } + + // To the party, or to the PC when the party is full. + Turn caught(){ + const CatchDestination destination = m_party < PARTY_SIZE ? CatchDestination::PARTY : CatchDestination::PC; + if (!m_actions.finish_catch(destination)){ + end(CaptureEnd::FAILED, "the overworld didn't come back after the catch"); + return Turn::CAPTURE_OVER; + } + m_party += destination == CatchDestination::PARTY ? 1 : 0; + m_result.caught.push_back(destination); + m_logger.log(std::format("Capture: caught {}, to the {}.", m_plan.species, destination_name(destination))); + return Turn::BATTLE_OVER; + } + + Logger& m_logger; + CaptureActions& m_actions; + const CapturePlan& m_plan; + size_t m_party; + CaptureResult m_result; +}; + +} // namespace + +CaptureResult run_capture(Logger& logger, CaptureActions& actions, const CapturePlan& plan, size_t party_size){ + return CaptureRun(logger, actions, plan, party_size).run(); +} + + +std::string capture_message(const CapturePlan& plan, const CaptureResult& result){ + const std::string tally = std::format( + "{} encounters, {} balls thrown, {} of {} caught", + result.encounters, result.balls_thrown, result.caught.size(), plan.catches + ); + switch (result.end){ + case CaptureEnd::CAUGHT:{ + std::string where; + for (CatchDestination destination : result.caught){ + where += (where.empty() ? "" : ", ") + std::string(destination_name(destination)); + } + return std::format("Capture: caught {} {} ({}): {}.", plan.catches, plan.species, where, tally); + } + case CaptureEnd::SHINY: + return std::format( + "Capture: a shiny {} in encounter {}. Stopped in its battle without running, for you to decide: " + "catch it or run by hand, then save.", + result.detail.empty() ? "Pokemon" : result.detail, result.encounters + ); + case CaptureEnd::OUT_OF_ENCOUNTERS: + return std::format("Capture of {}: out of encounters: {}.", plan.species, tally); + case CaptureEnd::OUT_OF_BALLS: + return std::format( + "Capture of {}: out of balls{}: {}.", + plan.species, result.detail.empty() ? "" : " (" + result.detail + ")", tally + ); + case CaptureEnd::NO_ENCOUNTER: + return std::format("Capture of {}: no wild battle started: {}.", plan.species, tally); + case CaptureEnd::PLAYER_FAINTED: + return std::format("Capture of {}: the player's Pokemon fainted: {}.", plan.species, tally); + case CaptureEnd::FAILED: + return std::format("Capture of {}: {}: {}.", plan.species, result.detail, tally); + } + return "Capture: ?"; +} + + +bool pace_until_battle(Logger& logger, PatchSteps& steps, size_t max_steps){ + for (size_t c = 0; c < max_steps; c++){ + if (steps.step()){ + return true; + } + // The flash can be missed (console B, 2026-11-03): the battle's + // first text then waits for A, and the D-pad does nothing. Found a + // step late, the player stays where the battle started, but the + // step after it still counts as taken. + if (steps.battle_shows()){ + logger.log(std::format("Pacing: a battle shows after step {}; its flash was missed.", c + 1), COLOR_ORANGE); + return true; + } + // Console B, 2026-11-03 (m63): Camper Shane on Route 24 saw the + // player pace in his sight and walked up; his message stayed up + // while the rest of the steps paced in vain. + if (steps.message_shows()){ + const std::string trainer = steps.fight_trainer(); + logger.log(std::format("Pacing: trainer battle during pacing: {}, after step {}.", trainer, c + 1), COLOR_ORANGE); + } + } + if (steps.overworld_shows()){ + return false; + } + if (steps.battle_shows()){ + logger.log(std::format("Pacing: a battle shows after the last of {} steps; its flash was missed.", max_steps), COLOR_ORANGE); + return true; + } + logger.log(std::format("Pacing: no battle in {} steps, and the overworld doesn't show.", max_steps), COLOR_RED); + steps.dump_screen("no-battle-not-overworld"); + return false; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureConsole.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureConsole.cpp new file mode 100644 index 0000000000..f0ef770df8 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureConsole.cpp @@ -0,0 +1,317 @@ +/* AutoStory Capture + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonFramework/Exceptions/ProgramFinishedException.h" +#include "CommonFramework/Tools/DebugDumper.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" +#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleScreenDetector.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_WildEncounterReader.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" +#include "VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMenuNavigation.h" +#include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryCapture.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BikeSpinPresses.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_MovementMechanics.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBike.h" +#include "PokemonFRLG_AutoStoryPacing.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using namespace std::chrono_literals; +using Pokemon::Direction; + +namespace{ + +constexpr size_t PARTY_SIZE = 6; +constexpr size_t MOVE_COUNT = 4; + +Direction opposite(Direction direction){ + switch (direction){ + case Direction::NORTH: return Direction::SOUTH; + case Direction::EAST: return Direction::WEST; + case Direction::SOUTH: return Direction::NORTH; + case Direction::WEST: return Direction::EAST; + } + return direction; +} + +} // namespace + + +std::optional run_storage_game_step( + Logger& logger, VideoStream* stream, const Pokemon::StoryStep& step, + CaptureActions& capture, PcStorageActions& pc +){ + if (step.action == CAPTURE_ACTION){ + const std::optional plan = capture_plan_of(step.args); + if (!plan){ + return Pokemon::outcome_failed("bad_args", step.action); + } + const CaptureResult result = run_capture(logger, capture, *plan, pc.read_party().size()); + const std::string message = capture_message(*plan, result); + logger.log(message, result.end == CaptureEnd::CAUGHT ? COLOR_BLACK : COLOR_RED); + if (result.end == CaptureEnd::SHINY){ + // Not a failed Outcome, which would reload the save. + if (stream != nullptr){ + throw ProgramFinishedException(message, *stream); + } + throw ProgramFinishedException(message); + } + if (result.end == CaptureEnd::CAUGHT){ + return Pokemon::outcome_ok(); + } + return Pokemon::outcome_failed(std::string("capture_") + std::string(capture_end_name(result.end)), message); + } + if (step.action == PC_ACTION){ + const std::optional transfer = pc_transfer_of(step.args); + if (!transfer){ + return Pokemon::outcome_failed("bad_args", step.action); + } + const PcResult result = run_pc_transfer(logger, pc, *transfer); + switch (result.end){ + case PcEnd::DONE: + case PcEnd::SKIPPED: + return Pokemon::outcome_ok(); + case PcEnd::REFUSED: + return Pokemon::outcome_failed("pc_refused", result.detail); + case PcEnd::FAILED: + return Pokemon::outcome_failed("pc_failed", result.detail); + } + } + return std::nullopt; +} + + + + +OverworldWalkSteps::BikeSelectCalls console_bike_select(ConsoleHandle& console, ProControllerContext& context, PlayerGender player){ + OverworldWalkSteps::BikeSelectCalls calls; + calls.press_select = [&console, &context]{ + console.log("Pacing: SELECT (MINUS) off the Bicycle."); + pbf_press_button(context, BUTTON_MINUS, MovementMechanics::BIKE_SELECT_PRESS, MovementMechanics::BIKE_SELECT_SETTLE); + }; + calls.riding = [&console, &context, player]{ + context.wait_for_all_requests(); + VideoSnapshot screen = console.video().snapshot(); + return screen && OverworldWalkSteps::screen_shows_riding(*screen.frame, player); + }; + return calls; +} + +ConsolePatchSteps::ConsolePatchSteps( + ConsoleHandle& console, ProControllerContext& context, PlayerGender player, Direction pace, PaceSpot& spot, + const PaceTrainerBattle& trainer_battle +) + : m_console(console) + , m_context(context) + , m_player(player) + , m_pace(pace) + , m_spot(spot) + , m_trainer_battle(trainer_battle) +{} + +bool ConsolePatchSteps::step(){ + const Direction way = m_spot.displaced ? opposite(m_pace) : m_pace; + BattleFlashWatcher battle(COLOR_RED); + const int ret = run_until( + m_console, m_context, + [&](ProControllerContext& context){ + step_once(m_console, context, way, m_spot.facing, m_player); + }, + {battle} + ); + m_spot = {.displaced = !m_spot.displaced, .facing = way}; + return ret == 0; +} + +bool ConsolePatchSteps::battle_shows(){ + m_context.wait_for_all_requests(); + VideoSnapshot screen = m_console.video().snapshot(); + return screen && BattleScreenDetector(COLOR_RED).detect(screen); +} + +bool ConsolePatchSteps::overworld_shows(){ + return PokemonFRLG::overworld_shows(m_console, m_context); +} + +bool ConsolePatchSteps::message_shows(){ + m_context.wait_for_all_requests(); + VideoSnapshot screen = m_console.video().snapshot(); + return screen && WhiteDialogDetector(COLOR_RED).detect(screen); +} + +std::string ConsolePatchSteps::fight_trainer(){ + m_trainer_battle(); + // Back on the patch's tile, facing as the walk back left it. + m_spot = {}; + return "a trainer"; +} + +void ConsolePatchSteps::dump_screen(std::string_view label){ + m_context.wait_for_all_requests(); + dump_debug_image(m_console, "AutoStory/pace", std::string(label), m_console.video().snapshot()); +} + + +ConsoleCaptureActions::ConsoleCaptureActions( + ConsoleHandle& console, ProControllerContext& context, Language language, PlayerGender player, + PaceTrainerBattle trainer_battle +) + : m_console(console) + , m_context(context) + , m_language(language) + , m_player(player) + , m_trainer_battle(std::move(trainer_battle)) +{} + +bool ConsoleCaptureActions::find_encounter(Direction pace){ + ConsolePatchSteps steps(m_console, m_context, m_player, pace, m_spot, m_trainer_battle); + return find_paced_encounter(m_console.logger(), console_bike_select(m_console, m_context, m_player), steps); +} + +EncounterSeen ConsoleCaptureActions::read_encounter(){ + EncounterSeen seen; + // The shiny sound plays as the wild Pokemon slides in; the lead is + // sent out only if none was heard. + seen.shiny = handle_encounter(m_console, m_context, true); + if (seen.shiny){ + return seen; + } + m_context.wait_for_all_requests(); + VideoSnapshot screen = m_console.video().snapshot(); + seen.species = WildEncounterReader(COLOR_RED).read_encounter(m_console.logger(), m_language, screen, {}).name; + return seen; +} + +bool ConsoleCaptureActions::flee(){ + try{ + flee_battle(m_console, m_context); + // The pacing counts its taps: one lost to the battle's exit + // would put it a tile off. + wait_out_battle_exit(m_console, m_context); + return true; + }catch (OperationFailedException& e){ + m_console.log("Capture: " + e.message(), COLOR_RED); + return false; + } +} + +FoeHp ConsoleCaptureActions::read_foe_hp(){ + // No reader for the wild Pokemon's HP bar yet. + return FoeHp::UNKNOWN; +} + +TurnEnd ConsoleCaptureActions::attack(size_t move){ + // Only called with the HP bar read green, which the console can't read + // yet (read_foe_hp()): not run on the console. + if (!move_cursor_to_option(m_console, m_context, BattleMenuOption::FIGHT)){ + return TurnEnd::FAILED; + } + pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); + if (!move_cursor_to_option(m_console, m_context, BattleMoveOption(move))){ + return TurnEnd::FAILED; + } + pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); + BattleMenuWatcher menu(COLOR_RED); + const int ret = run_until( + m_console, m_context, + [](ProControllerContext& context){ + pbf_mash_button(context, BUTTON_B, 30000ms); + }, + {menu} + ); + return ret == 0 ? TurnEnd::MENU : TurnEnd::FAILED; +} + +ThrowEnd ConsoleCaptureActions::throw_ball(){ + if (!move_cursor_to_option(m_console, m_context, BattleMenuOption::BAG)){ + return ThrowEnd::FAILED; + } + pbf_press_button(m_context, BUTTON_A, 160ms, 1200ms); + m_context.wait_for_all_requests(); + if (!open_ball_pocket()){ + m_console.log("Capture: no Poke Ball found in the bag.", COLOR_RED); + pbf_mash_button(m_context, BUTTON_B, 2000ms); + m_context.wait_for_all_requests(); + return ThrowEnd::NO_BALLS; + } + // The top row, USE, the throw. + pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); + pbf_press_button(m_context, BUTTON_A, 160ms, 640ms); + m_context.wait_for_all_requests(); + return wait_for_throw(); +} + +bool ConsoleCaptureActions::open_ball_pocket(){ + // The bag opens on the pocket used last: Items, Key Items and Poke + // Balls, RIGHT from one to the next. + for (size_t c = 0; c < 3; c++){ + VideoSnapshot screen = m_console.video().snapshot(); + const std::vector rows = read_bag_pocket(m_console.logger(), m_language, screen); + if (!rows.empty() && rows.front().item == "poke-ball"){ + return true; + } + pbf_press_dpad(m_context, DPAD_RIGHT, 160ms, 640ms); + m_context.wait_for_all_requests(); + } + return false; +} + +ThrowEnd ConsoleCaptureActions::wait_for_throw(){ + // Either the battle menu (it broke free) or, after "Gotcha!" and the + // Pokedex page, "Give a nickname?". B moves the messages on; one that + // answers the nickname NO leads to the overworld. + const WallClock deadline = current_time() + 60000ms; + for (size_t polls = 1; current_time() < deadline; polls++){ + m_context.wait_for_all_requests(); + VideoSnapshot screen = m_console.video().snapshot(); + if (screen && yes_no_cursor(screen)){ + return ThrowEnd::CAUGHT; + } + if (screen && BattleMenuDetector(COLOR_RED).detect(screen)){ + return ThrowEnd::BROKE_FREE; + } + if (polls % 4 != 0){ + pbf_wait(m_context, 500ms); + continue; + } + if (overworld_shows(m_console, m_context)){ + return ThrowEnd::CAUGHT; + } + pbf_press_button(m_context, BUTTON_B, 160ms, 340ms); + } + return ThrowEnd::FAILED; +} + +bool ConsoleCaptureActions::finish_catch(CatchDestination destination){ + m_console.log(std::string("Capture: no nickname; it goes to the ") + std::string(destination_name(destination)) + "."); + try{ + // B answers the nickname NO and moves the messages on. + mash_until_overworld(m_console, m_context, 30000ms); + return true; + }catch (OperationFailedException& e){ + m_console.log("Capture: " + e.message(), COLOR_RED); + return false; + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp index 6c0792f7c4..ef1d6325c0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -26,6 +26,7 @@ #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -349,8 +350,9 @@ class QuietLogger : public Logger{ // Battle checkpoint `id`'s precondition: a LEVEL step on the lead before // its battle `battle`, at least `pokeguy`, pokeguy's level there (whose -// sims stand for the fight at that level or above). A lead at that level -// passes it; one a level below stops the checkpoint before the fight. +// sims stand for the fight at that level or above). A lead up to +// LEVEL_CHECK_TOLERANCE below it passes; one more below stops the +// checkpoint before the fight. UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id, std::string_view battle, unsigned pokeguy){ std::optional check; for (const StoryStep& step : checkpoint(id).steps){ @@ -364,7 +366,8 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id if (!check || check->slot != 0 || check->level != pokeguy){ return std::format("{}: expected a LEVEL step on the lead, at least Lv{}, before {}.", id, pokeguy, battle); } - for (const unsigned level : {pokeguy, pokeguy - 1}){ + const unsigned lowest_passing = pokeguy - Pokemon::LEVEL_CHECK_TOLERANCE; + for (const unsigned level : {pokeguy, lowest_passing, lowest_passing - 1}){ const MemberReader lead = [level](size_t slot) -> std::optional{ if (slot != 0){ return std::nullopt; @@ -372,9 +375,9 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id return MemberInfo{.species = "blastoise", .level = level}; }; const LevelResult result = run_level_check(logger, lead, *check); - const LevelEnd expected = level >= pokeguy ? LevelEnd::REACHED : LevelEnd::BELOW; + const LevelEnd expected = level >= lowest_passing ? LevelEnd::REACHED : LevelEnd::BELOW; if (result.end != expected || result.level != level){ - return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= pokeguy ? "fails" : "passes", pokeguy); + return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= lowest_passing ? "fails" : "passes", pokeguy); } } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.cpp new file mode 100644 index 0000000000..d149767ba3 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.cpp @@ -0,0 +1,189 @@ +/* AutoStory Check Level Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_StorySegments.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldObjects.h" +#include "PokemonFRLG_AutoStoryCheckLevel_Tests.h" +#include "PokemonFRLG_AutoStoryPacedRoute.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +using Pokemon::StoryCheckLevel; + +// The story maps with Viridian Gym's trainers beaten, as 17.04b walks out. +std::vector beaten_gym_maps(){ + std::vector maps = story_maps(); + for (MapData& map : maps){ + if (map.name != "ViridianCity_Gym"){ + continue; + } + for (MapObject& object : map.objects){ + object.trainer.reset(); + } + } + return maps; +} + +const StoryCheckpoint& checkpoint_row(std::string_view id){ + const std::vector& rows = story_checkpoints(); + const auto row = std::find_if(rows.begin(), rows.end(), [id](const StoryCheckpoint& data){ return data.id == id; }); + if (row == rows.end()){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No checkpoint {}.", id)); + } + return *row; +} + +struct GiovanniRun{ + bool completed = false; + std::vector lines; + std::vector stubs; + // The stubbed steps that are checks `level` doesn't run. + std::vector skipped_checks_run; +}; + +// 17.04 (the level check before Giovanni, his battle) and 17.04b (out of +// the gym, Fly to the Center) at `level`, each saving at its end. +GiovanniRun run_giovanni_rows(StoryCheckLevel level){ + const std::vector maps = beaten_gym_maps(); + StoryMapsSim sim(StorySimKnobs{.maps = &maps, .checks = level}); + const std::vector rows = {&checkpoint_row("17.04"), &checkpoint_row("17.04b")}; + Pokemon::Segment segment; + segment.id = "17"; + for (const StoryCheckpoint* data : rows){ + segment.checkpoints.push_back(Pokemon::CheckpointSpec{ + .id = data->id, .title = data->title, .saves = true, + .build = [&sim, data]{ return Pokemon::build_story_checkpoint(*data, sim); }, + }); + } + GiovanniRun run; + Pokemon::SegmentHooks hooks; + hooks.save = [](Pokemon::RunState&){ return Pokemon::outcome_ok(); }; + hooks.reload = [](Pokemon::RunState&){ return Pokemon::outcome_ok(); }; + hooks.log = [&run](const std::string& line){ run.lines.push_back(line); }; + Pokemon::RunState state; + Pokemon::SegmentPolicy policy; + policy.attempts_per_checkpoint = 1; + run.completed = Pokemon::run_segment({.from = "17.04", .to = "17.04b"}, policy, segment, hooks, state).completed; + run.stubs = sim.stubs().rows(); + for (const RowStubs& stubbed : run.stubs){ + for (const StoryCheckpoint* data : rows){ + for (const StoryStep& step : data->steps){ + const Pokemon::StoryAction* action = sim.actions().find(step); + const bool was_stubbed = data->id == stubbed.row && std::ranges::find(stubbed.steps, step.name) != stubbed.steps.end(); + if (was_stubbed && action != nullptr && action->check && !Pokemon::runs_check(level, *action->check)){ + run.skipped_checks_run.push_back(std::format("{}/{}", data->id, step.name)); + } + } + } + } + return run; +} + +bool stubbed(const GiovanniRun& run, std::string_view row, std::string_view step){ + return std::ranges::any_of(run.stubs, [&](const RowStubs& stubs){ + return stubs.row == row && std::ranges::find(stubs.steps, std::string(step)) != stubs.steps.end(); + }); +} + +std::string joined(const std::vector& lines){ + std::string text; + for (const std::string& line : lines){ + text += std::format("\n {}", line); + } + return text; +} + + +struct CheckLevelCase{ + struct Input{ + StoryCheckLevel level; + }; + struct Expectation{ + // Whether 17.04's lead_lv50_for_giovanni (a PARTY_STATS check, a + // summary read on the console) reaches the console's binding. + bool level_check_runs; + }; + + std::string_view name; + Input input; + Expectation expectation; +}; + +const CheckLevelCase CHECK_LEVEL_CASES[] = { + { + .name = "17.04 and 17.04b at Default read no summary and no Bag", + .input = {.level = StoryCheckLevel::DEFAULT}, + .expectation = {.level_check_runs = false}, + }, + { + .name = "17.04 and 17.04b at Thorough check the lead's level", + .input = {.level = StoryCheckLevel::THOROUGH}, + .expectation = {.level_check_runs = true}, + }, +}; + +class Test_AutoStoryCheckLevel : public UnitTest{ +public: + explicit Test_AutoStoryCheckLevel(const CheckLevelCase& scenario) + : UnitTest(std::format("PokemonFRLG::AutoStory - Simulation: {}", scenario.name)) + , m_scenario(scenario) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + const GiovanniRun run = run_giovanni_rows(m_scenario.input.level); + if (!run.completed){ + return std::format("Expected 17.04 and 17.04b through:{}", joined(run.lines)); + } + if (!run.skipped_checks_run.empty()){ + return std::format("Expected no check this level skips to run:{}", joined(run.skipped_checks_run)); + } + if (stubbed(run, "17.04", "lead_lv50_for_giovanni") != m_scenario.expectation.level_check_runs){ + return std::format("Expected 17.04's level check {}.", m_scenario.expectation.level_check_runs ? "run" : "skipped"); + } + if (!stubbed(run, "17.04", "giovanni")){ + return "Expected Giovanni's battle at every level."; + } + return true; + }catch (Exception& e){ + return std::format("{}: {}", e.name(), e.message()); + } + } + +private: + CheckLevelCase m_scenario; +}; + +} // namespace + + +void add_tests_AutoStoryCheckLevel(UnitTestDatabase& database){ + for (const CheckLevelCase& scenario : CHECK_LEVEL_CASES){ + database.add(scenario); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.h new file mode 100644 index 0000000000..46acd2844d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.h @@ -0,0 +1,28 @@ +/* AutoStory Check Level Tests + * + * From: https://github.com/PokemonAutomation/ + * + * FRLG's rows at a check level on the story maps' simulation: a check + * step the level doesn't run is skipped, not played or stubbed. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryCheckLevel_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryCheckLevel_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Rows 17.04 and 17.04b on StoryMapsSim at the Default and Thorough check levels. +void add_tests_AutoStoryCheckLevel(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp index 771f17b205..5dca3c21ad 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp @@ -24,6 +24,7 @@ #include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "Pokemon/Navigation/Pokemon_GateTiles.h" #include "Pokemon/Navigation/Pokemon_MapData.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" @@ -562,8 +563,9 @@ class QuietLogger : public Logger{ // Battle checkpoint `id`'s precondition: a LEVEL step on the lead before // its battle `battle`, at least `pokeguy`, pokeguy's level there (whose -// sims stand for the fight at that level or above). A lead at that level -// passes it; one a level below stops the checkpoint before the fight. +// sims stand for the fight at that level or above). A lead up to +// LEVEL_CHECK_TOLERANCE below it passes; one more below stops the +// checkpoint before the fight. UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id, std::string_view battle, unsigned pokeguy){ std::optional check; for (const StoryStep& step : checkpoint(id).steps){ @@ -577,7 +579,8 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id if (!check || check->slot != 0 || check->level != pokeguy){ return std::format("{}: expected a LEVEL step on the lead, at least Lv{}, before {}.", id, pokeguy, battle); } - for (const unsigned level : {pokeguy, pokeguy - 1}){ + const unsigned lowest_passing = pokeguy - Pokemon::LEVEL_CHECK_TOLERANCE; + for (const unsigned level : {pokeguy, lowest_passing, lowest_passing - 1}){ const MemberReader lead = [level](size_t slot) -> std::optional{ if (slot != 0){ return std::nullopt; @@ -585,9 +588,9 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id return MemberInfo{.species = "blastoise", .level = level}; }; const LevelResult result = run_level_check(logger, lead, *check); - const LevelEnd expected = level >= pokeguy ? LevelEnd::REACHED : LevelEnd::BELOW; + const LevelEnd expected = level >= lowest_passing ? LevelEnd::REACHED : LevelEnd::BELOW; if (result.end != expected || result.level != level){ - return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= pokeguy ? "fails" : "passes", pokeguy); + return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= lowest_passing ? "fails" : "passes", pokeguy); } } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index ce4dd0fe37..09d1c3417c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -31,6 +31,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryBoulderPresses.h" #include "PokemonFRLG_AutoStoryBoulders.h" #include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryHealingSteps.h" @@ -63,13 +64,13 @@ constexpr Milliseconds SCENE_TIMEOUT = 300000ms; constexpr Milliseconds YES_NO_TIMEOUT = 60000ms; constexpr Milliseconds BATTLE_TEXT_TIMEOUT = 90000ms; -// The engine knows nothing of consoles: a failed console step is a failed -// Outcome, which the segment answers by reloading the save. +// A failed save as a failed Outcome, which reloads it; its frame is kept. template -Outcome guarded(Body&& body){ +Outcome guarded(StoryEnv& env, Body&& body){ try{ return body(); }catch (OperationFailedException& e){ + InterruptLogGuard(env.console.logger()).save_frame("save", e); return Pokemon::outcome_failed("operation_failed", e.message()); } } @@ -115,10 +116,10 @@ void log_arrival(StoryEnv& env, const std::string& label, const std::string& map env.console.log(std::string(Pokemon::ROUTE_LOG_TAG) + Pokemon::route_arrived_line(label, {{map, tile}})); } -// The walker's check that each leg to a wall ended at it (a diagnostic): -// with Thorough checks only, as Fast trusts the walk. +// The walker's check that each leg to a wall ended at it (a diagnostic), +// at the levels that run LEG_END_TAP checks. WallCheck wall_check(const StoryEnv& env){ - return checks_screen(env.checks) ? WallCheck::TAP : WallCheck::SKIP; + return Pokemon::runs_check(env.checks, Pokemon::StoryCheckKind::LEG_END_TAP) ? WallCheck::TAP : WallCheck::SKIP; } // The story's interrupts for `step`'s walk, with FRLG's screen observer, @@ -320,11 +321,12 @@ Outcome get_ready(StoryEnv& env, RunState& state, const StoryStep& step){ } // namespace - const RouteCosts& story_route_costs(){ static const RouteCosts COSTS = []{ RouteCosts costs = default_route_costs(); costs[RouteCost::SURF] = -1; + costs[RouteCost::LINE_TILE] = 100; + costs[RouteCost::OPEN_CHECK] = 0; return costs; }(); return COSTS; @@ -606,8 +608,8 @@ Outcome cut_tree(StoryEnv& env, RunState& state, const StoryStep& step){ } // PUSH_BOULDER_VARIANT: the boulder in the step's direction, Strength -// used if the step says so, and `tiles` steps pushing it on. Not yet -// checked on the console. +// used if the step says so, and pushed `tiles` tiles, the player behind +// it (push_boulder_tiles()): every tap read off the screen. Outcome push_boulder(StoryEnv& env, RunState& state, const StoryStep& step){ const std::optional here = story_pose(state.pose); if (!here){ @@ -620,14 +622,12 @@ Outcome push_boulder(StoryEnv& env, RunState& state, const StoryStep& step){ face_wall(env.console, env.context, direction, env.player_gender); } if (arg(step, "activate")){ - pbf_press_button(env.context, BUTTON_A, 160ms, 800ms); - answer_yes_no(env.console, env.context, true, BUTTON_B, YES_NO_TIMEOUT); - mash_until_overworld(env.console, env.context, SCENE_TIMEOUT); - } - for (int64_t c = 0; c < tiles; c++){ - step_once(env.console, env.context, direction, direction, env.player_gender); + if (const std::optional failure = use_strength(env.console, env.context, MapPosition{here->map, here->tile}, direction)){ + return Pokemon::outcome_failed("boulder_push", *failure); + } } - return boulder_pushed(state, step, story_maps()); + ConsoleBoulderPresses presses(env.console, env.context, env.player_gender); + return boulder_push_outcome(step, story_maps(), push_boulder_tiles(direction, tiles, presses), state); } // Vermilion Gym's trash cans on the console: a walk to each can's stand @@ -809,7 +809,7 @@ StoryExecutor::StoryExecutor(StoryEnv& env) : m_env(env) , m_guard(env.console.logger()) , m_table(make_story_action_table([this](StoryActionId id){ return console_action(id); })) - , m_executor(m_table, m_guard) + , m_executor(m_table, m_guard, env.checks) , m_look(env.console, env.context) , m_interrupts(step_interrupts( [this](bool fresh){ return m_look.look(fresh); }, @@ -822,7 +822,9 @@ StoryExecutor::StoryExecutor(StoryEnv& env) } Outcome StoryExecutor::run(const StoryStep& step, RunState& state){ - return trainers_back_on_warp([&]{ return regrow_on_warp(story_maps(), [&]{ return m_executor.run(step, state); }, state); }, state); + Outcome outcome = trainers_back_on_warp([&]{ return regrow_on_warp(story_maps(), [&]{ return m_executor.run(step, state); }, state); }, state); + m_env.supplies.counts_read = m_env.supplies.counts_read && items_pocket_change(step.kind, step.action).value_or(ItemsPocketChange::STALE) != ItemsPocketChange::STALE; + return outcome; } bool StoryExecutor::master_ball_skipped(bool take_master_ball, Pokemon::StoryCheckLevel checks){ @@ -908,7 +910,7 @@ StoryRunPlan plan_story_run( std::string check_save_place(StoryEnv& env, const std::string& start_map){ - if (save_card_place(start_map).empty()){ + if (save_card_place(start_map).empty() || !Pokemon::runs_check(env.checks, Pokemon::StoryCheckKind::SAVE_PLACE)){ return ""; } const std::string place = read_save_place(env.console, env.context, env.language); @@ -942,19 +944,16 @@ void read_bag_supplies(StoryEnv& env, StartMenu menu){ if (menu != StartMenu::FULL){ return; } - const std::vector rows = read_items_pocket(env.console, env.context, env.language); - if (rows.empty()){ + if (!Pokemon::runs_check(env.checks, Pokemon::StoryCheckKind::BAG_CONTENTS)){ + env.console.log(std::format("Story: {}; keeping the save's counts.", Pokemon::skipped_check_line("the Bag after the load", env.checks))); + }else if (const std::vector rows = read_items_pocket(env.console, env.context, env.language); rows.empty()){ env.console.log("Couldn't read the Items pocket; going on with the checkpoint's items.", COLOR_ORANGE); - return; - } - const std::vector unread = set_from_loaded_bag(env.supplies, env.saved_supplies, rows); - for (const std::string& item : unread){ - env.console.log(std::format( - "Story: couldn't read how many {} the bag holds; counting {}.", item, item_count(env.supplies, item) - ), COLOR_ORANGE); + }else{ + const bool same = bag_matches(env.supplies, rows); + env.console.log(std::format("Story: the Bag after the load {} the save's counts; a battle reads it again.", same ? "matches" : "differs from")); + env.bag_read = true; } - env.bag_read = unread.empty(); - // A status or HP the checkpoint was saved with. + // A status or HP the checkpoint was saved with: not a check, it acts. recover_after_battle(env.console, env.context, env.supplies, env.checks, env.language); } @@ -997,7 +996,7 @@ Pokemon::Checkpoint build_checkpoint(const StoryCheckpoint& data, StoryExecutor& // program last saved there. With none kept, it passes. Pokemon::Checkpoint checkpoint = Pokemon::build_story_checkpoint(data, executor, &env.prepared); add_start_check( - checkpoint, checked_start_pose(data), + checkpoint, Pokemon::runs_check(env.checks, Pokemon::StoryCheckKind::START_SCREEN) ? checked_start_pose(data) : std::nullopt, [&env, id = data.id]{ return read_console_start(env, id); }, [&env](const std::string& line){ env.console.log(line, COLOR_ORANGE); } ); @@ -1006,7 +1005,7 @@ Pokemon::Checkpoint build_checkpoint(const StoryCheckpoint& data, StoryExecutor& env.start_menu = data.menu; const StartMenu menu = data.menu; checkpoint.save = [&env, menu, id = data.id](RunState&){ - return guarded([&]{ + return guarded(env, [&]{ save_game(env.console, env.context, menu, env.language, [end_map = checkpoint_end_map(id)](const std::string& place){ return save_end_error(end_map, place); }); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h index c86d8dac51..ad0f740c12 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -41,6 +41,7 @@ #include "PokemonFRLG_AutoStoryStartFrames.h" #include "PokemonFRLG_AutoStoryStepInterrupts.h" #include "PokemonFRLG_AutoStoryStepTable.h" +#include "PokemonFRLG_AutoStoryItemsPocketChange.h" #include "PokemonFRLG_AutoStoryCheckpoints.h" #include "PokemonFRLG_AutoStoryLineTrainer.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" @@ -83,8 +84,8 @@ struct StoryEnv{ // The once_per_save steps done from the last save that changed // nothing: a retry after a reload skips them. Emptied by a save. Pokemon::PreparedSteps prepared = {}; - // The last save's Items pocket was read in full (read_bag_supplies()): - // a reload restores `saved_supplies` without reading it again. + // The last save's Items pocket was checked (read_bag_supplies()): a + // reload of the same save doesn't check it again. bool bag_read = false; // The frames of where each checkpoint starts, for the start check: a // save at a checkpoint's end keeps one for the next checkpoint. @@ -117,8 +118,8 @@ struct StoryEnv{ }; // After a save is loaded for a checkpoint that starts on `start_map`: the -// save card's place, read from the START menu, against it, at every checks -// level. Empty if the save is there (or the card can't be read), else why +// save card's place, read from the START menu, against it (a SAVE_PLACE +// check). Empty if the save is there (or the card can't be read), else why // not. std::string check_save_place(StoryEnv& env, const std::string& start_map); @@ -128,11 +129,12 @@ std::string check_save_place(StoryEnv& env, const std::string& start_map); // kept if no move can be read. void read_lead_moves(StoryEnv& env, StartMenu menu); -// After a save is loaded, with START's menu `menu`: the Items pocket's -// counts as read (set_from_loaded_bag()), in place of the row's, which -// are kept if nothing can be read. Only with the full menu: the rows -// before it carry the items they have. Sets `bag_read` when every count -// was read. +// After a save is loaded, with START's menu `menu`: the Items pocket read +// and logged against the counts the story keeps (a BAG_CONTENTS check, +// skipped below its level), then a status or HP the save carried +// recovered. Only with the full menu. The check changes no count: a step +// that uses items reads the pocket itself (Supplies::counts_read). Sets +// `bag_read` once the pocket was read. void read_bag_supplies(StoryEnv& env, StartMenu menu); // Does FRLG's kinds of story step on the console, each with its row of @@ -155,7 +157,9 @@ class StoryExecutor : public Pokemon::StoryStepExecutor{ m_menu = menu; } - // The step's action from the table. + // The step's action from the table. Done or failed part way, a step + // items_pocket_change() calls STALE leaves the next battle to read the + // Items pocket first (Supplies::counts_read). virtual Pokemon::Outcome run(const StoryStep& step, Pokemon::RunState& state) override; // The step condition master_ball_skipped: the program's option is off, or // the run is a SPEEDRUN, where the Master Ball's few seconds are not spent. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp index d9891e960d..2c0eee6802 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -11,7 +11,7 @@ * within one of the table's pose, while the program goes on from the * table's (BDSP 01.04, lab-B 2026-11-09). * - WILD_BATTLES: wild battles at the game's own odds on every map with - * land encounters, over GAME_ODDS_SEEDS seeds (08.01's Rock Tunnel). + * land encounters, over wild_battle_seeds() seeds (08.01's Rock Tunnel). * - LATE_FADE: every warp's fade ends LATE_FADE later than the sim's * usual (07.02's warp to Cerulean City). * - SLOW_FADE_IN: after every warp's fade the new map fades in for @@ -78,6 +78,7 @@ #include "PokemonFRLG_AutoStoryItemUse.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStorySimBudget.h" #include "PokemonFRLG_AutoStoryTable.h" #include "PokemonFRLG_AutoStoryFaultSweep_Tests.h" @@ -121,7 +122,11 @@ const std::map STORY_ENCOUNTER_RATES{ // Caves wild on every floor tile, also where the maps mark no wild tiles // (Mt. Moon B2F, console B, 2026-11-03). const std::set WILD_FLOOR_MAPS{"MtMoon_1F", "MtMoon_B1F", "MtMoon_B2F"}; -constexpr unsigned GAME_ODDS_SEEDS = 30; +// Seeds of wild battles at the game's odds per row: a few in the +// per-push CI run, all with the slow tests on (PA_SLOW_TESTS). +unsigned wild_battle_seeds(){ + return slow_tests_enabled() ? 30 : 5; +} // The caves the story walks dark: no Flash before Lavender Town. const std::set DARK_MAPS{"RockTunnel_1F", "RockTunnel_B1F"}; // Seeds of wild battles at the game's odds in the dark, after a run @@ -514,7 +519,8 @@ UnitTestResult sweep_wild_battles(Logger& logger, const StoryCheckpoint& row, co std::vector failures; std::vector seconds, again, lost; int battles = 0; - for (unsigned seed = 1; seed <= GAME_ODDS_SEEDS; seed++){ + const unsigned seeds = wild_battle_seeds(); + for (unsigned seed = 1; seed <= seeds; seed++){ SimScript script; script.encounter_rates = STORY_ENCOUNTER_RATES; script.encounter_seed = seed; @@ -534,9 +540,9 @@ UnitTestResult sweep_wild_battles(Logger& logger, const StoryCheckpoint& row, co } logger.log(std::format( "Fault sweep {} wild battles: passed {}/{}, {} battles; of those passed: time (s) mean {}, clean {:.1f}; tiles walked again mean {}; s lost per battle mean {}", - row.id, GAME_ODDS_SEEDS - failures.size(), GAME_ODDS_SEEDS, battles, mean_of(seconds), clean.time.count() / 1000., mean_of(again), mean_of(lost) + row.id, seeds - failures.size(), seeds, battles, mean_of(seconds), clean.time.count() / 1000., mean_of(again), mean_of(lost) )); - return sweep_result(logger, FaultClass::WILD_BATTLES, row.id, GAME_ODDS_SEEDS, failures); + return sweep_result(logger, FaultClass::WILD_BATTLES, row.id, seeds, failures); } // Row `row` with every warp's fade ending LATE_FADE late. @@ -785,6 +791,13 @@ class Test_AutoStoryFaultSweep : public UnitTest{ if (known == KNOWN_FAILING.end()){ return result; } + if (result.result == UnitTestResult::PASSED && m_fault == FaultClass::WILD_BATTLES && !slow_tests_enabled()){ + // Its failing seeds may be past the few run without the slow tests. + return UnitTestResult(UnitTestResult::SKIPPED, std::format( + "on KNOWN_FAILING ({}), passes on the first {} seeds: set {}=1 to run them all", + known->second, wild_battle_seeds(), SLOW_TESTS_VARIABLE + )); + } if (result.result == UnitTestResult::PASSED){ return "on KNOWN_FAILING (" + known->second + ") but passes now: take it off the list."; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFrameReplay_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFrameReplay_Tests.cpp index 1603f79349..f5bb9ce4b5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFrameReplay_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFrameReplay_Tests.cpp @@ -37,7 +37,7 @@ using namespace std::chrono_literals; const WallClock T0 = WallClock() + std::chrono::hours(1); -// As the walk's WARP_TIMEOUT (PokemonFRLG_OverworldWalk.cpp). +// As the walk's WARP_TIMEOUT (PokemonFRLG_OverworldWalkWatches.h). constexpr Milliseconds WARP_WAIT = 8000ms; // A one-tile walk onto a door: a tile's time, then the release. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp index 7d07c643d0..49efb33aed 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp @@ -21,6 +21,7 @@ #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -279,8 +280,9 @@ class QuietLogger : public Logger{ // Battle checkpoint `id`'s precondition: a LEVEL step on the lead before // its battle `battle`, at least `pokeguy`, pokeguy's level there (whose -// sims stand for the fight at that level or above). A lead at that level -// passes it; one a level below stops the checkpoint before the fight. +// sims stand for the fight at that level or above). A lead up to +// LEVEL_CHECK_TOLERANCE below it passes; one more below stops the +// checkpoint before the fight. UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id, std::string_view battle, unsigned pokeguy){ std::optional check; for (const StoryStep& step : checkpoint(id).steps){ @@ -294,7 +296,8 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id if (!check || check->slot != 0 || check->level != pokeguy){ return std::format("{}: expected a LEVEL step on the lead, at least Lv{}, before {}.", id, pokeguy, battle); } - for (const unsigned level : {pokeguy, pokeguy - 1}){ + const unsigned lowest_passing = pokeguy - Pokemon::LEVEL_CHECK_TOLERANCE; + for (const unsigned level : {pokeguy, lowest_passing, lowest_passing - 1}){ const MemberReader lead = [level](size_t slot) -> std::optional{ if (slot != 0){ return std::nullopt; @@ -302,9 +305,9 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id return MemberInfo{.species = "blastoise", .level = level}; }; const LevelResult result = run_level_check(logger, lead, *check); - const LevelEnd expected = level >= pokeguy ? LevelEnd::REACHED : LevelEnd::BELOW; + const LevelEnd expected = level >= lowest_passing ? LevelEnd::REACHED : LevelEnd::BELOW; if (result.end != expected || result.level != level){ - return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= pokeguy ? "fails" : "passes", pokeguy); + return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= lowest_passing ? "fails" : "passes", pokeguy); } } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.cpp new file mode 100644 index 0000000000..6df0104cdd --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.cpp @@ -0,0 +1,81 @@ +/* AutoStory Gen 3 Damage + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include "PokemonFRLG_AutoStoryGen3Damage.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +int staged_stat(int stat, int stage){ + stage = std::clamp(stage, -6, 6); + if (stage >= 0){ + return stat * (2 + stage) / 2; + } + return stat * 2 / (2 - stage); +} + +int badge_boosted(int stat){ + return stat * 110 / 100; +} + +std::vector gen3_damage_rolls(const Gen3Hit& hit){ + if (hit.power <= 0){ + return {}; + } + // @smogon/calc calculateADV(): a critical hit keeps only the stages + // that help the attacker. + const bool attack_staged = hit.attack_stage > 0 || (!hit.critical && hit.attack_stage < 0); + const bool defense_staged = hit.defense_stage < 0 || (!hit.critical && hit.defense_stage > 0); + const int64_t attack = attack_staged ? staged_stat(hit.attack, hit.attack_stage) : hit.attack; + const int64_t defense = std::max(1, defense_staged ? staged_stat(hit.defense, hit.defense_stage) : hit.defense); + const int64_t level_factor = 2 * hit.level / 5 + 2; + int64_t base = level_factor * attack * hit.power / defense / 50; + if (hit.burned_physical){ + base /= 2; + } + base = static_cast(std::floor(static_cast(base) * hit.weather)); + base = (hit.physical ? std::max(base, 1) : base) + 2; + if (hit.critical){ + base *= 2; + } + if (hit.stab){ + base = base * 3 / 2; + } + base = static_cast(std::floor(static_cast(base) * hit.effectiveness_first)); + base = static_cast(std::floor(static_cast(base) * hit.effectiveness_second)); + std::vector rolls; + for (int64_t percent = 85; percent <= 100; percent++){ + rolls.push_back(static_cast(std::max(base == 0 ? 0 : 1, base * percent / 100))); + } + return rolls; +} + +int battle_speed(int raw, int stage, bool paralyzed){ + const int speed = staged_stat(raw, stage); + return paralyzed ? speed / 4 : speed; +} + +double hit_chance(int accuracy, int accuracy_stage, int evasion_stage){ + // pret's sAccuracyStageRatios, from -6 to +6. + constexpr int RATIOS[13][2] = { + {33, 100}, {36, 100}, {43, 100}, {50, 100}, {60, 100}, {75, 100}, {1, 1}, + {133, 100}, {166, 100}, {2, 1}, {233, 100}, {133, 50}, {3, 1}, + }; + const int stage = std::clamp(accuracy_stage - evasion_stage, -6, 6) + 6; + const int percent = accuracy * RATIOS[stage][0] / RATIOS[stage][1]; + return std::min(1.0, percent / 100.0); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.h new file mode 100644 index 0000000000..612df42455 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.h @@ -0,0 +1,75 @@ +/* AutoStory Gen 3 Damage + * + * From: https://github.com/PokemonAutomation/ + * + * FireRed/LeafGreen's damage, speed and accuracy as PokemonSimulation's + * League sim computes them (@smogon/calc's Gen 3 mechanics, measured raw + * stats): what the planned League policy's rows read (KO risk, sure KO, + * who moves first). Badge boosts (Boulder: Attack, Soul: Defense, + * Thunder: Speed, Volcano: Sp. Atk and Sp. Def) are on our side only and + * apply to the raw stat before its stage, rounding down. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryGen3Damage_H +#define PokemonAutomation_PokemonFRLG_AutoStoryGen3Damage_H + +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// A stat at stage `stage` (-6 to +6): (2 + stage) / 2 up, 2 / (2 - stage) down, rounded down. +int staged_stat(int stat, int stage); + +// A raw stat with its badge's 10% boost, rounded down. +int badge_boosted(int stat); + +// One hit, from the attacker's side. +struct Gen3Hit{ + int level = 1; + // The attacker's Attack (physical) or Sp. Atk (special), and the + // defender's Defense or Sp. Def: raw, with badge boosts applied. + int attack = 1; + int defense = 1; + int power = 0; + int attack_stage = 0; + int defense_stage = 0; + // Same type as the attacker: x1.5. + bool stab = false; + // Type effectiveness on each of the defender's types (2, 1, 0.5, 0). + double effectiveness_first = 1.0; + double effectiveness_second = 1.0; + // A critical hit: x2, and the attacker's drops and the defender's + // rises are ignored. + bool critical = false; + // A burned attacker's physical hit: halved. + bool burned_physical = false; + // A physical hit does at least 1 before the +2; a special one may do 0. + bool physical = true; + // The weather on the move's type (@smogon/calc's final modifiers): + // 1.5 for Fire in sun or Water in rain, 0.5 for Water in sun, Fire in + // rain or Solar Beam in rain, else 1. + double weather = 1.0; +}; + +// The hit's 16 damage rolls (85% to 100%), lowest first; empty for a +// move with no power. +std::vector gen3_damage_rolls(const Gen3Hit& hit); + +// The Speed a turn's order compares: `raw` (with Thunder's boost on our +// side) at `stage`, a quarter while paralyzed. +int battle_speed(int raw, int stage, bool paralyzed); + +// The chance a move of `accuracy` percent hits, +// with the attacker's accuracy stage and the defender's evasion stage. +double hit_chance(int accuracy, int accuracy_stage, int evasion_stage); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.cpp index 7ae4c5addd..293fb86dbb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.cpp @@ -64,6 +64,10 @@ void took_recovery_item(Supplies& supplies, const std::string& item){ add_pp(supplies.lead, ELIXIR_PP); return; } + if (item == "max-elixir"){ + restore_pp(supplies.lead); + return; + } if (const int healed = healing_hp(item); healed > 0){ // One Potion (20 HP) takes a starter of the early levels from red // to green; the bar can't be read again on the overworld. The HP @@ -87,6 +91,15 @@ std::optional missing_hp(const Supplies& supplies, int fallback_max_hp){ return missing - supplies.healed_since_measured; } +bool hp_at_least_percent(const Supplies& supplies, int fallback_max_hp, int percent){ + const std::optional missing = missing_hp(supplies, fallback_max_hp); + if (!missing){ + return false; + } + const int max_hp = supplies.lead.stats && supplies.lead.stats->hp > 0 ? supplies.lead.stats->hp : fallback_max_hp; + return (max_hp - *missing) * 100 >= percent * max_hp; +} + std::optional heal_to_full( Supplies& supplies, int fallback_max_hp, const std::function& use, std::string_view first_item @@ -228,6 +241,40 @@ UnitTestResult test_missing_hp_edges(){ return true; } +// The heal before Bruno and Agatha (heal_to_full's below_percent 50): HP +// the bar showed, against the share it must reach to skip the heal. +struct HpShareCase{ + std::string_view name; + struct Input{ + std::optional fill; + int percent; + } input; + struct Expectation{ + bool at_least; + } expectation; +}; + +const HpShareCase HP_SHARE_CASES[] = { + {"Bruno's entry on console B, 117 of 165: no heal", {.fill = 117.0 / 165, .percent = 50}, {.at_least = true}}, + {"PokeGuy's Agatha entry, 45 of 165: heal", {.fill = 45.0 / 165, .percent = 50}, {.at_least = false}}, + {"no bar measured since the load: heal", {.fill = std::nullopt, .percent = 50}, {.at_least = false}}, + {"a full bar at the default 100: no heal", {.fill = 1.0, .percent = 100}, {.at_least = true}}, +}; + +UnitTestResult test_hp_at_least_percent(){ + for (const HpShareCase& test : HP_SHARE_CASES){ + Supplies supplies = bag(0, 0); + supplies.lead.stats = Stats{.hp = 165}; + if (test.input.fill){ + measured_hp(supplies, *test.input.fill); + } + if (hp_at_least_percent(supplies, /*fallback_max_hp=*/165, test.input.percent) != test.expectation.at_least){ + return std::format("{}: expected {}.", test.name, test.expectation.at_least ? "at least" : "below"); + } + } + return true; +} + // PokeGuy's bag after Agatha (docs/battles/pokeguy-conditions.md lance: // Full Restores 12 to 11), read at the checkpoint's start. Supplies league_bag(int full_restores){ @@ -352,6 +399,7 @@ void add_tests_AutoStoryHealing(UnitTestDatabase& database){ database.add(HealingCase{"Kayden hits hard: healed to full before Koga", test_hard_hit_healed}); database.add(HealingCase{"out of Potions: the HP stays missing", test_out_of_potions}); database.add(HealingCase{"missing HP: unknown, full, the summary's maximum", test_missing_hp_edges}); + database.add(HealingCase{"before an Elite Four fight: a heal only below half HP", test_hp_at_least_percent}); database.add(HealingCase{"the Mart buys the shortfall for a full bar", test_cover_shortfall}); database.add(HealingCase{"a Full Restore after Agatha, Potions without one", test_full_restore_after_agatha}); database.add(HealingCase{"an Elixir after Lance: 10 PP each, at most full", test_elixir_after_lance}); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.h index 61b5d76fe3..30dc733e6f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.h @@ -36,7 +36,7 @@ void measured_hp(Supplies& supplies, double fill); // One of `item` was used on the lead: its count spent (spend_item()), // and what it does taken into `supplies`: its HP (healing_hp()); a Full // Restore's whole HP and cure; an Elixir's PP (ELIXIR_PP for every move, -// add_pp()); else its cure. +// add_pp()) and a Max Elixir's (all of it, restore_pp()); else its cure. void took_recovery_item(Supplies& supplies, const std::string& item); // The HP the lead misses: the bar's empty share of its maximum HP (the @@ -45,6 +45,10 @@ void took_recovery_item(Supplies& supplies, const std::string& item); // Nothing if no bar was measured since the checkpoint loaded. std::optional missing_hp(const Supplies& supplies, int fallback_max_hp); +// The lead's HP, as missing_hp() counts it, is at least `percent` of its +// maximum (the summary's, else `fallback_max_hp`); false if unknown. +bool hp_at_least_percent(const Supplies& supplies, int fallback_max_hp, int percent); + // Uses healing items with `use` (which returns whether the item was used, // having called took_recovery_item()) until missing_hp() is 0 or less: // a Super Potion while more than a Potion's HP is missing, else a Potion, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.cpp index a50b68fd64..9308efa89c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.cpp @@ -18,6 +18,7 @@ #include "PokemonFRLG_AutoStoryHealing.h" #include "PokemonFRLG_AutoStoryHealingSteps.h" #include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryLeagueSteps.h" #include "PokemonFRLG_AutoStoryMartPlan.h" namespace PokemonAutomation{ @@ -49,6 +50,11 @@ ItemUseEnd use_lead_item_from_bag(StoryEnv& env, const StoryStep& step, const st Outcome heal(StoryEnv& env, const StoryStep& step, int max_hp){ const std::optional before = missing_hp(env.supplies, max_hp); + const int64_t* below = game_arg(step.args, "below_percent"); + if (below != nullptr && hp_at_least_percent(env.supplies, max_hp, static_cast(*below))){ + env.console.log(std::format("Story: {}: {}, HP at least {}%: no heal.", step.name, hp_text(before), *below)); + return Pokemon::outcome_ok(); + } const auto use = [&](const std::string& item){ if (is_lead_recovery_item(item)){ return use_lead_item_from_bag(env, step, item) == ItemUseEnd::USED; @@ -135,6 +141,7 @@ std::vector healing_action_specs(){ {.kind = Pokemon::StoryStepKind::GAME, .name = HEAL_TO_FULL_ACTION, .args = { max_hp, optional_arg("full_restore", Pokemon::StoryArgType::BOOLEAN, false, "a Full Restore first if the bag holds one"), + optional_arg("below_percent", Pokemon::StoryArgType::INTEGER, int64_t(100), "heal only when the HP is below this share of the maximum"), }}, {.kind = Pokemon::StoryStepKind::GAME, .name = RESTORE_PP_ACTION, .args = { required_arg("item", Pokemon::StoryArgType::WORD, "the PP item used on the lead: elixir"), @@ -164,6 +171,9 @@ std::optional run_healing_step(StoryEnv& env, Pokemon::RunState& state, if (step.action == RESTORE_PP_ACTION){ return restore_pp_step(env, step); } + if (std::optional league = run_league_step(env, step)){ + return league; + } if (step.action != HEAL_TO_FULL_ACTION && step.action != CHECK_FULL_HP_ACTION){ return std::nullopt; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.h index 7dd5bb2895..a91260d1cd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealingSteps.h @@ -31,8 +31,12 @@ namespace PokemonFRLG{ // The GAME step that heals the lead to full with the bag (heal_to_full()): // max_hp INTEGER, the lead's maximum HP when the summary wasn't read; // full_restore BOOLEAN (default false), a Full Restore first if the bag -// holds one (heal_to_full()'s first item). HP still missing when the -// bag runs out is logged; the check fails on it. +// holds one (heal_to_full()'s first item); below_percent INTEGER (default +// 100), heal only when the HP is below this share of the maximum, as +// before an Elite Four fight: high risk, a Full Restore at yellow +// (RISK_HEALS in PokemonFRLG_AutoStoryBattlePolicy.cpp), out of battle +// where it costs no turn. HP still missing when the bag runs out is +// logged; the check fails on it. inline const std::string HEAL_TO_FULL_ACTION = "heal_to_full"; // The GAME step "restore_pp" uses a PP item on the lead from the bag: // item WORD, "elixir" (FRLG's Elixir restores every move, no move to diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp index 36546d5c91..153886ae3e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp @@ -56,7 +56,7 @@ bool is_party_item(std::string_view item){ return item == "rare-candy"; } bool is_lead_recovery_item(std::string_view item){ - return item == "elixir" || item == "full-restore"; + return item == "elixir" || item == "max-elixir" || item == "full-restore"; } bool is_repel(std::string_view item){ return item == "repel" || item == "super-repel" || item == "max-repel"; @@ -295,12 +295,8 @@ bool ConsoleItemUseActions::open_pocket(BagPocket pocket){ } std::vector ConsoleItemUseActions::read_pocket(){ - const PocketRead read = read_open_pocket(m_console, m_context, m_language); - // Back to the top, where use_row() counts its DOWN presses from. - for (size_t c = 0; c < read.downs; c++){ - pbf_press_dpad(m_context, DPAD_UP, CURSOR_TAP, CURSOR_WAIT); - } - return read.rows; + // It ends on the top row, where use_row() counts its DOWN presses from. + return read_open_pocket(m_console, m_context, m_language).rows; } void ConsoleItemUseActions::use_row(size_t row){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp index eceedcb97c..7f2375d3de 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp @@ -62,6 +62,18 @@ class SimPocketList : public PocketList{ const size_t bottom = m_rows.size() > SHOWN ? m_rows.size() - SHOWN : 0; m_top = std::min(m_cursor > STOP ? m_cursor - STOP : 0, bottom); } + // The list scrolls back under the cursor on its fourth row shown. + virtual void cursor_up() override{ + if (m_cursor > 0){ + m_cursor--; + } + constexpr size_t STOP = ITEM_LIST_ROWS / 2; + m_top = std::min(m_top, m_cursor > STOP ? m_cursor - STOP : 0); + } + // The row (from 0) the cursor is on. + size_t cursor() const{ + return m_cursor; + } private: std::vector m_rows; @@ -469,6 +481,9 @@ struct PocketReadExpectation{ size_t rows; // The DOWN presses the read took (as many UP back to the top). size_t downs; + // The row (from 0) the read leaves the cursor on: the top, where the + // next visit to the pocket counts its DOWN presses from. + size_t cursor_after = 0; }; struct PocketReadCase{ std::string name; @@ -496,6 +511,9 @@ class Test_ReadWholePocket : public UnitTest{ return std::format("Row {}: read {}, expected {}.", c + 1, read.rows[c].item, m_case.input.rows[c].item); } } + if (list.cursor() != m_case.expectation.cursor_after){ + return std::format("The read left the cursor on row {}; expected row {}.", list.cursor() + 1, m_case.expectation.cursor_after + 1); + } return true; } @@ -509,6 +527,14 @@ const std::vector ELEVEN_ROWS = { {"rare-candy", 3}, {"x-special", 18}, {"x-speed", 6}, {"x-accuracy", 5}, {"guard-spec", 2}, }; +// 19.01b's Items pocket at the Route 22 rival (console B, 2026-11-16), 15 +// rows and the CANCEL. +const std::vector ROUTE22_RIVAL_ROWS = { + {"moon-stone", 2}, {"potion", 3}, {"repel", 2}, {"escape-rope", 4}, {"super-repel", 4}, + {"rare-candy", 1}, {"x-special", 14}, {"x-speed", 6}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"elixir", 1}, {"super-potion", 6}, {"antidote", 1}, {"parlyz-heal", 2}, +}; + const PocketReadCase POCKET_READ_CASES[] = { { .name = "three rows: one page, no DOWN", @@ -530,6 +556,11 @@ const PocketReadCase POCKET_READ_CASES[] = { .input = {.rows = ELEVEN_ROWS, .cancel_read = false}, .expectation = {.rows = 11, .downs = 10}, }, + { + .name = "fifteen rows: back on the top row after 13 DOWN", + .input = {.rows = ROUTE22_RIVAL_ROWS}, + .expectation = {.rows = 15, .downs = 13}, + }, }; struct StepDoneInput{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.cpp index d247693ae2..0a4cb3824e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.cpp @@ -128,23 +128,15 @@ std::vector set_from_bag(Supplies& supplies, const std::vector set_from_loaded_bag(Supplies& supplies, Supplies& saved, const std::vector& rows){ - if (rows.empty()){ - return {}; - } - std::vector unread = set_from_bag(supplies, rows); - saved.potions = supplies.potions; - saved.super_potions = supplies.super_potions; - saved.antidotes = supplies.antidotes; - saved.parlyz_heals = supplies.parlyz_heals; - saved.awakenings = supplies.awakenings; - saved.full_heals = supplies.full_heals; - saved.pocket = supplies.pocket; - saved.other_counts = supplies.other_counts; - return unread; +bool bag_matches(const Supplies& kept, const std::vector& rows){ + Supplies read = kept; + set_from_bag(read, rows); + return read.potions == kept.potions && read.super_potions == kept.super_potions && read.antidotes == kept.antidotes + && read.parlyz_heals == kept.parlyz_heals && read.awakenings == kept.awakenings && read.full_heals == kept.full_heals; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.h index 2348473d9d..c2507e1a37 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.h @@ -52,11 +52,9 @@ int item_shown_row(const Supplies& supplies, int row); // items, for the log. std::vector set_from_bag(Supplies& supplies, const std::vector& rows); -// After a save is loaded: the Items pocket as read, taken into `supplies` -// and `saved` (what a reload restores) in place of the row's counts, as -// set_from_bag() does. With nothing read both keep the row's. Returns the -// items whose count couldn't be read. -std::vector set_from_loaded_bag(Supplies& supplies, Supplies& saved, const std::vector& rows); +// Whether the Items pocket as read holds the counts `kept` has of the +// items the story counts (the Bag's check; it changes no count). +bool bag_matches(const Supplies& kept, const std::vector& rows); // From the overworld: opens the Items pocket, reads it, and closes the // bag again. Empty if nothing could be read. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.cpp new file mode 100644 index 0000000000..0518046b11 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.cpp @@ -0,0 +1,129 @@ +/* AutoStory Items Pocket Change + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "PokemonFRLG_AutoStoryCaptureStep.h" +#include "PokemonFRLG_AutoStoryFieldMoves.h" +#include "PokemonFRLG_AutoStoryFossil.h" +#include "PokemonFRLG_AutoStoryGrindStep.h" +#include "PokemonFRLG_AutoStoryHealingSteps.h" +#include "PokemonFRLG_AutoStoryLeagueSteps.h" +#include "PokemonFRLG_AutoStoryHideout.h" +#include "PokemonFRLG_AutoStoryItemsPocketChange.h" +#include "PokemonFRLG_AutoStoryItemUse.h" +#include "PokemonFRLG_AutoStoryMartPlan.h" +#include "PokemonFRLG_AutoStoryMember.h" +#include "PokemonFRLG_AutoStoryPcTransfer.h" +#include "PokemonFRLG_AutoStoryPoses.h" +#include "PokemonFRLG_AutoStoryRooms.h" +#include "PokemonFRLG_AutoStorySlope.h" +#include "PokemonFRLG_AutoStorySlopeRun.h" +#include "PokemonFRLG_AutoStoryTeachPlan.h" +#include "PokemonFRLG_AutoStoryTrashCanLayout.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +using Pokemon::StoryStepKind; + +// A row of items_pocket_change(): an empty `action` stands for every +// action of a kind other than GAME without a row of its own. +struct ItemsPocketChangeRow{ + StoryStepKind kind; + std::string_view action; + ItemsPocketChange change; +}; + +// The GAME step that uses a PP item on the lead +// (PokemonFRLG_AutoStoryHealingSteps.h). +constexpr std::string_view RESTORE_PP = "restore_pp"; + +// Every place the story changes the Items pocket. COUNTED: a battle's +// items (spend_item()) and the recovery after it, a READY's, a GRIND's +// battles, the healing steps (took_recovery_item()), count_items +// (set_from_bag()). STALE: the Marts (SHOP, mart: bought and sold), a +// TALK, its ANSWER or the text after it (gifts, item balls), a use_item +// step (Repels, Rare Candies). A walk's Repel renewed when one wears off +// is marked where it is used (StoryWildBattle). TMs, HMs, Poke Balls and +// key items have pockets of their own: a TEACH, a capture or a fossil +// leave the Items pocket as it is. +const std::vector& items_pocket_change_rows(){ + static const std::vector ROWS = { + {StoryStepKind::NEW_GAME, "", ItemsPocketChange::NONE}, + {StoryStepKind::OPTIONS, "", ItemsPocketChange::NONE}, + {StoryStepKind::ROUTE, "", ItemsPocketChange::NONE}, + {StoryStepKind::LEGS, "", ItemsPocketChange::NONE}, + {StoryStepKind::STEP, "", ItemsPocketChange::NONE}, + {StoryStepKind::TALK, "", ItemsPocketChange::STALE}, + {StoryStepKind::ANSWER, "", ItemsPocketChange::STALE}, + {StoryStepKind::MASH, "", ItemsPocketChange::STALE}, + {StoryStepKind::BATTLE, "", ItemsPocketChange::COUNTED}, + {StoryStepKind::TRAIN, "", ItemsPocketChange::COUNTED}, + {StoryStepKind::HEAL, "", ItemsPocketChange::NONE}, + {StoryStepKind::SHOP, "", ItemsPocketChange::STALE}, + {StoryStepKind::SAVE, "", ItemsPocketChange::NONE}, + {StoryStepKind::READY, "", ItemsPocketChange::COUNTED}, + {StoryStepKind::GAME, CLOSE_TRAINER_CARD, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, LEAVE_GIFT_SUMMARY, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, CUT_TREE_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, PUSH_BOULDER_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, TRASH_CANS_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, PC_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, CAPTURE_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, FOSSIL_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, LEVEL_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, MART_ACTION, ItemsPocketChange::STALE}, + {StoryStepKind::GAME, TEACH_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, GRIND_ACTION, ItemsPocketChange::COUNTED}, + {StoryStepKind::GAME, GRIND_CHECK_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, SLOPE_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, COUNT_ITEMS_VARIANT, ItemsPocketChange::COUNTED}, + {StoryStepKind::GAME, POSTER_SWITCH_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, LIFT_FLOOR_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, USE_ITEM_VARIANT, ItemsPocketChange::STALE}, + {StoryStepKind::GAME, RIDE_BIKE_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, REGISTER_BIKE_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, CENTER_ENTER_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, CENTER_EXIT_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, FLY_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, SURF_VARIANT, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, HEAL_TO_FULL_ACTION, ItemsPocketChange::COUNTED}, + {StoryStepKind::GAME, RESTORE_PP, ItemsPocketChange::COUNTED}, + {StoryStepKind::GAME, CHECK_FULL_HP_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, BAG_CHECK_ACTION, ItemsPocketChange::NONE}, + {StoryStepKind::GAME, LEAGUE_START_ACTION, ItemsPocketChange::COUNTED}, + {StoryStepKind::GAME, LEAGUE_BETWEEN_FIGHTS_ACTION, ItemsPocketChange::COUNTED}, + }; + return ROWS; +} + +} // namespace + +std::optional items_pocket_change(StoryStepKind kind, std::string_view action){ + std::optional kind_change; + for (const ItemsPocketChangeRow& row : items_pocket_change_rows()){ + if (row.kind != kind){ + continue; + } + if (row.action == action){ + return row.change; + } + if (row.action.empty() && kind != StoryStepKind::GAME){ + kind_change = row.change; + } + } + return kind_change; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.h new file mode 100644 index 0000000000..5a4d7be3ad --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.h @@ -0,0 +1,47 @@ +/* AutoStory Items Pocket Change + * + * From: https://github.com/PokemonAutomation/ + * + * What each story step does to the Items pocket, which a battle's items + * are used from by their rows: one row per action, so the counts a battle + * trusts are read in this run after the last step that changed the + * pocket uncounted (Supplies::counts_read). + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryItemsPocketChange_H +#define PokemonAutomation_PokemonFRLG_AutoStoryItemsPocketChange_H + +#include +#include +#include "Pokemon/AutoStory/Types/Pokemon_StoryStepKind.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// What a step does to the Items pocket. +enum class ItemsPocketChange{ + // Nothing in it changes. + NONE, + // Items used, each taken off the story's counts as it goes + // (spend_item()), or the pocket read and its counts taken. + COUNTED, + // Items come or go that the story doesn't count (a Mart, a gift, an + // item ball, a use_item step): the counts and rows after it are a + // guess, and the next battle reads the pocket first. + STALE, +}; + +// The change a step of `kind` done by `action` (StoryStep::action, empty +// for the kind's own) makes; nothing for an action without a row, which +// the story takes as STALE. Every action story_action_specs() names has +// a row. +std::optional items_pocket_change(Pokemon::StoryStepKind kind, std::string_view action); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp index bf1a30af1b..03973c1e23 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp @@ -131,29 +131,19 @@ UnitTestResult test_pocket_rows(Logger&){ return true; } -// #211: a row loaded from a save counted no Potions, so its wild battles -// were all run from. The counts come from the bag as read, both for the -// run and for a reload; with nothing read, the row's are kept. +// The Bag's check after a load compares the pocket read with the counts +// kept and changes none: a battle with a row's guess reads it itself. UnitTestResult test_loaded_bag(Logger&){ - Supplies row; - Supplies saved = row; - const std::vector unread = set_from_loaded_bag(row, saved, {{"potion", 4}, {"antidote", 2}}); - if (row.potions != 4 || saved.potions != 4 || row.antidotes != 2 || saved.antidotes != 2 || !unread.empty()){ - return std::format( - "Expected 4 Potions and 2 Antidotes from the bag, now and for a reload; got {} and {}, {} and {}.", - row.potions, saved.potions, row.antidotes, saved.antidotes - ); + Supplies kept; + kept.potions = 4; + kept.antidotes = 2; + const std::vector same = {{"potion", 4}, {"antidote", 2}}; + const std::vector fewer = {{"potion", 1}, {"antidote", 2}}; + if (!bag_matches(kept, same)){ + return "Expected 4 Potions and 2 Antidotes read to match the counts kept."; } - if (item_row(saved, "antidote") != 1){ - return "Expected the reload's pocket order from the bag."; - } - - Supplies known; - known.potions = 2; - Supplies known_saved = known; - set_from_loaded_bag(known, known_saved, {}); - if (known.potions != 2 || known_saved.potions != 2){ - return "Expected the row's 2 Potions kept with nothing read."; + if (bag_matches(kept, fewer) || kept.potions != 4){ + return "Expected 1 Potion read to differ, and the 4 kept unchanged."; } return true; } @@ -205,15 +195,11 @@ UnitTestResult test_loaded_bag_other_items(Logger&){ Supplies row; row.potions = 0; row.parlyz_heals = 0; - Supplies saved = row; - set_from_loaded_bag(row, saved, {{"", 1}, {"parlyz-heal", 1}, {"potion", 15}}); - if (row.potions != 15 || saved.potions != 15 || row.parlyz_heals != 1){ - return std::format( - "Expected 15 Potions and 1 Parlyz Heal from the bag, now and for a reload; got {}, {} and {}.", - row.potions, saved.potions, row.parlyz_heals - ); + set_from_bag(row, {{"", 1}, {"parlyz-heal", 1}, {"potion", 15}}); + if (row.potions != 15 || row.parlyz_heals != 1){ + return std::format("Expected 15 Potions and 1 Parlyz Heal from the bag, got {} and {}.", row.potions, row.parlyz_heals); } - if (item_row(row, "parlyz-heal") != 1 || item_row(row, "potion") != 2 || item_row(saved, "potion") != 2){ + if (item_row(row, "parlyz-heal") != 1 || item_row(row, "potion") != 2){ return std::format( "Expected the Parlyz Heal in row 1 and the Potions in row 2 below the Moon Stone, got {} and {}.", item_row(row, "parlyz-heal"), item_row(row, "potion") @@ -226,13 +212,9 @@ UnitTestResult test_loaded_bag_other_items(Logger&){ // from the bag and found in their row. UnitTestResult test_loaded_bag_awakenings(Logger&){ Supplies row; - Supplies saved = row; - set_from_loaded_bag(row, saved, {{"", 1}, {"parlyz-heal", 1}, {"potion", 15}, {"awakening", 3}}); - if (row.awakenings != 3 || saved.awakenings != 3 || item_count(row, "awakening") != 3 || item_row(row, "awakening") != 3){ - return std::format( - "Expected 3 Awakenings in row 3, now and for a reload; got {} and {}, row {}.", - row.awakenings, saved.awakenings, item_row(row, "awakening") - ); + set_from_bag(row, {{"", 1}, {"parlyz-heal", 1}, {"potion", 15}, {"awakening", 3}}); + if (row.awakenings != 3 || item_count(row, "awakening") != 3 || item_row(row, "awakening") != 3){ + return std::format("Expected 3 Awakenings in row 3, got {}, row {}.", row.awakenings, item_row(row, "awakening")); } return true; } @@ -830,7 +812,7 @@ const AutoStoryItemsTestCase AUTO_STORY_ITEMS_CASES[] = { .expectation = {.description = "parses item pocket rows from visual representation"}, }, { - .input = {.name = "a loaded save's counts come from the bag", .body = test_loaded_bag}, + .input = {.name = "the Bag's check compares, changing no count", .body = test_loaded_bag}, .expectation = {.description = "initializes bag counts when loading saved state"}, }, { diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp index e68adde227..b96c60e3a9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp @@ -37,7 +37,9 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryFaultSweep_Tests.h" #include "PokemonFRLG_AutoStoryResources.h" +#include "PokemonFRLG_AutoStoryRockTunnel_Tests.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStorySimBudget.h" #include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -318,46 +320,64 @@ std::string walk_below_martha(OverworldSim& sim, const std::vector& le // end of the walk back east 12 along row 38, placed 0 to 3 tiles in by // the dark screen; "found again" at the rock (20, 35) while against the // wall (25, 35); ended on (21, 35), where martha_line found no trainer. -// Here the second battle on each step of that walk back: with the dark -// cave's stops placed anywhere on their leg, every one ends on (16, 35); -// without, some don't. -UnitTestResult test_b1f_dark_row38_battle_old_legs(Logger& logger){ - const std::vector old_legs{{Direction::WEST, 16}, {Direction::NORTH, 2}, {Direction::EAST, 6}, {Direction::WEST, 3}}; +// The legs below_martha_line walked then. +const std::vector ROW38_OLD_LEGS{{Direction::WEST, 16}, {Direction::NORTH, 2}, {Direction::EAST, 6}, {Direction::WEST, 3}}; +// The steps of that walk the second battle may come on. +constexpr int ROW38_FIRST_BATTLE = 8; +constexpr int ROW38_LAST_BATTLE = 60; + +// The dark cave, a battle 6 tiles in, and one seen late on step `second`. +SimScript row38_battles_script(int second){ + SimScript script; + script.dark_maps = ROCK_TUNNEL_DARK; + script.encounters = {SimEncounter{.grass_step = 6}, SimEncounter{.grass_step = second, .seen_late = true}}; + return script; +} + +// The second battle on each step `first` to `last` of the walk back along +// row 38 with the old legs: with the dark cave's stops placed anywhere on +// their leg, every one ends on (16, 35). Steps 8 to 60 in all, split over +// cases (with the walks without the rules, 106 took 391 s on Fork Draft +// CI, 2026-11-16). +UnitTestResult test_b1f_dark_row38_battle_old_legs(int first, int last){ std::string failures; - int old_wrong = 0; - for (int second = 8; second <= 60; second++){ - SimScript script; - script.dark_maps = ROCK_TUNNEL_DARK; - script.encounters = {SimEncounter{.grass_step = 6}, SimEncounter{.grass_step = second, .seen_late = true}}; - OverworldSim fixed(maps_after_route10(), MapPosition{ROCK_TUNNEL_B1F, {29, 37}}, Direction::NORTH, script); - if (const std::string failure = walk_below_martha(fixed, old_legs, SimWalkerRules{}); !failure.empty()){ + for (int second = first; second <= last; second++){ + OverworldSim fixed(maps_after_route10(), MapPosition{ROCK_TUNNEL_B1F, {29, 37}}, Direction::NORTH, row38_battles_script(second)); + if (const std::string failure = walk_below_martha(fixed, ROW38_OLD_LEGS, SimWalkerRules{}); !failure.empty()){ failures += std::format("{}battle on step {}: {}", failures.empty() ? "" : " | ", second, failure); } - SimWalkerRules old_rules; - old_rules.whole_leg_in_dark = false; - old_rules.dark_cave_not_battle = false; - OverworldSim old(maps_after_route10(), MapPosition{ROCK_TUNNEL_B1F, {29, 37}}, Direction::NORTH, script); - if (const std::string failure = walk_below_martha(old, old_legs, old_rules); !failure.empty()){ - old_wrong++; - logger.log(std::format("Without the dark cave rules, battle on step {}: {}", second, failure)); - } } if (!failures.empty()){ return failures; } - if (old_wrong == 0){ - return "Without the dark cave rules every walk still ended on (16, 35): the test doesn't show the failure."; - } return true; } +// The same walks without the dark cave's rules: one of them doesn't end on +// (16, 35), or the cases above don't show the failure. Stops at the first. +UnitTestResult test_b1f_dark_row38_old_rules_fail(Logger& logger){ + SimWalkerRules old_rules; + old_rules.whole_leg_in_dark = false; + old_rules.dark_cave_not_battle = false; + for (int second = ROW38_FIRST_BATTLE; second <= ROW38_LAST_BATTLE; second++){ + OverworldSim old(maps_after_route10(), MapPosition{ROCK_TUNNEL_B1F, {29, 37}}, Direction::NORTH, row38_battles_script(second)); + if (const std::string failure = walk_below_martha(old, ROW38_OLD_LEGS, old_rules); !failure.empty()){ + logger.log(std::format("Without the dark cave rules, battle on step {}: {}", second, failure)); + return true; + } + } + return "Without the dark cave rules every walk still ended on (16, 35): the test doesn't show the failure."; +} + // Rock Tunnel dark, from Winston's tile: below_martha_line, martha_line // and Martha's battle with one wild battle on each step the walk takes, // on rows 37 and 38 and on row 35 between the corner (11, 35) and // (16, 35), seen as it starts and seen late: Martha alone is fought. -UnitTestResult test_b1f_dark_martha_battle_anywhere(Logger&){ +// Steps `first` to `last` of the walk: steps 1 to 40 in all, split over +// cases (80 walks took 248 s on Fork Draft CI, 2026-11-16). +UnitTestResult test_b1f_dark_martha_battle_on_steps(int first, int last){ std::string failures; - for (int step = 1; step <= 40; step++){ + for (int step = first; step <= last; step++){ for (const bool late : {false, true}){ SimScript script; script.dark_maps = ROCK_TUNNEL_DARK; @@ -374,143 +394,6 @@ UnitTestResult test_b1f_dark_martha_battle_anywhere(Logger&){ return true; } -// 08.01 whole with a wild battle every 7 to 25 steps on the tunnel's floor, -// the gaps drawn from each of these seeds: the row ends where it should. -UnitTestResult test_rock_tunnel_frequent_battles(Logger&){ - std::string failures; - for (unsigned seed = 1; seed <= 12; seed++){ - std::mt19937 random(seed); - std::uniform_int_distribution gap(7, 25); - std::vector gaps; - for (int c = 0; c < 400; c++){ - gaps.push_back(gap(random)); - } - const UnitTestResult result = row_on_sim( - "08.01", battles_every(gaps), {ROCK_TUNNEL_TRAINERS}, MapPosition{ROUTE10, {8, 58}} - ); - if (result.result != UnitTestResult::PASSED){ - failures += std::format("{}Seed {}: {}", failures.empty() ? "" : " | ", seed, result.message); - } - } - if (!failures.empty()){ - return failures; - } - return true; -} - -// The sim at row `id`'s start, with `script`. -OverworldSim row_start_sim(std::string_view id, SimScript script){ - const StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint(id).start)); - return OverworldSim(maps_after_route10(), MapPosition{at.map, at.tile}, *at.facing, std::move(script)); -} - -// One run of a row on the sim, against the same row with no wild battle. -struct RowRunNumbers{ - bool passed = false; - double seconds = 0; - int tiles = 0; - // Tiles walked beyond the run with no wild battle: walked again after - // a battle, finding the player and the way back. - int tiles_again = 0; - int battles = 0; - // Per wild battle, the time beyond the run with no wild battle, less - // the battles' own: from each battle's end until the walk is back - // where it was cut off. - double seconds_lost_per_battle = 0; -}; - -RowRunNumbers row_numbers(const SimState& run, bool passed, const SimState& clean){ - RowRunNumbers out; - out.passed = passed; - out.seconds = run.time.count() / 1000.; - out.tiles = run.steps; - out.tiles_again = run.steps - clean.steps; - out.battles = run.wild_battles; - const Milliseconds lost = run.time - clean.time - run.in_wild_battles; - out.seconds_lost_per_battle = run.wild_battles > 0 ? lost.count() / 1000. / run.wild_battles : 0; - return out; -} - -// The mean and 90th percentile of `values`. -std::string mean_p90(std::vector values){ - if (values.empty()){ - return "-"; - } - std::sort(values.begin(), values.end()); - const double mean = std::accumulate(values.begin(), values.end(), 0.) / values.size(); - const double p90 = values[std::min(values.size() - 1, (size_t)(0.9 * values.size()))]; - return std::format("mean {:.1f}, p90 {:.1f}", mean, p90); -} - -// How many of `runs` passed, and over those, the mean and 90th percentile -// of each number. -std::string numbers_summary(const std::vector& runs){ - std::vector seconds, tiles, again, battles, lost; - size_t passed = 0; - for (const RowRunNumbers& run : runs){ - passed += run.passed ? 1 : 0; - if (!run.passed){ - continue; - } - seconds.push_back(run.seconds); - tiles.push_back(run.tiles); - again.push_back(run.tiles_again); - battles.push_back(run.battles); - if (run.battles > 0){ - lost.push_back(run.seconds_lost_per_battle); - } - } - return std::format( - "passed {}/{}; of those passed: time (s) {}; tiles {}; tiles walked again {}; wild battles {}; s lost per battle {}", - passed, runs.size(), mean_p90(seconds), mean_p90(tiles), mean_p90(again), mean_p90(battles), mean_p90(lost) - ); -} - -// The land encounter rates of the maps 08.01 and 08.02 walk (pokefirered -// src/data/wild_encounters.json, FireRed). -const std::map ROCK_TUNNEL_ENCOUNTER_RATES{ - {ROCK_TUNNEL_1F, 7}, - {ROCK_TUNNEL_B1F, 7}, - {ROUTE10, 21}, -}; - -constexpr unsigned GAME_ODDS_SEEDS = 30; - -// 08.01 whole, its wild battles at the game's own odds (OverworldSim:: -// rolls_encounter()), from each of these seeds: every run ends where it -// should. Logs the runs' numbers and the step taps the game ignored. -UnitTestResult test_rock_tunnel_game_odds(Logger& logger){ - OverworldSim clean_sim = row_start_sim("08.01", SimScript{}); - if (const UnitTestResult clean = row_checked(clean_sim, "08.01", {ROCK_TUNNEL_TRAINERS}, MapPosition{ROUTE10, {8, 58}}); clean.result != UnitTestResult::PASSED){ - return clean; - } - std::vector runs; - std::string failures; - int ignored = 0; - for (unsigned seed = 1; seed <= GAME_ODDS_SEEDS; seed++){ - SimScript script; - script.encounter_rates = ROCK_TUNNEL_ENCOUNTER_RATES; - script.encounter_seed = seed; - script.dark_maps = ROCK_TUNNEL_DARK; - OverworldSim sim = row_start_sim("08.01", script); - const UnitTestResult result = row_checked(sim, "08.01", {ROCK_TUNNEL_TRAINERS}, MapPosition{ROUTE10, {8, 58}}); - const bool passed = result.result == UnitTestResult::PASSED; - runs.push_back(row_numbers(sim.state(), passed, clean_sim.state())); - ignored += sim.state().step_taps_ignored; - if (!passed){ - failures += std::format("{}Seed {}: {}", failures.empty() ? "" : " | ", seed, result.message); - } - } - logger.log(std::format( - "08.01 at the game's encounter odds, {} step taps ignored: {}", ignored, numbers_summary(runs) - )); - if (!failures.empty()){ - return failures; - } - return true; -} - - // 08.02 on the sim: no trainer met, the ledge hopped, Lavender's nurse. UnitTestResult test_lavender_row(Logger&){ return row_on_sim("08.02", SimScript{}, {{}}, MapPosition{LAVENDER_CENTER, {7, 4}}); @@ -1048,11 +931,8 @@ const AutoStoryLavenderCase AUTO_STORY_LAVENDER_CASES[] = { {.input = {"09.02 B2F's drawn route: the plan sees no more of the Grunt, and is no longer", test_b2f_drawn_route}, .expectation = {}}, {.input = {"09.02 B2F's tapped legs keep their tile: no holds to walls after them", test_b2f_tapped_legs_keep_their_tile}, .expectation = {}}, {.input = {"08.01 B1F row 37 with a wild battle every 10 to 14 steps", test_b1f_row37_battles_every_12}, .expectation = {}}, - {.input = {"08.01 a wild battle every 7 to 25 steps, 12 seeds", test_rock_tunnel_frequent_battles}, .expectation = {}}, - {.input = {"08.01 wild battles at the game's odds, 30 seeds", test_rock_tunnel_game_odds}, .expectation = {}}, {.input = {"08.01 B1F a wild battle into row 38, then a step short: Martha still sees the player", test_b1f_martha_after_row38_battle}, .expectation = {}}, - {.input = {"08.01 B1F dark, the 13:35 legs: a battle at the end of the walk back along row 38", test_b1f_dark_row38_battle_old_legs}, .expectation = {}}, - {.input = {"08.01 B1F dark, a wild battle on any step to Martha's line", test_b1f_dark_martha_battle_anywhere}, .expectation = {}}, + {.input = {"08.01 B1F dark, the 13:35 legs without the dark cave's rules: a walk back along row 38 ends elsewhere", test_b1f_dark_row38_old_rules_fail}, .expectation = {}}, {.input = {"08.01 B1F dark, winston_line: a wild battle on the 2nd tap, the 3rd after it", test_winston_line_battle_on_tap_2}, .expectation = {}}, {.input = {"08.02 Route 10 south, the ledge, Lavender Town's Pokemon Center", test_lavender_row}, .expectation = {}}, {.input = {"08.02 a tile off after each open leg", test_lavender_tile_off}, .expectation = {}}, @@ -1066,10 +946,49 @@ const AutoStoryLavenderCase AUTO_STORY_LAVENDER_CASES[] = { {.input = {"09.02 no tile of B3F or B2F walked twice: no way out and back", test_hideout_giovanni_row_no_tile_twice}, .expectation = {}}, }; +namespace{ + +// The step ranges the slow B1F tests are split into, one case each. +struct StepRange{ + int first; + int last; +}; +const StepRange ROW38_BATTLE_STEPS[] = {{8, 20}, {21, 33}, {34, 46}, {47, 60}}; +const StepRange MARTHA_BATTLE_STEPS[] = {{1, 10}, {11, 20}, {21, 30}, {31, 40}}; + +// A case named `name` that runs `test` on `range`, logging its time. +AutoStoryLavenderCase step_range_case(std::string name, UnitTestResult (*test)(int, int), StepRange range){ + return {.input = {name, [name, test, range](Logger& logger){ + return timed_case(logger, name, [&]{ return test(range.first, range.last); }); + }}, .expectation = {}}; +} + +// The cases split by steps, so each fits STAGE_BUDGET. +std::vector split_cases(){ + std::vector cases; + for (const StepRange& range : ROW38_BATTLE_STEPS){ + cases.push_back(step_range_case(std::format( + "08.01 B1F dark, the 13:35 legs: a battle on steps {} to {} of the walk back along row 38", range.first, range.last + ), test_b1f_dark_row38_battle_old_legs, range)); + } + for (const StepRange& range : MARTHA_BATTLE_STEPS){ + cases.push_back(step_range_case(std::format( + "08.01 B1F dark, a wild battle on steps {} to {} to Martha's line", range.first, range.last + ), test_b1f_dark_martha_battle_on_steps, range)); + } + return cases; +} + +} // namespace + void add_tests_AutoStoryLavender(UnitTestDatabase& database){ for (const auto& item : AUTO_STORY_LAVENDER_CASES){ database.add(item); } + for (AutoStoryLavenderCase& item : split_cases()){ + database.add(std::move(item)); + } + add_tests_AutoStoryRockTunnel(database); add_tests_AutoStoryResources(database); add_tests_AutoStoryFaultSweep(database); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.cpp new file mode 100644 index 0000000000..9eeb5e7d19 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.cpp @@ -0,0 +1,91 @@ +/* AutoStory Lead Out + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonTools/OCR/OCR_Routines.h" +#include "Pokemon/Inference/Pokemon_NameReader.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_OcrPreprocessing.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_WildEncounterReader.h" +#include "PokemonFRLG_AutoStoryBattleData.h" +#include "PokemonFRLG_AutoStoryLeadOut.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +LeadOnField lead_on_field(const LeadOnFieldInput& input){ + if (!input.own_out.empty() && input.own_out == input.lead){ + return LeadOnField::OUT; + } + if (!input.own_out.empty() && !input.member_sent){ + return LeadOnField::FORCED_OUT; + } + return input.box_gone ? LeadOnField::FAINTED : LeadOnField::OUT; +} + +namespace{ + +// The player's HP box's name, as WildEncounterReader's for the foe. +const ImageFloatBox OWN_NAME_BOX(0.585, 0.490, 0.260, 0.063); +// The party list's names: the big top-left slot's, then the column's, +// OWN_PARTY_ROW apart. +const ImageFloatBox FIRST_SLOT_NAME_BOX(0.131, 0.235, 0.158, 0.058); +constexpr double SLOT_NAME_X = 0.488; +constexpr double SLOT_NAME_Y = 0.085; +constexpr double SLOT_NAME_WIDTH = 0.204; +constexpr double SLOT_NAME_HEIGHT = 0.058; +constexpr double OWN_PARTY_ROW = 0.150; +constexpr size_t PARTY_SIZE = 6; + +std::string read_name(Logger& logger, Language language, const ImageViewRGB32& name_box, const std::set& species, bool bright){ + const std::vector& filters = bright ? BRIGHT_TEXT_FILTERS() : DARK_TEXT_FILTERS(); + const OCR::StringMatchResult result = Pokemon::PokemonNameReader(species).read_substring( + logger, language, preprocess_for_ocr(name_box), filters, + /*min_text_ratio=*/0.01, /*max_text_ratio=*/0.50, WildEncounterReader::MAX_LOG10P + ); + return result.results.empty() ? std::string() : result.results.begin()->second.token; +} + +} // namespace + +std::string read_own_battler(Logger& logger, Language language, const ImageViewRGB32& screen){ + if (language == Language::None){ + return ""; + } + const ImageViewRGB32 game = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + const std::string read = read_name(logger, language, extract_box_reference(game, OWN_NAME_BOX), battle_species(), /*bright=*/false); + logger.log(read.empty() ? "Battle: our Pokemon out wasn't read." : std::format("Battle: our {} is out.", read)); + return read; +} + +std::optional party_slot_of(Logger& logger, Language language, const ImageViewRGB32& screen, std::string_view species){ + if (language == Language::None){ + return std::nullopt; + } + const ImageViewRGB32 game = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + const std::set wanted{std::string(species)}; + for (size_t slot = 0; slot < PARTY_SIZE; slot++){ + const ImageFloatBox box = slot == 0 ? FIRST_SLOT_NAME_BOX : ImageFloatBox( + SLOT_NAME_X, SLOT_NAME_Y + OWN_PARTY_ROW * static_cast(slot - 1), SLOT_NAME_WIDTH, SLOT_NAME_HEIGHT + ); + if (read_name(logger, language, extract_box_reference(game, box), wanted, /*bright=*/true) == species){ + return slot; + } + } + return std::nullopt; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.h new file mode 100644 index 0000000000..d523a0245e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.h @@ -0,0 +1,74 @@ +/* AutoStory Lead Out + * + * From: https://github.com/PokemonAutomation/ + * + * Which of the player's Pokemon is out in a trainer's battle: the name its + * HP box shows, the party list's slot that reads the lead, and the one rule + * that tells a lead dragged out by Roar or Whirlwind from a faint. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeadOut_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeadOut_H + +#include +#include +#include +#include +#include "Common/Cpp/Logging/AbstractLogger.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "CommonFramework/Language.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Where the lead is at a trainer battle's menu. +enum class LeadOnField{ + OUT, + FAINTED, + // Another member is out that the battle loop didn't send: the lead is + // alive in the party. + FORCED_OUT, +}; + +// What the battle loop knows at a trainer battle's menu. +struct LeadOnFieldInput{ + // The lead's HP box went (the faint watch). + bool box_gone = false; + // The loop sent a member from the party list. + bool member_sent = false; + // Our Pokemon out as read (read_own_battler()), "" if not read. + std::string_view own_out = {}; + // The lead's species. + std::string_view lead = {}; +}; + +// The one rule: the member out read as the lead's species, the lead is +// out; another member read out while none was sent from the party list, +// it was dragged out (console B, 2026-11-16, Bruno's Onix's Roar, read as +// a faint: the lead's box gone); else the box gone means it fainted. +LeadOnField lead_on_field(const LeadOnFieldInput& input); + +// The player's Pokemon out on `screen`, a battle menu: the name its HP +// box shows, among battle_species(); empty if not read. After a Roar or +// Whirlwind it is another member than the lead (console B, 2026-11-16, +// Bruno's Onix dragged Lapras in). +std::string read_own_battler(Logger& logger, Language language, const ImageViewRGB32& screen); + +// The slot of the party list on `screen` (from 0, the big top-left one) +// whose name reads `species`; none if no slot does. +std::optional party_slot_of(Logger& logger, Language language, const ImageViewRGB32& screen, std::string_view species); + + +// Registers the lead-out unit tests. +void add_tests_AutoStoryLeadOut(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut_Tests.cpp new file mode 100644 index 0000000000..f7f1002a8d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut_Tests.cpp @@ -0,0 +1,160 @@ +/* AutoStory Lead Out Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Filesystem/Filesystem.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "Tests/ImageUnitTest.h" +#include "Tests/TestUtils.h" +#include "PokemonFRLG_AutoStoryLeadOut.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The lead at a trainer's battle menu, by the one rule (lead_on_field()). +struct LeadOnFieldCase{ + std::string_view name; + // The lead is Blastoise. + struct Input{ + bool box_gone; + bool member_sent; + std::string_view own_out; + }; + Input input; + struct Expectation{ + LeadOnField lead; + }; + Expectation expectation; +}; + +const LeadOnFieldCase LEAD_ON_FIELD_CASES[] = { + { + .name = "Bruno's Onix's Roar (console B, 2026-11-16): Lapras out, box gone, none sent", + .input = {.box_gone = true, .member_sent = false, .own_out = "lapras"}, + .expectation = {.lead = LeadOnField::FORCED_OUT}, + }, + { + .name = "a Roar the box watch missed", + .input = {.box_gone = false, .member_sent = false, .own_out = "lapras"}, + .expectation = {.lead = LeadOnField::FORCED_OUT}, + }, + { + .name = "a real faint: a member sent from the party list", + .input = {.box_gone = true, .member_sent = true, .own_out = "lapras"}, + .expectation = {.lead = LeadOnField::FAINTED}, + }, + { + .name = "the lead read out: its box only hid in an animation", + .input = {.box_gone = true, .member_sent = false, .own_out = "blastoise"}, + .expectation = {.lead = LeadOnField::OUT}, + }, + { + .name = "nothing read, box gone: fainted", + .input = {.box_gone = true, .member_sent = false, .own_out = ""}, + .expectation = {.lead = LeadOnField::FAINTED}, + }, +}; + +class Test_LeadOnField : public UnitTest{ +public: + explicit Test_LeadOnField(const LeadOnFieldCase& test) + : UnitTest(std::format("PokemonFRLG::AutoStoryLeadOut - {}", test.name)) + , m_test(test) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const LeadOnFieldCase::Input& input = m_test.input; + const LeadOnField lead = lead_on_field({ + .box_gone = input.box_gone, .member_sent = input.member_sent, + .own_out = input.own_out, .lead = "blastoise", + }); + if (lead != m_test.expectation.lead){ + return "Unexpected verdict."; + } + return true; + } + +private: + LeadOnFieldCase m_test; +}; + +// read_own_battler() on console B's battle menus named +// _.png, in English. +class Test_OwnBattler : public ImageUnitTest{ +public: + Test_OwnBattler(const std::string& image) + : ImageUnitTest(std::format("PokemonFRLG::AutoStoryBattle own battler - {}", image), {image}) + { + m_memory += PADDLE_OCR_SINGLE_LINE_MEMORY_ESTIMATE; + } + + virtual UnitTestResult run_on_images( + Logger& logger, CancellableScope& scope, + const std::vector& images + ) const override{ + const std::vector words = parse_words(Filesystem::Path(image_paths()[0]).stem().string()); + if (words.empty()){ + return "Error: filename must be _."; + } + const std::string read = read_own_battler(logger, Language::English, images[0]); + return read == words.back() ? UnitTestResult(true) : UnitTestResult(std::format("Read \"{}\", expected {}.", read, words.back())); + } +}; + +// party_slot_of() on a party list: `species` at `slot` (from 0). +class Test_PartySlotOf : public ImageUnitTest{ +public: + Test_PartySlotOf(const std::string& image, std::string species, size_t slot) + : ImageUnitTest(std::format("PokemonFRLG::AutoStoryBattle party slot of {} - {}", species, image), {image}) + , m_species(std::move(species)) + , m_slot(slot) + { + m_memory += PADDLE_OCR_SINGLE_LINE_MEMORY_ESTIMATE; + } + + virtual UnitTestResult run_on_images( + Logger& logger, CancellableScope& scope, + const std::vector& images + ) const override{ + const std::optional slot = party_slot_of(logger, Language::English, images[0], m_species); + return slot == std::optional(m_slot) + ? UnitTestResult(true) + : UnitTestResult(std::format("{}: slot {}, expected {}.", m_species, slot ? std::format("{}", *slot) : "none", m_slot)); + } + +private: + std::string m_species; + size_t m_slot; +}; + +} // namespace + + +void add_tests_AutoStoryLeadOut(UnitTestDatabase& database){ + for (const LeadOnFieldCase& test : LEAD_ON_FIELD_CASES){ + database.add(test); + } + // Bruno's Onix's Roar (console B, 2026-11-16, 20.02): Lapras out; the turn before, Blastoise. + database.add("PokemonFRLG/AutoStoryBattle/BrunoOnixRoar_OwnBattler_lapras.png"); + database.add("PokemonFRLG/AutoStoryBattle/BrunoOnix_OwnBattler_blastoise.png"); + database.add("PokemonFRLG/Party/Party_6.png", "blastoise", /*slot=*/4); + database.add("PokemonFRLG/Party/Party_6.png", "raichu", /*slot=*/0); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueBudget.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueBudget.h new file mode 100644 index 0000000000..396959c6a6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueBudget.h @@ -0,0 +1,126 @@ +/* AutoStory League Budget + * + * From: https://github.com/PokemonAutomation/ + * + * The items one League fight may spend from the bag (its FightBudget), + * as PokemonFRLG_AutoStoryLeaguePlan.h plans them and the battle policy + * spends them. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeagueBudget_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeagueBudget_H + +#include +#include +#include +#include +#include +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Item counts by bag slug ("full-restore"). +using BagCounts = std::map>; + +// The items a League fight may spend from the bag. +struct FightBudget{ + int full_restore = 0; + int x_special = 0; + int x_speed = 0; + int x_accuracy = 0; + int guard_spec = 0; + // Elixirs and Max Elixirs. + int elixir = 0; + // Hyper Potions and Max Potions: the bigger heal before a Full Restore. + int hyper_potion = 0; + int full_heal = 0; + + bool operator==(const FightBudget&) const = default; +}; + +// The count in `budget` that `item` (a bag slug) is budgeted under: a +// Max Elixir counts as an Elixir, a Max Potion as a Hyper Potion; none +// for an item the budget doesn't hold. `Budget` is FightBudget, const or not. +template +auto budget_count(std::string_view item, Budget& budget) -> decltype(&budget.full_restore); + +template +auto budget_count(std::string_view item, Budget& budget) -> decltype(&budget.full_restore){ + if (item == "full-restore"){ + return &budget.full_restore; + } + if (item == "x-special"){ + return &budget.x_special; + } + if (item == "x-speed"){ + return &budget.x_speed; + } + if (item == "x-accuracy"){ + return &budget.x_accuracy; + } + if (item == "guard-spec"){ + return &budget.guard_spec; + } + if (item == "elixir" || item == "max-elixir"){ + return &budget.elixir; + } + if (item == "hyper-potion" || item == "max-potion"){ + return &budget.hyper_potion; + } + if (item == "full-heal"){ + return &budget.full_heal; + } + return nullptr; +} + +// `item`'s count in `budget`, none for an item the budget doesn't hold. +inline std::optional budget_left(const FightBudget& budget, std::string_view item){ + const int* count = budget_count(item, budget); + if (count == nullptr){ + return std::nullopt; + } + return *count; +} + +// One `item` used: its budget count down, not below 0 (a KO-risk heal +// taken over budget comes out of the bag, not the later fights' budgets). +inline void spend_budget(FightBudget& budget, std::string_view item){ + int* count = budget_count(item, budget); + if (count != nullptr && *count > 0){ + (*count)--; + } +} + +// `a` and `b` added up. +inline FightBudget add_budgets(const FightBudget& a, const FightBudget& b){ + return FightBudget{ + .full_restore = a.full_restore + b.full_restore, + .x_special = a.x_special + b.x_special, + .x_speed = a.x_speed + b.x_speed, + .x_accuracy = a.x_accuracy + b.x_accuracy, + .guard_spec = a.guard_spec + b.guard_spec, + .elixir = a.elixir + b.elixir, + .hyper_potion = a.hyper_potion + b.hyper_potion, + .full_heal = a.full_heal + b.full_heal, + }; +} + +// "FR 3, X Sp 4, X Spe 2, X Acc 2, GS 1, Elixir 1, Hyper 2, FH 1". +inline std::string budget_text(const FightBudget& budget){ + return std::format( + "FR {}, X Sp {}, X Spe {}, X Acc {}, GS {}, Elixir {}, Hyper {}, FH {}", + budget.full_restore, budget.x_special, budget.x_speed, budget.x_accuracy, budget.guard_spec, budget.elixir, + budget.hyper_potion, budget.full_heal + ); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.cpp new file mode 100644 index 0000000000..de6369db68 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.cpp @@ -0,0 +1,52 @@ +/* AutoStory League Fight Data + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "PokemonFRLG_AutoStoryLeagueFightData.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +const LeagueFightData* league_fight_data(const LeaguePlanData& plan, std::string_view name){ + for (const LeagueFightData& fight : plan.fights){ + if (fight.name == name){ + return &fight; + } + } + return nullptr; +} + +const LeagueFoePlan* league_foe_plan(const LeagueFightData& fight, size_t slot, std::string_view species){ + if (slot < fight.foes.size() && fight.foes[slot].species == species){ + return &fight.foes[slot]; + } + for (const LeagueFoePlan& foe : fight.foes){ + if (foe.species == species){ + return &foe; + } + } + return nullptr; +} + +int count_of(const SlugCounts& counts, std::string_view name){ + const auto it = counts.find(name); + return it == counts.end() ? 0 : it->second; +} + +int spendable(const LeagueFightData& fight, const SlugCounts& bag, std::string_view item){ + return count_of(bag, item) - count_of(fight.reserve_items, item); +} + +int pp_above_reserve(const LeagueFightData& fight, std::string_view move, int pp){ + return pp - count_of(fight.reserve_pp, move); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.h new file mode 100644 index 0000000000..b1c95c00f2 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.h @@ -0,0 +1,43 @@ +/* AutoStory League Fight Data + * + * From: https://github.com/PokemonAutomation/ + * + * One fight of the League plan (PokemonFRLG_AutoStoryLeaguePlanData.h): + * finding it and its foes, and what it holds back for later fights. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeagueFightData_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeagueFightData_H + +#include +#include +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The fight `name` in `plan`; none if it has none. +const LeagueFightData* league_fight_data(const LeaguePlanData& plan, std::string_view name); + +// The foe at party `slot`, or, when another species is there (a party cut +// short), the first of `species`; none if the fight has none. +const LeagueFoePlan* league_foe_plan(const LeagueFightData& fight, size_t slot, std::string_view species); + +// `counts`'s count of `name`; 0 if it has none. +int count_of(const SlugCounts& counts, std::string_view name); + +// The bag's count of `item` above the fight's reserve for it. +int spendable(const LeagueFightData& fight, const SlugCounts& bag, std::string_view item); + +// `pp` of `move` above the fight's reserve for it. +int pp_above_reserve(const LeagueFightData& fight, std::string_view move, int pp); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.cpp new file mode 100644 index 0000000000..464eece559 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.cpp @@ -0,0 +1,118 @@ +/* AutoStory League Foes + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "PokemonFRLG_AutoStoryLeagueFoes.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr std::string_view FOES_FILE = "frlg-league-foes"; +constexpr std::string_view FOES_FORMAT = "frlg-league-foes/1"; + +uint16_t stat_of(const JsonObject& stats, const std::string& key){ + return static_cast(stats.get_integer_throw(key)); +} + +LeagueMoveData move_of(const JsonObject& object){ + LeagueMoveData move{ + .type = Pokemon::POKEMON_TYPE_SLUGS().get_enum(object.get_string_throw("type"), Pokemon::PokemonType::NONE), + .power = static_cast(object.get_integer_throw("power")), + .priority = static_cast(object.get_integer_default("priority", 0)), + .physical = object.get_boolean_default("physical", false), + .two_turn = object.get_boolean_default("two_turn", false), + }; + // The export writes 101 for a move that never misses. + const int accuracy = static_cast(object.get_integer_throw("accuracy")); + if (accuracy <= 100){ + move.accuracy = accuracy; + } + if (const JsonValue* fixed = object.get_value("fixed_damage")){ + move.fixed_damage = static_cast(fixed->to_integer_throw()); + } + if (const JsonArray* hits = object.get_array("hits")){ + move.hits = std::pair(static_cast((*hits)[0].to_integer_throw()), static_cast((*hits)[1].to_integer_throw())); + } + return move; +} + +LeagueFoeData foe_of(const JsonObject& object){ + const JsonObject& stats = object.get_object_throw("stats"); + LeagueFoeData foe{ + .species = object.get_string_throw("species"), + .level = static_cast(object.get_integer_throw("level")), + .ability = object.get_string_default("ability"), + .stats = Stats{ + .hp = stat_of(stats, "hp"), .attack = stat_of(stats, "atk"), .defense = stat_of(stats, "def"), + .sp_attack = stat_of(stats, "spa"), .sp_defense = stat_of(stats, "spd"), .speed = stat_of(stats, "spe"), + }, + }; + if (const std::string* item = object.get_string("held_item")){ + foe.held_item = *item; + } + for (const JsonValue& move : object.get_array_throw("moves")){ + foe.moves.push_back(move.to_string_throw()); + } + return foe; +} + +LeagueTrainerData trainer_of(const JsonObject& object){ + LeagueTrainerData trainer; + for (const auto& [item, count] : object.get_object_throw("items")){ + trainer.items[item] = static_cast(count.to_integer_throw()); + } + for (const JsonValue& foe : object.get_array_throw("party")){ + trainer.party.push_back(foe_of(foe.to_object_throw())); + } + return trainer; +} + +} // namespace + + +LeagueFoesData parse_league_foes(std::string_view json){ + const JsonValue value = parse_json(std::string(json)); + const JsonObject& root = value.to_object_throw(); + if (root.get_string_default("format") != FOES_FORMAT){ + throw ParseException(std::format("{}.json: not a {} file.", FOES_FILE, FOES_FORMAT)); + } + LeagueFoesData data; + for (const auto& [name, move] : root.get_object_throw("moves")){ + data.moves[name] = move_of(move.to_object_throw()); + } + for (const auto& [name, trainer] : root.get_object_throw("trainers")){ + data.trainers[name] = trainer_of(trainer.to_object_throw()); + } + return data; +} + +const LeagueFoesData& league_foes_data(){ + static const LeagueFoesData DATA = []{ + for (const auto& [file, text] : autostory_checkpoint_json()){ + if (file == FOES_FILE){ + return parse_league_foes(text); + } + } + throw ParseException(std::format("StoryData/{}.json is not built into the program.", FOES_FILE)); + }(); + return DATA; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.h new file mode 100644 index 0000000000..e38edd0e9b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.h @@ -0,0 +1,86 @@ +/* AutoStory League Foes + * + * From: https://github.com/PokemonAutomation/ + * + * The League trainers' parties as PokemonSimulation's League sim fights + * them, built into the program from StoryData/frlg-league-foes.json + * (format "frlg-league-foes/1"): each slot's species, level, ability, + * raw stats, held item and moves, each trainer's items, and the moves' + * data the planned policy's damage needs. The file is exported from the + * sim's data/runs/pokeguy-leafgreen-15934/battle-reference.json with the + * stats its Showdown Gen 3 engine gives (the file's "source"); it is not + * edited by hand. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeagueFoes_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeagueFoes_H + +#include +#include +#include +#include +#include +#include +#include "Pokemon/Pokemon_Types.h" +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" +#include "PokemonFRLG_AutoStoryStats.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// A move as the League sim's damage reads it. +struct LeagueMoveData{ + Pokemon::PokemonType type = Pokemon::PokemonType::NONE; + int power = 0; + // Percent; none for a move that never misses. + std::optional accuracy = std::nullopt; + int priority = 0; + // Gen 3's split by type. + bool physical = false; + bool two_turn = false; + // Damage that doesn't depend on stats (Dragon Rage: 40). + std::optional fixed_damage = std::nullopt; + // Hits per use, fewest and most (Double Slap: 2 to 5). + std::optional> hits = std::nullopt; +}; + +// One Pokemon of a League trainer's party. +struct LeagueFoeData{ + std::string species = {}; + int level = 1; + // Showdown's ability id ("waterabsorb", "thickfat"). + std::string ability = {}; + Stats stats = {}; + std::optional held_item = std::nullopt; + std::vector moves = {}; +}; + +// A League trainer: its items and its party, in slot order. +struct LeagueTrainerData{ + // Its items by slug ("full-restore": 2). + SlugCounts items = {}; + std::vector party = {}; +}; + +// The whole file: the moves' data and every League trainer. +struct LeagueFoesData{ + std::map> moves = {}; + // By trainer ("TRAINER_ELITE_FOUR_LORELEI"). + std::map> trainers = {}; +}; + +// The data in `json`; throws ParseException on another format. +LeagueFoesData parse_league_foes(std::string_view json); + +// The data built into the program (StoryData/frlg-league-foes.json). +const LeagueFoesData& league_foes_data(); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.cpp new file mode 100644 index 0000000000..4391492183 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.cpp @@ -0,0 +1,461 @@ +/* AutoStory League Parity Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Each decision of StoryData/frlg-league-parity.json (PokemonSimulation's + * pokesim.cli.frlg_league_parity: N League chains of its planned policy) + * holds what the program can read or track and, apart, what only the + * sim knows ("hidden": the foe's exact HP, its exact sleep counter, its + * moves' PP). The program's policy decides each turn twice: from the + * state the program can see, and from that state with the hidden part + * put back. With the hidden part back it must choose as the sim did; a + * visible-state difference is put down to the hidden part that fixes it. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_AutoStoryLeagueFightData.h" +#include "PokemonFRLG_AutoStoryLeagueFoes.h" +#include "PokemonFRLG_AutoStoryPlannedBattle.h" +#include "PokemonFRLG_AutoStoryPlannedBetween.h" +#include "PokemonFRLG_AutoStoryPlannedPolicy.h" +#include "PokemonFRLG_AutoStoryTable.h" +#include "PokemonFRLG_AutoStoryLeagueParity_Tests.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr std::string_view PARITY_FORMAT = "frlg-league-parity/1"; + +// What the sim knows and the program can't, put back one at a time. +enum class Hidden{ + FOE_HP, + FOE_SLEEP, + FOE_PP, +}; +constexpr std::array ALL_HIDDEN{Hidden::FOE_HP, Hidden::FOE_SLEEP, Hidden::FOE_PP}; + +std::string_view hidden_name(Hidden hidden){ + switch (hidden){ + case Hidden::FOE_HP: + return "foe HP (bar)"; + case Hidden::FOE_SLEEP: + return "foe sleep length"; + case Hidden::FOE_PP: + return "foe PP"; + } + return ""; +} + +PlannedStatus planned_status_of(std::string_view name){ + static const std::map STATUSES{ + {"none", PlannedStatus::NONE}, {"poison", PlannedStatus::POISON}, {"paralysis", PlannedStatus::PARALYSIS}, + {"sleep", PlannedStatus::SLEEP}, {"burn", PlannedStatus::BURN}, {"freeze", PlannedStatus::FREEZE}, + }; + const auto it = STATUSES.find(name); + return it == STATUSES.end() ? PlannedStatus::NONE : it->second; +} + +// The status as the program reads it off our HP box. +StatusCondition condition_of(std::string_view name){ + switch (planned_status_of(name)){ + case PlannedStatus::NONE: + return StatusCondition::NONE; + case PlannedStatus::POISON: + return StatusCondition::POISON; + case PlannedStatus::PARALYSIS: + return StatusCondition::PARALYSIS; + case PlannedStatus::SLEEP: + return StatusCondition::SLEEP; + case PlannedStatus::BURN: + case PlannedStatus::FREEZE: + return StatusCondition::OTHER; + } + return StatusCondition::NONE; +} + +int integer(const JsonObject& object, const std::string& key){ + return static_cast(object.get_integer_default(key, 0)); +} + +SlugCounts counts_of(const JsonObject& object){ + SlugCounts counts; + for (const auto& [name, count] : object){ + counts[name] = static_cast(count.to_integer_throw()); + } + return counts; +} + +StatStages stages_of(const JsonObject& object){ + const JsonObject& stages = object.get_object_throw("stages"); + return StatStages{ + .attack = integer(stages, "atk"), .defense = integer(stages, "def"), .sp_attack = integer(stages, "spa"), + .sp_defense = integer(stages, "spd"), .speed = integer(stages, "spe"), .accuracy = integer(stages, "accuracy"), + .evasion = integer(stages, "evasion"), + }; +} + +FieldWeather weather_of(std::string_view name){ + if (name == "sun"){ + return FieldWeather::SUN; + } + if (name == "rain"){ + return FieldWeather::RAIN; + } + return FieldWeather::NONE; +} + +BattleTrackState track_of(const JsonObject& line){ + const JsonObject& own = line.get_object_throw("own"); + const JsonObject& foe = line.get_object_throw("foe"); + const JsonObject& field = line.get_object_throw("field"); + BattleTrackState track{ + .own = stages_of(own), + .mist_turns = integer(own, "mist_turns"), + .foe = stages_of(foe), + .foe_status = planned_status_of(foe.get_string_throw("status")), + .foe_sleep_turns = integer(foe, "sleep_min_left"), + .foe_recharging = foe.get_boolean_default("recharging", false), + .weather = weather_of(field.get_string_throw("weather")), + .weather_turns = integer(field, "weather_turns"), + .trainer_full_restores = integer(line.get_object_throw("trainer_state"), "full_restores_used"), + }; + if (const std::string* charging = foe.get_string("charging")){ + track.foe_charging = *charging; + } + return track; +} + +const LeagueTrainerData& trainer_of(const std::string& trainer){ + const auto it = league_foes_data().trainers.find(trainer); + if (it == league_foes_data().trainers.end()){ + throw ParseException(std::format("frlg-league-parity.json: no League trainer {}.", trainer)); + } + return it->second; +} + +PlannedFoeTrack foe_track_of(const JsonObject& line){ + const LeagueTrainerData& trainer = trainer_of(line.get_string_throw("trainer")); + const JsonObject& foe = line.get_object_throw("foe"); + const size_t slot = static_cast(foe.get_integer_throw("slot")); + if (slot >= trainer.party.size()){ + throw ParseException(std::format("frlg-league-parity.json: no party slot {}.", slot)); + } + return PlannedFoeTrack{ + .foe = trainer.party[slot], + .slot = slot, + .fill = foe.get_double_throw("fill"), + .party_alive = integer(line.get_object_throw("trainer_state"), "foes_left"), + .full_restores_carried = count_of(trainer.items, "full-restore"), + }; +} + +PartyMember lead_of(const JsonObject& own){ + const JsonObject& stats = own.get_object_throw("stats"); + PartyMember lead{ + .species = own.get_string_throw("species"), + .level = static_cast(own.get_integer_throw("level")), + .stats = Stats{ + .hp = static_cast(integer(stats, "hp")), .attack = static_cast(integer(stats, "atk")), + .defense = static_cast(integer(stats, "def")), .sp_attack = static_cast(integer(stats, "spa")), + .sp_defense = static_cast(integer(stats, "spd")), .speed = static_cast(integer(stats, "spe")), + }, + }; + for (const JsonValue& value : own.get_array_throw("moves")){ + const JsonObject& move = value.to_object_throw(); + lead.moves.push_back(KnownMove{.move = move.get_string_throw("id"), .pp = static_cast(integer(move, "pp"))}); + } + return lead; +} + +// The state the program builds from what it can see. +PlannedState visible_state(const JsonObject& line){ + const JsonObject& own = line.get_object_throw("own"); + const PlannedInputs inputs{ + .lead = lead_of(own), + .hp = integer(own, "hp"), + .status = condition_of(own.get_string_throw("status")), + .track = track_of(line), + .foe = foe_track_of(line), + .bag = counts_of(line.get_object_throw("bag")), + }; + return planned_state(inputs, league_foes_data()); +} + +void put_back(const JsonObject& hidden, Hidden part, PlannedState& state){ + switch (part){ + case Hidden::FOE_HP: + state.foe.hp = integer(hidden, "foe_hp"); + return; + case Hidden::FOE_SLEEP: + state.foe.sleeping = integer(hidden, "foe_sleep_turns") > 1; + return; + case Hidden::FOE_PP:{ + const SlugCounts pp = counts_of(hidden.get_object_throw("foe_pp")); + for (PlannedMove& move : state.foe.moves){ + move.pp = count_of(pp, move.id); + } + return; + } + } +} + + +// The sim's choice of one turn. +struct SimChoice{ + std::string row; + std::optional item; + std::optional move_slot; +}; + +SimChoice sim_choice(const JsonObject& line){ + const JsonObject& choice = line.get_object_throw("choice"); + SimChoice sim{.row = choice.get_string_throw("row")}; + if (const std::string* item = choice.get_string("item")){ + sim.item = *item; + } + if (const JsonValue* slot = choice.get_value("move_slot")){ + sim.move_slot = static_cast(slot->to_integer_throw()); + } + return sim; +} + +// plan:struggle's move is the caller's best attack, not the policy's. +bool same_choice(const PlannedChoice& program, const SimChoice& sim){ + if (program.row != sim.row || program.item != sim.item){ + return false; + } + return sim.row == "plan:struggle" || program.move_slot == sim.move_slot; +} + +std::string choice_text(const PlannedChoice& choice){ + return std::format("{} {}", choice.row, + choice.item ? *choice.item : choice.move_slot ? std::format("move {}", *choice.move_slot) : std::string("-")); +} + + +// The tallies by the sim's row. +struct RowTally{ + int decisions = 0; + // The program chose otherwise from what it can see. + int visible = 0; + // ... and with the hidden part put back. + int oracle = 0; +}; + +class Parity{ +public: + void turn(const JsonObject& line){ + const SimChoice sim = sim_choice(line); + const LeagueFightData* fight = league_fight_data(league_plan_data(), line.get_string_throw("fight")); + if (fight == nullptr){ + throw ParseException("frlg-league-parity.json: a fight the League plan doesn't have."); + } + const int streak = integer(line, "streak"); + const PlannedState visible = visible_state(line); + RowTally& tally = m_rows[sim.row]; + tally.decisions++; + if (same_choice(choose_planned(visible, *fight, streak), sim)){ + return; + } + tally.visible++; + const JsonObject& hidden = line.get_object_throw("hidden"); + PlannedState oracle = visible; + for (Hidden part : ALL_HIDDEN){ + put_back(hidden, part, oracle); + } + const PlannedChoice program = choose_planned(oracle, *fight, streak); + if (!same_choice(program, sim)){ + tally.oracle++; + note_oracle(line, program, sim); + return; + } + m_causes[cause(visible, hidden, *fight, streak, sim)]++; + } + void between(const JsonObject& line); + std::string table() const; + int oracle_mismatches() const; + +private: + std::string cause(const PlannedState& visible, const JsonObject& hidden, const LeagueFightData& fight, int streak, const SimChoice& sim) const{ + for (Hidden part : ALL_HIDDEN){ + PlannedState state = visible; + put_back(hidden, part, state); + if (same_choice(choose_planned(state, fight, streak), sim)){ + return std::string(hidden_name(part)); + } + } + return "several hidden parts"; + } + void note_oracle(const JsonObject& line, const PlannedChoice& program, const SimChoice& sim){ + const JsonObject& foe = line.get_object_throw("foe"); + const bool screens = integer(foe, "reflect_turns") > 0 || integer(foe, "light_screen_turns") > 0; + if (screens){ + m_screen_lines++; + } + if (m_examples.size() < 12){ + m_examples.push_back(std::format("chain {} {} turn {} vs {}{}: sim {} {}, program {}", + integer(line, "chain"), line.get_string_throw("fight"), integer(line, "turn"), foe.get_string_throw("species"), + screens ? " (Reflect/Light Screen up)" : "", sim.row, sim.item ? *sim.item : sim.move_slot ? std::format("move {}", *sim.move_slot) : "-", + choice_text(program))); + } + } + + std::map m_rows; + std::map m_causes; + int m_screen_lines = 0; + std::vector m_examples; +}; + +void Parity::between(const JsonObject& line){ + const LeagueFightData* next = league_fight_data(league_plan_data(), line.get_string_throw("fight")); + if (next == nullptr){ + throw ParseException("frlg-league-parity.json: a fight the League plan doesn't have."); + } + const JsonObject& carry = line.get_object_throw("carry"); + PlannedCarry program{ + .hp = integer(carry, "hp"), + .max_hp = integer(carry, "max_hp"), + .status = planned_status_of(carry.get_string_throw("status")), + .pp = counts_of(carry.get_object_throw("pp")), + .full_pp = counts_of(carry.get_object_throw("full_pp")), + .bag = counts_of(carry.get_object_throw("bag")), + }; + std::vector sim; + for (const JsonValue& item : line.get_array_throw("used")){ + sim.push_back(item.to_string_throw()); + } + RowTally& tally = m_rows["between"]; + tally.decisions++; + if (planned_between(program, *next) != sim){ + tally.visible++; + tally.oracle++; + if (m_examples.size() < 12){ + m_examples.push_back(std::format("chain {} before {}: the between top-ups differ", integer(line, "chain"), line.get_string_throw("fight"))); + } + } +} + +std::string Parity::table() const{ + std::string text = "row: decisions, differ from what the program sees, differ with the hidden part back\n"; + for (const auto& [row, tally] : m_rows){ + text += std::format(" {}: {}, {}, {}\n", row, tally.decisions, tally.visible, tally.oracle); + } + text += "visible-only differences, by the hidden part that fixes them:\n"; + for (const auto& [cause, count] : m_causes){ + text += std::format(" {}: {}\n", cause, count); + } + text += std::format("with the hidden part back, {} differ with the foe's Reflect or Light Screen up\n", m_screen_lines); + for (const std::string& example : m_examples){ + text += std::format(" {}\n", example); + } + return text; +} + +int Parity::oracle_mismatches() const{ + int total = 0; + for (const auto& [row, tally] : m_rows){ + total += tally.oracle; + } + return total; +} + +const JsonObject& parity_root(const JsonValue& value){ + const JsonObject& root = value.to_object_throw(); + if (root.get_string_default("format") != PARITY_FORMAT){ + throw ParseException(std::format("frlg-league-parity.json: not a {} file.", PARITY_FORMAT)); + } + return root; +} + +std::string parity_text(std::string_view file){ + for (const auto& [name, text] : autostory_checkpoint_json()){ + if (name == file){ + return text; + } + } + throw ParseException(std::format("StoryData/{}.json is not built into the program.", file)); +} + + +struct ParityInput{ + // A StoryData file of the sim's decisions. + std::string file = {}; +}; +struct ParityExpectation{ + // Decisions the program makes otherwise with the hidden part put back. + int mismatches = 0; +}; +struct ParityCase{ + std::string name; + ParityInput input; + ParityExpectation expectation; +}; + +class Test_LeagueParity : public UnitTest{ +public: + explicit Test_LeagueParity(ParityCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryLeagueParity - {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const JsonValue value = parse_json(parity_text(m_case.input.file)); + Parity parity; + for (const JsonValue& decision : parity_root(value).get_array_throw("decisions")){ + const JsonObject& line = decision.to_object_throw(); + if (line.get_string_throw("kind") == "between"){ + parity.between(line); + }else{ + parity.turn(line); + } + } + const std::string table = parity.table(); + logger.log(table); + if (parity.oracle_mismatches() != m_case.expectation.mismatches){ + return std::format("expected {} decisions to differ with the hidden part put back, read {}:\n{}", + m_case.expectation.mismatches, parity.oracle_mismatches(), table); + } + return true; + } + +private: + ParityCase m_case; +}; + +const ParityCase PARITY_CASES[] = { + { + .name = "the sim's planned League chains", + .input = {.file = "frlg-league-parity"}, + .expectation = {.mismatches = 0}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryLeagueParity(UnitTestDatabase& database){ + for (const ParityCase& test_case : PARITY_CASES){ + database.add(test_case); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.h new file mode 100644 index 0000000000..2bae72f33b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.h @@ -0,0 +1,30 @@ +/* AutoStory League Parity Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of the League parity test: every decision PokemonSimulation's + * planned policy made in a set of League chains + * (StoryData/frlg-league-parity.json, written by the sim's + * pokesim.cli.frlg_league_parity), made again by the program's policy. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeagueParity_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeagueParity_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Registers the League parity test. +void add_tests_AutoStoryLeagueParity(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.cpp new file mode 100644 index 0000000000..dbf6d832c4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.cpp @@ -0,0 +1,245 @@ +/* AutoStory League Plan + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "PokemonFRLG_AutoStoryLeaguePlan.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The bag the League is restocked to (20.01a's Mart and earlier rows): +// the bag of 2026-11-16, plus Full Heals for the fights' budgets. Not a +// precondition: the League is planned from whatever the bag holds (user, +// 2026-11-16: no money left for the next run). +struct MinimumRow{ + std::string_view item; + int count; +}; +constexpr MinimumRow LEAGUE_MINIMUM[] = { + {"full-restore", 8}, + {"x-special", 15}, + {"x-speed", 5}, + {"x-accuracy", 3}, + {"guard-spec", 2}, + {"max-elixir", 1}, + {"elixir", 1}, + {"super-potion", 6}, + {"full-heal", 6}, +}; + +// The Champion keeps at least this many Full Restores (at most half the +// bag): its fight is where the sim's chains end. +constexpr int CHAMPION_FULL_RESTORES = 3; + +// One fight's row: its Full Restore weight (the sim's median spend in +// tenths), the setup items it wants (the note's budgeted-C2 table, X Sp / +// X Spe / X Acc), Guard Spec and Elixirs, its entry HP and PP, and the +// Hyper (or Max) Potions and Full Heals it wants: two each against +// Lorelei's Lapras (user, 2026-11-16), Full Heals against Agatha's +// Hypnosis. +struct FightRow{ + std::string_view trainer; + std::string_view name; + int full_restore_weight; + int x_special; + int x_speed; + int x_accuracy; + int guard_spec; + int elixir; + int entry_hp_percent; + int surf_pp_floor; + int blizzard_pp_floor; + int hyper_potion; + int full_heal; +}; +constexpr size_t FIGHTS = 5; +constexpr std::array LEAGUE_FIGHTS = {{ + // Full HP from Indigo Plateau's nurse. + {"TRAINER_ELITE_FOUR_LORELEI", "lorelei", 6, 4, 1, 0, 0, 0, 100, 0, 0, 2, 2}, + // 80%: PokeGuy's 130/162; a 30% floor lost 26% of the sim's chains here. + {"TRAINER_ELITE_FOUR_BRUNO", "bruno", 15, 4, 5, 0, 0, 0, 80, 7, 0, 1, 0}, + // 27%: PokeGuy's 45/165, Torrent on. + {"TRAINER_ELITE_FOUR_AGATHA", "agatha", 2, 2, 1, 0, 0, 0, 27, 6, 0, 1, 2}, + {"TRAINER_ELITE_FOUR_LANCE", "lance", 30, 3, 1, 1, 0, 1, 100, 6, 5, 2, 1}, + {"TRAINER_CHAMPION_FIRST_BULBASAUR", "champion", 22, 4, 2, 2, 1, 1, 100, 8, 2, 2, 1}, +}}; + +using Split = std::array; + +int held(const BagCounts& bag, std::string_view item){ + const auto found = bag.find(item); + return found == bag.end() ? 0 : std::max(0, found->second); +} + +// `total` split in proportion to `weights` (largest remainder, ties to +// the later fight); all zero if the weights are. +Split split_by_weight(int total, const Split& weights, size_t count = FIGHTS){ + Split out{}; + int sum = 0; + for (size_t c = 0; c < count; c++){ + sum += weights[c]; + } + if (sum <= 0 || total <= 0){ + return out; + } + int given = 0; + std::array remainder{}; + for (size_t c = 0; c < count; c++){ + out[c] = total * weights[c] / sum; + remainder[c] = total * weights[c] % sum; + given += out[c]; + } + for (; given < total; given++){ + size_t best = 0; + for (size_t c = 0; c < count; c++){ + if (remainder[c] >= remainder[best]){ + best = c; + } + } + out[best]++; + remainder[best] = -1; + } + return out; +} + +// `total` against each fight's wanted count: all of it when the bag +// covers them (the rest spare), else the Champion first and the rest in +// proportion. +Split split_wanted(int total, const Split& wanted, int& spare){ + int sum = 0; + for (const int count : wanted){ + sum += count; + } + if (total >= sum){ + spare = total - sum; + return wanted; + } + spare = 0; + const int champion = std::min(wanted[FIGHTS - 1], total); + Split out = split_by_weight(total - champion, wanted, FIGHTS - 1); + out[FIGHTS - 1] = champion; + return out; +} + +Split split_full_restores(int total){ + Split weights{}; + for (size_t c = 0; c < FIGHTS; c++){ + weights[c] = LEAGUE_FIGHTS[c].full_restore_weight; + } + Split out = split_by_weight(total, weights); + const int reserve = std::min(CHAMPION_FULL_RESTORES, total / 2); + for (size_t c = 0; c + 1 < FIGHTS && out[FIGHTS - 1] < reserve; c++){ + const int moved = std::min(out[c], reserve - out[FIGHTS - 1]); + out[c] -= moved; + out[FIGHTS - 1] += moved; + } + return out; +} + +// The fights' wanted counts of one item: `member` of each row. +Split wanted_of(int FightRow::* member){ + Split out{}; + for (size_t c = 0; c < FIGHTS; c++){ + out[c] = LEAGUE_FIGHTS[c].*member; + } + return out; +} + +} // namespace + + +std::optional league_shortfalls(const BagCounts& bag){ + std::string out; + for (const MinimumRow& row : LEAGUE_MINIMUM){ + const int count = held(bag, row.item); + if (count < row.count){ + out += std::format("{}{} {} of {}", out.empty() ? "" : ", ", row.item, count, row.count); + } + } + if (out.empty()){ + return std::nullopt; + } + return out; +} + +LeaguePlan plan_league(const BagCounts& bag){ + int spare_special = 0; + int spare_speed = 0; + int spare_accuracy = 0; + int spare_guard = 0; + int spare_elixir = 0; + int spare_hyper = 0; + int spare_full_heal = 0; + const Split full_restore = split_full_restores(held(bag, "full-restore")); + const Split special = split_wanted(held(bag, "x-special"), wanted_of(&FightRow::x_special), spare_special); + const Split speed = split_wanted(held(bag, "x-speed"), wanted_of(&FightRow::x_speed), spare_speed); + const Split accuracy = split_wanted(held(bag, "x-accuracy"), wanted_of(&FightRow::x_accuracy), spare_accuracy); + const Split guard = split_wanted(held(bag, "guard-spec"), wanted_of(&FightRow::guard_spec), spare_guard); + const Split elixir = split_wanted( + held(bag, "elixir") + held(bag, "max-elixir"), wanted_of(&FightRow::elixir), spare_elixir + ); + const Split hyper = split_wanted( + held(bag, "hyper-potion") + held(bag, "max-potion"), wanted_of(&FightRow::hyper_potion), spare_hyper + ); + const Split full_heal = split_wanted(held(bag, "full-heal"), wanted_of(&FightRow::full_heal), spare_full_heal); + LeaguePlan plan; + for (size_t c = 0; c < FIGHTS; c++){ + const FightRow& row = LEAGUE_FIGHTS[c]; + plan.fights.push_back(LeagueFightPlan{ + .trainer = std::string(row.trainer), + .name = std::string(row.name), + .budget = { + .full_restore = full_restore[c], .x_special = special[c], .x_speed = speed[c], + .x_accuracy = accuracy[c], .guard_spec = guard[c], .elixir = elixir[c], + .hyper_potion = hyper[c], .full_heal = full_heal[c], + }, + .entry_hp_percent = row.entry_hp_percent, + .surf_pp_floor = row.surf_pp_floor, + .blizzard_pp_floor = row.blizzard_pp_floor, + }); + } + plan.spare = FightBudget{ + .full_restore = 0, .x_special = spare_special, .x_speed = spare_speed, + .x_accuracy = spare_accuracy, .guard_spec = spare_guard, .elixir = spare_elixir, + .hyper_potion = spare_hyper, .full_heal = spare_full_heal, + }; + return plan; +} + +std::vector league_plan_lines(const LeaguePlan& plan){ + std::vector lines; + for (const LeagueFightPlan& fight : plan.fights){ + lines.push_back(std::format( + "League plan: {}: {}; enter at {}% HP, Surf >= {}, Blizzard >= {}.", + fight.name, budget_text(fight.budget), fight.entry_hp_percent, fight.surf_pp_floor, fight.blizzard_pp_floor + )); + } + lines.push_back("League plan: spare: " + budget_text(plan.spare) + "."); + return lines; +} + +const LeagueFightPlan* league_fight(const LeaguePlan& plan, std::string_view trainer){ + for (const LeagueFightPlan& fight : plan.fights){ + if (fight.trainer == trainer){ + return &fight; + } + } + return nullptr; +} + + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.h new file mode 100644 index 0000000000..bc59a8e2d7 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.h @@ -0,0 +1,100 @@ +/* AutoStory League Plan + * + * From: https://github.com/PokemonAutomation/ + * + * The Elite Four and the Champion are one checkpoint with no save between + * the fights (user, 2026-11-16), so the bag read at the League's start is + * all five fights get. This plans it out: a pure function from the bag's + * counts to an item budget per fight, and the rules between the fights. + * + * The planner (plan_league()): + * - LEAGUE_MINIMUM is the bag the League is restocked to; + * league_shortfalls() names what is short, for the log. The League + * is planned from whatever the bag holds (user, 2026-11-16). + * - Full Restores are spread over the five fights by the median each + * fight spends in PokemonSimulation's budgeted-C2 League chains + * (sim/frlg-e4-replica, ~/BDSPLab/notes/frlg-e4-replica-policy.md): + * Lance and the Champion take the most. The Champion keeps a reserve + * of at least CHAMPION_FULL_RESTORES (half the bag at most), taken + * from the earliest fights. + * - X Special, X Speed, X Accuracy, Guard Spec, the Elixirs, Hyper (and + * Max) Potions and Full Heals go by + * each fight's wanted count (the note's budgeted-C2 table); a bag + * short of the sum gives the Champion its count first and splits the + * rest in proportion. A bag with more than the sum keeps the extra + * as spare, which the KO-risk rules may still use. + * - Every split is largest-remainder, ties to the later fight. + * - What a fight leaves of its budget rolls forward to the next. + * + * Between the fights: between_fight_action() (PokemonFRLG_AutoStoryLeagueSteps.h) + * from each fight's entry HP and PP floors. + * + * The in-battle rules that spend the budget are in + * PokemonFRLG_AutoStoryBattlePolicy.h (BUDGETED_SETUP). + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeaguePlan_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeaguePlan_H + +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "PokemonFRLG_AutoStoryLeagueBudget.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// One League fight in the plan. +struct LeagueFightPlan{ + // The battle step's trainer ("TRAINER_ELITE_FOUR_LORELEI"). + std::string trainer; + // "lorelei". + std::string name; + FightBudget budget; + // The HP the lead enters with, in percent of its maximum. + int entry_hp_percent = 100; + // The PP the lead enters with, at least. + int surf_pp_floor = 0; + int blizzard_pp_floor = 0; +}; + +// The League's plan: the fights in order, and what the bag holds beyond +// their budgets. +struct LeaguePlan{ + std::vector fights; + FightBudget spare; +}; + +// The items `bag` holds less of than LEAGUE_MINIMUM, as "full-restore 7 +// of 8, max-elixir 0 of 1"; none when it holds enough. +std::optional league_shortfalls(const BagCounts& bag); + +// The budgets and between-fight rows for the five fights from `bag`. +LeaguePlan plan_league(const BagCounts& bag); + +// The plan, one line per fight, for the log. +std::vector league_plan_lines(const LeaguePlan& plan); + +// The fight in `plan` whose trainer is `trainer`, none if it isn't one. +const LeagueFightPlan* league_fight(const LeaguePlan& plan, std::string_view trainer); + +// A League run: the plan, and what the fights before have left of theirs. +struct LeagueRun{ + LeaguePlan plan; + FightBudget carried; +}; + +// Registers the League plan tests. +void add_tests_AutoStoryLeaguePlan(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.cpp new file mode 100644 index 0000000000..9eed49fd6f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.cpp @@ -0,0 +1,159 @@ +/* AutoStory League Plan Data + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr std::string_view PLAN_FILE = "frlg-league-plan"; +constexpr std::string_view PLAN_FORMAT = "frlg-league-plan/1"; + +struct ItemName{ + std::string_view sim; + std::string_view slug; +}; +// The plan's item names (PokemonSimulation's) and the program's slugs. +constexpr ItemName ITEM_NAMES[] = { + {"xspecial", "x-special"}, {"xspeed", "x-speed"}, {"xaccuracy", "x-accuracy"}, + {"xattack", "x-attack"}, {"xdefend", "x-defend"}, {"guardspec", "guard-spec"}, + {"fullrestore", "full-restore"}, {"maxpotion", "max-potion"}, {"hyperpotion", "hyper-potion"}, + {"superpotion", "super-potion"}, {"potion", "potion"}, {"fullheal", "full-heal"}, + {"parlyzheal", "parlyz-heal"}, {"antidote", "antidote"}, {"awakening", "awakening"}, + {"burnheal", "burn-heal"}, {"iceheal", "ice-heal"}, {"elixir", "elixir"}, {"maxelixir", "max-elixir"}, +}; + +std::string item_slug(std::string_view sim){ + for (const ItemName& name : ITEM_NAMES){ + if (name.sim == sim){ + return std::string(name.slug); + } + } + throw ParseException(std::format("{}.json: unknown item \"{}\".", PLAN_FILE, sim)); +} + +struct TrainerFight{ + std::string_view prefix; + std::string_view fight; +}; +constexpr TrainerFight TRAINER_FIGHTS[] = { + {"TRAINER_ELITE_FOUR_LORELEI", "lorelei"}, + {"TRAINER_ELITE_FOUR_BRUNO", "bruno"}, + {"TRAINER_ELITE_FOUR_AGATHA", "agatha"}, + {"TRAINER_ELITE_FOUR_LANCE", "lance"}, + {"TRAINER_CHAMPION_FIRST", "champion"}, +}; + +SlugCounts counts_of(const JsonObject* object, bool items){ + SlugCounts counts; + if (object == nullptr){ + return counts; + } + for (const auto& [name, value] : *object){ + counts[items ? item_slug(name) : name] = static_cast(value.to_integer_throw()); + } + return counts; +} + +LeagueFoePlan foe_of(const JsonObject& object){ + LeagueFoePlan foe{.species = object.get_string_throw("species")}; + for (const JsonValue& move : object.get_array_throw("moves")){ + foe.moves.push_back(move.to_string_throw()); + } + const JsonArray* setup = object.get_array("setup"); + if (setup == nullptr){ + return foe; + } + for (const JsonValue& value : *setup){ + const JsonObject& goal = value.to_object_throw(); + LeagueSetupGoal parsed{ + .item = item_slug(goal.get_string_throw("item")), + .stage = static_cast(goal.get_integer_default("stage", 1)), + }; + if (const std::string* serves = goal.get_string("serves")){ + parsed.serves = *serves; + } + foe.setup.push_back(std::move(parsed)); + } + return foe; +} + +LeagueFightData fight_of(const std::string& name, const JsonObject& object){ + LeagueFightData fight{.name = name}; + for (const JsonValue& foe : object.get_array_throw("foes")){ + fight.foes.push_back(foe_of(foe.to_object_throw())); + } + if (const JsonObject* between = object.get_object("between")){ + if (const JsonValue* hp = between->get_value("hp")){ + fight.between_hp = hp->to_double_throw(); + } + fight.between_pp = counts_of(between->get_object("pp"), false); + } + if (const JsonObject* reserve = object.get_object("reserve")){ + fight.reserve_pp = counts_of(reserve->get_object("pp"), false); + fight.reserve_items = counts_of(reserve->get_object("items"), true); + } + return fight; +} + +} // namespace + + +LeaguePlanData parse_league_plan(std::string_view json){ + const JsonValue value = parse_json(std::string(json)); + const JsonObject& root = value.to_object_throw(); + if (root.get_string_default("format") != PLAN_FORMAT){ + throw ParseException(std::format("{}.json: not a {} plan.", PLAN_FILE, PLAN_FORMAT)); + } + LeaguePlanData plan; + const JsonObject& fights = root.get_object_throw("fights"); + // In the League's order, whatever the file's. + for (const TrainerFight& trainer : TRAINER_FIGHTS){ + const std::string name(trainer.fight); + if (const JsonObject* fight = fights.get_object(name)){ + plan.fights.push_back(fight_of(name, *fight)); + } + } + return plan; +} + +const LeaguePlanData& league_plan_data(){ + static const LeaguePlanData PLAN = []{ + for (const auto& [file, text] : autostory_checkpoint_json()){ + if (file == PLAN_FILE){ + return parse_league_plan(text); + } + } + throw ParseException(std::format("StoryData/{}.json is not built into the program.", PLAN_FILE)); + }(); + return PLAN; +} + +std::optional league_fight_name(std::string_view trainer){ + for (const TrainerFight& fight : TRAINER_FIGHTS){ + if (trainer.starts_with(fight.prefix)){ + return std::string(fight.fight); + } + } + return std::nullopt; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.h new file mode 100644 index 0000000000..90aa426fbc --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.h @@ -0,0 +1,87 @@ +/* AutoStory League Plan Data + * + * From: https://github.com/PokemonAutomation/ + * + * The League plan PokemonSimulation's planned policy runs + * (docs/battles/frlg-league-plan.md, format "frlg-league-plan/1"), built + * into the program from StoryData/frlg-league-plan.json: for each fight, + * each foe's move ranking and setup goals, what to restore before the + * fight, and the PP and items the fight must leave for later ones. + * + * Items and moves are the program's slugs ("x-special", "surf"); the + * file's sim names ("xspecial") are mapped when it is read. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeaguePlanData_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeaguePlanData_H + +#include +#include +#include +#include +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Counts by item or move slug. +using SlugCounts = std::map>; + +// An X item (or Guard Spec) to use until its stage is reached. +struct LeagueSetupGoal{ + std::string item = {}; + int stage = 1; + // The move the stage is for: the goal is skipped while that move has + // no PP above the fight's reserve. None for Guard Spec. + std::optional serves = std::nullopt; +}; + +// One foe of a fight, by its trainer's party slot. +struct LeagueFoePlan{ + std::string species = {}; + // The ranking: the first with PP above the reserve is used. + std::vector moves = {}; + std::vector setup = {}; +}; + +// One fight of the plan: its foes, the top-ups before it and its reserves. +struct LeagueFightData{ + // "lorelei", "bruno", "agatha", "lance", "champion". + std::string name = {}; + std::vector foes = {}; + // Before this fight: the HP to restore to, as a share of the maximum + // (none: no target), and each move's PP floor. + std::optional between_hp = std::nullopt; + SlugCounts between_pp = {}; + // PP this fight must not spend, by move, and the items it must leave + // in the bag. + SlugCounts reserve_pp = {}; + SlugCounts reserve_items = {}; +}; + +// The whole plan: its fights in the League's order. +struct LeaguePlanData{ + std::vector fights = {}; +}; + +// The plan in `json`; throws ParseException on another format or an +// unknown item. +LeaguePlanData parse_league_plan(std::string_view json); + +// The plan built into the program (StoryData/frlg-league-plan.json). +const LeaguePlanData& league_plan_data(); + +// The fight a battle step's trainer ("TRAINER_ELITE_FOUR_LORELEI", +// "TRAINER_CHAMPION_FIRST_BULBASAUR") is, as the plan names it; none for +// another trainer. +std::optional league_fight_name(std::string_view trainer); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan_Tests.cpp new file mode 100644 index 0000000000..18d47d3a6e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan_Tests.cpp @@ -0,0 +1,651 @@ +/* AutoStory League Plan Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The League planner (PokemonFRLG_AutoStoryLeaguePlan.h) on the bag of + * 2026-11-16, a smaller and a larger one; the minimum check; the items + * between the fights (PokemonFRLG_AutoStoryLeagueSteps.h); and the + * budgeted C2 policy's turns (PokemonFRLG_AutoStoryBattlePolicy.h). + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryLeaguePlan.h" +#include "PokemonFRLG_AutoStoryLeagueSteps.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The bag at the League's start on console B, 2026-11-16. +const BagCounts BAG_NOW = { + {"full-restore", 8}, {"x-special", 15}, {"x-speed", 5}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"elixir", 1}, {"super-potion", 6}, {"full-heal", 2}, {"parlyz-heal", 2}, +}; + + +struct LeaguePlanInput{ + BagCounts bag; +}; + +struct LeaguePlanExpectation{ + // Lorelei, Bruno, Agatha, Lance, the Champion. + std::array budgets; + FightBudget spare; +}; + +struct LeaguePlanCase{ + std::string name; + LeaguePlanInput input; + LeaguePlanExpectation expectation; +}; + +class Test_LeaguePlan : public UnitTest{ +public: + explicit Test_LeaguePlan(LeaguePlanCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - League plan: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const LeaguePlan plan = plan_league(m_case.input.bag); + if (plan.fights.size() != m_case.expectation.budgets.size()){ + return std::format("expected {} fights, planned {}", m_case.expectation.budgets.size(), plan.fights.size()); + } + for (size_t c = 0; c < plan.fights.size(); c++){ + if (plan.fights[c].budget != m_case.expectation.budgets[c]){ + return std::format( + "{}: expected {}, planned {}", + plan.fights[c].name, budget_text(m_case.expectation.budgets[c]), budget_text(plan.fights[c].budget) + ); + } + } + if (plan.spare != m_case.expectation.spare){ + return std::format("spare: expected {}, planned {}", budget_text(m_case.expectation.spare), budget_text(plan.spare)); + } + return true; + } + +private: + LeaguePlanCase m_case; +}; + +FightBudget budget(int full_restore, int x_special, int x_speed, int x_accuracy, int guard_spec, int elixir){ + return FightBudget{ + .full_restore = full_restore, .x_special = x_special, .x_speed = x_speed, + .x_accuracy = x_accuracy, .guard_spec = guard_spec, .elixir = elixir, + }; +} + +// `base` with its Hyper (and Max) Potions and Full Heals. +FightBudget with_heals(FightBudget base, int hyper_potion, int full_heal){ + base.hyper_potion = hyper_potion; + base.full_heal = full_heal; + return base; +} + +const LeaguePlanCase LEAGUE_PLAN_CASES[] = { + { + .name = "the bag of 2026-11-16", + .input = {.bag = BAG_NOW}, + // Full Restores by the sim's medians, the Champion's reserve of 3 + // taken from Lorelei; 15 X Specials against 17 wanted, the + // Champion's 4 first. + .expectation = { + .budgets = { + budget(/*full_restore=*/0, /*x_special=*/3, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/2, /*x_special=*/3, /*x_speed=*/2, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + with_heals(budget(/*full_restore=*/0, /*x_special=*/2, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), /*hyper_potion=*/0, /*full_heal=*/1), + budget(/*full_restore=*/3, /*x_special=*/3, /*x_speed=*/1, /*x_accuracy=*/1, /*guard_spec=*/0, /*elixir=*/1), + with_heals(budget(/*full_restore=*/3, /*x_special=*/4, /*x_speed=*/2, /*x_accuracy=*/2, /*guard_spec=*/1, /*elixir=*/1), /*hyper_potion=*/0, /*full_heal=*/1), + }, + .spare = budget(/*full_restore=*/0, /*x_special=*/0, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/1, /*elixir=*/0), + }, + }, + { + .name = "a smaller bag", + .input = {.bag = { + {"full-restore", 4}, {"x-special", 10}, {"x-speed", 3}, {"x-accuracy", 2}, {"guard-spec", 1}, {"elixir", 1}, + }}, + // The Champion's Full Restore reserve is half the bag, 2. + .expectation = { + .budgets = { + budget(/*full_restore=*/0, /*x_special=*/2, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/0, /*x_special=*/2, /*x_speed=*/1, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/0, /*x_special=*/1, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/2, /*x_special=*/1, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/2, /*x_special=*/4, /*x_speed=*/2, /*x_accuracy=*/2, /*guard_spec=*/1, /*elixir=*/1), + }, + .spare = {}, + }, + }, + { + .name = "a larger bag (the note's buy)", + .input = {.bag = { + {"full-restore", 12}, {"x-special", 18}, {"x-speed", 9}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"elixir", 1}, {"super-potion", 6}, + }}, + // Every X Special wanted, one spare; Lance and the Champion take + // the extra Full Restores. + .expectation = { + .budgets = { + budget(/*full_restore=*/1, /*x_special=*/4, /*x_speed=*/1, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/2, /*x_special=*/4, /*x_speed=*/4, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/0, /*x_special=*/2, /*x_speed=*/1, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/5, /*x_special=*/3, /*x_speed=*/1, /*x_accuracy=*/1, /*guard_spec=*/0, /*elixir=*/1), + budget(/*full_restore=*/4, /*x_special=*/4, /*x_speed=*/2, /*x_accuracy=*/2, /*guard_spec=*/1, /*elixir=*/1), + }, + .spare = budget(/*full_restore=*/0, /*x_special=*/1, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/1, /*elixir=*/0), + }, + }, + { + .name = "the bag after the 2026-11-16 15:35 run, no restock", + .input = {.bag = { + {"full-restore", 7}, {"x-special", 10}, {"x-speed", 5}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"full-heal", 2}, + }}, + // The Champion's 4 X Specials first; its Full Heal first, the + // other to Agatha (Hypnosis). + .expectation = { + .budgets = { + budget(/*full_restore=*/0, /*x_special=*/2, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + budget(/*full_restore=*/1, /*x_special=*/2, /*x_speed=*/2, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), + with_heals(budget(/*full_restore=*/0, /*x_special=*/1, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/0, /*elixir=*/0), /*hyper_potion=*/0, /*full_heal=*/1), + budget(/*full_restore=*/3, /*x_special=*/1, /*x_speed=*/1, /*x_accuracy=*/1, /*guard_spec=*/0, /*elixir=*/0), + with_heals(budget(/*full_restore=*/3, /*x_special=*/4, /*x_speed=*/2, /*x_accuracy=*/2, /*guard_spec=*/1, /*elixir=*/1), /*hyper_potion=*/0, /*full_heal=*/1), + }, + .spare = budget(/*full_restore=*/0, /*x_special=*/0, /*x_speed=*/0, /*x_accuracy=*/0, /*guard_spec=*/1, /*elixir=*/0), + }, + }, + { + .name = "Hyper Potions and Full Heals for every fight", + .input = {.bag = {{"hyper-potion", 6}, {"max-potion", 2}, {"full-heal", 6}}}, + // Two of each against Lorelei's Lapras; a Max Potion counts as a Hyper Potion. + .expectation = { + .budgets = { + with_heals(FightBudget{}, /*hyper_potion=*/2, /*full_heal=*/2), + with_heals(FightBudget{}, /*hyper_potion=*/1, /*full_heal=*/0), + with_heals(FightBudget{}, /*hyper_potion=*/1, /*full_heal=*/2), + with_heals(FightBudget{}, /*hyper_potion=*/2, /*full_heal=*/1), + with_heals(FightBudget{}, /*hyper_potion=*/2, /*full_heal=*/1), + }, + .spare = {}, + }, + }, +}; + + +struct LeagueMinimumInput{ + BagCounts bag; +}; + +struct LeagueMinimumExpectation{ + // league_shortfalls()'s list, none when the bag is enough. + std::optional shortfalls; +}; + +struct LeagueMinimumCase{ + std::string name; + LeagueMinimumInput input; + LeagueMinimumExpectation expectation; +}; + +class Test_LeagueMinimum : public UnitTest{ +public: + explicit Test_LeagueMinimum(LeagueMinimumCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - League minimum: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const std::optional found = league_shortfalls(m_case.input.bag); + if (found != m_case.expectation.shortfalls){ + return std::format( + "expected {}, read {}", + m_case.expectation.shortfalls.value_or("nothing short"), found.value_or("nothing short") + ); + } + return true; + } + +private: + LeagueMinimumCase m_case; +}; + +const LeagueMinimumCase LEAGUE_MINIMUM_CASES[] = { + { + .name = "the bag of 2026-11-16 lacks only Full Heals", + .input = {.bag = BAG_NOW}, + .expectation = {.shortfalls = "full-heal 2 of 6"}, + }, + { + .name = "one Full Restore and the Max Elixir short", + .input = {.bag = { + {"full-restore", 7}, {"x-special", 15}, {"x-speed", 5}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"elixir", 1}, {"super-potion", 6}, {"full-heal", 6}, + }}, + .expectation = {.shortfalls = "full-restore 7 of 8, max-elixir 0 of 1"}, + }, + { + .name = "more than the minimum is enough", + .input = {.bag = { + {"full-restore", 12}, {"x-special", 18}, {"x-speed", 9}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"elixir", 1}, {"super-potion", 10}, {"full-heal", 8}, + }}, + .expectation = {.shortfalls = std::nullopt}, + }, +}; + + +struct BetweenFightsInput{ + BetweenFightView lead; + BagCounts bag; + // The next fight, by its plan row's name. + std::string next; +}; + +struct BetweenFightsExpectation{ + BetweenFightAction action; +}; + +struct BetweenFightsCase{ + std::string name; + BetweenFightsInput input; + BetweenFightsExpectation expectation; +}; + +std::string action_text(const BetweenFightAction& action){ + switch (action.move){ + case BetweenFightMove::READY: + return "ready"; + case BetweenFightMove::USE_ITEM: + return std::format("the {}", action.item.value_or("?")); + case BetweenFightMove::READ_HP: + return "read the HP"; + case BetweenFightMove::HP_UNKNOWN: + return "HP unknown"; + } + return "?"; +} + +class Test_BetweenFights : public UnitTest{ +public: + explicit Test_BetweenFights(BetweenFightsCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - League between fights: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const LeaguePlan plan = plan_league(BAG_NOW); + const LeagueFightPlan* next = nullptr; + for (const LeagueFightPlan& fight : plan.fights){ + if (fight.name == m_case.input.next){ + next = &fight; + } + } + if (next == nullptr){ + return "no fight " + m_case.input.next; + } + const BetweenFightAction action = between_fight_action(m_case.input.lead, m_case.input.bag, *next); + if (action != m_case.expectation.action){ + return std::format("expected {}, chose {}", action_text(m_case.expectation.action), action_text(action)); + } + return true; + } + +private: + BetweenFightsCase m_case; +}; + +BetweenFightView lead_at(std::optional hp, int max_hp, int surf_pp = 15, int blizzard_pp = 5){ + return BetweenFightView{ + .hp = hp, .max_hp = max_hp, .hp_reread = false, .cure = "", + .surf_pp = surf_pp, .surf_max_pp = 15, .blizzard_pp = blizzard_pp, .blizzard_max_pp = 5, + }; +} + +// `lead` after its HP was read again (READ_HP). +BetweenFightView reread(BetweenFightView lead){ + lead.hp_reread = true; + return lead; +} + +BetweenFightView with_cure(BetweenFightView lead, std::string cure){ + lead.cure = std::move(cure); + return lead; +} + +BetweenFightAction use(std::string item){ + return BetweenFightAction{.move = BetweenFightMove::USE_ITEM, .item = std::move(item)}; +} + +const BetweenFightAction READY{.move = BetweenFightMove::READY}; + +const BetweenFightsCase BETWEEN_FIGHTS_CASES[] = { + { + .name = "into Bruno at 117/165: a Super Potion up to 80%", + .input = {.lead = lead_at(/*hp=*/117, /*max_hp=*/165), .bag = BAG_NOW, .next = "bruno"}, + .expectation = {.action = use("super-potion")}, + }, + { + .name = "into Bruno at 140/165: nothing", + .input = {.lead = lead_at(/*hp=*/140, /*max_hp=*/165), .bag = BAG_NOW, .next = "bruno"}, + .expectation = {.action = READY}, + }, + { + .name = "into Agatha at 48/165: nothing, above 27%", + .input = {.lead = lead_at(/*hp=*/48, /*max_hp=*/165), .bag = BAG_NOW, .next = "agatha"}, + .expectation = {.action = READY}, + }, + { + .name = "into Lance at 48/168: a Super Potion, not a Full Restore", + .input = {.lead = lead_at(/*hp=*/48, /*max_hp=*/168), .bag = BAG_NOW, .next = "lance"}, + .expectation = {.action = use("super-potion")}, + }, + { + .name = "into Lance at 98/168, no Super Potion left: a Full Restore", + .input = {.lead = lead_at(/*hp=*/98, /*max_hp=*/168), .bag = {{"full-restore", 5}}, .next = "lance"}, + .expectation = {.action = use("full-restore")}, + }, + { + .name = "into Lance at 48/168, no Super Potion, Hyper Potions held: a Hyper Potion, not a Full Restore", + .input = {.lead = lead_at(/*hp=*/48, /*max_hp=*/168), .bag = {{"hyper-potion", 2}, {"full-restore", 5}}, .next = "lance"}, + .expectation = {.action = use("hyper-potion")}, + }, + { + .name = "paralysed: a Parlyz Heal first", + .input = { + .lead = with_cure(lead_at(/*hp=*/60, /*max_hp=*/168), "parlyz-heal"), + .bag = BAG_NOW, .next = "lance", + }, + .expectation = {.action = use("parlyz-heal")}, + }, + { + .name = "into the Champion with Surf 3, Blizzard 0: the Elixir", + .input = {.lead = lead_at(/*hp=*/171, /*max_hp=*/171, /*surf_pp=*/3, /*blizzard_pp=*/0), .bag = BAG_NOW, .next = "champion"}, + .expectation = {.action = use("elixir")}, + }, + { + .name = "into Lance with Blizzard 0 and no Elixir: the Max Elixir", + .input = { + .lead = lead_at(/*hp=*/168, /*max_hp=*/168, /*surf_pp=*/9, /*blizzard_pp=*/0), + .bag = {{"max-elixir", 1}}, .next = "lance", + }, + .expectation = {.action = use("max-elixir")}, + }, + { + .name = "HP unknown: read it again, no Full Restore", + .input = {.lead = lead_at(/*hp=*/std::nullopt, /*max_hp=*/165), .bag = BAG_NOW, .next = "bruno"}, + .expectation = {.action = {.move = BetweenFightMove::READ_HP}}, + }, + { + .name = "read again at 117/165: a Super Potion up to Bruno's 80%", + .input = {.lead = reread(lead_at(/*hp=*/117, /*max_hp=*/165)), .bag = BAG_NOW, .next = "bruno"}, + .expectation = {.action = use("super-potion")}, + }, + { + .name = "read again at 140/165: ready for Bruno", + .input = {.lead = reread(lead_at(/*hp=*/140, /*max_hp=*/165)), .bag = BAG_NOW, .next = "bruno"}, + .expectation = {.action = READY}, + }, + { + .name = "still unknown after reading it again: stop, no Full Restore", + .input = {.lead = reread(lead_at(/*hp=*/std::nullopt, /*max_hp=*/165)), .bag = BAG_NOW, .next = "bruno"}, + .expectation = {.action = {.move = BetweenFightMove::HP_UNKNOWN}}, + }, + { + .name = "poisoned, no Antidote or Full Heal: a Full Restore", + .input = { + .lead = with_cure(lead_at(/*hp=*/150, /*max_hp=*/168), "antidote"), + .bag = {{"full-restore", 5}, {"super-potion", 6}}, .next = "lance", + }, + .expectation = {.action = use("full-restore")}, + }, + { + .name = "poisoned with HP unknown: the Antidote before reading the HP", + .input = { + .lead = with_cure(lead_at(/*hp=*/std::nullopt, /*max_hp=*/168), "antidote"), + .bag = {{"antidote", 1}, {"full-restore", 5}}, .next = "lance", + }, + .expectation = {.action = use("antidote")}, + }, +}; + + + +// The League's budgeted C2 (budgeted-setup) at one turn of a League +// fight (Bruno's unless named): the foe out and its bar, the lead's HP, +// status and Surf PP, and the fight's budget. The lead is the one into +// Bruno (console B, 2026-11-16): Blastoise Lv52, HP 165, Sp. Atk 114, +// Speed 113 (124 with the badge). Onix's best ordinary hit is 37, +// Hitmonchan's 66 (mean 28); both are slower; Surf KOs Onix from full, +// not Hitmonchan (about 48 of 131 at its lowest roll). Lorelei's Dewgong +// hits up to 30 (mean 13), her Lapras up to 39 (mean 15); Agatha's +// second Gengar up to 49 and is faster. +struct BudgetedTurnInput{ + std::string_view battle = "bruno"; + size_t foe_index; + double hp; + double foe_fill = 1.0; + std::optional budget = std::nullopt; + StatusCondition status = StatusCondition::NONE; + uint8_t surf_pp = 14; + // The foe's evasion stages (Double Team). + int foe_evasion = 0; + // Items in the bag beyond the lead's usual ones. + BagCounts extra_bag = {}; + // The turns before this one, at the same state, the policy chose for. + int turns_before = 0; +}; + +struct BudgetedTurnExpectation{ + // The item used, "" for an attack. + std::string_view item; + // For an attack: the move the policy names, "" for none. + std::optional move = std::nullopt; +}; + +struct BudgetedTurnCase{ + std::string name; + BudgetedTurnInput input; + BudgetedTurnExpectation expectation; +}; + +const Pokemon::StoryStep& league_battle(std::string_view name){ + for (const StoryCheckpoint& row : story_checkpoints()){ + for (const Pokemon::StoryStep& step : row.steps){ + if (row.id == "20.01" && step.kind == Pokemon::StoryStepKind::BATTLE && step.name == name){ + return step; + } + } + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No battle {} in 20.01.", name)); +} + +Supplies league_turn_supplies(const BudgetedTurnInput& input){ + const Pokemon::StoryStep& step = league_battle(input.battle); + Supplies supplies; + std::vector bag = { + {"full-restore", 10}, {"x-special", 10}, {"x-speed", 4}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"elixir", 1}, {"parlyz-heal", 2}, + }; + for (const auto& [item, count] : input.extra_bag){ + bag.push_back({item, count}); + } + set_from_bag(supplies, bag); + supplies.lead = PartyMember{ + .species = "blastoise", + .moves = {{"bite", 25}, {"strength", 15}, {"surf", input.surf_pp}, {"blizzard", 5}}, + .moves_through_level = 52, + .moves_read = true, + .level = 52, + .stats = Stats{.hp = 165, .attack = 99, .defense = 129, .sp_attack = 114, .sp_defense = 144, .speed = 113}, + }; + supplies.foes = Pokemon::story_arg>(step.args, "foes"); + supplies.policy = battle_policy_of(step.args); + supplies.budget = input.budget; + return supplies; +} + +class Test_BudgetedTurn : public UnitTest{ +public: + explicit Test_BudgetedTurn(BudgetedTurnCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - League budgeted C2: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const BudgetedTurnInput& input = m_case.input; + const Supplies supplies = league_turn_supplies(input); + if (supplies.policy.kind != BattlePolicyKind::BUDGETED_SETUP){ + return std::format("20.01 {}: expected budgeted-setup.", input.battle); + } + PolicyState state(supplies.policy); + state.foe_evasion_raised(input.foe_evasion); + const PolicyView view{ + .hp = input.hp, .max_hp = 165, .status = input.status, .speed = 113, + .foe_index = input.foe_index, .foe_fill = input.foe_fill, + }; + for (int turn = 0; turn < input.turns_before; turn++){ + state.choose(supplies, view); + } + const PolicyState::Turn turn = state.choose(supplies, view); + const std::string_view chosen = turn.item ? std::string_view(turn.item->item) : std::string_view(); + if (chosen != m_case.expectation.item){ + return std::format("expected \"{}\", chose \"{}\" ({})", m_case.expectation.item, chosen, state.state_line(supplies, view)); + } + const std::string_view move = turn.move ? std::string_view(*turn.move) : std::string_view(); + if (m_case.expectation.move && move != *m_case.expectation.move){ + return std::format("expected the move \"{}\", named \"{}\" ({})", *m_case.expectation.move, move, state.state_line(supplies, view)); + } + return true; + } + +private: + BudgetedTurnCase m_case; +}; + +FightBudget bruno_budget(int full_restore, int x_special){ + return FightBudget{.full_restore = full_restore, .x_special = x_special, .x_speed = 2}; +} + +const BudgetedTurnCase BUDGETED_TURN_CASES[] = { + { + .name = "KO risk: 60 HP against Hitmonchan's 66: a Full Restore", + .input = {.foe_index = 1, .hp = 60}, + .expectation = {.item = "full-restore"}, + }, + { + .name = "sure KO first: 30 HP, Onix slower and KO'd by Surf: attack", + .input = {.foe_index = 0, .hp = 30}, + .expectation = {.item = ""}, + }, + { + .name = "sure KO first: 20 HP, Hitmonchan at a 30% bar: attack", + .input = {.foe_index = 1, .hp = 20, .foe_fill = 0.3}, + .expectation = {.item = ""}, + }, + { + .name = "setup within the budget: an X Special", + .input = {.foe_index = 1, .hp = 165, .budget = bruno_budget(/*full_restore=*/1, /*x_special=*/1)}, + .expectation = {.item = "x-special"}, + }, + { + .name = "setup capped: no X Special left in the budget: attack", + .input = {.foe_index = 1, .hp = 165, .budget = bruno_budget(/*full_restore=*/1, /*x_special=*/0)}, + .expectation = {.item = ""}, + }, + { + .name = "Surf out of PP: an Elixir", + .input = {.foe_index = 1, .hp = 165, .surf_pp = 0}, + .expectation = {.item = "elixir"}, + }, + { + .name = "paralysed above the foe's hit: a Parlyz Heal", + .input = {.foe_index = 1, .hp = 165, .status = StatusCondition::PARALYSIS}, + .expectation = {.item = "parlyz-heal"}, + }, + { + .name = "no X Accuracy against Double Team: evasion +2, X Accuracy in the budget: attack", + .input = { + .foe_index = 1, .hp = 165, + .budget = FightBudget{.full_restore = 1, .x_accuracy = 3}, + .foe_evasion = 2, + }, + .expectation = {.item = ""}, + }, + { + .name = "Lapras at 24 HP, Hyper Potions held but not budgeted: a Full Restore", + .input = { + .battle = "lorelei", .foe_index = 4, .hp = 24, .budget = FightBudget{}, + .extra_bag = {{"hyper-potion", 2}}, + }, + .expectation = {.item = "full-restore"}, + }, + { + .name = "Dewgong's bar unmoved after two Super Potions, 25 HP: a Full Restore, no third", + .input = { + .battle = "lorelei", .foe_index = 0, .hp = 25, .budget = FightBudget{}, + .extra_bag = {{"super-potion", 4}}, .turns_before = 2, + }, + .expectation = {.item = "full-restore"}, + }, + { + .name = "asleep against Agatha's second Gengar at 110 HP: a Full Heal", + .input = { + .battle = "agatha", .foe_index = 4, .hp = 110, .status = StatusCondition::SLEEP, + .extra_bag = {{"full-heal", 2}}, + }, + .expectation = {.item = "full-heal"}, + }, + { + .name = "asleep at 40 HP against Gengar's 49: a Full Restore", + .input = { + .battle = "agatha", .foe_index = 4, .hp = 40, .status = StatusCondition::SLEEP, + .extra_bag = {{"full-heal", 2}}, + }, + .expectation = {.item = "full-restore"}, + }, + { + .name = "Hitmonchan at a 4% bar: Strength, not Surf", + .input = {.foe_index = 1, .hp = 165, .foe_fill = 0.04}, + .expectation = {.item = "", .move = "strength"}, + }, + { + .name = "Hitmonchan at a 30% bar: Strength doesn't KO, no move named", + .input = {.foe_index = 1, .hp = 165, .foe_fill = 0.3}, + .expectation = {.item = "", .move = ""}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryLeaguePlan(UnitTestDatabase& database){ + for (const LeaguePlanCase& item : LEAGUE_PLAN_CASES){ + database.add(item); + } + for (const LeagueMinimumCase& item : LEAGUE_MINIMUM_CASES){ + database.add(item); + } + for (const BetweenFightsCase& item : BETWEEN_FIGHTS_CASES){ + database.add(item); + } + for (const BudgetedTurnCase& item : BUDGETED_TURN_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.cpp new file mode 100644 index 0000000000..1abaf4aea4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.cpp @@ -0,0 +1,346 @@ +/* AutoStory League Steps + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "Common/Cpp/Color.h" +#include "Common/Cpp/Exceptions.h" +#include "PokemonFRLG_AutoStoryBag.h" +#include "PokemonFRLG_AutoStoryBagUse.h" +#include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryGameArgs.h" +#include "PokemonFRLG_AutoStoryHealing.h" +#include "PokemonFRLG_AutoStoryHealingSteps.h" +#include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryLeaguePlan.h" +#include "PokemonFRLG_AutoStoryLeagueSteps.h" +#include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryLeagueFightData.h" +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" +#include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryPlannedBetween.h" +#include "PokemonFRLG_AutoStoryStartMenu.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using Pokemon::Outcome; +using Pokemon::StoryStep; + +namespace{ + +// `item` (is_lead_recovery_item()) on the lead from the bag, found by +// reading the pocket: taken into the supplies if used. +ItemUseEnd use_lead_item_from_bag(StoryEnv& env, const StoryStep& step, const std::string& item){ + ConsoleItemUseActions bag(env.console, env.context, env.language, step_start_menu(step.args)); + const ItemUseEnd end = use_item_from_bag(env.console.logger(), bag, item); + if (end == ItemUseEnd::USED){ + took_recovery_item(env.supplies, item); + } + return end; +} + +int held_count(const BagCounts& bag, std::string_view item){ + const auto found = bag.find(item); + return found == bag.end() ? 0 : std::max(0, found->second); +} + +// A budgeted item (a Full Restore, Hyper or Max Potion, Full Heal, Elixir +// or Max Elixir) used between fights comes out of the next fight's +// budget (it may go below 0 here: the budget planned for that fight is +// added to it). +void charge_next_fight(FightBudget& carried, std::string_view item){ + if (int* count = budget_count(item, carried)){ + (*count)--; + } +} + +// The League's items as the story counts them. +BagCounts league_bag(const Supplies& supplies){ + BagCounts bag; + for (const std::string_view item : { + "full-restore", "x-special", "x-speed", "x-accuracy", "guard-spec", "max-elixir", "elixir", + "super-potion", "full-heal", "parlyz-heal", "antidote", "awakening", "max-potion", "hyper-potion", + }){ + bag.emplace(std::string(item), bag_count(supplies, item)); + } + return bag; +} + +// LEAGUE_START_ACTION: the Items pocket read, checked against the +// League's minimum and planned. +Outcome league_start(StoryEnv& env, const StoryStep& step){ + const std::vector rows = read_items_pocket(env.console, env.context, env.language); + if (rows.empty()){ + return Pokemon::outcome_failed("bag_unread", step.name); + } + set_from_bag(env.supplies, rows); + env.supplies.counts_read = true; + const BagCounts bag = league_bag(env.supplies); + if (const std::optional short_items = league_shortfalls(bag)){ + env.console.log(std::format( + "Story: {}: the bag is short of the League's restock list: {}. Planning from the bag as it is.", + step.name, *short_items + ), COLOR_ORANGE); + } + LeagueRun run{.plan = plan_league(bag), .carried = {}}; + for (const std::string& line : league_plan_lines(run.plan)){ + env.console.log(line); + } + env.supplies.league = std::move(run); + // The row starts after Indigo Plateau's nurse (20.01a) and nothing + // hurts the lead before Lorelei; a fresh program has measured nothing. + if (!missing_hp(env.supplies, 1)){ + env.console.log(std::format("Story: {}: HP unknown since the load; full from the nurse before this row.", step.name), COLOR_ORANGE); + measured_hp(env.supplies, 1.0); + } + return Pokemon::outcome_ok(); +} + +// The lead's move `move`: its PP and full PP, 0 and 0 if it doesn't know it. +std::pair move_pp(const PartyMember& lead, std::string_view move){ + for (const KnownMove& known : lead.moves){ + if (known.move == move){ + return {known.pp, max_pp(move)}; + } + } + return {0, 0}; +} + +// The lead's state between fights, as between_fight_action() reads it +// (`hp_reread`: READ_HP was done this step), its move for `next`, and the +// line that logs both. +BetweenFightAction logged_between_action( + StoryEnv& env, std::string_view step, const LeagueFightPlan& next, int max_hp, bool hp_reread +){ + const std::pair surf = move_pp(env.supplies.lead, "surf"); + const std::pair blizzard = move_pp(env.supplies.lead, "blizzard"); + const StatusCondition status = env.supplies.status; + const std::optional missing = missing_hp(env.supplies, max_hp); + const BetweenFightView lead{ + .hp = missing ? std::optional(max_hp - std::max(0, *missing)) : std::nullopt, + .max_hp = max_hp, + .hp_reread = hp_reread, + .cure = status == StatusCondition::NONE ? std::string() + : !cure_of(status).empty() ? std::string(cure_of(status)) : std::string("full-heal"), + .surf_pp = surf.first, .surf_max_pp = surf.second, + .blizzard_pp = blizzard.first, .blizzard_max_pp = blizzard.second, + }; + const BetweenFightAction action = between_fight_action(lead, league_bag(env.supplies), next); + const std::string what = action.move == BetweenFightMove::USE_ITEM ? std::format("the {}", action.item.value_or("?")) + : action.move == BetweenFightMove::READ_HP ? std::string("read the HP again") + : action.move == BetweenFightMove::HP_UNKNOWN ? std::string("HP still unknown") + : std::string("ready"); + env.console.log(std::format( + "Story: {}: before {}: HP {}/{}, {}, Surf {}/{}, Blizzard {}/{}: {}.", + step, next.name, lead.hp ? std::to_string(*lead.hp) : std::string("?"), max_hp, status_name(status), + surf.first, surf.second, blizzard.first, blizzard.second, what + ), action.move == BetweenFightMove::READY || action.move == BetweenFightMove::USE_ITEM ? COLOR_BLACK : COLOR_RED); + return action; +} + +PlannedStatus carry_status(StatusCondition status){ + switch (status){ + case StatusCondition::POISON: + return PlannedStatus::POISON; + case StatusCondition::PARALYSIS: + return PlannedStatus::PARALYSIS; + case StatusCondition::SLEEP: + return PlannedStatus::SLEEP; + case StatusCondition::OTHER: + return PlannedStatus::BURN; + case StatusCondition::NONE: + break; + } + return PlannedStatus::NONE; +} + +// Our side between fights as planned_between() reads it; none while the +// HP is unknown. +std::optional between_carry(const Supplies& supplies, int max_hp){ + const std::optional missing = missing_hp(supplies, max_hp); + if (!missing){ + return std::nullopt; + } + PlannedCarry carry{.hp = max_hp - std::max(0, *missing), .max_hp = max_hp, .status = carry_status(supplies.status)}; + for (const KnownMove& known : supplies.lead.moves){ + carry.pp[known.move] = known.pp; + carry.full_pp[known.move] = max_pp(known.move); + } + for (const auto& [item, count] : league_bag(supplies)){ + carry.bag[item] = count; + } + return carry; +} + +// The planned policy's top-ups before `next` (planned_between()), one +// item at a time from the lead's state, until none is left; the PP is +// read off the lead's summary again after a PP item. False if the HP is +// unknown. +bool planned_between_fights(StoryEnv& env, const StoryStep& step, const LeagueFightData& next, int max_hp){ + constexpr int MAX_ITEMS = 10; + for (int c = 0; c < MAX_ITEMS; c++){ + std::optional carry = between_carry(env.supplies, max_hp); + if (!carry){ + return false; + } + const int hp = carry->hp; + const std::vector items = planned_between(*carry, next); + env.console.log(std::format( + "Story: {}: before {}: HP {}/{}, {}: {}.", step.name, next.name, hp, max_hp, + status_name(env.supplies.status), items.empty() ? std::string("ready") : std::format("the {}", items.front()) + )); + if (items.empty()){ + return true; + } + const std::string& item = items.front(); + const bool used = is_lead_recovery_item(item) + ? use_lead_item_from_bag(env, step, item) == ItemUseEnd::USED + : use_recovery_item(env.console, env.context, item, env.checks, env.language, env.supplies); + if (!used){ + env.console.log(std::format("Story: {}: couldn't use the {}; going on.", step.name, item), COLOR_RED); + return true; + } + if (env.supplies.league){ + charge_next_fight(env.supplies.league->carried, item); + } + if (item == "elixir" || item == "max-elixir"){ + read_lead_moves(env, step_start_menu(step.args)); + } + } + return true; +} + +// LEAGUE_BETWEEN_FIGHTS_ACTION: between_fight_action()'s moves until it is +// READY, each item used from the bag; a Full Restore, Elixir or Max Elixir +// counts against the next fight's budget. READ_HP: no overworld reader +// has the lead's current HP yet (the summary's POKEMON SKILLS read keeps +// only its maximum), so the HP stays unknown and the step fails before +// the fight. +Outcome league_between_fights(StoryEnv& env, const StoryStep& step, int fallback_max_hp){ + constexpr int MAX_MOVES = 10; + const std::string* trainer = game_arg(step.args, "next"); + if (trainer == nullptr || !env.supplies.league){ + return Pokemon::outcome_failed("bad_args", std::format("{}{}", step.name, env.supplies.league ? "" : ": no League plan (league_start)")); + } + const LeagueFightPlan* next = league_fight(env.supplies.league->plan, *trainer); + if (next == nullptr){ + return Pokemon::outcome_failed("bad_args", std::format("{}: no League fight {}", step.name, *trainer)); + } + const int max_hp = env.supplies.lead.stats && env.supplies.lead.stats->hp > 0 ? env.supplies.lead.stats->hp : fallback_max_hp; + // The planned policy's targets (frlg-league-plan.json's between rows). + const std::optional fight = league_fight_name(*trainer); + if (const LeagueFightData* planned = fight ? league_fight_data(league_plan_data(), *fight) : nullptr){ + return planned_between_fights(env, step, *planned, max_hp) + ? Pokemon::outcome_ok() + : Pokemon::outcome_failed("hp_unknown", std::format("{}: before {}", step.name, planned->name)); + } + bool hp_reread = false; + for (int c = 0; c < MAX_MOVES; c++){ + const BetweenFightAction action = logged_between_action(env, step.name, *next, max_hp, hp_reread); + switch (action.move){ + case BetweenFightMove::READY: + return Pokemon::outcome_ok(); + case BetweenFightMove::READ_HP: + hp_reread = true; + continue; + case BetweenFightMove::HP_UNKNOWN: + // Never into a fight on an HP the story doesn't know (Bruno, + // console B, 2026-11-16: entered at 71% after "HP unknown"). + return Pokemon::outcome_failed("hp_unknown", std::format("{}: before {}", step.name, next->name)); + case BetweenFightMove::USE_ITEM: + break; + } + const std::string item = action.item.value_or(""); + const bool used = is_lead_recovery_item(item) + ? use_lead_item_from_bag(env, step, item) == ItemUseEnd::USED + : use_recovery_item(env.console, env.context, item, env.checks, env.language, env.supplies); + if (!used){ + env.console.log(std::format("Story: {}: couldn't use the {}; going on.", step.name, item), COLOR_RED); + return Pokemon::outcome_ok(); + } + charge_next_fight(env.supplies.league->carried, item); + } + return Pokemon::outcome_ok(); +} + +} // namespace + + +BetweenFightAction between_fight_action( + const BetweenFightView& lead, const BagCounts& bag, const LeagueFightPlan& next +){ + // The PP an Elixir restores to each move (pokefirered items.json). + constexpr int ELIXIR_PP = 10; + const auto first_held = [&](std::initializer_list items) -> std::optional{ + for (const std::string_view item : items){ + if (held_count(bag, item) > 0){ + return BetweenFightAction{.move = BetweenFightMove::USE_ITEM, .item = std::string(item)}; + } + } + return std::nullopt; + }; + if (!lead.cure.empty()){ + if (std::optional cure = first_held({lead.cure, "full-heal", "full-restore"})){ + return *cure; + } + } + if (!lead.hp){ + return BetweenFightAction{.move = lead.hp_reread ? BetweenFightMove::HP_UNKNOWN : BetweenFightMove::READ_HP}; + } + const int target = (lead.max_hp * next.entry_hp_percent + 99) / 100; + if (*lead.hp < target){ + if (std::optional heal = first_held({"super-potion", "hyper-potion", "max-potion", "full-restore"})){ + return *heal; + } + } + const bool surf_low = lead.surf_max_pp > 0 && lead.surf_pp < next.surf_pp_floor; + const bool blizzard_low = lead.blizzard_max_pp > 0 && lead.blizzard_pp < next.blizzard_pp_floor; + if (!surf_low && !blizzard_low){ + return BetweenFightAction{}; + } + const bool elixir_reaches = + std::min(lead.surf_pp + ELIXIR_PP, lead.surf_max_pp) >= std::min(next.surf_pp_floor, lead.surf_max_pp) + && std::min(lead.blizzard_pp + ELIXIR_PP, lead.blizzard_max_pp) >= std::min(next.blizzard_pp_floor, lead.blizzard_max_pp); + const std::optional pp = elixir_reaches + ? first_held({"elixir", "max-elixir"}) + : first_held({"max-elixir", "elixir"}); + return pp.value_or(BetweenFightAction{}); +} + + +std::vector league_action_specs(){ + return { + {.kind = Pokemon::StoryStepKind::GAME, .name = LEAGUE_START_ACTION, .args = {}}, + {.kind = Pokemon::StoryStepKind::GAME, .name = LEAGUE_BETWEEN_FIGHTS_ACTION, .args = { + required_arg("max_hp", Pokemon::StoryArgType::INTEGER, "the lead's maximum HP when its summary wasn't read"), + required_arg("next", Pokemon::StoryArgType::WORD, "the next fight's trainer, as its battle step names it"), + }}, + }; +} + +std::optional run_league_step(StoryEnv& env, const StoryStep& step){ + if (step.action == LEAGUE_START_ACTION){ + return league_start(env, step); + } + if (step.action != LEAGUE_BETWEEN_FIGHTS_ACTION){ + return std::nullopt; + } + const int64_t* max_hp = game_arg(step.args, "max_hp"); + if (max_hp == nullptr){ + return Pokemon::outcome_failed("bad_args", step.action); + } + return league_between_fights(env, step, static_cast(*max_hp)); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.h new file mode 100644 index 0000000000..04ffbe7158 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.h @@ -0,0 +1,107 @@ +/* AutoStory League Steps + * + * From: https://github.com/PokemonAutomation/ + * + * The League's own steps (one checkpoint from Lorelei's door to the Hall + * of Fame, no save between; PokemonFRLG_AutoStoryLeaguePlan.h plans it): + * + * league_start: reads the Items pocket, logs what the bag lacks of the + * League's restock list, and logs and keeps the plan made from the bag + * as it is; the fights' battles spend its budgets (Supplies::budget). + * + * league_between_fights (next WORD, the next fight's trainer; max_hp + * INTEGER, the lead's maximum HP when its summary wasn't read): does + * between_fight_action()'s moves one at a time from the lead's state. A + * budgeted item (Full Restore, Hyper or Max Potion, Full Heal, Elixir, + * Max Elixir) counts against the next fight's budget. Never a fight on an unknown HP (Bruno, console B, 2026-11-16: + * entered at 71%), and never a Full Restore for a read failure. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLeagueSteps_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLeagueSteps_H + +#include +#include +#include +#include "Pokemon/AutoStory/Pokemon_StoryOutcome.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryStep.h" +#include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryLeaguePlan.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The GAME step at the League's start (league_start above). +inline const std::string LEAGUE_START_ACTION = "league_start"; +// The GAME step between two League fights (league_between_fights above). +inline const std::string LEAGUE_BETWEEN_FIGHTS_ACTION = "league_between_fights"; + +// The lead between two fights, as between_fight_action() reads it. +struct BetweenFightView{ + // None when no bar was measured since the load and no item healed it + // to a known HP. + std::optional hp = std::nullopt; + int max_hp = 0; + // Whether the HP was already read again this step (READ_HP). + bool hp_reread = false; + // The item that cures the lead's status ("parlyz-heal"; "full-heal" + // for one with no own cure), "" for none. + std::string cure; + int surf_pp = 0; + int surf_max_pp = 0; + int blizzard_pp = 0; + int blizzard_max_pp = 0; +}; + +// What league_between_fights does next (between_fight_action()). +enum class BetweenFightMove{ + // Into the fight. + READY, + // The action's item on the lead. + USE_ITEM, + // Read the lead's HP again. + READ_HP, + // The HP is still unknown after reading it again: stop before the fight. + HP_UNKNOWN, +}; + +// between_fight_action()'s move, with its item. +struct BetweenFightAction{ + BetweenFightMove move = BetweenFightMove::READY; + // USE_ITEM's item (a bag slug). + std::optional item = std::nullopt; + + bool operator==(const BetweenFightAction&) const = default; +}; + +// The next move before `next`, from the lead's state, in this order: +// 1. a status: its own cure, else a Full Heal, else a Full Restore; +// 2. HP unknown: read it again; still unknown: HP_UNKNOWN (a Full +// Restore is never spent on a read failure); +// 3. HP below the fight's entry target: the cheapest heal held, a +// Super Potion, then a Hyper Potion, a Max Potion, a Full Restore +// last; +// 4. Surf or Blizzard below the fight's PP floor: an Elixir when it +// reaches the floor, else a Max Elixir, else the Elixir anyway; +// 5. READY (also when the bag has nothing that helps). +BetweenFightAction between_fight_action( + const BetweenFightView& lead, const BagCounts& bag, const LeagueFightPlan& next +); + +// LEAGUE_START_ACTION's and LEAGUE_BETWEEN_FIGHTS_ACTION's specs. +std::vector league_action_specs(); + +// On the console, a LEAGUE_START_ACTION or LEAGUE_BETWEEN_FIGHTS_ACTION +// step; nothing for another. +std::optional run_league_step(StoryEnv& env, const Pokemon::StoryStep& step); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeague_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeague_Tests.cpp index e223df6a75..40662bdf62 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeague_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeague_Tests.cpp @@ -2,15 +2,18 @@ * * From: https://github.com/PokemonAutomation/ * - * Rows 20.01a to 20.05 (StoryData/frlg-20.0N.plan.json) on the overworld - * sim: Indigo Plateau's Mart, the Elite Four's rooms one way north, the - * Champion's door; and the battles' foe rows against their generator. + * Rows 20.01a and 20.01 (StoryData/frlg-20.01*.plan.json) on the + * overworld sim: Indigo Plateau's Mart, the Elite Four's rooms one way + * north, the Champion's door, all in 20.01 (one checkpoint, no save + * between the fights); the battles' foe rows against their generator; and + * the League plan's steps around the fights. * */ #include #include #include +#include #include #include #include @@ -21,7 +24,10 @@ #include "Pokemon/AutoStory/Pokemon_StoryPostconditionCheck.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "PokemonFRLG_AutoStoryBattlePolicy.h" #include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryItemsPocket.h" +#include "PokemonFRLG_AutoStoryLeaguePlan.h" #include "PokemonFRLG_AutoStoryPoses.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryRows20_Tests.h" @@ -75,12 +81,30 @@ const StoryCheckpoint& league_row(std::string_view id){ throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No checkpoint {}.", id)); } -// Runs the walking steps of `row` on `sim`, from `at`, up to (not including) the step -// named `until`, or all of them if `until` is empty. The other steps (the -// Mart, the level checks, the heals, the scenes and the battles) are the -// console's. -std::string walk_league_row(const StoryCheckpoint& row, std::string_view until, OverworldSim& sim, StoryPose& at){ +// The step `name` of row `id`. +const StoryStep& league_step(std::string_view id, std::string_view name){ + for (const StoryStep& step : league_row(id).steps){ + if (step.name == name){ + return step; + } + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No step {} in {}.", name, id)); +} + +// Runs the walking steps of `row` on `sim`, from `at`, after the step +// named `from` (from the row's first if empty) up to (not including) the +// step named `until`, or all of them if `until` is empty. The other steps +// (the Mart, the level checks, the heals, the scenes and the battles) are +// the console's. +std::string walk_league_row( + const StoryCheckpoint& row, std::string_view until, OverworldSim& sim, StoryPose& at, std::string_view from = {} +){ + bool started = from.empty(); for (const StoryStep& step : row.steps){ + if (!started){ + started = step.name == from; + continue; + } if (step.name == until){ return ""; } @@ -113,16 +137,22 @@ UnitTestResult walk_to_room(std::string_view id, std::string_view until, std::st return true; } -// Walks row `id` from in front of the beaten trainer round them to below -// their door, up to the step `door` into it. The map pack draws the door -// closed (a wall: the game opens it with setmetatile when the trainer is -// beaten, PokemonLeague_EventScript_OpenDoor), so the step through it and -// the next room's walk are the console's. -UnitTestResult walk_to_door(std::string_view id, std::string_view door, const MapPosition& below){ +// Walks 20.01 from in front of the trainer its battle step `battle` beat +// (the step's declared pose) round them to below their door, up to the +// step `door` into it. The map pack draws the door closed (a wall: the +// game opens it with setmetatile when the trainer is beaten, +// PokemonLeague_EventScript_OpenDoor), so the step through it and the +// next room's walk are the console's. +UnitTestResult walk_to_door(std::string_view battle, std::string_view door, const MapPosition& below){ + const std::string_view id = "20.01"; const StoryCheckpoint& row = league_row(id); - StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); + const StoryStep& beaten = league_step(id, battle); + if (!beaten.pose_after){ + return std::format("{} {}: no declared pose after the battle.", id, battle); + } + StoryPose at = *story_pose(Pokemon::pose_of(*beaten.pose_after)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); - if (const std::string failure = walk_league_row(row, door, sim, at); !failure.empty()){ + if (const std::string failure = walk_league_row(row, door, sim, at, battle); !failure.empty()){ return failure; } if (!(sim.state().position == below) || sim.state().facing != Direction::NORTH){ @@ -153,16 +183,6 @@ UnitTestResult test_indigo_mart_counter(){ return true; } -// The step `name` of row `id`. -const StoryStep& league_step(std::string_view id, std::string_view name){ - for (const StoryStep& step : league_row(id).steps){ - if (step.name == name){ - return step; - } - } - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No step {} in {}.", name, id)); -} - // The battle's foe_threats are PokemonSimulation's planning_risk() for // each foe leading against the entry state of its pokeguy case // (src/pokesim/games/frlg/battle/player_strategy/planning.py, as 19.01's @@ -186,44 +206,45 @@ struct LeagueFight{ std::vector> rows; }; -// The generator's rows for the five League battles, in the doc's foe order. +// The generator's rows for the five League battles, in the doc's foe order, +// against console B's Lv54 Blastoise (171 HP, Def 135, Sp. Def 150). std::vector league_fights(){ return { {"20.01", "lorelei", { - {93, 21, 13, 45, 22, 0, 0}, // Dewgong - {91, 0, 0, 0, 15, 0, 0}, // Cloyster - {45, 27, 9, 60, 30, 0, 0}, // Slowbro - {110, 25, 9, 57, 28, 0, 0}, // Jynx - {94, 36, 15, 78, 39, 0, 0}, // Lapras + {93, 17, 10, 37, 30, 0, 0}, // Dewgong: worst normal hit 30 as seen on console B, not 18 + {91, 0, 0, 0, 12, 0, 0, 0, 1}, // Cloyster (Dive charges a turn) + {45, 21, 7, 49, 24, 0, 0}, // Slowbro + {110, 22, 10, 48, 24, 0, 0}, // Jynx + {94, 28, 12, 62, 31, 0, 0}, // Lapras }}, - {"20.02", "bruno", { - {81, 32, 19, 75, 37, 0, 0}, // Onix - {101, 51, 28, 132, 66, 0, 0}, // Hitmonchan - {113, 65, 52, 136, 68, 0, 0}, // Hitmonlee - {96, 41, 41, 84, 42, 0, 0}, // Onix - {83, 0, 5, 183, 91, 0, 0}, // Machamp + {"20.01", "bruno", { + {81, 26, 16, 63, 31, 0, 0, 1}, // Onix (Roar) + {101, 43, 24, 108, 54, 0, 0}, // Hitmonchan + {113, 54, 44, 114, 57, 0, 0}, // Hitmonlee + {96, 33, 33, 69, 34, 0, 0}, // Onix + {83, 0, 4, 150, 75, 0, 0}, // Machamp }}, - {"20.03", "agatha", { - {126, 32, 10, 72, 36, 0, 0}, // Gengar - {129, 33, 31, 69, 34, 0, 0}, // Golbat - {108, 0, 0, 0, 48, 0, 0}, // Haunter - {111, 61, 61, 126, 63, 0, 0}, // Arbok - {150, 47, 40, 99, 49, 0, 0}, // Gengar + {"20.01", "agatha", { + {126, 0, 3, 60, 30, 0, 0}, // Gengar + {129, 28, 17, 60, 30, 0, 0}, // Golbat + {108, 0, 0, 0, 41, 0, 0}, // Haunter + {111, 51, 31, 108, 54, 0, 0}, // Arbok + {150, 40, 24, 84, 42, 0, 0}, // Gengar }}, - {"20.04", "lance", { - {112, 40, 32, 42, 93, 0, 0}, // Gyarados - {96, 40, 17, 87, 62, 0, 0}, // Dragonair - {96, 0, 0, 0, 62, 0, 0}, // Dragonair - {173, 47, 47, 96, 78, 0, 0}, // Aerodactyl - {107, 64, 24, 144, 114, 0, 0}, // Dragonite + {"20.01", "lance", { + {112, 40, 31, 40, 80, 0, 0}, // Gyarados + {96, 40, 16, 78, 53, 0, 0}, // Dragonair + {96, 0, 0, 0, 53, 0, 0}, // Dragonair + {173, 41, 41, 84, 67, 0, 0}, // Aerodactyl + {107, 56, 19, 126, 98, 0, 0}, // Dragonite }}, - {"20.05", "champion", { - {130, 41, 27, 87, 43, 1, 0}, // Pidgeot (Sand Attack) - {159, 77, 70, 159, 79, 0, 0}, // Alakazam - {70, 0, 10, 210, 105, 0, 0}, // Rhydon - {118, 51, 46, 110, 55, 0, 0}, // Gyarados - {139, 50, 51, 104, 52, 0, 0}, // Arcanine - {125, 217, 218, 444, 222, 0, 0},// Venusaur + {"20.01", "champion", { + {130, 35, 24, 75, 37, 1, 0, 1}, // Pidgeot (Sand Attack, Whirlwind) + {159, 70, 64, 144, 72, 0, 0}, // Alakazam + {70, 0, 8, 183, 91, 0, 0}, // Rhydon + {118, 44, 43, 96, 48, 0, 0}, // Gyarados + {139, 45, 45, 92, 46, 0, 0, 1}, // Arcanine (Roar) + {125, 194, 182, 396, 198, 0, 0, 0, 1}, // Venusaur (Solar Beam charges a turn) }}, }; } @@ -238,6 +259,70 @@ UnitTestResult test_foe_threats_are_the_generators(){ return true; } +// The Champion's Venusaur: the battle texts read before the turn, and +// the turns (attacks) taken after them before this one. +struct VenusaurTurnInput{ + std::vector battle_texts = {}; + int turns_after_texts = 0; +}; + +// The policy's item, "" for an attack. +struct VenusaurTurnExpectation{ + std::string_view item; +}; + +struct VenusaurTurnCase{ + std::string_view name; + VenusaurTurnInput input; + VenusaurTurnExpectation expectation; +}; + +// Solar Beam without sun charges a turn first: no KO risk until Venusaur +// is charging (PokemonSimulation #110: the policy only attacked, and the +// Champion was 0%). Charged, its hit KOs from full: attack. +const VenusaurTurnCase VENUSAUR_TURN_CASES[] = { + {"not charging: X Special", {{}, 0}, {"x-special"}}, + {"charging Solar Beam: attack", {{"foevenusaurtookinsunlight"}, 0}, {""}}, + {"the turn after its charge: X Special", {{"foevenusaurtookinsunlight"}, 1}, {"x-special"}}, + {"in Sunny Day's sun: attack", {{"thesunlightgotbright"}, 0}, {""}}, + {"after the sun faded: X Special", {{"thesunlightgotbright", "thesunlightfaded"}, 0}, {"x-special"}}, +}; + +// Console B's Blastoise (Lv54, 2026-11-16) at full HP against Venusaur. +UnitTestResult test_venusaur_charge(){ + const StoryStep& step = league_step("20.01", "champion"); + constexpr size_t VENUSAUR = 5; + for (const VenusaurTurnCase& test : VENUSAUR_TURN_CASES){ + Supplies supplies; + set_from_bag(supplies, {{"full-restore", 10}, {"x-special", 10}, {"x-speed", 4}, {"x-accuracy", 3}}); + supplies.lead = PartyMember{ + .species = "blastoise", + .moves = {{"bite", 25}, {"strength", 15}, {"surf", 15}, {"blizzard", 5}}, + .moves_through_level = 54, + .moves_read = true, + .level = 54, + .stats = Stats{.hp = 171, .attack = 101, .defense = 135, .sp_attack = 119, .sp_defense = 150, .speed = 117}, + }; + supplies.foes = Pokemon::story_arg>(step.args, "foes"); + supplies.policy = battle_policy_of(step.args); + PolicyState state(supplies.policy); + PolicyView view{ + .hp = 171, .max_hp = 171, .status = StatusCondition::NONE, .speed = 117, + .foe_index = VENUSAUR, .foe_fill = 1.0, .battle_texts = test.input.battle_texts, + }; + for (int turn = 0; turn < test.input.turns_after_texts; turn++){ + state.choose(supplies, view); + view.battle_texts.clear(); + } + const std::optional item = state.choose(supplies, view).item; + const std::string_view chosen = item ? std::string_view(item->item) : std::string_view(); + if (chosen != test.expectation.item){ + return std::format("Venusaur {}: expected \"{}\", got \"{}\".", test.name, test.expectation.item, chosen); + } + } + return true; +} + // The index of the step `name` in `row`, or the step count if none. size_t step_index(const StoryCheckpoint& row, std::string_view name){ size_t index = 0; @@ -247,25 +332,48 @@ size_t step_index(const StoryCheckpoint& row, std::string_view name){ return index; } -// PokeGuy's items between the fights: a Full Restore after Agatha (the -// heal into Lance), one Elixir after Lance, before the Champion's door. -UnitTestResult test_pokeguy_items_between_fights(){ - const StoryCheckpoint& lance = league_row("20.04"); - const size_t heal = step_index(lance, "heal_after_agatha"); - if (heal == lance.steps.size() || !Pokemon::story_arg(lance.steps[heal].args, "full_restore")){ - return "20.04 heal_after_agatha: expected a Full Restore first."; - } - const StoryCheckpoint& champion = league_row("20.05"); - const size_t elixir = step_index(champion, "elixir_after_lance"); - if (elixir >= step_index(champion, "champions_door") || champion.steps[elixir].action != "restore_pp" - || Pokemon::story_arg(champion.steps[elixir].args, "item") != "elixir" - ){ - return "20.05: expected restore_pp elixir before the Champion's door."; - } - return true; -} - +// The League plan's steps in 20.01: league_start before the League's +// door, and before each fight after Lorelei's a league_between_fights +// for that fight's trainer, after the fight before it. +UnitTestResult test_league_plan_steps(){ + const StoryCheckpoint& row = league_row("20.01"); + const size_t start = step_index(row, "league_start"); + if (start >= step_index(row, "league_door") || row.steps[start].action != "league_start"){ + return "20.01: expected league_start before the League's door."; + } + struct Between{ + std::string_view after; + std::string_view step; + std::string_view battle; + std::string_view trainer; + }; + const Between betweens[] = { + {"lorelei", "items_before_bruno", "bruno", "TRAINER_ELITE_FOUR_BRUNO"}, + {"bruno", "items_before_agatha", "agatha", "TRAINER_ELITE_FOUR_AGATHA"}, + {"agatha", "items_before_lance", "lance", "TRAINER_ELITE_FOUR_LANCE"}, + {"lance", "items_before_champion", "champion", "TRAINER_CHAMPION_FIRST_BULBASAUR"}, + }; + for (const Between& between : betweens){ + const size_t at = step_index(row, between.step); + if (at <= step_index(row, between.after) || at >= step_index(row, between.battle) + || row.steps[at].action != "league_between_fights" + || Pokemon::story_arg(row.steps[at].args, "next") != between.trainer + ){ + return std::format("20.01: expected {} (league_between_fights, next {}) between {} and {}.", between.step, between.trainer, between.after, between.battle); + } + if (Pokemon::story_arg(league_step("20.01", between.battle).args, "trainer") != between.trainer){ + return std::format("20.01 {}: expected trainer {}.", between.battle, between.trainer); + } + } + return true; +} + const AutoStoryLeagueCase AUTO_STORY_LEAGUE_CASES[] = { + { + .name = "20.01 the Champion's Venusaur: Solar Beam is a KO risk only charged or in sun", + .input = {.body = test_venusaur_charge}, + .expectation = {.description = "X Special until it charges or the sun is out, then an attack"}, + }, { .name = "20.01a Indigo Plateau's Mart counter", .input = {.body = test_indigo_mart_counter}, @@ -279,42 +387,42 @@ const AutoStoryLeagueCase AUTO_STORY_LEAGUE_CASES[] = { .expectation = {.description = "Lorelei's room, no trainer met"}, }, { - .name = "20.02 around Lorelei to below her door", + .name = "20.01 around Lorelei to below her door", .input = {.body = []{ - return walk_to_door("20.02", "loreleis_door", MapPosition{"PokemonLeague_LoreleisRoom", {6, 3}}); + return walk_to_door("lorelei", "loreleis_door", MapPosition{"PokemonLeague_LoreleisRoom", {6, 3}}); }}, .expectation = {.description = "Lorelei's room (6, 3) facing north"}, }, { - .name = "20.03 around Bruno to below his door", + .name = "20.01 around Bruno to below his door", .input = {.body = []{ - return walk_to_door("20.03", "brunos_door", MapPosition{"PokemonLeague_BrunosRoom", {6, 3}}); + return walk_to_door("bruno", "brunos_door", MapPosition{"PokemonLeague_BrunosRoom", {6, 3}}); }}, .expectation = {.description = "Bruno's room (6, 3) facing north"}, }, { - .name = "20.04 around Agatha to below her door", + .name = "20.01 around Agatha to below her door", .input = {.body = []{ - return walk_to_door("20.04", "agathas_door", MapPosition{"PokemonLeague_AgathasRoom", {6, 3}}); + return walk_to_door("agatha", "agathas_door", MapPosition{"PokemonLeague_AgathasRoom", {6, 3}}); }}, .expectation = {.description = "Agatha's room (6, 3) facing north"}, }, { - .name = "20.05 around Lance to below the Champion's door", + .name = "20.01 around Lance to below the Champion's door", .input = {.body = []{ - return walk_to_door("20.05", "champions_door", MapPosition{"PokemonLeague_LancesRoom", {6, 6}}); + return walk_to_door("lance", "champions_door", MapPosition{"PokemonLeague_LancesRoom", {6, 6}}); }}, .expectation = {.description = "Lance's room (6, 6) facing north"}, }, { - .name = "20.01 to 20.05 the League's foe rows are the generator's", + .name = "20.01 the League's foe rows are the generator's", .input = {.body = test_foe_threats_are_the_generators}, .expectation = {.description = "PokemonSimulation planning_risk() rows"}, }, { - .name = "20.04 and 20.05 PokeGuy's Full Restore after Agatha and Elixir after Lance", - .input = {.body = test_pokeguy_items_between_fights}, - .expectation = {.description = "heal_after_agatha full_restore; restore_pp elixir before the Champion's door"}, + .name = "20.01 the League plan's steps: league_start, then the items before each fight", + .input = {.body = test_league_plan_steps}, + .expectation = {.description = "league_start before the door; league_between_fights before Bruno, Agatha, Lance and the Champion"}, }, }; @@ -325,6 +433,7 @@ void add_tests_AutoStoryLeague(UnitTestDatabase& database){ for (const auto& item : AUTO_STORY_LEAGUE_CASES){ database.add(item); } + add_tests_AutoStoryLeaguePlan(database); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLineTrainer.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLineTrainer.cpp index 0a0e755efa..56a033d8fd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLineTrainer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLineTrainer.cpp @@ -7,6 +7,7 @@ #include #include #include "Pokemon/AutoStory/Pokemon_TilePose.h" +#include "PokemonFRLG_AutoStoryMovedBoulders.h" #include "PokemonFRLG_AutoStoryLineTrainer.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryTrainerLine.h" @@ -43,6 +44,7 @@ Pokemon::Outcome trainers_back_on_warp(const std::function& const std::string map_before = state.pose.map; Pokemon::Outcome outcome = run(); trainers_back_after_map_change(map_before, state.pose.map, state.flags); + boulders_back_after_map_change(map_before, state.pose.map, state.flags); return outcome; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp index 31300bef8d..3cabc3ba9f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp @@ -5,6 +5,7 @@ */ #include +#include "Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h" #include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryMember.h" #include "PokemonFRLG_AutoStorySummary.h" @@ -59,13 +60,26 @@ LevelResult run_level_check(Logger& logger, const MemberReader& reader, const Le logger.log(std::format("Level: couldn't read slot {}'s level.", check.slot + 1), COLOR_RED); return {}; } - const bool reached = *member->level >= check.level; - logger.log(std::format( - "Level: slot {} ({}) is level {}, {} {}.", - check.slot + 1, member->species.empty() ? "?" : member->species, - *member->level, reached ? "at least" : "below", check.level - )); - return {.end = reached ? LevelEnd::REACHED : LevelEnd::BELOW, .level = member->level}; + const Pokemon::LevelVerdict verdict = Pokemon::level_verdict(*member->level, check.level); + const std::string species = member->species.empty() ? "?" : member->species; + switch (verdict){ + case Pokemon::LevelVerdict::MET: + logger.log(std::format("Level: slot {} ({}) is level {}, at least {}.", check.slot + 1, species, *member->level, check.level)); + break; + case Pokemon::LevelVerdict::WITHIN_TOLERANCE: + logger.log(std::format( + "Level: slot {} ({}) is level {}, below {} but within {} of it: going on.", + check.slot + 1, species, *member->level, check.level, Pokemon::LEVEL_CHECK_TOLERANCE + ), COLOR_ORANGE); + break; + case Pokemon::LevelVerdict::BELOW: + logger.log(std::format( + "Level: slot {} ({}) is level {}, more than {} below {}.", + check.slot + 1, species, *member->level, Pokemon::LEVEL_CHECK_TOLERANCE, check.level + ), COLOR_RED); + break; + } + return {.end = verdict == Pokemon::LevelVerdict::BELOW ? LevelEnd::BELOW : LevelEnd::REACHED, .level = member->level}; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h index 53ae672f3d..2f6fd0d697 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h @@ -38,7 +38,10 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// What a LEVEL step checks: party slot `slot` (0-5) is at least `level`. +// What a LEVEL step checks: party slot `slot` (0-5) is at least `level`, +// less the shared tolerance (Pokemon::level_verdict(), +// Types/Pokemon_StoryLevelCheck.h). A PARTY_STATS +// check: a run below its level skips the step. struct LevelCheck{ size_t slot = 0; unsigned level = 1; @@ -68,7 +71,8 @@ struct LevelResult{ std::optional level = std::nullopt; }; -// Reads the member and compares. +// Reads the member and compares (Pokemon::level_verdict()): within the +// tolerance it is REACHED, logged as a warning. LevelResult run_level_check(Logger& logger, const MemberReader& reader, const LevelCheck& check); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMoveData.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMoveData.h index 05869cfca1..b37c80241d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMoveData.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMoveData.h @@ -3,8 +3,8 @@ * From: https://github.com/PokemonAutomation/ * * What the story needs of moves, species and the type chart to choose an - * attack when the plan has none: each move's type, whether it does damage - * and its PP; each species' types (BattleData/moves.json, species.json, + * attack when the plan has none: each move's type, power and PP; each + * species' types (BattleData/moves.json, species.json, * type_chart.json, from pret/pokefirered). * */ @@ -33,6 +33,9 @@ struct MoveData{ // It does damage: any power, including moves whose damage doesn't // come from their power (Flail, Dragon Rage). bool damaging = false; + // Base power: 1 for a move whose damage doesn't come from it, 0 for + // one that does no damage (pret src/data/battle_moves.h). + uint8_t power = 0; // Full PP. uint8_t pp = 0; }; @@ -58,6 +61,10 @@ size_t type_effectiveness(PokemonType attack, PokemonType defend); // either of two; NONE for any other species. PokemonType ability_immunity(std::string_view species); +// `species` can have Thick Fat in Gen 3, as its only ability or either of +// two: Fire and Ice moves hit it at half power. +bool may_have_thick_fat(std::string_view species); + // `move` takes a turn to charge or to dig or fly up (Dig, Fly, Solar Beam, // Skull Bash, Razor Wind, Sky Attack), so it hits half as often as another // move of its strength. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.cpp new file mode 100644 index 0000000000..c8f7f8fa91 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.cpp @@ -0,0 +1,132 @@ +/* AutoStory Moved Boulders + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Pokemon/Navigation/Pokemon_GateTiles.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldTiles.h" +#include "PokemonFRLG_AutoStoryMovedBoulders.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The prefix of a pushed boulder's run flag (moved_boulders()). +constexpr std::string_view BOULDER_AT_FLAG = "boulder_at:"; + +// ",", or nothing if `text` isn't that. +std::optional parse_flag_tile(std::string_view text){ + const size_t comma = text.find(','); + if (comma == std::string_view::npos){ + return std::nullopt; + } + TilePos tile; + const std::string_view x_text = text.substr(0, comma); + const std::string_view y_text = text.substr(comma + 1); + const std::from_chars_result x_read = std::from_chars(x_text.data(), x_text.data() + x_text.size(), tile.x); + const std::from_chars_result y_read = std::from_chars(y_text.data(), y_text.data() + y_text.size(), tile.y); + if (x_read.ec != std::errc() || x_read.ptr != x_text.data() + x_text.size() + || y_read.ec != std::errc() || y_read.ptr != y_text.data() + y_text.size()){ + return std::nullopt; + } + return tile; +} + +std::string boulder_at_flag(const BoulderMove& move){ + return std::format("{}{}@{},{}={},{}", BOULDER_AT_FLAG, move.map, move.from.x, move.from.y, move.at.x, move.at.y); +} + +} // namespace + + +std::vector moved_boulders(const std::set& run_flags){ + std::vector moved; + for (const std::string& flag : run_flags){ + if (!flag.starts_with(BOULDER_AT_FLAG)){ + continue; + } + const std::string_view rest = std::string_view(flag).substr(BOULDER_AT_FLAG.size()); + const size_t at_sign = rest.find('@'); + const size_t equals = rest.find('='); + const bool shaped = at_sign != std::string_view::npos && at_sign != 0 && equals != std::string_view::npos && at_sign < equals; + const std::optional from = shaped ? parse_flag_tile(rest.substr(at_sign + 1, equals - at_sign - 1)) : std::nullopt; + const std::optional at = shaped ? parse_flag_tile(rest.substr(equals + 1)) : std::nullopt; + if (!from || !at){ + throw ParseException(std::format("run flag \"{}\" isn't \"{}@,=,\"", flag, BOULDER_AT_FLAG)); + } + moved.emplace_back(BoulderMove{.map = std::string(rest.substr(0, at_sign)), .from = *from, .at = *at}); + } + return moved; +} + +void note_boulder_pushed(const MapPosition& start, Direction direction, int64_t tiles, std::set& run_flags){ + const TilePos boulder = start.point.next(direction); + BoulderMove move{.map = start.map, .from = boulder, .at = boulder}; + for (const BoulderMove& before : moved_boulders(run_flags)){ + if (before.map == start.map && before.at == boulder){ + run_flags.erase(boulder_at_flag(before)); + move.from = before.from; + } + } + for (int64_t c = 0; c < tiles; c++){ + move.at = move.at.next(direction); + } + run_flags.insert(boulder_at_flag(move)); +} + +std::vector with_boulders_moved(std::vector maps, const std::vector& moved){ + for (const BoulderMove& move : moved){ + for (MapData& map : maps){ + if (map.name != move.map){ + continue; + } + // A boulder pushed onto a hole fell through it: it is gone from + // this floor, and the hole is open (OverworldSim::push_boulder()). + const bool fell = map.tiles.contains(move.at) && map.tiles.at(move.at) == TileKind::FALL_HOLE; + for (auto object = map.objects.begin(); object != map.objects.end(); ++object){ + if (object->name != "pushable_boulder" || object->x != move.from.x || object->y != move.from.y){ + continue; + } + if (fell){ + map.objects.erase(object); + }else{ + object->x = move.at.x; + object->y = move.at.y; + } + break; + } + } + } + return maps; +} + +void boulders_back_after_map_change(std::string_view map_before, std::string_view map_after, std::set& run_flags){ + if (map_before == map_after){ + return; + } + std::set on_switches; + for (const BoulderMove& move : moved_boulders(run_flags)){ + if (Pokemon::switch_with_button(load_map(move.map), move.at) != nullptr){ + on_switches.insert(boulder_at_flag(move)); + } + } + std::erase_if(run_flags, [&](const std::string& flag){ + return flag.starts_with(BOULDER_AT_FLAG) && !on_switches.contains(flag); + }); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.h new file mode 100644 index 0000000000..f6cacc93d4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.h @@ -0,0 +1,67 @@ +/* AutoStory Moved Boulders + * + * From: https://github.com/PokemonAutomation/ + * + * Where the Strength boulders a run pushed stand, kept as run flags, and + * the maps the walks after plan on, with the boulders there. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryMovedBoulders_H +#define PokemonAutomation_PokemonFRLG_AutoStoryMovedBoulders_H + +#include +#include +#include +#include +#include +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" +#include "PokemonFRLG_AutoStoryCheckpoints.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// A Strength boulder pushed off its map tile: the map, the tile the map +// has it on, and where it stands now. +struct BoulderMove{ + std::string map; + TilePos from; + TilePos at; +}; + +// The boulders `run_flags` says were pushed: a run flag each, +// "boulder_at:@,=,", the boulder's map tile, then the +// tile it stands on now ("boulder_at:VictoryRoad_1F@7,18=7,19"). The +// walks after a push plan around it there (run_story_maps()); with the +// boulder on its map tile instead, by_boulder_2_corner of 19.04b planned +// south from (7, 18) onto the boulder pushed to (7, 19), bumped it, and +// every leg after ran a row off (console B, 2026-11-16). A flag that +// doesn't parse throws ParseException. +std::vector moved_boulders(const std::set& run_flags); + +// Records in `run_flags` a push of the boulder `direction` of the player's +// `start` by `tiles` tiles: a boulder already pushed keeps its map tile in +// the flag. +void note_boulder_pushed(const MapPosition& start, Direction direction, int64_t tiles, std::set& run_flags); + +// `maps` with each boulder of `moved` on the tile it was pushed to, or +// gone if that tile is a hole it fell through: with it standing on 3F's +// hole (34, 18), 19.04d's drop_to_2f went round by 3F's west room into +// Cooltrainer Colby's line (console B, 2026-11-16). +std::vector with_boulders_moved(std::vector maps, const std::vector& moved); + +// After a step from `map_before` that ended on `map_after`: if the player +// left the map, the game put its boulders back on their map tiles, and +// their flags leave `run_flags`. Not a boulder on a floor switch's button: +// Victory Road's switch scripts keep it there for good +// (copyobjectxytoperm in pokefirered's VictoryRoad_*_EventScript_FloorSwitch). +void boulders_back_after_map_change(std::string_view map_before, std::string_view map_after, std::set& run_flags); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.cpp index 3ada1a2ccb..0e5d3cd57c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.cpp @@ -11,6 +11,7 @@ #include "Common/Cpp/Concurrency/Mutex.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_HideoutLiftRoom.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "PokemonFRLG_AutoStoryMovedBoulders.h" #include "PokemonFRLG_AutoStoryMovedTrainers.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" @@ -70,7 +71,8 @@ const std::vector& run_story_maps(const std::set& run_flag const bool cleared = run_flags.contains(std::string(SILPH_CLEARED_FLAG)); const std::vector& base = cleared ? cleared_story_maps() : story_maps(); const std::vector moved = moved_trainers(run_flags); - if (moved.empty()){ + const std::vector pushed = moved_boulders(run_flags); + if (moved.empty() && pushed.empty()){ return base; } // One copy per set of trainers moved, kept while the program runs: @@ -80,12 +82,15 @@ const std::vector& run_story_maps(const std::set& run_flag for (const TrainerMove& move : moved){ key += std::format("|{}={},{}", move.trainer, move.x, move.y); } + for (const BoulderMove& push : pushed){ + key += std::format("|{}@{},{}={},{}", push.map, push.from.x, push.from.y, push.at.x, push.at.y); + } static Mutex lock; static std::map> moved_maps; LockGuard guard(lock); auto it = moved_maps.find(key); if (it == moved_maps.end()){ - it = moved_maps.emplace(key, with_trainers_moved(base, moved)).first; + it = moved_maps.emplace(key, with_boulders_moved(with_trainers_moved(base, moved), pushed)).first; } return it->second; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.h index e7e6e6eb72..889f5e8c61 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.h @@ -54,7 +54,14 @@ inline constexpr std::string_view TRAINER_BEATEN_FLAG = "trainer_beaten:"; std::set beaten_trainers(const std::set& run_flags); // default_route_costs() without Surf, which the story hasn't got yet: // routes stay on land, even where water is the shorter way (Vermilion -// City's harbor). +// City's harbor). Trainers' lines cost (RouteCost::LINE_TILE 100): a +// battle the story wants has its own step into the line, and a route up +// Route 25's column 12 met Franklin on (12, 4) before 05.06's +// franklin_line. An open leg's check costs nothing (RouteCost::OPEN_CHECK +// 0): FRLG walks a tile per step on land, so an open leg lands where it +// was planned. Weighed, it sent routes to touch walls on the way (12.03 +// mansion_door: east 3 and north 2 to walls, west 11, north 1, for the +// console-passed north 3, west 8). const RouteCosts& story_route_costs(); // A ROUTE's legs from `pose` to `goal`, on story_route_costs(): from diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacing.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacing.cpp index 74f811fbbd..9df9952da4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacing.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacing.cpp @@ -1,54 +1,37 @@ -/* AutoStory Pacing - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include "CommonFramework/VideoPipeline/VideoFeed.h" -#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" -#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_MovementMechanics.h" -#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BikeSpinPresses.h" -#include "PokemonFRLG_AutoStoryPacing.h" -#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBike.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - -using OverworldWalkSteps::BikeSelectCalls; - - -bool select_off_bike(const BikeSelectCalls& calls){ - for (size_t c = 0; c < 2 && calls.riding(); c++){ - calls.press_select(); - } - return !calls.riding(); -} - -bool find_paced_encounter(Logger& logger, const BikeSelectCalls& bike, PatchSteps& steps){ - if (!select_off_bike(bike)){ - logger.log("Pacing: still on the Bicycle after SELECT twice; not pacing on it.", COLOR_RED); - return false; - } - return pace_until_battle(logger, steps, PACE_MAX_STEPS); -} - -BikeSelectCalls console_bike_select(ConsoleHandle& console, ProControllerContext& context, PlayerGender player){ - BikeSelectCalls calls; - calls.press_select = [&console, &context]{ - console.log("Pacing: SELECT (MINUS) off the Bicycle."); - pbf_press_button(context, BUTTON_MINUS, MovementMechanics::BIKE_SELECT_PRESS, MovementMechanics::BIKE_SELECT_SETTLE); - }; - calls.riding = [&console, &context, player]{ - context.wait_for_all_requests(); - VideoSnapshot screen = console.video().snapshot(); - return screen && OverworldWalkSteps::screen_shows_riding(*screen.frame, player); - }; - return calls; -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation +/* AutoStory Pacing + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_MovementMechanics.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BikeSpinPresses.h" +#include "PokemonFRLG_AutoStoryPacing.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBike.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using OverworldWalkSteps::BikeSelectCalls; + + +bool select_off_bike(const BikeSelectCalls& calls){ + for (size_t c = 0; c < 2 && calls.riding(); c++){ + calls.press_select(); + } + return !calls.riding(); +} + +bool find_paced_encounter(Logger& logger, const BikeSelectCalls& bike, PatchSteps& steps){ + if (!select_off_bike(bike)){ + logger.log("Pacing: still on the Bicycle after SELECT twice; not pacing on it.", COLOR_RED); + return false; + } + return pace_until_battle(logger, steps, PACE_MAX_STEPS); +} + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp index d273752dc0..78648f873b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include "PokemonFRLG_AutoStoryMoveData.h" #include "PokemonFRLG_AutoStoryParty.h" @@ -224,24 +225,59 @@ bool useless_against(const MoveData& move, std::string_view foe){ return ability_immunity(foe) == move.type || water_on_water || wonder_guard; } -// `move`'s type multiplier, in tenths, summed over `foes`: 0 against a foe -// it may do nothing to (useless_against()), halved for a two-turn move; 0 -// for a move that does no damage. Each foe must be in species_data(). (The -// data has no power, so STAB is left to the plan's order, which breaks ties.) -size_t matchup(std::string_view move, const std::vector& foes){ - const MoveData* data = move_data(move); - if (data == nullptr || !data->damaging){ +// In Gen 3 a move's type makes it physical or special. +bool physical(PokemonType type){ + switch (type){ + case PokemonType::NORMAL: + case PokemonType::FIGHTING: + case PokemonType::FLYING: + case PokemonType::POISON: + case PokemonType::GROUND: + case PokemonType::ROCK: + case PokemonType::BUG: + case PokemonType::GHOST: + case PokemonType::STEEL: + return true; + default: + return false; + } +} + +// A side's attacking or defending stat where the stats aren't known: the +// same for both, so only power and the multipliers tell moves apart. +constexpr double EVEN_STAT = 100; +// The level taken while the member's isn't known. +constexpr int DEFAULT_LEVEL = 50; + +// `move`'s Gen 3 damage on `foe` (pret src/battle_util.c +// CalculateBaseDamage, without the random roll and critical hits), 0 when +// it may do nothing; halved for a two-turn move. `foe` must be in species_data(). +double damage(const PartyMember& member, const MoveData& move, std::string_view move_name, std::string_view foe, const AttackContext& context){ + if (!move.damaging || useless_against(move, foe)){ return 0; } - size_t total = 0; - for (const std::string& foe : foes){ - if (useless_against(*data, foe)){ - continue; - } - size_t tenths = effectiveness(*data, *species_data(foe)); - total += takes_two_turns(move) ? tenths / 2 : tenths; + const bool is_physical = physical(move.type); + double attack = EVEN_STAT; + if (member.stats){ + attack = is_physical ? member.stats->attack : member.stats->sp_attack; + } + attack = std::floor(attack * stage_multiplier(is_physical ? context.attack_stage : context.sp_attack_stage)); + double defense = EVEN_STAT; + if (context.foe){ + defense = std::max(1, is_physical ? context.foe->defense : context.foe->sp_defense); + } + double power = move.power; + if (may_have_thick_fat(foe) && (move.type == PokemonType::FIRE || move.type == PokemonType::ICE)){ + power = std::floor(power / 2); } - return total; + const int level = battle_level(member) > 0 ? battle_level(member) : DEFAULT_LEVEL; + double hit = std::floor(std::floor(std::floor(2.0 * level / 5 + 2) * power * attack / defense) / 50) + 2; + const SpeciesData* types = species_data(member.species); + if (types != nullptr && (types->first == move.type || types->second == move.type)){ + hit = std::floor(hit * 1.5); + } + hit = std::floor(hit * static_cast(effectiveness(move, *species_data(foe))) / 10); + return takes_two_turns(move_name) ? hit / 2 : hit; } // The member's slots in the plan's order: its line's attacks first, as @@ -394,7 +430,23 @@ std::optional attack_slot(const PartyMember& member){ return TOP_LEFT_MOVE; } -std::optional attack_slot_against(const PartyMember& member, const std::vector& foes){ +double most_damage_against(const PartyMember& member, std::string_view foe, const AttackContext& context){ + if (species_data(foe) == nullptr){ + return 0; + } + double most = 0; + for (const KnownMove& known_move : member.moves){ + const MoveData* data = move_data(known_move.move); + if (data != nullptr && known_move.pp > 0){ + most = std::max(most, damage(member, *data, known_move.move, foe, context)); + } + } + return most; +} + +std::optional attack_slot_against( + const PartyMember& member, const std::vector& foes, const AttackContext& context +){ const std::optional plan = attack_slot(member); std::vector known; std::ranges::copy_if(foes, std::back_inserter(known), [](const std::string& foe){ @@ -404,12 +456,21 @@ std::optional attack_slot_against(const PartyMember& member, const std:: return plan; } std::optional best; - size_t best_matchup = 0; + double best_damage = 0; for (size_t slot : attack_order(member)){ - const size_t tenths = matchup(member.moves[slot].move, known); - if (member.moves[slot].pp > 0 && tenths > best_matchup){ + const KnownMove& known_move = member.moves[slot]; + const MoveData* data = move_data(known_move.move); + if (data == nullptr || known_move.pp <= 0){ + continue; + } + double total = 0; + for (const std::string& foe : known){ + total += damage(member, *data, known_move.move, foe, context); + } + const bool more_pp = best && total == best_damage && known_move.pp > member.moves[*best].pp; + if (total > 0 && (total > best_damage || more_pp)){ best = slot; - best_matchup = tenths; + best_damage = total; } } if (best){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.h index ae16cd586d..1443e7db4d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.h @@ -48,15 +48,25 @@ namespace PokemonFRLG{ std::optional attack_slot(const PartyMember& member); // The slot to attack `foes` with, any of them as likely to be out: the -// damaging move with PP left whose expected damage, summed over the foes, -// is best (type multiplier; 0 against a foe its ability may make immune, -// for a Water move on a Water foe, and on Shedinja unless super -// effective; halved for a two-turn move); ties go to the plan's attacks, -// then slot order. With no damaging move doing anything, the first move -// with PP left that isn't such a move. A foe the data doesn't have is left -// out; with none left, or while the story doesn't know all the lead's -// moves, attack_slot() itself. -std::optional attack_slot_against(const PartyMember& member, const std::vector& foes); +// damaging move with PP left whose Gen 3 damage, summed over the foes, is +// highest. The damage takes the member's level, its Attack or Sp. Atk +// (by the move's type, as in Gen 3) at its stage, the foe's Defense or +// Sp. Def, the move's power (halved for Fire and Ice on a foe that may +// have Thick Fat), STAB and the type multiplier; 0 against a foe its +// ability may make immune, for a Water move on a Water foe, and on +// Shedinja unless super effective; halved for a two-turn move. Without +// the member's stats both of its attacking stats count alike. Ties go to +// the move with more PP left, then the plan's attacks, then slot order. +// With no damaging move doing anything, the first move with PP left that +// isn't such a move. A foe the data doesn't have is left out; with none +// left, or while the story doesn't know all the lead's moves, +// attack_slot() itself. +std::optional attack_slot_against(const PartyMember& member, const std::vector& foes, const AttackContext& context = {}); + +// The most damage one of the member's damaging moves with PP left does to +// `foe`, by attack_slot_against()'s estimate (the highest roll, no +// critical hit); 0 if none does any or the data doesn't have the foe. +double most_damage_against(const PartyMember& member, std::string_view foe, const AttackContext& context); // A TM, HM or tutor taught it `move` at full PP: in `forgot`'s slot, or // in a free one when it forgot nothing. The game puts it there (console B, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcRun.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcRun.h index b32bf29283..e6c1f8cc35 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcRun.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcRun.h @@ -60,7 +60,8 @@ struct PcResult{ // Reads after this many presses without the overworld back: a failure. constexpr size_t PC_MAX_PRESSES = 80; -// OTHER read this many times in a row: a failure. +// A screen still changing (OTHER, or a box screen with its hand unread) +// read this many times in a row, about 5 s on the console: a failure. constexpr size_t PC_MAX_OTHER_IN_A_ROW = 10; // The overworld read this many times after A at the PC: it didn't boot. constexpr size_t PC_BOOT_READS = 4; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp index 088540b59d..fdaea2a94b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.cpp @@ -42,6 +42,18 @@ std::string pc_transfer_text(const PcTransfer& transfer){ return std::format("withdraw box={} slot={}", transfer.box + 1, transfer.box_slot + 1); } +// Whether `view` is a PC screen to act on, not one changing: a fade (a +// dark frame reads as OTHER) or, before the transfer, a box screen whose +// hand isn't read yet. After the transfer a box screen is only left, by B, +// which needs no hand. +bool settled(const PcView& view, bool transferred){ + if (view.screen == PcScreen::OTHER){ + return false; + } + const bool box_screen = view.screen == PcScreen::BOX_GRID || view.screen == PcScreen::PARTY_PANEL; + return transferred || !box_screen || view.cursor.has_value(); +} + } // namespace @@ -131,9 +143,18 @@ PcStorageDialog::PcStorageDialog(const PcTransfer& transfer) {} PcDecision PcStorageDialog::next(const PcView& view){ - if (view.screen != PcScreen::OTHER){ - m_others_in_a_row = 0; + // A fade, or a box screen still drawing its hand: wait for the screen, + // as long as a PC screen change takes, and press nothing into it. + if (!settled(view, m_transferred)){ + if (++m_others_in_a_row >= PC_MAX_OTHER_IN_A_ROW){ + return {PcPress::FAIL, view.screen == PcScreen::OTHER + ? std::format("no PC screen recognized in {} reads", m_others_in_a_row) + : std::format("the hand wasn't read on the {} in {} reads", pc_screen_name(view.screen), m_others_in_a_row) + }; + } + return {PcPress::WAIT}; } + m_others_in_a_row = 0; switch (view.screen){ case PcScreen::OVERWORLD: return on_overworld(); @@ -163,9 +184,6 @@ PcDecision PcStorageDialog::next(const PcView& view){ } return {PcPress::FAIL, "a YES/NO before the transfer"}; case PcScreen::OTHER: - if (++m_others_in_a_row >= PC_MAX_OTHER_IN_A_ROW){ - return {PcPress::FAIL, std::format("no PC screen recognized in {} reads", m_others_in_a_row)}; - } return {PcPress::WAIT}; } return {PcPress::FAIL, "unknown screen"}; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp index b0e2f14b14..6e96af70cf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage_Tests.cpp @@ -6,7 +6,8 @@ * Pokemon Storage System does (see PokemonFRLG_AutoStoryPcStorage.h): * deposits and withdrawals end with the Pokemon moved and the overworld * back; the refusals; a screen that isn't read fails instead of pressing - * on; and RELEASE is never reached. + * on; RELEASE is never reached; and nothing is pressed into the fades + * into and out of the box screens. * */ @@ -17,6 +18,7 @@ #include #include #include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Time.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "PokemonFRLG_AutoStoryPcStorage.h" @@ -27,6 +29,8 @@ namespace PokemonFRLG{ namespace{ +using namespace std::chrono_literals; + class QuietLogger : public Logger{ public: using Logger::log; @@ -47,6 +51,10 @@ class FakePc : public PcStorageActions{ size_t current_box = 0; // Screens whose cursor the step can't read. std::vector cursor_unread = {}; + // Into and out of a box screen: the black fade, then the box screen + // without its hand for this long. + Milliseconds box_fade = 0ms; + Milliseconds hand_late = 0ms; std::vector presses; // Set by a press the game would take some other way than the step means. std::string error; @@ -55,6 +63,12 @@ class FakePc : public PcStorageActions{ return party; } virtual PcView read_view() override{ + if (m_fade_left > 0ms){ + return {}; + } + if (m_hand_left > 0ms){ + return {.screen = m_screen}; + } PcView view{.screen = m_screen}; if (std::find(cursor_unread.begin(), cursor_unread.end(), m_screen) == cursor_unread.end() && m_screen != PcScreen::OVERWORLD && m_screen != PcScreen::TEXT @@ -72,6 +86,13 @@ class FakePc : public PcStorageActions{ } virtual void press(PcPress press) override{ presses.emplace_back(pc_press_name(press)); + if (m_fade_left > 0ms || m_hand_left > 0ms){ + if (press != PcPress::WAIT){ + error = std::format("pressed {} while the screen changed", pc_press_name(press)); + } + elapse(press); + return; + } switch (m_screen){ case PcScreen::OVERWORLD: if (press == PcPress::A){ @@ -127,6 +148,7 @@ class FakePc : public PcStorageActions{ } m_screen = m_cursor == 0 ? PcScreen::BOX_GRID : PcScreen::PARTY_PANEL; m_cursor = 0; + change_screen(); } // The party's six slots, then CLOSE BOX. void press_party_panel(PcPress press){ @@ -222,7 +244,25 @@ class FakePc : public PcStorageActions{ }else if (press == PcPress::B){ m_screen = PcScreen::STORAGE_MENU; m_cursor = m_option; + change_screen(); + } + } + + void change_screen(){ + m_fade_left = box_fade; + m_hand_left = m_screen == PcScreen::STORAGE_MENU ? 0ms : hand_late; + } + // The time a press takes on the console (ConsolePcStorageActions). + void elapse(PcPress press){ + Milliseconds time = 500ms; + if (press == PcPress::A || press == PcPress::B){ + time = 800ms; + }else if (press != PcPress::WAIT){ + time = 480ms; } + const Milliseconds fade = std::min(time, m_fade_left); + m_fade_left -= fade; + m_hand_left = std::max(0ms, m_hand_left - (time - fade)); } void show_text(PcScreen after, size_t pages){ @@ -249,6 +289,8 @@ class FakePc : public PcStorageActions{ PcScreen m_back = PcScreen::OVERWORLD; size_t m_held = 0; size_t m_grid_cursor = 0; + Milliseconds m_fade_left = 0ms; + Milliseconds m_hand_left = 0ms; }; @@ -312,6 +354,8 @@ struct PcCase{ std::vector box2 = {}; size_t current_box = 0; std::vector cursor_unread = {}; + Milliseconds box_fade = 0ms; + Milliseconds hand_late = 0ms; PcEnd end = PcEnd::DONE; std::string party_after = {}; std::string box1_after = {}; @@ -347,6 +391,37 @@ const std::vector PC_CASES = { .party_after = "squirtle magikarp", .box1_after = "pidgey spearow ekans", }, + { + .name = "withdraw with the box up 2.5 s after A: 2 s of fade, 0.5 s before the hand (console B, 2026-11-16)", + .transfer = {.action = PcAction::WITHDRAW, .box = 0, .box_slot = 0}, + .party = {{.species = "squirtle"}}, + .box1 = {"magikarp", "rattata"}, + .box_fade = 2000ms, + .hand_late = 500ms, + .end = PcEnd::DONE, + .party_after = "squirtle magikarp", + .box1_after = "rattata", + }, + { + .name = "deposit through the same fades into and out of the box", + .transfer = {.action = PcAction::DEPOSIT, .party_slot = 1, .box = 0}, + .party = SQUIRTLE_MAGIKARP, + .box_fade = 2000ms, + .hand_late = 500ms, + .end = PcEnd::DONE, + .party_after = "squirtle", + .box1_after = "magikarp", + }, + { + .name = "a fade that doesn't end: fail, nothing pressed into it", + .transfer = {.action = PcAction::WITHDRAW, .box = 0, .box_slot = 0}, + .party = {{.species = "squirtle"}}, + .box1 = {"magikarp"}, + .box_fade = 60000ms, + .end = PcEnd::FAILED, + .party_after = "squirtle", + .box1_after = "magikarp", + }, { .name = "withdraw an empty slot", .transfer = {.action = PcAction::WITHDRAW, .box = 0, .box_slot = 3}, @@ -432,6 +507,8 @@ UnitTestResult test_pc_transfers(){ } pc.current_box = item.current_box; pc.cursor_unread = item.cursor_unread; + pc.box_fade = item.box_fade; + pc.hand_late = item.hand_late; const PcResult result = run_pc_transfer(logger, pc, item.transfer); if (!pc.error.empty()){ return item.name + ": " + pc.error + " after " + joined(pc.presses); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h index 0dfc835fe1..2006c10f9b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h @@ -143,11 +143,8 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_19[] = { "19.04b walk west 2 (to wall) -> VictoryRoad_1F (15, 18) [wild]", "19.04b walk north 1 (to wall) -> VictoryRoad_1F (15, 17) [wild]", "19.04b walk west 4 (to wall) -> VictoryRoad_1F (11, 17) [wild]", - "19.04b walk south 4 (warp) -> Route23 (5, 29) [wild]", - "19.04b walk north 1 (warp) -> VictoryRoad_1F (11, 20)", - "19.04b walk west 3 (to wall) -> VictoryRoad_1F (8, 20) [wild]", - "19.04b walk north 1 (to wall) -> VictoryRoad_1F (8, 19) [wild]", - "19.04b walk west 4 (to wall) -> VictoryRoad_1F (4, 19) [wild]", + "19.04b walk south 2 -> VictoryRoad_1F (11, 19) [wild]", + "19.04b walk west 7 (to wall) -> VictoryRoad_1F (4, 19) [wild]", "19.04b walk north 1 (to wall) -> VictoryRoad_1F (4, 18) [wild]", "19.04b walk east 2 (to wall) -> VictoryRoad_1F (6, 18) [wild]", "19.04b walk north 1 (to wall) -> VictoryRoad_1F (6, 17) [wild]", @@ -266,10 +263,11 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_19[] = { "19.04d walk east 13 (to wall) -> VictoryRoad_3F (17, 15) [wild]", "19.04d hole_way_9 from VictoryRoad_3F (17, 15) facing east to VictoryRoad_3F (17, 19)", "19.04d walk south 4 (to wall) -> VictoryRoad_3F (17, 19) [wild]", - "19.04d behind_hole_boulder from VictoryRoad_3F (17, 19) facing south to VictoryRoad_3F (32, 18)", - "19.04d walk east 4 -> VictoryRoad_3F (21, 19) [wild]", - "19.04d walk north 1 -> VictoryRoad_3F (21, 18) [wild]", - "19.04d walk east 11 (to wall) -> VictoryRoad_3F (32, 18) [wild]", + "19.04d below_hole from VictoryRoad_3F (17, 19) facing south to VictoryRoad_3F (34, 19)", + "19.04d walk east 17 (to wall) -> VictoryRoad_3F (34, 19) [wild]", + "19.04d behind_hole_boulder from VictoryRoad_3F (34, 19) facing east to VictoryRoad_3F (32, 18)", + "19.04d walk west 2 -> VictoryRoad_3F (32, 19) [wild]", + "19.04d walk north 1 -> VictoryRoad_3F (32, 18) [wild]", "19.04d drop_to_2f from VictoryRoad_3F (33, 18) facing east to VictoryRoad_2F (34, 19)", "19.04d walk east 1 (warp) -> VictoryRoad_2F (34, 19) [wild]", "19.04d exit_way_1 from VictoryRoad_2F (15, 19) facing west to VictoryRoad_2F (31, 19)", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden20.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden20.h index d76feb6afe..3a61d07daf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden20.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden20.h @@ -30,32 +30,32 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_20[] = { "20.01 face north -> IndigoPlateau_PokemonCenter_1F (4, 2) [walk only]", "20.01 before_lorelei from PokemonLeague_LoreleisRoom (6, 7) facing north to PokemonLeague_LoreleisRoom (6, 6) facing north", "20.01 walk north 1 (to wall) -> PokemonLeague_LoreleisRoom (6, 6) [walk only]", - "20.02 below_loreleis_door from PokemonLeague_LoreleisRoom (6, 6) facing north to PokemonLeague_LoreleisRoom (6, 3) facing north", - "20.02 walk east 1 -> PokemonLeague_LoreleisRoom (7, 6) [walk only]", - "20.02 walk north 3 (to wall) -> PokemonLeague_LoreleisRoom (7, 3) [walk only]", - "20.02 walk west 1 -> PokemonLeague_LoreleisRoom (6, 3) [walk only]", - "20.02 face north -> PokemonLeague_LoreleisRoom (6, 3) [walk only]", - "20.02 before_bruno from PokemonLeague_BrunosRoom (6, 7) facing north to PokemonLeague_BrunosRoom (6, 6) facing north", - "20.02 walk north 1 (to wall) -> PokemonLeague_BrunosRoom (6, 6) [walk only]", - "20.03 below_brunos_door from PokemonLeague_BrunosRoom (6, 6) facing north to PokemonLeague_BrunosRoom (6, 3) facing north", - "20.03 walk east 1 -> PokemonLeague_BrunosRoom (7, 6) [walk only]", - "20.03 walk north 3 (to wall) -> PokemonLeague_BrunosRoom (7, 3) [walk only]", - "20.03 walk west 1 -> PokemonLeague_BrunosRoom (6, 3) [walk only]", - "20.03 face north -> PokemonLeague_BrunosRoom (6, 3) [walk only]", - "20.03 before_agatha from PokemonLeague_AgathasRoom (6, 7) facing north to PokemonLeague_AgathasRoom (6, 6) facing north", - "20.03 walk north 1 (to wall) -> PokemonLeague_AgathasRoom (6, 6) [walk only]", - "20.04 below_agathas_door from PokemonLeague_AgathasRoom (6, 6) facing north to PokemonLeague_AgathasRoom (6, 3) facing north", - "20.04 walk east 1 -> PokemonLeague_AgathasRoom (7, 6) [walk only]", - "20.04 walk north 3 (to wall) -> PokemonLeague_AgathasRoom (7, 3) [walk only]", - "20.04 walk west 1 -> PokemonLeague_AgathasRoom (6, 3) [walk only]", - "20.04 face north -> PokemonLeague_AgathasRoom (6, 3) [walk only]", - "20.04 before_lance from PokemonLeague_LancesRoom (6, 10) facing north to PokemonLeague_LancesRoom (6, 9) facing north", - "20.04 walk north 1 (to wall) -> PokemonLeague_LancesRoom (6, 9) [walk only]", - "20.05 below_champions_door from PokemonLeague_LancesRoom (6, 9) facing north to PokemonLeague_LancesRoom (6, 6) facing north", - "20.05 walk east 1 -> PokemonLeague_LancesRoom (7, 9) [walk only]", - "20.05 walk north 3 (to wall) -> PokemonLeague_LancesRoom (7, 6) [walk only]", - "20.05 walk west 1 -> PokemonLeague_LancesRoom (6, 6) [walk only]", - "20.05 face north -> PokemonLeague_LancesRoom (6, 6) [walk only]", + "20.01 below_loreleis_door from PokemonLeague_LoreleisRoom (6, 6) facing north to PokemonLeague_LoreleisRoom (6, 3) facing north", + "20.01 walk east 1 -> PokemonLeague_LoreleisRoom (7, 6) [walk only]", + "20.01 walk north 3 (to wall) -> PokemonLeague_LoreleisRoom (7, 3) [walk only]", + "20.01 walk west 1 -> PokemonLeague_LoreleisRoom (6, 3) [walk only]", + "20.01 face north -> PokemonLeague_LoreleisRoom (6, 3) [walk only]", + "20.01 before_bruno from PokemonLeague_BrunosRoom (6, 7) facing north to PokemonLeague_BrunosRoom (6, 6) facing north", + "20.01 walk north 1 (to wall) -> PokemonLeague_BrunosRoom (6, 6) [walk only]", + "20.01 below_brunos_door from PokemonLeague_BrunosRoom (6, 6) facing north to PokemonLeague_BrunosRoom (6, 3) facing north", + "20.01 walk east 1 -> PokemonLeague_BrunosRoom (7, 6) [walk only]", + "20.01 walk north 3 (to wall) -> PokemonLeague_BrunosRoom (7, 3) [walk only]", + "20.01 walk west 1 -> PokemonLeague_BrunosRoom (6, 3) [walk only]", + "20.01 face north -> PokemonLeague_BrunosRoom (6, 3) [walk only]", + "20.01 before_agatha from PokemonLeague_AgathasRoom (6, 7) facing north to PokemonLeague_AgathasRoom (6, 6) facing north", + "20.01 walk north 1 (to wall) -> PokemonLeague_AgathasRoom (6, 6) [walk only]", + "20.01 below_agathas_door from PokemonLeague_AgathasRoom (6, 6) facing north to PokemonLeague_AgathasRoom (6, 3) facing north", + "20.01 walk east 1 -> PokemonLeague_AgathasRoom (7, 6) [walk only]", + "20.01 walk north 3 (to wall) -> PokemonLeague_AgathasRoom (7, 3) [walk only]", + "20.01 walk west 1 -> PokemonLeague_AgathasRoom (6, 3) [walk only]", + "20.01 face north -> PokemonLeague_AgathasRoom (6, 3) [walk only]", + "20.01 before_lance from PokemonLeague_LancesRoom (6, 10) facing north to PokemonLeague_LancesRoom (6, 9) facing north", + "20.01 walk north 1 (to wall) -> PokemonLeague_LancesRoom (6, 9) [walk only]", + "20.01 below_champions_door from PokemonLeague_LancesRoom (6, 9) facing north to PokemonLeague_LancesRoom (6, 6) facing north", + "20.01 walk east 1 -> PokemonLeague_LancesRoom (7, 9) [walk only]", + "20.01 walk north 3 (to wall) -> PokemonLeague_LancesRoom (7, 6) [walk only]", + "20.01 walk west 1 -> PokemonLeague_LancesRoom (6, 6) [walk only]", + "20.01 face north -> PokemonLeague_LancesRoom (6, 6) [walk only]", }; } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.cpp new file mode 100644 index 0000000000..8ccf9f7c6c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.cpp @@ -0,0 +1,398 @@ +/* AutoStory Planned Battle + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "PokemonFRLG_AutoStoryGen3Damage.h" +#include "PokemonFRLG_AutoStoryLeagueFightData.h" +#include "PokemonFRLG_AutoStoryMoveData.h" +#include "PokemonFRLG_AutoStoryPlannedBattle.h" +#include "PokemonFRLG_AutoStoryPlannedRisk.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +using Pokemon::PokemonType; + +// The quantiles a multi-hit move's total is read as (the sim's damage.cjs). +constexpr int HIT_QUANTILES = 32; + +// The League's items as the policy counts them. +constexpr std::string_view LEAGUE_ITEMS[] = { + "full-restore", "max-potion", "hyper-potion", "super-potion", "full-heal", "parlyz-heal", "antidote", + "awakening", "burn-heal", "ice-heal", "elixir", "max-elixir", "x-special", "x-speed", "x-accuracy", + "x-attack", "x-defend", "guard-spec", +}; + +// One side of a hit: its stats as the battle uses them (badges applied), +// its HP, stages and status. +struct Side{ + int level = 1; + Stats stats = {}; + int hp = 0; + SpeciesData types = {}; + std::string ability = {}; + StatStages stages = {}; + PlannedStatus status = PlannedStatus::NONE; +}; + +// The pinch abilities of the species that have one as their only +// ability (the starters' lines): our lead's, which the story doesn't read. +std::string pinch_ability(std::string_view species){ + static const std::map ABILITIES{ + {"bulbasaur", "overgrow"}, {"ivysaur", "overgrow"}, {"venusaur", "overgrow"}, + {"charmander", "blaze"}, {"charmeleon", "blaze"}, {"charizard", "blaze"}, + {"squirtle", "torrent"}, {"wartortle", "torrent"}, {"blastoise", "torrent"}, + }; + const auto it = ABILITIES.find(species); + return it == ABILITIES.end() ? std::string() : std::string(it->second); +} + +// Overgrow, Blaze, Torrent and Swarm: x1.5 power to their type at a +// third of the HP or less (@smogon/calc calculateBasePowerADV, pret). +int base_power(const LeagueMoveData& move, const Side& attacker){ + const bool pinch = (attacker.ability == "overgrow" && move.type == PokemonType::GRASS) + || (attacker.ability == "blaze" && move.type == PokemonType::FIRE) + || (attacker.ability == "torrent" && move.type == PokemonType::WATER) + || (attacker.ability == "swarm" && move.type == PokemonType::BUG); + return pinch && attacker.hp * 3 <= attacker.stats.hp ? move.power * 3 / 2 : move.power; +} + +// The foe's HP as its bar's fill shows it. +int hp_of_fill(double fill, int max_hp){ + return fill <= 0 ? 0 : std::max(1, static_cast(std::lround(fill * max_hp))); +} + +// The weather on a move of `type` (@smogon/calc calculateFinalModsADV). +double weather_modifier(FieldWeather weather, PokemonType type, bool solar_beam){ + const bool sun = weather == FieldWeather::SUN; + const bool rain = weather == FieldWeather::RAIN; + if ((sun && type == PokemonType::FIRE) || (rain && type == PokemonType::WATER)){ + return 1.5; + } + if ((sun && type == PokemonType::WATER) || (rain && type == PokemonType::FIRE) || (rain && solar_beam)){ + return 0.5; + } + return 1.0; +} + +// The attacker's Attack or Sp. Atk before its stage (@smogon/calc +// calculateAttackADV): halved by the defender's Thick Fat on a Fire or +// Ice hit, then x1.5 for Guts with a status on a physical one. +int attack_stat(const LeagueMoveData& move, const Side& attacker, const Side& defender){ + int attack = move.physical ? attacker.stats.attack : attacker.stats.sp_attack; + if (defender.ability == "thickfat" && (move.type == PokemonType::FIRE || move.type == PokemonType::ICE)){ + attack /= 2; + } + if (move.physical && attacker.ability == "guts" && attacker.status != PlannedStatus::NONE){ + attack = attack * 3 / 2; + } + return attack; +} + +double effectiveness(PokemonType attack, PokemonType defend){ + return static_cast(type_effectiveness(attack, defend)) / 10.0; +} + +bool ability_blocks(std::string_view ability, PokemonType type){ + return (ability == "waterabsorb" && type == PokemonType::WATER) + || (ability == "voltabsorb" && type == PokemonType::ELECTRIC) + || (ability == "flashfire" && type == PokemonType::FIRE) + || (ability == "levitate" && type == PokemonType::GROUND); +} + +// A multi-hit move's total, as HIT_QUANTILES equally likely values: +// 2 and 3 hits 3/8 each, 4 and 5 hits 1/8 each (a fixed count: all of it). +std::vector multi_hit_rolls(const std::vector& per_hit, std::pair hits){ + const std::vector> weights = hits.first == hits.second + ? std::vector>{{hits.first, 1.0}} + : std::vector>{{2, 3.0 / 8}, {3, 3.0 / 8}, {4, 1.0 / 8}, {5, 1.0 / 8}}; + std::map total; + for (const auto& [count, weight] : weights){ + std::map sums{{0, 1.0}}; + for (int hit = 0; hit < count; hit++){ + std::map next; + for (const auto& [sum, chance] : sums){ + for (int damage : per_hit){ + next[sum + damage] += chance / static_cast(per_hit.size()); + } + } + sums = std::move(next); + } + for (const auto& [sum, chance] : sums){ + total[sum] += chance * weight; + } + } + std::vector rolls; + for (int i = 0; i < HIT_QUANTILES; i++){ + double cumulative = 0; + int value = total.rbegin()->first; + for (const auto& [sum, chance] : total){ + cumulative += chance; + if (cumulative >= (i + 0.5) / HIT_QUANTILES){ + value = sum; + break; + } + } + rolls.push_back(value); + } + return rolls; +} + +// `move` (`id`)'s damage rolls from `attacker` on `defender` in +// `weather`; empty for none. +std::vector damage_rolls(std::string_view id, const LeagueMoveData& move, const std::pair& sides, FieldWeather weather){ + const auto& [attacker, defender] = sides; + const double first = effectiveness(move.type, defender.types.first); + const double second = defender.types.second == defender.types.first ? 1.0 : effectiveness(move.type, defender.types.second); + if (first * second == 0 || ability_blocks(defender.ability, move.type)){ + return {}; + } + if (move.fixed_damage){ + return {*move.fixed_damage}; + } + const std::vector rolls = gen3_damage_rolls(Gen3Hit{ + .level = attacker.level, + .attack = attack_stat(move, attacker, defender), + .defense = move.physical ? defender.stats.defense : defender.stats.sp_defense, + .power = base_power(move, attacker), + .attack_stage = move.physical ? attacker.stages.attack : attacker.stages.sp_attack, + .defense_stage = move.physical ? defender.stages.defense : defender.stages.sp_defense, + .stab = move.type == attacker.types.first || move.type == attacker.types.second, + .effectiveness_first = first, + .effectiveness_second = second, + .burned_physical = move.physical && attacker.status == PlannedStatus::BURN && attacker.ability != "guts", + .physical = move.physical, + .weather = weather_modifier(weather, move.type, id == "solar-beam"), + }); + return move.hits && !rolls.empty() ? multi_hit_rolls(rolls, *move.hits) : rolls; +} + +Stats boosted_stats(const Stats& stats){ + return Stats{ + .hp = stats.hp, + .attack = static_cast(badge_boosted(stats.attack)), + .defense = static_cast(badge_boosted(stats.defense)), + .sp_attack = static_cast(badge_boosted(stats.sp_attack)), + .sp_defense = static_cast(badge_boosted(stats.sp_defense)), + .speed = static_cast(badge_boosted(stats.speed)), + }; +} + +SpeciesData types_of(std::string_view species){ + const SpeciesData* data = species_data(species); + return data != nullptr ? *data : SpeciesData{}; +} + +PlannedStatus planned_status(StatusCondition status){ + switch (status){ + case StatusCondition::POISON: + return PlannedStatus::POISON; + case StatusCondition::PARALYSIS: + return PlannedStatus::PARALYSIS; + case StatusCondition::SLEEP: + return PlannedStatus::SLEEP; + case StatusCondition::OTHER: + return PlannedStatus::BURN; + case StatusCondition::NONE: + break; + } + return PlannedStatus::NONE; +} + +// `id` as the policy weighs it, from the first of `sides` on the second. +PlannedMove planned_move(std::string_view id, int pp, const LeagueFoesData& data, const std::pair& sides, FieldWeather weather){ + PlannedMove planned{.id = std::string(id), .pp = pp}; + const auto found = data.moves.find(id); + if (found == data.moves.end()){ + return planned; + } + const LeagueMoveData& move = found->second; + const auto& [attacker, defender] = sides; + planned.accuracy = move.accuracy ? hit_chance(*move.accuracy, attacker.stages.accuracy, defender.stages.evasion) : 1.0; + planned.damage = damage_rolls(id, move, sides, weather); + planned.priority = move.priority; + planned.two_turn = move.two_turn; + return planned; +} + +PlannedOwn planned_own(const PlannedInputs& inputs, const std::pair& sides, const LeagueFoesData& data){ + const BattleTrackState& track = inputs.track; + const Side& us = sides.first; + PlannedOwn own{ + .hp = inputs.hp, + .max_hp = us.stats.hp, + .status = us.status, + .speed = battle_speed(us.stats.speed, track.own.speed, us.status == PlannedStatus::PARALYSIS), + .spa_stage = track.own.sp_attack, + .speed_stage = track.own.speed, + .accuracy_stage = track.own.accuracy, + .attack_stage = track.own.attack, + .defense_stage = track.own.defense, + .mist = track.mist_turns > 0, + }; + for (const KnownMove& known : inputs.lead.moves){ + own.moves.push_back(planned_move(known.move, known.pp, data, sides, track.weather)); + } + return own; +} + +// The foe's moves at full PP: the program can't see the foe's PP. +PlannedFoe planned_foe(const PlannedInputs& inputs, const std::pair& sides, const LeagueFoesData& data){ + const BattleTrackState& track = inputs.track; + const PlannedFoeTrack& foe = inputs.foe; + const Side& them = sides.second; + const int max_hp = foe.foe.stats.hp; + const int hp = hp_of_fill(foe.fill, max_hp); + PlannedFoe planned{ + .species = foe.foe.species, + .slot = foe.slot, + .hp = hp, + .max_hp = max_hp, + .speed = battle_speed(them.stats.speed, track.foe.speed, them.status == PlannedStatus::PARALYSIS), + .recharging = track.foe_recharging, + .sleeping = them.status == PlannedStatus::SLEEP && track.foe_sleep_turns > 1, + .frozen = them.status == PlannedStatus::FREEZE, + .charging = track.foe_charging, + .sun = track.weather == FieldWeather::SUN, + }; + for (const std::string& move : foe.foe.moves){ + planned.moves.push_back(planned_move(move, max_pp(move), data, {them, sides.first}, track.weather)); + } + return planned; +} + +// A turn's line for the log. +std::string turn_log(const LeagueFightData& fight, const PlannedState& state, const BattleTrackState& track, const PlannedChoice& choice){ + const PlannedDanger danger = planned_danger(state); + const std::string what = choice.item ? *choice.item + : choice.move_slot && *choice.move_slot < state.own.moves.size() ? state.own.moves[*choice.move_slot].id + : std::string("best attack"); + const StatStages& own = track.own; + const StatStages& foe = track.foe; + return std::format( + "{} HP {}/{}, {} {}/{} (slot {}, {} left), D {} mean {:.0f}, our stages atk {} def {} spa {} spd {} spe {} acc {} mist {}, " + "foe stages atk {} def {} spa {} spd {} spe {} eva {}, foe status {} sleep {}, weather {} ({}), " + "trainer Full Restores used {}: {} ({})", + fight.name, state.own.hp, state.own.max_hp, state.foe.species, state.foe.hp, state.foe.max_hp, + state.foe.slot, state.foe_party_alive, danger.normal_max, danger.mean, + own.attack, own.defense, own.sp_attack, own.sp_defense, own.speed, own.accuracy, track.mist_turns, + foe.attack, foe.defense, foe.sp_attack, foe.sp_defense, foe.speed, foe.evasion, + static_cast(track.foe_status), track.foe_sleep_turns, static_cast(track.weather), track.weather_turns, + track.trainer_full_restores, choice.row, what + ); +} + +} // namespace + + +PlannedState planned_state(const PlannedInputs& inputs, const LeagueFoesData& data){ + const Stats raw = inputs.lead.stats.value_or(Stats{}); + const BattleTrackState& track = inputs.track; + const Side us{ + .level = static_cast(battle_level(inputs.lead)), + .stats = boosted_stats(raw), + .hp = inputs.hp, + .types = types_of(inputs.lead.species), + .ability = pinch_ability(inputs.lead.species), + .stages = track.own, + .status = planned_status(inputs.status), + }; + const LeagueFoeData& foe_data = inputs.foe.foe; + const Side foe{ + .level = foe_data.level, .stats = foe_data.stats, .hp = hp_of_fill(inputs.foe.fill, foe_data.stats.hp), + .types = types_of(foe_data.species), .ability = foe_data.ability, + .stages = track.foe, .status = track.foe_status, + }; + const PlannedFoeTrack& foe_track = inputs.foe; + return PlannedState{ + .own = planned_own(inputs, {us, foe}, data), + .foe = planned_foe(inputs, {us, foe}, data), + .foe_party_alive = foe_track.party_alive, + .trainer_item_open = trainer_item_open(foe_track.full_restores_carried, track.trainer_full_restores, foe_track.party_alive), + .bag = inputs.bag, + }; +} + + +PlannedBattle::PlannedBattle(const LeagueFightData& fight, const LeagueTrainerData& trainer) + : m_fight(&fight) + , m_trainer(&trainer) +{} + +PlannedFoeTrack PlannedBattle::foe_out(const Supplies& supplies, const PolicyView& view){ + const std::vector& party = m_trainer->party; + size_t slot = std::min(view.foe_index, party.empty() ? 0 : party.size() - 1); + for (size_t index = slot; index < party.size() && !supplies.foe_out.empty(); index++){ + if (party[index].species == supplies.foe_out){ + slot = index; + break; + } + } + const LeagueFoeData foe = party.empty() ? LeagueFoeData{} : party[slot]; + m_track.foe_out(slot, foe.ability); + const auto carried = m_trainer->items.find("full-restore"); + return PlannedFoeTrack{ + .foe = foe, + .slot = slot, + .fill = view.foe_fill, + .party_alive = static_cast(party.size() - slot), + .full_restores_carried = carried == m_trainer->items.end() ? 0 : carried->second, + }; +} + +PlannedBattle::Turn PlannedBattle::choose(const Supplies& supplies, const PolicyView& view){ + m_track.read_turn(view.battle_texts); + PlannedInputs inputs{ + .lead = supplies.lead, + .hp = static_cast(std::lround(view.hp)), + .status = view.status, + .foe = foe_out(supplies, view), + }; + inputs.track = m_track.state(); + for (std::string_view item : LEAGUE_ITEMS){ + inputs.bag[std::string(item)] = bag_count(supplies, item); + } + const PlannedState state = planned_state(inputs, league_foes_data()); + const PlannedChoice choice = choose_planned(state, *m_fight, m_streak.streak(state)); + m_streak.chose(state, choice); + std::string log = turn_log(*m_fight, state, inputs.track, choice); + m_track.turn_chosen(); + return Turn{.choice = choice, .log = std::move(log)}; +} + +void PlannedBattle::item_used(std::string_view item){ + m_track.item_used(item); +} + +void PlannedBattle::lead_switched_in(){ + m_track.lead_switched_in(); +} + +std::optional planned_battle(std::string_view trainer){ + const std::optional name = league_fight_name(trainer); + if (!name){ + return std::nullopt; + } + const LeagueFightData* fight = league_fight_data(league_plan_data(), *name); + const auto found = league_foes_data().trainers.find(trainer); + if (fight == nullptr || found == league_foes_data().trainers.end()){ + return std::nullopt; + } + return PlannedBattle(*fight, found->second); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.h new file mode 100644 index 0000000000..ee103275cc --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.h @@ -0,0 +1,105 @@ +/* AutoStory Planned Battle + * + * From: https://github.com/PokemonAutomation/ + * + * A League fight fought by the planned policy + * (PokemonFRLG_AutoStoryPlannedPolicy.h): each turn's PlannedState from + * the lead as the story knows it, the foe out as the League foes data has + * it (PokemonFRLG_AutoStoryLeagueFoes.h) and what the items used and the + * battle texts tell (PokemonFRLG_AutoStoryBattleTrack.h), with every + * move's damage from Gen3Damage as @smogon/calc gives it: both sides' + * stages, the sun or rain, a burn, Guts, Thick Fat and the pinch + * abilities (our Blastoise's Torrent). + * + * Not modelled: the foe's PP (full, where the sim's engine counts it + * down), Reflect, and a sleep's exact length (the fewest turns it can + * last, where the sim knows it). + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlannedBattle_H +#define PokemonAutomation_PokemonFRLG_AutoStoryPlannedBattle_H + +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryBattleTrack.h" +#include "PokemonFRLG_AutoStoryLeagueFoes.h" +#include "PokemonFRLG_AutoStoryPartyMember.h" +#include "PokemonFRLG_AutoStoryPlannedPolicy.h" +#include "PokemonFRLG_AutoStoryPlannedState.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The foe out and its trainer. +struct PlannedFoeTrack{ + LeagueFoeData foe = {}; + size_t slot = 0; + // Its HP bar's filled share. + double fill = 1.0; + int party_alive = 1; + int full_restores_carried = 0; +}; + +// What planned_state() reads. +struct PlannedInputs{ + PartyMember lead = {}; + int hp = 0; + StatusCondition status = StatusCondition::NONE; + BattleTrackState track = {}; + PlannedFoeTrack foe = {}; + SlugCounts bag = {}; +}; + +// The policy's state: our moves' damage on the foe and its moves' on us +// as the track has the fight, with the badges' boosts on our stats (all +// eight held at the League). `moves` is the League foes data's move table. +PlannedState planned_state(const PlannedInputs& inputs, const LeagueFoesData& moves); + + +// A League fight's turns. +class PlannedBattle{ +public: + PlannedBattle(const LeagueFightData& fight, const LeagueTrainerData& trainer); + + // A turn's choice, and its line for the log. + struct Turn{ + PlannedChoice choice = {}; + std::string log = {}; + }; + Turn choose(const Supplies& supplies, const PolicyView& view); + void item_used(std::string_view item); + // Back in after Roar or Whirlwind: its stages are gone. + void lead_switched_in(); + +private: + PlannedFoeTrack foe_out(const Supplies& supplies, const PolicyView& view); + + // Built-in data, never null. + const LeagueFightData* m_fight; + const LeagueTrainerData* m_trainer; + BattleTrack m_track; + PlannedStreak m_streak; +}; + +// The League fight `trainer` (a battle step's "trainer") is fought by +// the planned policy: its plan and its foes data, or none for another +// trainer. +std::optional planned_battle(std::string_view trainer); + + +// Registers the planned battle tests. +void add_tests_AutoStoryPlannedBattle(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle_Tests.cpp new file mode 100644 index 0000000000..5b40611eaf --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle_Tests.cpp @@ -0,0 +1,348 @@ +/* AutoStory Planned Battle Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The League foes data as built into the program, and the planned + * policy's state from it: damage rolls checked against @smogon/calc 0.12 + * (PokemonSimulation's engine) with the same raw stats. + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_AutoStoryLeagueFoes.h" +#include "PokemonFRLG_AutoStoryPlannedBattle.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// Our Lv54 Blastoise (PokemonSimulation chain.py LV54), knowing the League plan's moves. +PartyMember blastoise(){ + return PartyMember{ + .species = "blastoise", + .moves = {{"surf", 15}, {"bite", 25}, {"blizzard", 5}, {"strength", 15}}, + .level = 54, + .stats = Stats{.hp = 171, .attack = 104, .defense = 134, .sp_attack = 118, .sp_defense = 149, .speed = 117}, + }; +} + +const LeagueFoeData& foe_of(std::string_view trainer, size_t slot){ + const auto it = league_foes_data().trainers.find(trainer); + if (it == league_foes_data().trainers.end() || slot >= it->second.party.size()){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No {} slot {} in the League foes.", trainer, slot)); + } + return it->second.party[slot]; +} + +std::vector damage_of(const std::vector& moves, std::string_view move){ + for (const PlannedMove& planned : moves){ + if (planned.id == move){ + return planned.damage; + } + } + return {}; +} + + +struct FoesInput{ + std::string trainer = {}; + size_t slot = 0; +}; +struct FoesExpectation{ + std::string species = {}; + int level = 0; + int hp = 0; + int full_restores = 0; +}; +struct FoesCase{ + std::string name; + FoesInput input; + FoesExpectation expectation; +}; + +class Test_LeagueFoes : public UnitTest{ +public: + explicit Test_LeagueFoes(FoesCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedBattle - League foes: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const LeagueFoeData& foe = foe_of(m_case.input.trainer, m_case.input.slot); + const auto& items = league_foes_data().trainers.find(m_case.input.trainer)->second.items; + const auto restores = items.find("full-restore"); + const int carried = restores == items.end() ? 0 : restores->second; + const FoesExpectation& want = m_case.expectation; + if (foe.species != want.species || foe.level != want.level || foe.stats.hp != want.hp || carried != want.full_restores){ + return std::format("{} Lv{} {} HP, {} Full Restores.", foe.species, foe.level, foe.stats.hp, carried); + } + return true; + } + +private: + FoesCase m_case; +}; + +const FoesCase FOES_CASES[] = { + { + .name = "Lorelei's lead", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 0}, + .expectation = {.species = "dewgong", .level = 52, .hp = 171, .full_restores = 2}, + }, + { + .name = "Lance's lead", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 0}, + .expectation = {.species = "gyarados", .level = 56, .hp = 189, .full_restores = 2}, + }, + { + .name = "the Champion's last", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 5}, + .expectation = {.species = "venusaur", .level = 63, .hp = 193, .full_restores = 4}, + }, +}; + + +struct DamageInput{ + std::string trainer = {}; + size_t slot = 0; + // The fight as tracked: stages, the foe's status, the weather. + BattleTrackState track = {}; + // Ours or the foe's. + bool ours = true; + // Our HP (of 171). + int hp = 171; + std::string move = {}; +}; +struct DamageExpectation{ + // Lowest first; empty for no damage. + std::vector rolls = {}; +}; +struct DamageCase{ + std::string name; + DamageInput input; + DamageExpectation expectation; +}; + +class Test_PlannedDamage : public UnitTest{ +public: + explicit Test_PlannedDamage(DamageCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedBattle - damage: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const PlannedInputs inputs{ + .lead = blastoise(), + .hp = m_case.input.hp, + .track = m_case.input.track, + .foe = {.foe = foe_of(m_case.input.trainer, m_case.input.slot), .slot = m_case.input.slot}, + }; + const PlannedState state = planned_state(inputs, league_foes_data()); + const std::vector got = damage_of(m_case.input.ours ? state.own.moves : state.foe.moves, m_case.input.move); + if (got != m_case.expectation.rolls){ + return std::format("Rolls {}..{} ({}).", got.empty() ? 0 : got.front(), got.empty() ? 0 : got.back(), got.size()); + } + return true; + } + +private: + DamageCase m_case; +}; + +const DamageCase DAMAGE_CASES[] = { + { + .name = "Lance's Gyarados's Hyper Beam on us", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 0, .ours = false, .move = "hyper-beam"}, + .expectation = {.rolls = {68, 68, 69, 70, 71, 72, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80}}, + }, + { + .name = "our Surf at +2 on Lance's Dragonite", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 4, .track = {.own = {.sp_attack = 2}}, .move = "surf"}, + .expectation = {.rolls = {45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 54}}, + }, + { + .name = "our Surf at +2 on Lance's Dragonite under a third of our HP: Torrent", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 4, .track = {.own = {.sp_attack = 2}}, .hp = 57, .move = "surf"}, + .expectation = {.rolls = {68, 69, 70, 71, 72, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80, 81}}, + }, + { + .name = "our Surf at +2 on Lance's Dragonite just over a third of our HP: no Torrent", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 4, .track = {.own = {.sp_attack = 2}}, .hp = 58, .move = "surf"}, + .expectation = {.rolls = {45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 54}}, + }, + { + .name = "our Blizzard on Lance's Dragonite", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 4, .move = "blizzard"}, + .expectation = {.rolls = {159, 161, 163, 165, 167, 169, 171, 172, 174, 176, 178, 180, 182, 184, 186, 188}}, + }, + { + .name = "our Strength at -1 (Intimidate) on Lance's Gyarados", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 0, .track = {.own = {.attack = -1}}, .move = "strength"}, + .expectation = {.rolls = {22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 27}}, + }, + { + .name = "Dragonair's Dragon Rage on us", + .input = {.trainer = "TRAINER_ELITE_FOUR_LANCE", .slot = 1, .ours = false, .move = "dragon-rage"}, + .expectation = {.rolls = {40}}, + }, + { + .name = "our Surf on Lorelei's Lapras (Water Absorb)", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 4, .move = "surf"}, + .expectation = {.rolls = {}}, + }, + { + .name = "our Surf on the Champion's Venusaur", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 5, .move = "surf"}, + .expectation = {.rolls = {27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32}}, + }, + { + .name = "our Surf on Venusaur in Sunny Day's sun: halved", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 5, .track = {.weather = FieldWeather::SUN}, .move = "surf"}, + .expectation = {.rolls = {13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16}}, + }, + { + .name = "our Surf on Venusaur in rain: x1.5", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 5, .track = {.weather = FieldWeather::RAIN}, .move = "surf"}, + .expectation = {.rolls = {39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47}}, + }, + { + .name = "Arcanine's Flamethrower on us in the sun: x1.5", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 4, .track = {.weather = FieldWeather::SUN}, .ours = false, .move = "flamethrower"}, + .expectation = {.rolls = {46, 47, 47, 48, 48, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 55}}, + }, + { + .name = "Venusaur's Solar Beam on us after Growth", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 5, .track = {.foe = {.sp_attack = 1}}, .ours = false, .move = "solar-beam"}, + .expectation = {.rolls = {255, 258, 261, 264, 267, 270, 273, 276, 279, 282, 285, 288, 291, 294, 297, 300}}, + }, + { + .name = "our Blizzard at +2 on Lorelei's Dewgong (Thick Fat)", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 0, .track = {.own = {.sp_attack = 2}}, .move = "blizzard"}, + .expectation = {.rolls = {12, 12, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15}}, + }, + { + .name = "our Blizzard at +3 on Dewgong (Thick Fat)", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 0, .track = {.own = {.sp_attack = 3}}, .move = "blizzard"}, + .expectation = {.rolls = {16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19}}, + }, + { + .name = "our Surf on Slowbro after Amnesia", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 2, .track = {.foe = {.sp_defense = 2}}, .move = "surf"}, + .expectation = {.rolls = {17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 21}}, + }, + { + .name = "Arbok's Iron Tail on us after Screech", + .input = {.trainer = "TRAINER_ELITE_FOUR_AGATHA", .slot = 3, .track = {.own = {.defense = -2}}, .ours = false, .move = "iron-tail"}, + .expectation = {.rolls = {33, 33, 33, 34, 34, 35, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39}}, + }, + { + .name = "a burned Machamp's Cross Chop on us: Guts", + .input = {.trainer = "TRAINER_ELITE_FOUR_BRUNO", .slot = 4, .track = {.foe_status = PlannedStatus::BURN}, .ours = false, .move = "cross-chop"}, + .expectation = {.rolls = {95, 96, 97, 98, 99, 100, 101, 103, 104, 105, 106, 107, 108, 109, 110, 112}}, + }, +}; + + +struct StateInput{ + std::string trainer = {}; + size_t slot = 0; + BattleTrackState track = {}; +}; +struct StateExpectation{ + int our_speed = 0; + int foe_speed = 0; + bool foe_sleeping = false; + double surf_accuracy = 1.0; +}; +struct StateCase{ + std::string name; + StateInput input; + StateExpectation expectation; +}; + +class Test_PlannedTrackState : public UnitTest{ +public: + explicit Test_PlannedTrackState(StateCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedBattle - state: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const PlannedInputs inputs{ + .lead = blastoise(), + .hp = 171, + .track = m_case.input.track, + .foe = {.foe = foe_of(m_case.input.trainer, m_case.input.slot), .slot = m_case.input.slot}, + }; + const PlannedState state = planned_state(inputs, league_foes_data()); + double surf_accuracy = 0; + for (const PlannedMove& move : state.own.moves){ + surf_accuracy = move.id == "surf" ? move.accuracy : surf_accuracy; + } + const StateExpectation& want = m_case.expectation; + if (state.own.speed != want.our_speed || state.foe.speed != want.foe_speed + || state.foe.sleeping != want.foe_sleeping || surf_accuracy != want.surf_accuracy){ + return std::format("Speed {} vs {}, foe sleeping {}, Surf accuracy {}.", state.own.speed, state.foe.speed, state.foe.sleeping, surf_accuracy); + } + return true; + } + +private: + StateCase m_case; +}; + +// Our Speed 117 is 128 with Thunder's boost. +const StateCase STATE_CASES[] = { + { + .name = "Venusaur paralyzed: a quarter of its Speed", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 5, .track = {.foe_status = PlannedStatus::PARALYSIS}}, + .expectation = {.our_speed = 128, .foe_speed = 31}, + }, + { + .name = "after Scary Face: our Speed at -2", + .input = {.trainer = "TRAINER_CHAMPION_FIRST_BULBASAUR", .slot = 2, .track = {.own = {.speed = -2}}}, + .expectation = {.our_speed = 64, .foe_speed = 70}, + }, + { + .name = "Gengar after Double Team: our Surf can miss", + .input = {.trainer = "TRAINER_ELITE_FOUR_AGATHA", .slot = 0, .track = {.foe = {.evasion = 1}}}, + .expectation = {.our_speed = 128, .foe_speed = 126, .surf_accuracy = 0.75}, + }, + { + .name = "Lapras rested: asleep for more than this turn", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 4, .track = {.foe_status = PlannedStatus::SLEEP, .foe_sleep_turns = 2}}, + .expectation = {.our_speed = 128, .foe_speed = 94, .foe_sleeping = true}, + }, + { + .name = "Lapras on its last turn of sleep: may wake and hit", + .input = {.trainer = "TRAINER_ELITE_FOUR_LORELEI", .slot = 4, .track = {.foe_status = PlannedStatus::SLEEP, .foe_sleep_turns = 1}}, + .expectation = {.our_speed = 128, .foe_speed = 94, .foe_sleeping = false}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryPlannedBattle(UnitTestDatabase& database){ + for (const FoesCase& test_case : FOES_CASES){ + database.add(test_case); + } + for (const DamageCase& test_case : DAMAGE_CASES){ + database.add(test_case); + } + for (const StateCase& test_case : STATE_CASES){ + database.add(test_case); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.cpp new file mode 100644 index 0000000000..7e6f2702fe --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.cpp @@ -0,0 +1,122 @@ +/* AutoStory Planned Between + * + * From: https://github.com/PokemonAutomation/ + * + * planned.py's between() (PokemonSimulation #111, 4a79ccc): keep the two + * in step. + * + */ + +#include +#include +#include +#include +#include "PokemonFRLG_AutoStoryLeagueFightData.h" +#include "PokemonFRLG_AutoStoryPlannedBetween.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr std::string_view FULL_RESTORE = "full-restore"; +constexpr int SUPER_POTION_HP = 50; +// What an Elixir restores to each move. +constexpr int ELIXIR_PP = 10; +// The most potions the HP top-up takes. +constexpr int MAX_HP_ITEMS = 20; + +// The bag of one top-up: what may be used and what was. +class TopUp{ +public: + TopUp(PlannedCarry& carry, const LeagueFightData& next) + : m_carry(carry) + , m_next(next) + {} + bool can(std::string_view item) const{ + return spendable(m_next, m_carry.bag, item) > 0; + } + void use(std::string_view item){ + m_carry.bag[std::string(item)]--; + m_used.emplace_back(item); + } + std::vector used(){ + return std::move(m_used); + } + +private: + PlannedCarry& m_carry; + const LeagueFightData& m_next; + std::vector m_used; +}; + +void cure(PlannedCarry& carry, TopUp& top_up){ + if (carry.status == PlannedStatus::NONE){ + return; + } + for (std::optional name : {status_cure(carry.status), std::optional("full-heal"), std::optional(FULL_RESTORE)}){ + if (name && top_up.can(*name)){ + top_up.use(*name); + carry.status = PlannedStatus::NONE; + if (*name == FULL_RESTORE){ + carry.hp = carry.max_hp; + } + return; + } + } +} + +void heal(PlannedCarry& carry, TopUp& top_up, double share){ + const int target = static_cast(carry.max_hp * share + 0.999); + for (int c = 0; c < MAX_HP_ITEMS && carry.hp < target; c++){ + const bool potions_reach = target - carry.hp <= SUPER_POTION_HP * count_of(carry.bag, "super-potion"); + if (top_up.can("super-potion") && (potions_reach || !top_up.can(FULL_RESTORE))){ + top_up.use("super-potion"); + carry.hp = std::min(carry.max_hp, carry.hp + SUPER_POTION_HP); + }else if (top_up.can(FULL_RESTORE)){ + top_up.use(FULL_RESTORE); + carry.hp = carry.max_hp; + }else{ + return; + } + } +} + +void restore_pp(PlannedCarry& carry, TopUp& top_up, const SlugCounts& floors){ + const bool under_floor = std::any_of(floors.begin(), floors.end(), [&](const auto& floor){ + return count_of(carry.pp, floor.first) < floor.second; + }); + if (!under_floor){ + return; + } + for (std::string_view name : {"elixir", "max-elixir"}){ + if (!top_up.can(name)){ + continue; + } + top_up.use(name); + for (auto& [move, pp] : carry.pp){ + const int full = count_of(carry.full_pp, move); + pp = name == "max-elixir" ? full : std::min(full, pp + ELIXIR_PP); + } + return; + } +} + +} // namespace + + +std::vector planned_between(PlannedCarry& carry, const LeagueFightData& next){ + TopUp top_up(carry, next); + cure(carry, top_up); + heal(carry, top_up, next.between_hp.value_or(1.0)); + restore_pp(carry, top_up, next.between_pp); + return top_up.used(); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.h new file mode 100644 index 0000000000..e5a4cd2930 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.h @@ -0,0 +1,45 @@ +/* AutoStory Planned Between + * + * From: https://github.com/PokemonAutomation/ + * + * The planned policy's top-ups between two League fights, as planned.py's + * between() makes them (PokemonSimulation #111): the next fight's + * `between` row of the League plan, its item reserve held. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlannedBetween_H +#define PokemonAutomation_PokemonFRLG_AutoStoryPlannedBetween_H + +#include +#include +#include "PokemonFRLG_AutoStoryPlannedState.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Our side between two fights. +struct PlannedCarry{ + int hp = 0; + int max_hp = 0; + PlannedStatus status = PlannedStatus::NONE; + // PP left and full PP, by move. + SlugCounts pp = {}; + SlugCounts full_pp = {}; + SlugCounts bag = {}; +}; + +// The top-ups before `next` (its `between` row): a cure, Super Potions +// (then a Full Restore) to the HP target, a PP item to the PP floor; +// `next`'s item reserve holds. Updates `carry`; returns the items used, +// in order. +std::vector planned_between(PlannedCarry& carry, const LeagueFightData& next); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.cpp new file mode 100644 index 0000000000..7b0456d559 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.cpp @@ -0,0 +1,444 @@ +/* AutoStory Planned Policy + * + * From: https://github.com/PokemonAutomation/ + * + * A line-for-line port of planned.py (PokemonSimulation #111, 4a79ccc): + * keep the two in step. + * + */ + +#include +#include +#include +#include "PokemonFRLG_AutoStoryLeagueFightData.h" +#include "PokemonFRLG_AutoStoryPlannedPolicy.h" +#include "PokemonFRLG_AutoStoryPlannedRisk.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr int WHOLE_HEAL = std::numeric_limits::max() / 2; +constexpr std::string_view FULL_RESTORE = "full-restore"; +constexpr std::string_view GUARD_SPEC = "guard-spec"; + +int heal_hp(std::string_view item){ + if (item == "super-potion"){ + return 50; + } + if (item == "hyper-potion"){ + return 200; + } + if (item == "potion"){ + return 20; + } + if (item == "max-potion" || item == FULL_RESTORE){ + return WHOLE_HEAL; + } + return 0; +} + +// Cheapest first: what a sure KO spends. +int pp_value(std::string_view move){ + if (move == "strength"){ + return 0; + } + if (move == "bite"){ + return 1; + } + if (move == "surf"){ + return 2; + } + if (move == "blizzard"){ + return 9; + } + return 5; +} + +int sum_of(const std::vector& damage){ + return std::accumulate(damage.begin(), damage.end(), 0); +} + +bool sure_ko(const PlannedMove& move, int hp){ + return move.accuracy >= 1 && !move.two_turn && !move.damage.empty() && move.min_damage() >= hp; +} + +int stage_of(const PlannedOwn& own, std::string_view item){ + if (item == "x-special"){ + return own.spa_stage; + } + if (item == "x-speed"){ + return own.speed_stage; + } + if (item == "x-accuracy"){ + return own.accuracy_stage; + } + if (item == "x-attack"){ + return own.attack_stage; + } + if (item == "x-defend"){ + return own.defense_stage; + } + return 0; +} + +const PlannedMove* own_move(const PlannedOwn& own, std::string_view id){ + for (const PlannedMove& move : own.moves){ + if (move.usable() && move.id == id){ + return &move; + } + } + return nullptr; +} + +std::optional slot_of(const PlannedOwn& own, const PlannedMove* move){ + if (move == nullptr){ + return std::nullopt; + } + return static_cast(move - own.moves.data()); +} + +// The smallest heal that lifts HP above D and gains at least D plus a mean hit; else bigger. +std::optional heal(const PlannedState& state, const PlannedDanger& danger, const LeagueFightData& fight){ + const PlannedOwn& own = state.own; + const int missing = own.max_hp - own.hp; + for (std::string_view name : {"super-potion", "hyper-potion", "max-potion"}){ + if (spendable(fight, state.bag, name) <= 0){ + continue; + } + const int gained = std::min(missing, heal_hp(name)); + if (own.hp + gained > danger.normal_max && gained - danger.normal_max >= danger.mean){ + return std::string(name); + } + } + // Over the reserve if need be: dying here loses the League anyway. + if (count_of(state.bag, FULL_RESTORE) > 0){ + return std::string(FULL_RESTORE); + } + for (std::string_view name : {"max-potion", "hyper-potion", "super-potion"}){ + if (count_of(state.bag, name) > 0 && own.hp + std::min(missing, heal_hp(name)) > danger.normal_max){ + return std::string(name); + } + } + return std::nullopt; +} + +// The first unmet setup goal whose served move still has PP and whose item is spendable. +const LeagueSetupGoal* setup_goal(const PlannedState& state, const LeagueFightData& fight, const LeagueFoePlan& plan){ + const PlannedOwn& own = state.own; + for (const LeagueSetupGoal& goal : plan.setup){ + if (goal.serves){ + const PlannedMove* served = own_move(own, *goal.serves); + if (served == nullptr || pp_above_reserve(fight, served->id, served->pp) <= 0){ + continue; + } + } + if (spendable(fight, state.bag, goal.item) <= 0){ + continue; + } + if (goal.item == GUARD_SPEC){ + if (own.mist){ + continue; + } + return &goal; + } + if (stage_of(own, goal.item) < goal.stage){ + return &goal; + } + } + return nullptr; +} + +const PlannedMove* best_expected(const PlannedOwn& own, const LeagueFightData& fight, bool above_reserve){ + const PlannedMove* best = nullptr; + for (const PlannedMove& move : own.moves){ + if (!move.usable() || move.damage.empty()){ + continue; + } + if (above_reserve && (move.max_damage() <= 0 || pp_above_reserve(fight, move.id, move.pp) <= 0)){ + continue; + } + if (best == nullptr || move.expected_hit() > best->expected_hit()){ + best = &move; + } + } + return best; +} + +const PlannedMove* planned_move(const PlannedState& state, const LeagueFightData& fight, const LeagueFoePlan& plan){ + const PlannedOwn& own = state.own; + for (const std::string& name : plan.moves){ + const PlannedMove* move = own_move(own, name); + if (move != nullptr && pp_above_reserve(fight, move->id, move->pp) > 0){ + return move; + } + } + // Nothing planned has PP: the best expected hit among moves not held in reserve. + const PlannedMove* best = best_expected(own, fight, true); + return best != nullptr ? best : best_expected(own, fight, false); +} + +// With a trainer heal open, never drop the foe into [1, 1/4): an opener +// whose every roll leaves it at or above 1/4 and after which the +// finisher's lowest roll KOs. +const PlannedMove* kill_order(const PlannedState& state, const LeagueFightData& fight, const PlannedMove& chosen){ + const PlannedFoe& foe = state.foe; + const int quarter = foe.max_hp / 4; + const int hp = foe.hp; + const std::vector& rolls = chosen.damage; + if (!state.trainer_item_open || rolls.empty() || chosen.min_damage() >= hp){ + return nullptr; + } + const bool into_heal_range = std::any_of(rolls.begin(), rolls.end(), [&](int roll){ + return 0 < hp - roll && hp - roll < quarter; + }); + if (!into_heal_range){ + return nullptr; + } + std::vector moves; + int finisher = 0; + for (const PlannedMove& move : state.own.moves){ + if (move.usable() && move.max_damage() > 0 && pp_above_reserve(fight, move.id, move.pp) > 0){ + moves.push_back(&move); + finisher = std::max(finisher, move.accuracy >= 1 ? move.min_damage() : 0); + } + } + const auto strongest = [&](bool needs_finisher) -> const PlannedMove*{ + const PlannedMove* best = nullptr; + for (const PlannedMove* move : moves){ + if (hp - move->max_damage() < quarter){ + continue; + } + if (needs_finisher && hp - move->min_damage() > finisher){ + continue; + } + if (best == nullptr || sum_of(move->damage) > sum_of(best->damage)){ + best = move; + } + } + return best; + }; + const PlannedMove* opener = strongest(true); + if (opener == nullptr){ + // No two-hit kill: the strongest hit that still leaves the foe at or above 1/4. + opener = strongest(false); + } + return opener != nullptr && opener != &chosen ? opener : nullptr; +} + +bool medicine(const PlannedChoice& choice){ + if (!choice.item){ + return false; + } + const std::string& item = *choice.item; + return heal_hp(item) > 0 || item == "full-heal" || item == "awakening" || item == "antidote" + || item == "parlyz-heal" || item == "burn-heal" || item == "ice-heal"; +} + +PlannedChoice item_choice(std::string_view row, std::string_view item){ + return {.row = std::string(row), .item = std::string(item)}; +} + +PlannedChoice move_choice(std::string_view row, std::optional slot){ + return {.row = std::string(row), .move_slot = slot}; +} + +// sure_ko's row: the cheapest move that KOs for certain, moving first. +std::optional sure_ko_row(const PlannedState& state, const LeagueFightData& fight, int danger){ + const PlannedOwn& own = state.own; + const int target_hp = foe_hp_at_our_move(state); + const PlannedMove* cheapest = nullptr; + for (const PlannedMove& move : own.moves){ + if (!move.usable() || !sure_ko(move, target_hp) || !we_move_first(state, move)){ + continue; + } + if (pp_above_reserve(fight, move.id, move.pp) <= 0 && own.hp > danger){ + continue; + } + if (cheapest == nullptr || pp_value(move.id) < pp_value(cheapest->id)){ + cheapest = &move; + } + } + if (cheapest == nullptr){ + return std::nullopt; + } + return move_choice("sure_ko", slot_of(own, cheapest)); +} + +std::optional sleep_cure_row(const PlannedState& state, int danger){ + const PlannedOwn& own = state.own; + if (own.hp <= danger && danger < own.max_hp && count_of(state.bag, FULL_RESTORE) > 0){ + return item_choice("sleep_cure", FULL_RESTORE); + } + const std::optional cure = status_cure(own.status); + for (std::optional name : {cure, std::optional("full-heal"), std::optional(FULL_RESTORE)}){ + if (name && count_of(state.bag, *name) > 0){ + return item_choice("sleep_cure", *name); + } + } + return std::nullopt; +} + +std::optional ko_risk_rows( + const PlannedState& state, const LeagueFightData& fight, const PlannedDanger& danger, int streak +){ + const PlannedOwn& own = state.own; + const bool has_restore = count_of(state.bag, FULL_RESTORE) > 0; + if (own.status != PlannedStatus::NONE && has_restore){ + return item_choice("status_ko", FULL_RESTORE); + } + if (streak >= 2){ + if (has_restore){ + return item_choice("ko_heal", FULL_RESTORE); + } + return std::nullopt; + } + const std::optional name = heal(state, danger, fight); + if (name){ + return item_choice("ko_heal", *name); + } + return std::nullopt; +} + +std::optional cure_row(const PlannedState& state, const LeagueFightData& fight){ + switch (state.own.status){ + case PlannedStatus::PARALYSIS: + case PlannedStatus::POISON: + case PlannedStatus::BURN: + break; + default: + return std::nullopt; + } + for (std::optional name : {status_cure(state.own.status), std::optional("full-heal")}){ + if (name && spendable(fight, state.bag, *name) > 0){ + return item_choice("cure", *name); + } + } + return std::nullopt; +} + +// Every planned move is out of PP above its reserve. +bool plan_out_of_pp(const PlannedState& state, const LeagueFightData& fight, const LeagueFoePlan& plan){ + for (const PlannedMove& move : state.own.moves){ + if (!move.usable() || std::find(plan.moves.begin(), plan.moves.end(), move.id) == plan.moves.end()){ + continue; + } + if (pp_above_reserve(fight, move.id, move.pp) > 0){ + return false; + } + } + return true; +} + +std::optional setup_row( + const PlannedState& state, const LeagueFightData& fight, const LeagueFoePlan& plan, const PlannedDanger& danger +){ + const LeagueSetupGoal* goal = setup_goal(state, fight, plan); + if (goal == nullptr){ + return std::nullopt; + } + const PlannedOwn& own = state.own; + const int turns = static_cast(std::count_if(plan.setup.begin(), plan.setup.end(), [](const LeagueSetupGoal& g){ + return g.item != GUARD_SPEC; + })); + const double keep = std::min(own.max_hp * 0.75, danger.normal_max + std::max(0, turns - 1) * danger.mean); + if (own.hp >= keep || foe_hp_at_our_move(state) != state.foe.hp){ + return item_choice("plan:setup", goal->item); + } + const std::optional name = heal(state, danger, fight); + if (name && (*name != FULL_RESTORE || spendable(fight, state.bag, FULL_RESTORE) > 0)){ + return item_choice("plan:setup_heal", *name); + } + return std::nullopt; +} + +// The rows after KO risk and cures: pp_restore, the plan's setup and +// moves, and kill_order. +PlannedChoice plan_rows(const PlannedState& state, const LeagueFightData& fight, const LeagueFoePlan& plan, const PlannedDanger& danger){ + const PlannedOwn& own = state.own; + const bool risk = own.hp <= danger.normal_max; + const PlannedMove* chosen = planned_move(state, fight, plan); + if ((chosen == nullptr || plan_out_of_pp(state, fight, plan)) && !risk && !plan.moves.empty()){ + for (std::string_view name : {"elixir", "max-elixir"}){ + if (spendable(fight, state.bag, name) > 0){ + return item_choice("pp_restore", name); + } + } + } + if (!risk){ + if (std::optional choice = setup_row(state, fight, plan, danger)){ + return *choice; + } + } + if (chosen == nullptr){ + return move_choice("plan:struggle", std::nullopt); + } + const bool awake = own.status != PlannedStatus::SLEEP && own.status != PlannedStatus::FREEZE; + if (awake){ + if (const PlannedMove* opener = kill_order(state, fight, *chosen)){ + return move_choice("kill_order", slot_of(own, opener)); + } + } + return move_choice("plan:move", slot_of(own, chosen)); +} + +} // namespace + + +PlannedChoice choose_planned(const PlannedState& state, const LeagueFightData& fight, int streak){ + const PlannedOwn& own = state.own; + if (own.locked_slot){ + return move_choice("locked", own.locked_slot); + } + const LeagueFoePlan* found = league_foe_plan(fight, state.foe.slot, state.foe.species); + const LeagueFoePlan plan = found != nullptr ? *found : LeagueFoePlan{.species = state.foe.species}; + const PlannedDanger danger = planned_danger(state); + const int d = danger.normal_max; + const bool awake = own.status != PlannedStatus::SLEEP && own.status != PlannedStatus::FREEZE; + // A sure KO waits while this foe is the plan's setup foe and we are + // safe: the setup carries to the next foes. + const bool goal_first = own.hp > d && setup_goal(state, fight, plan) != nullptr && state.foe_party_alive > 1; + if (awake && !goal_first){ + if (std::optional choice = sure_ko_row(state, fight, d)){ + return *choice; + } + } + if (!awake){ + if (std::optional choice = sleep_cure_row(state, d)){ + return *choice; + } + } + const bool risk = own.hp <= d; + if (risk && d < own.max_hp){ + if (std::optional choice = ko_risk_rows(state, fight, danger, streak)){ + return *choice; + } + } + if (!risk && streak == 0){ + if (std::optional choice = cure_row(state, fight)){ + return *choice; + } + } + return plan_rows(state, fight, plan, danger); +} + +int PlannedStreak::streak(const PlannedState& state) const{ + return state.foe.species == m_species && state.foe.hp == m_hp ? m_streak : 0; +} + +void PlannedStreak::chose(const PlannedState& state, const PlannedChoice& choice){ + const int before = streak(state); + m_species = state.foe.species; + m_hp = state.foe.hp; + m_streak = medicine(choice) ? before + 1 : 0; +} + + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.h new file mode 100644 index 0000000000..2744502df1 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.h @@ -0,0 +1,84 @@ +/* AutoStory Planned Policy + * + * From: https://github.com/PokemonAutomation/ + * + * The League's battle policy as PokemonSimulation runs it ("planned", + * src/pokesim/games/frlg/league/planned.py, docs/battles/frlg-league-plan.md): + * the League plan (PokemonFRLG_AutoStoryLeaguePlanData.h) plus a short + * override table, first row that applies. Each choice names its row: + * locked a forced move (two-turn, recharge, Outrage); + * sure_ko a move's lowest roll KOs the foe (at full HP when its + * trainer's Full Restore lands first), it can't miss + * (accuracy with stages and evasion) and we move first + * (speed with stages and paralysis): the cheapest one; + * not while this foe has a setup goal left, we're safe, + * and its trainer has more Pokemon; + * sleep_cure asleep or frozen: a Full Restore at KO risk, else the cure; + * status_ko a status at KO risk: a Full Restore; + * ko_heal HP <= D, the foe's worst ordinary hit now: the smallest + * heal that clears D with a mean hit to spare; after two + * medicine turns with the foe's HP unchanged, a Full Restore; + * cure paralysis, poison or a burn with no KO risk: the cure; + * kill_order the trainer can still heal and the planned hit can + * leave the foe at 1-24%: a hit that leaves it at 25% or + * more (one after which the finisher KOs, if any); + * pp_restore every planned move out of PP: an Elixir not reserved; + * plan:setup the first unmet setup goal whose move has PP, with the + * HP for it (else plan:setup_heal); + * plan:move the first planned move with PP above the reserve; + * plan:struggle no move with PP: the caller's best attack. + * Pure decisions from the state the caller builds + * (PokemonFRLG_AutoStoryPlannedState.h); nothing here reads a screen. + * The KO risk is PokemonFRLG_AutoStoryPlannedRisk.h's; the top-ups + * between fights are PokemonFRLG_AutoStoryPlannedBetween.h's. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlannedPolicy_H +#define PokemonAutomation_PokemonFRLG_AutoStoryPlannedPolicy_H + +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" +#include "PokemonFRLG_AutoStoryPlannedState.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// A turn's choice: an item, a move slot, or neither for plan:struggle; +// and the row that chose it, for the log. +struct PlannedChoice{ + std::string row = {}; + std::optional item = std::nullopt; + std::optional move_slot = std::nullopt; +}; + +// The override table and the plan for `fight`; `streak` is the medicine +// turns in a row against the foe at this HP (PlannedStreak). +PlannedChoice choose_planned(const PlannedState& state, const LeagueFightData& fight, int streak); + +// The medicine turns in a row against one foe at one HP. +class PlannedStreak{ +public: + int streak(const PlannedState& state) const; + void chose(const PlannedState& state, const PlannedChoice& choice); + +private: + std::string m_species; + int m_hp = -1; + int m_streak = 0; +}; + +// Registers the planned policy tests. +void add_tests_AutoStoryPlannedPolicy(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy_Tests.cpp new file mode 100644 index 0000000000..15728f5516 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy_Tests.cpp @@ -0,0 +1,676 @@ +/* AutoStory Planned Policy Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The League plan as built into the program, the Gen 3 damage the + * policy reads (expected rolls from @smogon/calc, as PokemonSimulation's + * engine computes them), and the planned policy on the console failures + * of 2026-11-16 and the Champion loss: PokemonSimulation #111's + * test_planned.py cases, case for case. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_AutoStoryGen3Damage.h" +#include "PokemonFRLG_AutoStoryHealing.h" +#include "PokemonFRLG_AutoStoryLeagueFightData.h" +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" +#include "PokemonFRLG_AutoStoryPlannedBetween.h" +#include "PokemonFRLG_AutoStoryPlannedPolicy.h" +#include "PokemonFRLG_AutoStoryPlannedRisk.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The bag at the League's start on console B, 2026-11-16 (test_planned.py's BAG). +const SlugCounts BAG = { + {"full-restore", 8}, {"x-special", 15}, {"x-speed", 5}, {"x-accuracy", 3}, {"guard-spec", 2}, + {"max-elixir", 1}, {"elixir", 1}, {"super-potion", 6}, {"full-heal", 2}, {"parlyz-heal", 2}, + {"antidote", 1}, +}; +const SlugCounts NO_ELIXIRS = []{ + SlugCounts bag = BAG; + bag["elixir"] = 0; + bag["max-elixir"] = 0; + return bag; +}(); +const SlugCounts FULL_PP = {{"bite", 25}, {"strength", 15}, {"surf", 15}, {"blizzard", 5}}; +// Our Lv54 Blastoise (console B, 2026-11-16): 171 HP; Speed 117, 128 with Thunder's boost. +constexpr int OUR_MAX_HP = 171; +constexpr int OUR_SPEED = 117; + +// 16 rolls from `low` to `high`. +std::vector rolls(int low, int high){ + std::vector out; + for (int c = 0; c < 16; c++){ + out.push_back(low + (high - low) * c / 15); + } + return out; +} + +// Our four moves' damage on the foe out, and their PP. +struct OurHits{ + std::vector bite = {}; + std::vector strength = {}; + std::vector surf = {}; + std::vector blizzard = {}; +}; + +PlannedOwn blastoise(const OurHits& hits, const SlugCounts& pp){ + const auto pp_of = [&](const std::string& move){ + const auto it = pp.find(move); + return it == pp.end() ? FULL_PP.at(move) : it->second; + }; + return PlannedOwn{ + .hp = OUR_MAX_HP, + .max_hp = OUR_MAX_HP, + .speed = battle_speed(badge_boosted(OUR_SPEED), /*stage=*/0, /*paralyzed=*/false), + .moves = { + {.id = "bite", .pp = pp_of("bite"), .damage = hits.bite}, + {.id = "strength", .pp = pp_of("strength"), .damage = hits.strength}, + {.id = "surf", .pp = pp_of("surf"), .damage = hits.surf}, + {.id = "blizzard", .pp = pp_of("blizzard"), .damage = hits.blizzard}, + }, + }; +} + +const LeagueFightData& fight(std::string_view name){ + const LeagueFightData* data = league_fight_data(league_plan_data(), name); + if (data == nullptr){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No {} in the League plan.", name)); + } + return *data; +} + +std::string move_id(const PlannedState& state, const PlannedChoice& choice){ + if (choice.item){ + return *choice.item; + } + if (choice.move_slot){ + return state.own.moves[*choice.move_slot].id; + } + return ""; +} + +std::string describe(const PlannedState& state, const PlannedChoice& choice){ + return std::format("{} ({})", choice.row, move_id(state, choice)); +} + +// Blastoise at `hits` and `pp`, with stages, at `hp`. +struct OurSetup{ + int spa = 0; + int speed = 0; + int accuracy = 0; + int hp = OUR_MAX_HP; +}; +PlannedOwn blastoise_at(const OurHits& hits, const SlugCounts& pp, const OurSetup& setup){ + PlannedOwn own = blastoise(hits, pp); + own.spa_stage = setup.spa; + own.speed_stage = setup.speed; + own.speed = battle_speed(badge_boosted(OUR_SPEED), setup.speed, /*paralyzed=*/false); + own.accuracy_stage = setup.accuracy; + own.hp = setup.hp; + for (PlannedMove& move : own.moves){ + move.accuracy = hit_chance(/*accuracy=*/100, setup.accuracy, /*evasion_stage=*/0); + } + return own; +} + + +// The League's foes as the cases need them (pret's parties; the rolls on +// our Lv54 Blastoise are the sim's where test_planned.py names them). +PlannedFoe golbat(){ + return {.species = "golbat", .slot = 1, .hp = 161, .max_hp = 161, .speed = 129, + .moves = {{.id = "wing-attack", .pp = 35, .damage = rolls(25, 30)}}}; +} +PlannedFoe gyarados(){ + return {.species = "gyarados", .slot = 0, .hp = 189, .max_hp = 189, .speed = 112, + .moves = {{.id = "hyper-beam", .pp = 5, .accuracy = 0.9, .damage = rolls(68, 80)}}}; +} +PlannedFoe dragonair(){ + return {.species = "dragonair", .slot = 1, .hp = 146, .max_hp = 146, .speed = 96, + .moves = { + {.id = "hyper-beam", .pp = 5, .accuracy = 0.9, .damage = rolls(45, 54)}, + {.id = "dragon-rage", .pp = 10, .damage = rolls(40, 40)}, + }}; +} +PlannedFoe dragonite(){ + return {.species = "dragonite", .slot = 4, .hp = 197, .max_hp = 197, .speed = 107, + .moves = {{.id = "hyper-beam", .pp = 5, .accuracy = 0.9, .damage = rolls(70, 83)}}}; +} +const OurHits ON_DRAGONITE = {.bite = rolls(22, 26), .strength = rolls(18, 22), .surf = rolls(22, 27), .blizzard = rolls(120, 142)}; + + +const OurHits ON_GOLBAT = {.bite = rolls(40, 48), .strength = rolls(30, 36), .surf = rolls(50, 59), .blizzard = rolls(70, 83)}; +const OurHits ON_GYARADOS = {.bite = rolls(40, 48), .strength = rolls(30, 36), .surf = rolls(25, 30), .blizzard = rolls(45, 54)}; +// The old rows' setup, complete. +const OurSetup SET_UP = {.spa = 3, .speed = 6, .accuracy = 2}; + +PlannedFoe lapras_at_12_percent(){ + return {.species = "lapras", .slot = 4, .hp = 26, .max_hp = 220, .speed = 94, + .moves = {{.id = "body-slam", .pp = 15, .damage = rolls(30, 36)}}}; +} +PlannedFoe onix(){ + return {.species = "onix", .slot = 3, .hp = 118, .max_hp = 118, .speed = 96, + .moves = {{.id = "earthquake", .pp = 10, .damage = rolls(28, 33)}}}; +} +PlannedFoe gengar_at_40(){ + return {.species = "gengar", .slot = 0, .hp = 40, .max_hp = 145, .speed = 126, + .moves = {{.id = "shadow-ball", .pp = 15, .damage = rolls(30, 36)}}}; +} +PlannedFoe machamp_at_79(){ + return {.species = "machamp", .slot = 4, .hp = 79, .max_hp = 183, .speed = 83, + .moves = {{.id = "cross-chop", .pp = 5, .accuracy = 0.8, .damage = rolls(60, 71)}}}; +} +PlannedFoe venusaur(){ + return {.species = "venusaur", .slot = 5, .hp = 193, .max_hp = 193, .speed = 125, + .moves = {{.id = "razor-leaf", .pp = 25, .accuracy = 0.95, .damage = rolls(60, 71)}}}; +} +SlugCounts without(SlugCounts bag, std::string_view item){ + bag[std::string(item)] = 0; + return bag; +} +// The PP before the Champion on console B, 2026-11-16, topped up by an Elixir. +const SlugCounts CHAMPION_PP = {{"bite", 25}, {"strength", 15}, {"surf", 15}, {"blizzard", 5}}; + + +struct PolicyInput{ + PlannedState state = {}; + std::string fight = {}; + int streak = 0; +}; +// The row and pick (a move or an item) wanted, and those ruled out. +struct PolicyExpectation{ + std::optional row = std::nullopt; + std::optional pick = std::nullopt; + std::vector not_rows = {}; + std::vector not_picks = {}; + // The choice is a move (not an item). + bool attacks = false; +}; +struct PolicyCase{ + std::string name; + PolicyInput input; + PolicyExpectation expectation; +}; + +class Test_PlannedChoice : public UnitTest{ +public: + explicit Test_PlannedChoice(PolicyCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const PolicyInput& input = m_case.input; + const PolicyExpectation& want = m_case.expectation; + const PlannedChoice choice = choose_planned(input.state, fight(input.fight), input.streak); + const std::string pick = move_id(input.state, choice); + const bool ruled_out = std::ranges::find(want.not_rows, choice.row) != want.not_rows.end() + || std::ranges::find(want.not_picks, pick) != want.not_picks.end(); + if ((want.row && choice.row != *want.row) || (want.pick && pick != *want.pick) || ruled_out + || (want.attacks && !choice.move_slot)){ + return std::format("Chose {}.", describe(input.state, choice)); + } + return true; + } + +private: + PolicyCase m_case; +}; + +const PolicyCase POLICY_CASES[] = { + { + .name = "1. Blizzard reserved before Lance: not on Golbat", + .input = {.state = {.own = blastoise_at(ON_GOLBAT, {}, SET_UP), .foe = golbat(), .foe_party_alive = 4, .bag = BAG}, .fight = "agatha"}, + .expectation = {.not_picks = {"blizzard"}}, + }, + { + .name = "1. Blizzard reserved before Lance: not on Gyarados", + .input = {.state = {.own = blastoise_at(ON_GYARADOS, {}, SET_UP), .foe = gyarados(), .foe_party_alive = 5, .bag = BAG}, .fight = "lance"}, + .expectation = {.not_picks = {"blizzard"}}, + }, + { + .name = "2. no setup for Blizzard at 0 PP", + .input = {.state = {.own = blastoise(ON_GYARADOS, {{"blizzard", 0}}), .foe = gyarados(), .foe_party_alive = 5, .bag = NO_ELIXIRS}, .fight = "lance"}, + .expectation = {.not_picks = {"x-accuracy", "x-special"}}, + }, + { + .name = "2. setup for Blizzard with PP", + .input = {.state = {.own = blastoise(ON_GYARADOS, {}), .foe = gyarados(), .foe_party_alive = 5, .bag = BAG}, .fight = "lance"}, + .expectation = {.row = "plan:setup", .pick = "x-special"}, + }, + { + .name = "3. Dragonite without Blizzard takes Bite", + .input = {.state = {.own = blastoise_at(ON_DRAGONITE, {{"blizzard", 0}}, SET_UP), .foe = dragonite(), .foe_party_alive = 1, .bag = NO_ELIXIRS}, .fight = "lance"}, + .expectation = {.pick = "bite"}, + }, + { + .name = "4. no finisher into a trainer's Full Restore", + .input = {.state = {.own = blastoise_at({.bite = rolls(20, 24), .strength = rolls(30, 36), .surf = rolls(25, 30), .blizzard = rolls(20, 24)}, {}, {.spa = 3}), + .foe = lapras_at_12_percent(), .foe_party_alive = 1, .trainer_item_open = true, .bag = BAG}, .fight = "lorelei"}, + .expectation = {.not_rows = {"sure_ko"}}, + }, + { + .name = "5. no Super Potion that doesn't outpace the foe", + .input = {.state = {.own = blastoise_at({.bite = rolls(30, 36), .strength = rolls(20, 24), .surf = rolls(25, 30), .blizzard = rolls(90, 106)}, {}, {.hp = 50}), + .foe = dragonair(), .foe_party_alive = 4, .bag = BAG}, .fight = "lance"}, + .expectation = {.row = "ko_heal", .not_picks = {"super-potion"}}, + }, + { + .name = "5. the third medicine turn: a Full Restore", + .input = {.state = {.own = blastoise_at({.bite = rolls(30, 36), .strength = rolls(20, 24), .surf = rolls(25, 30), .blizzard = rolls(90, 106)}, {}, {.hp = 50}), + .foe = dragonair(), .foe_party_alive = 4, .bag = BAG}, .fight = "lance", .streak = 2}, + .expectation = {.row = "ko_heal", .pick = "full-restore"}, + }, + { + .name = "6. KO risk from the current foe: the second Onix's hits", + .input = {.state = {.own = blastoise_at({.bite = rolls(40, 48), .strength = rolls(20, 24), .surf = rolls(130, 154), .blizzard = rolls(60, 72)}, {}, {.spa = 2, .speed = 1, .hp = 60}), + .foe = onix(), .foe_party_alive = 2, .bag = BAG}, .fight = "bruno"}, + .expectation = {.attacks = true}, + }, + { + .name = "8. evasion is no sure KO", + .input = {.state = {.own = blastoise_at({.bite = rolls(50, 60), .strength = {}, .surf = rolls(45, 54), .blizzard = rolls(40, 48)}, {}, {.spa = 2, .speed = 1, .accuracy = -3}), + .foe = gengar_at_40(), .foe_party_alive = 1, .bag = BAG}, .fight = "agatha"}, + .expectation = {.not_rows = {"sure_ko"}}, + }, + { + .name = "kill order keeps Machamp out of heal range", + .input = {.state = {.own = blastoise({.bite = rolls(25, 30), .strength = rolls(20, 24), .surf = rolls(63, 75), .blizzard = rolls(40, 48)}, {}), + .foe = machamp_at_79(), .foe_party_alive = 1, .trainer_item_open = true, .bag = BAG}, .fight = "bruno"}, + .expectation = {.row = "kill_order", .pick = "bite"}, + }, + { + .name = "the Max Elixir is held in Lance's fight", + .input = {.state = {.own = blastoise(ON_DRAGONITE, {{"blizzard", 0}, {"bite", 0}, {"surf", 0}}), .foe = dragonite(), .foe_party_alive = 1, .bag = without(BAG, "elixir")}, + .fight = "lance"}, + .expectation = {.not_picks = {"max-elixir"}}, + }, + { + .name = "Champion loss: Venusaur takes Blizzard", + .input = {.state = {.own = blastoise({.bite = rolls(30, 36), .strength = rolls(25, 30), .surf = rolls(20, 24), .blizzard = rolls(95, 112)}, CHAMPION_PP), + .foe = venusaur(), .foe_party_alive = 1, .bag = without(BAG, "elixir")}, .fight = "champion"}, + .expectation = {.pick = "blizzard"}, + }, +}; + + +struct RiskInput{ + PlannedState state = {}; + // The move we_move_first() is asked about. + PlannedMove move = {}; +}; +struct RiskExpectation{ + int danger = 0; + int foe_hp_at_our_move = 0; + bool we_move_first = false; +}; +struct RiskCase{ + std::string name; + RiskInput input; + RiskExpectation expectation; +}; + +class Test_PlannedRisk : public UnitTest{ +public: + explicit Test_PlannedRisk(RiskCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - risk: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const PlannedState& state = m_case.input.state; + const int danger = planned_danger(state).normal_max; + const int foe_hp = foe_hp_at_our_move(state); + const bool first = we_move_first(state, m_case.input.move); + const RiskExpectation& want = m_case.expectation; + if (danger != want.danger || foe_hp != want.foe_hp_at_our_move || first != want.we_move_first){ + return std::format("D {}, foe HP at our move {}, we move first {}.", danger, foe_hp, first); + } + return true; + } + +private: + RiskCase m_case; +}; + +const PlannedMove SURF = {.id = "surf", .pp = 15}; + +const RiskCase RISK_CASES[] = { + { + .name = "4. the trainer's Full Restore lands first: no risk, a full foe", + .input = {.state = {.own = blastoise({}, {}), .foe = lapras_at_12_percent(), .foe_party_alive = 1, .trainer_item_open = true}, .move = SURF}, + .expectation = {.danger = 0, .foe_hp_at_our_move = 220, .we_move_first = true}, + }, + { + .name = "6. the second Onix's Earthquake", + .input = {.state = {.own = blastoise({}, {}), .foe = onix(), .foe_party_alive = 2}, .move = SURF}, + .expectation = {.danger = 33, .foe_hp_at_our_move = 118, .we_move_first = true}, + }, + { + .name = "7. at +0 we outspeed Hitmonchan", + .input = {.state = {.own = blastoise({}, {}), .foe = {.species = "hitmonchan", .slot = 1, .hp = 131, .max_hp = 131, .speed = 101}}, .move = SURF}, + .expectation = {.danger = 0, .foe_hp_at_our_move = 131, .we_move_first = true}, + }, + { + .name = "7. after Rock Tomb Hitmonchan moves first", + .input = {.state = {.own = blastoise_at({}, {}, {.speed = -1}), .foe = {.species = "hitmonchan", .slot = 1, .hp = 131, .max_hp = 131, .speed = 101}}, .move = SURF}, + .expectation = {.danger = 0, .foe_hp_at_our_move = 131, .we_move_first = false}, + }, + { + .name = "9. Gyarados's Hyper Beam is in the risk", + .input = {.state = {.own = blastoise({}, {}), .foe = gyarados(), .foe_party_alive = 5}, .move = SURF}, + .expectation = {.danger = 80, .foe_hp_at_our_move = 189, .we_move_first = true}, + }, +}; + + +struct ItemSlotInput{ + int carried = 0; + int used = 0; + int alive = 0; +}; +struct ItemSlotExpectation{ + bool open = false; +}; +struct ItemSlotCase{ + std::string name; + ItemSlotInput input; + ItemSlotExpectation expectation; +}; + +class Test_TrainerItemSlots : public UnitTest{ +public: + explicit Test_TrainerItemSlots(ItemSlotCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - pret's trainer item slots: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const ItemSlotInput& input = m_case.input; + if (trainer_item_open(input.carried, input.used, input.alive) != m_case.expectation.open){ + return std::format("Open {}.", !m_case.expectation.open); + } + return true; + } + +private: + ItemSlotCase m_case; +}; + +const ItemSlotCase ITEM_SLOT_CASES[] = { + {.name = "an Elite Four member's first", .input = {.carried = 2, .used = 0, .alive = 5}, .expectation = {.open = true}}, + {.name = "the second, five left", .input = {.carried = 2, .used = 1, .alive = 5}, .expectation = {.open = false}}, + {.name = "the second, four left", .input = {.carried = 2, .used = 1, .alive = 4}, .expectation = {.open = true}}, + {.name = "both used", .input = {.carried = 2, .used = 2, .alive = 1}, .expectation = {.open = false}}, + {.name = "the Champion's third, four left", .input = {.carried = 4, .used = 2, .alive = 4}, .expectation = {.open = false}}, + {.name = "the Champion's third, three left", .input = {.carried = 4, .used = 2, .alive = 3}, .expectation = {.open = true}}, +}; + + +struct BetweenInput{ + PlannedCarry carry = {}; + // The fights topped up for, in order. + std::vector fights = {}; +}; +struct BetweenExpectation{ + int hp = 0; + int blizzard_pp = 0; + int max_elixirs = 0; +}; +struct BetweenCase{ + std::string name; + BetweenInput input; + BetweenExpectation expectation; +}; + +class Test_PlannedBetween : public UnitTest{ +public: + explicit Test_PlannedBetween(BetweenCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - between: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + PlannedCarry carry = m_case.input.carry; + for (const std::string& next : m_case.input.fights){ + planned_between(carry, fight(next)); + } + const BetweenExpectation& want = m_case.expectation; + const int blizzard = count_of(carry.pp, "blizzard"); + const int max_elixirs = count_of(carry.bag, "max-elixir"); + if (carry.hp != want.hp || blizzard != want.blizzard_pp || max_elixirs != want.max_elixirs){ + return std::format("HP {}, Blizzard {}, Max Elixirs {}.", carry.hp, blizzard, max_elixirs); + } + return true; + } + +private: + BetweenCase m_case; +}; + +// Console B, 2026-11-16: Surf 7, Blizzard 0. +const SlugCounts SPENT_PP = {{"bite", 25}, {"strength", 15}, {"surf", 7}, {"blizzard", 0}}; + +const BetweenCase BETWEEN_CASES[] = { + { + .name = "the Max Elixir is held before Lance", + .input = {.carry = {.hp = OUR_MAX_HP, .max_hp = OUR_MAX_HP, .pp = SPENT_PP, .full_pp = FULL_PP, .bag = without(BAG, "elixir")}, .fights = {"lance"}}, + .expectation = {.hp = OUR_MAX_HP, .blizzard_pp = 0, .max_elixirs = 1}, + }, + { + .name = "the Max Elixir is used before the Champion", + .input = {.carry = {.hp = OUR_MAX_HP, .max_hp = OUR_MAX_HP, .pp = SPENT_PP, .full_pp = FULL_PP, .bag = without(BAG, "elixir")}, .fights = {"lance", "champion"}}, + .expectation = {.hp = OUR_MAX_HP, .blizzard_pp = 5, .max_elixirs = 0}, + }, + { + .name = "Champion loss: entry 89/171 topped up, Blizzard restored", + .input = {.carry = {.hp = 89, .max_hp = OUR_MAX_HP, .pp = SPENT_PP, .full_pp = FULL_PP, .bag = BAG}, .fights = {"champion"}}, + .expectation = {.hp = OUR_MAX_HP, .blizzard_pp = 5, .max_elixirs = 1}, + }, +}; + + +struct DamageInput{ + Gen3Hit hit = {}; +}; +struct DamageExpectation{ + std::vector rolls = {}; +}; +struct DamageCase{ + std::string name; + DamageInput input; + DamageExpectation expectation; +}; + +class Test_Gen3Damage : public UnitTest{ +public: + explicit Test_Gen3Damage(DamageCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - Gen 3 damage: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const std::vector got = gen3_damage_rolls(m_case.input.hit); + const std::vector& want = m_case.expectation.rolls; + if (got != want){ + return std::format("Rolls {}..{} ({}); expected {}..{}.", + got.empty() ? 0 : got.front(), got.empty() ? 0 : got.back(), got.size(), want.front(), want.back()); + } + return true; + } + +private: + DamageCase m_case; +}; + +// Expected rolls: @smogon/calc 0.10 calculate() for Gen 3 with these raw stats. +const DamageCase DAMAGE_CASES[] = { + { + .name = "Lv56 Hyper Beam, 150 Attack on 156 Defense", + .input = {.hit = {.level = 56, .attack = 150, .defense = 156, .power = 150}}, + .expectation = {.rolls = {60, 61, 61, 62, 63, 63, 64, 65, 66, 66, 67, 68, 68, 69, 70, 71}}, + }, + { + .name = "the same on -1 Defense", + .input = {.hit = {.level = 56, .attack = 150, .defense = 156, .power = 150, .defense_stage = -1}}, + .expectation = {.rolls = {89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 105}}, + }, + { + .name = "Lv54 Surf at +2 on Dragonite, STAB, resisted", + .input = {.hit = {.level = 54, .attack = 125, .defense = 157, .power = 95, .attack_stage = 2, .stab = true, .effectiveness_first = 0.5}}, + .expectation = {.rolls = {45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 53}}, + }, + { + .name = "Lv54 Blizzard on Dragonite, 4x", + .input = {.hit = {.level = 54, .attack = 125, .defense = 157, .power = 120, .effectiveness_first = 2, .effectiveness_second = 2}}, + .expectation = {.rolls = {153, 154, 156, 158, 160, 162, 163, 165, 167, 169, 171, 172, 174, 176, 178, 180}}, + }, + { + .name = "a critical hit ignores -1 Attack and +2 Defense", + .input = {.hit = {.level = 56, .attack = 170, .defense = 156, .power = 100, .attack_stage = -1, .defense_stage = 2, .stab = true, .critical = true}}, + .expectation = {.rolls = {137, 139, 140, 142, 144, 145, 147, 149, 150, 152, 153, 155, 157, 158, 160, 162}}, + }, +}; + + +struct RecoveryInput{ + std::string item = {}; + int surf_pp = 0; + int blizzard_pp = 0; +}; +struct RecoveryExpectation{ + int surf_pp = 0; + int blizzard_pp = 0; +}; +struct RecoveryCase{ + std::string name; + RecoveryInput input; + RecoveryExpectation expectation; +}; + +class Test_RecoveryItem : public UnitTest{ +public: + explicit Test_RecoveryItem(RecoveryCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + Supplies supplies; + supplies.lead.moves = {{.move = "surf", .pp = static_cast(m_case.input.surf_pp)}, {.move = "blizzard", .pp = static_cast(m_case.input.blizzard_pp)}}; + took_recovery_item(supplies, m_case.input.item); + const int surf = supplies.lead.moves[0].pp; + const int blizzard = supplies.lead.moves[1].pp; + if (surf != m_case.expectation.surf_pp || blizzard != m_case.expectation.blizzard_pp){ + return std::format("Surf {}, Blizzard {}.", surf, blizzard); + } + return true; + } + +private: + RecoveryCase m_case; +}; + +// Console B, 2026-11-16: the PP read after the Max Elixir before the +// Champion still said Blizzard 0/5; took_recovery_item() restored PP for +// an Elixir only. +const RecoveryCase RECOVERY_CASES[] = { + { + .name = "Champion loss: the Max Elixir restores the lead's PP", + .input = {.item = "max-elixir", .surf_pp = 7, .blizzard_pp = 0}, + .expectation = {.surf_pp = 15, .blizzard_pp = 5}, + }, +}; + + +struct FoePlanInput{ + std::string fight = {}; + size_t slot = 0; + std::string species = {}; +}; +struct FoePlanExpectation{ + std::string first_move = {}; + size_t setup_goals = 0; +}; +struct FoePlanCase{ + std::string name; + FoePlanInput input; + FoePlanExpectation expectation; +}; + +class Test_LeagueFoePlan : public UnitTest{ +public: + explicit Test_LeagueFoePlan(FoePlanCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryPlannedPolicy - League plan built in: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const FoePlanInput& input = m_case.input; + const LeagueFoePlan* foe = league_foe_plan(fight(input.fight), input.slot, input.species); + if (foe == nullptr){ + return "Not found."; + } + const std::string first = foe->moves.empty() ? "" : foe->moves.front(); + if (first != m_case.expectation.first_move || foe->setup.size() != m_case.expectation.setup_goals){ + return std::format("First move {}, {} setup goals.", first, foe->setup.size()); + } + return true; + } + +private: + FoePlanCase m_case; +}; + +const FoePlanCase FOE_PLAN_CASES[] = { + { + .name = "Bruno's second Onix, by its slot", + .input = {.fight = "bruno", .slot = 3, .species = "onix"}, + .expectation = {.first_move = "surf", .setup_goals = 0}, + }, + { + .name = "Dragonite at another slot, by species", + .input = {.fight = "lance", .slot = 0, .species = "dragonite"}, + .expectation = {.first_move = "blizzard", .setup_goals = 0}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryPlannedPolicy(UnitTestDatabase& database){ + for (const DamageCase& test_case : DAMAGE_CASES){ + database.add(test_case); + } + for (const PolicyCase& test_case : POLICY_CASES){ + database.add(test_case); + } + for (const RiskCase& test_case : RISK_CASES){ + database.add(test_case); + } + for (const ItemSlotCase& test_case : ITEM_SLOT_CASES){ + database.add(test_case); + } + for (const BetweenCase& test_case : BETWEEN_CASES){ + database.add(test_case); + } + for (const RecoveryCase& test_case : RECOVERY_CASES){ + database.add(test_case); + } + for (const FoePlanCase& test_case : FOE_PLAN_CASES){ + database.add(test_case); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.cpp new file mode 100644 index 0000000000..a476522187 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.cpp @@ -0,0 +1,79 @@ +/* AutoStory Planned Risk + * + * From: https://github.com/PokemonAutomation/ + * + * planned.py's foe_hp_at_our_move(), danger() and we_move_first() + * (PokemonSimulation #111, 4a79ccc): keep the two in step. + * + */ + +#include +#include "PokemonFRLG_AutoStoryPlannedRisk.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr int MAX_TRAINER_ITEMS = 4; + +bool trainer_uses_item(const PlannedState& state){ + return state.trainer_item_open && state.foe.hp > 0 && state.foe.hp < state.foe.max_hp / 4; +} + +} // namespace + + +bool trainer_item_open(int carried, int used, int alive){ + for (int slot = used; slot < carried; slot++){ + if (slot == 0 || alive <= MAX_TRAINER_ITEMS - slot + 1){ + return true; + } + } + return false; +} + +int foe_hp_at_our_move(const PlannedState& state){ + return trainer_uses_item(state) ? state.foe.max_hp : state.foe.hp; +} + +PlannedDanger planned_danger(const PlannedState& state){ + const PlannedOwn& own = state.own; + const PlannedFoe& foe = state.foe; + const int residual = own.max_hp / 8 * ((own.status == PlannedStatus::POISON ? 1 : 0) + (own.leech_seed ? 1 : 0)); + if (foe.recharging || foe.sleeping || foe.frozen || trainer_uses_item(state)){ + return {.normal_max = residual, .mean = static_cast(residual)}; + } + int worst = 0; + double mean = 0; + for (const PlannedMove& move : foe.moves){ + if (!move.usable() || move.max_damage() <= 0){ + continue; + } + const bool charging = move.two_turn && foe.charging == move.id; + if (move.two_turn && !charging && !(foe.sun && move.id == "solar-beam")){ + continue; + } + worst = std::max(worst, move.max_damage()); + mean = std::max(mean, move.expected_hit()); + } + return {.normal_max = residual + worst, .mean = residual + mean}; +} + +bool we_move_first(const PlannedState& state, const PlannedMove& move){ + if (move.priority != 0){ + return move.priority > 0; + } + if (state.foe.recharging){ + return true; + } + return state.own.speed > state.foe.speed; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.h new file mode 100644 index 0000000000..d53d23b934 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.h @@ -0,0 +1,49 @@ +/* AutoStory Planned Risk + * + * From: https://github.com/PokemonAutomation/ + * + * What a League turn risks, as planned.py reads it (PokemonSimulation + * #111): the trainer's Full Restore slots, the foe's HP when our move + * lands, the HP we can lose this turn and who moves first. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlannedRisk_H +#define PokemonAutomation_PokemonFRLG_AutoStoryPlannedRisk_H + +#include "PokemonFRLG_AutoStoryPlannedState.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// pret ShouldUseItem's slot gate for a trainer carrying `carried` items +// of one kind (Full Restores), `used` of them used, with `alive` Pokemon +// left: slot i > 0 stays shut while more than 4 - i + 1 are alive. +bool trainer_item_open(int carried, int used, int alive); + +// The foe's HP when our move lands: full when its trainer uses the item +// first (under 1/4 with a slot open). +int foe_hp_at_our_move(const PlannedState& state); + +// The HP we can lose this turn: residual damage plus the foe's worst +// ordinary hit as it stands (normal_max), and the mean of its best hit. +// Residual only while it recharges, sleeps, is frozen or uses an item. +struct PlannedDanger{ + int normal_max = 0; + double mean = 0; +}; + +// The danger of `state`'s turn (PlannedDanger). +PlannedDanger planned_danger(const PlannedState& state); + +// `move` lands before the foe's: by priority, its recharge, then Speed. +bool we_move_first(const PlannedState& state, const PlannedMove& move); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedState.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedState.h new file mode 100644 index 0000000000..7e998571ac --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedState.h @@ -0,0 +1,144 @@ +/* AutoStory Planned State + * + * From: https://github.com/PokemonAutomation/ + * + * A League turn as the planned policy (PokemonFRLG_AutoStoryPlannedPolicy.h) + * reads it: our Pokemon out and the foe out, each move with its damage + * rolls on the other side, and the bag. PlannedBattle builds it from the + * screen and the battle texts; tests build it by hand. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlannedState_H +#define PokemonAutomation_PokemonFRLG_AutoStoryPlannedState_H + +#include +#include +#include +#include +#include +#include +#include "PokemonFRLG_AutoStoryLeaguePlanData.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// A move as the policy weighs it. +struct PlannedMove{ + std::string id = {}; + int pp = 0; + // The chance it hits, with stages and evasion (hit_chance()). + double accuracy = 1.0; + // Its damage rolls on the other side, lowest first + // (gen3_damage_rolls()); empty for no damage. + std::vector damage = {}; + int priority = 0; + // Charges a turn first (Solar Beam, Dive, Sky Attack). + bool two_turn = false; + + bool usable() const{ + return pp > 0; + } + int min_damage() const{ + return damage.empty() ? 0 : damage.front(); + } + int max_damage() const{ + return damage.empty() ? 0 : damage.back(); + } + // The mean roll times the chance it hits. + double expected_hit() const{ + if (damage.empty()){ + return 0; + } + return static_cast(std::accumulate(damage.begin(), damage.end(), 0)) / static_cast(damage.size()) * accuracy; + } +}; + +// A Pokemon's status condition, as the policy tells them apart. +enum class PlannedStatus{ + NONE, + POISON, + PARALYSIS, + SLEEP, + BURN, + FREEZE, +}; + +// The item that cures `status`; none for no status. +inline std::optional status_cure(PlannedStatus status){ + switch (status){ + case PlannedStatus::SLEEP: + return "awakening"; + case PlannedStatus::POISON: + return "antidote"; + case PlannedStatus::PARALYSIS: + return "parlyz-heal"; + case PlannedStatus::BURN: + return "burn-heal"; + case PlannedStatus::FREEZE: + return "ice-heal"; + case PlannedStatus::NONE: + return std::nullopt; + } + return std::nullopt; +} + +// Our Pokemon out. +struct PlannedOwn{ + int hp = 0; + int max_hp = 0; + PlannedStatus status = PlannedStatus::NONE; + // battle_speed(): with Thunder's boost, the stage and paralysis. + int speed = 0; + int spa_stage = 0; + int speed_stage = 0; + int accuracy_stage = 0; + int attack_stage = 0; + int defense_stage = 0; + bool mist = false; + bool leech_seed = false; + // In the move list's order. + std::vector moves = {}; + // The slot of a move we are locked into. + std::optional locked_slot = std::nullopt; +}; + +// The foe out. +struct PlannedFoe{ + std::string species = {}; + // Its trainer's party slot. + size_t slot = 0; + int hp = 0; + int max_hp = 0; + // battle_speed(): with its stage and paralysis. + int speed = 0; + bool recharging = false; + // Asleep for more than this turn. + bool sleeping = false; + bool frozen = false; + // The two-turn move it is charging. + std::optional charging = std::nullopt; + bool sun = false; + // Its moves, with their damage on us. + std::vector moves = {}; +}; + +// One turn's state: both sides, the trainer and our bag. +struct PlannedState{ + PlannedOwn own = {}; + PlannedFoe foe = {}; + // The trainer's Pokemon still standing, the one out included. + int foe_party_alive = 1; + // The trainer has an open item slot (trainer_item_open()). + bool trainer_item_open = false; + SlugCounts bag = {}; +}; + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.cpp index ea54c6e3c4..5f6854fb5a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.cpp @@ -4,6 +4,7 @@ * */ +#include #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonFRLG_AutoStoryPocketList.h" @@ -50,6 +51,9 @@ PocketRead read_whole_pocket(PocketList& list){ } } read.rows = pocket_rows(std::move(reads)); + for (size_t c = 0; c < read.downs; c++){ + list.cursor_up(); + } return read; } @@ -59,6 +63,11 @@ namespace{ // (read_items_pocket()'s, console B 2026-11-12). constexpr Milliseconds SCROLL_TAP = 100ms; constexpr Milliseconds SCROLL_WAIT = 400ms; +// An UP back to the top, with no read after it (the field bag's). +constexpr Milliseconds CURSOR_UP_WAIT = 150ms; +// The UP presses that bring the battle bag's cursor to the top, at +// least: what the battle sent before the pocket's rows were counted. +constexpr size_t MIN_HOME_UPS = 12; // The open pocket on the console's screen. class ConsolePocketList : public PocketList{ @@ -82,6 +91,10 @@ class ConsolePocketList : public PocketList{ pbf_press_dpad(m_context, DPAD_DOWN, SCROLL_TAP, SCROLL_WAIT); m_screen = VideoSnapshot(); } + virtual void cursor_up() override{ + pbf_press_dpad(m_context, DPAD_UP, SCROLL_TAP, CURSOR_UP_WAIT); + m_screen = VideoSnapshot(); + } private: ConsoleHandle& m_console; @@ -97,6 +110,30 @@ PocketRead read_open_pocket(ConsoleHandle& console, ProControllerContext& contex return read_whole_pocket(list); } +void open_battle_items_pocket(ProControllerContext& context){ + for (DpadPosition position : {DPAD_LEFT, DPAD_UP, DPAD_RIGHT}){ + pbf_press_dpad(context, position, /*hold=*/160ms, /*release=*/240ms); + } + pbf_press_button(context, BUTTON_A, /*hold=*/160ms, /*release=*/1500ms); + for (int c = 0; c < 2; c++){ + pbf_press_dpad(context, DPAD_LEFT, /*hold=*/160ms, /*release=*/500ms); + } +} + +void open_battle_bag(ProControllerContext& context, size_t rows){ + open_battle_items_pocket(context); + for (size_t c = 0; c < std::max(rows, MIN_HOME_UPS); c++){ + pbf_press_dpad(context, DPAD_UP, /*hold=*/100ms, /*release=*/150ms); + } +} + +std::vector read_battle_pocket(ConsoleHandle& console, ProControllerContext& context, Language language, size_t rows){ + open_battle_bag(context, rows); + std::vector read = read_open_pocket(console, context, language).rows; + pbf_press_button(context, BUTTON_B, /*hold=*/160ms, /*release=*/1500ms); + return read; +} + } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.h index b3216dc487..577819f6a5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.h @@ -35,10 +35,12 @@ class PocketList{ virtual std::optional read_shown(int shown) = 0; // DOWN: the cursor one row down. virtual void cursor_down() = 0; + // UP: the cursor one row up. + virtual void cursor_up() = 0; }; -// A pocket read whole, and the DOWN presses it took: as many UP put the -// cursor back on the top row. +// A pocket read whole, and the DOWN presses it took (and the UP presses +// that put the cursor back on the top row after). struct PocketRead{ std::vector rows; size_t downs = 0; @@ -49,13 +51,30 @@ struct PocketRead{ // (or the list stops scrolling, its CANCEL unread). The cursor must start // on the top row. Reading the first six only ended 14.03's Rare Candy // step with "no rare-candy left", its RARE CANDY the 7th row (console B, -// 2026-11-14). +// 2026-11-14). It ends with the cursor back on the top row: the game +// keeps a pocket's cursor between visits, the field's and the battle's +// alike, and a read left on row 14 of 16 put the battle's 12 UP one row +// short, so the X Special's DOWN presses stopped on the X Speed (console +// B, 2026-11-16, 19.01b's rival fought with no setup). PocketRead read_whole_pocket(PocketList& list); // The bag's open pocket on the console, read whole (read_whole_pocket()), -// its cursor on the top row to start; it ends where the read left it. +// its cursor on the top row to start and to end. PocketRead read_open_pocket(ConsoleHandle& console, ProControllerContext& context, Language language); +// From the battle menu: BAG, its cursor on the Items pocket's top row. The +// bag opens on the pocket used last; Items is the first. `rows` is the +// pocket's rows as far as known, its CANCEL included: the UP presses +// that bring the cursor to the top from wherever the last visit left it. +void open_battle_bag(ProControllerContext& context, size_t rows); +// From the battle menu: BAG, on the Items pocket, its cursor where the +// last visit left it. +void open_battle_items_pocket(ProControllerContext& context); +// From the battle menu: the Items pocket through BAG (`rows` as +// open_battle_bag() takes it), read whole, and back to the battle menu. +// Empty if nothing could be read. +std::vector read_battle_pocket(ConsoleHandle& console, ProControllerContext& context, Language language, size_t rows); + } // namespace PokemonFRLG } // namespace NintendoSwitch diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.cpp new file mode 100644 index 0000000000..cc46853afc --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.cpp @@ -0,0 +1,409 @@ +/* AutoStory Rock Tunnel Tests + * + * From: https://github.com/PokemonAutomation/ + * + * 08.01 through Rock Tunnel on the overworld sim, one floor at a time: + * each floor from where a clean run of the row reaches it, with wild + * battles every few steps and at the game's own odds. One case a floor + * fits STAGE_BUDGET, where one on the whole row ran past it. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldObjects.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteSteps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryPoses.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRockTunnel_Tests.h" +#include "PokemonFRLG_AutoStorySimBudget.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +const std::string ROCK_TUNNEL_1F = "RockTunnel_1F"; +const std::string ROCK_TUNNEL_B1F = "RockTunnel_B1F"; +const std::string ROUTE10 = "Route10"; + +// Rock Tunnel has no Flash: both floors are dark. +const std::set ROCK_TUNNEL_DARK{ROCK_TUNNEL_1F, ROCK_TUNNEL_B1F}; + +const StoryCheckpoint& checkpoint(std::string_view id){ + const std::vector& rows = story_checkpoints(); + const auto row = std::find_if(rows.begin(), rows.end(), [&](const StoryCheckpoint& data){ return data.id == id; }); + if (row == rows.end()){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No checkpoint {}.", id)); + } + return *row; +} + +// The maps as 07.02 leaves them: the story's flags, Rock Tunnel's and +// Route 10's trainers unfought. +std::vector maps_after_route10(){ + const std::vector all = overworld_maps(); + std::set flags = map_flag_set(all, "after_hall_of_fame"); + flags.merge(map_flag_set(all, "new_game")); + flags.erase("FLAG_HIDE_VERMILION_CITY_OAKS_AIDE"); + return overworld_maps(flags); +} + +// Wild battles on the tunnel's floor, `gaps` steps apart in turn, from the +// first step: as many as a row walks. +SimScript battles_every(const std::vector& gaps){ + SimScript script; + int step = 0; + for (size_t c = 0; step < 3000; c++){ + step += gaps[c % gaps.size()]; + script.encounters.push_back(SimEncounter{.grass_step = step}); + } + return script; +} + +// One run of a row on the sim, against the same row with no wild battle. +struct RowRunNumbers{ + bool passed = false; + double seconds = 0; + int tiles = 0; + // Tiles walked beyond the run with no wild battle: walked again after + // a battle, finding the player and the way back. + int tiles_again = 0; + int battles = 0; + // Per wild battle, the time beyond the run with no wild battle, less + // the battles' own: from each battle's end until the walk is back + // where it was cut off. + double seconds_lost_per_battle = 0; +}; + +RowRunNumbers row_numbers(const SimState& run, bool passed, const SimState& clean){ + RowRunNumbers out; + out.passed = passed; + out.seconds = run.time.count() / 1000.; + out.tiles = run.steps; + out.tiles_again = run.steps - clean.steps; + out.battles = run.wild_battles; + const Milliseconds lost = run.time - clean.time - run.in_wild_battles; + out.seconds_lost_per_battle = run.wild_battles > 0 ? lost.count() / 1000. / run.wild_battles : 0; + return out; +} + +// The mean and 90th percentile of `values`. +std::string mean_p90(std::vector values){ + if (values.empty()){ + return "-"; + } + std::sort(values.begin(), values.end()); + const double mean = std::accumulate(values.begin(), values.end(), 0.) / values.size(); + const double p90 = values[std::min(values.size() - 1, (size_t)(0.9 * values.size()))]; + return std::format("mean {:.1f}, p90 {:.1f}", mean, p90); +} + +// How many of `runs` passed, and over those, the mean and 90th percentile +// of each number. +std::string numbers_summary(const std::vector& runs){ + std::vector seconds, tiles, again, battles, lost; + size_t passed = 0; + for (const RowRunNumbers& run : runs){ + passed += run.passed ? 1 : 0; + if (!run.passed){ + continue; + } + seconds.push_back(run.seconds); + tiles.push_back(run.tiles); + again.push_back(run.tiles_again); + battles.push_back(run.battles); + if (run.battles > 0){ + lost.push_back(run.seconds_lost_per_battle); + } + } + return std::format( + "passed {}/{}; of those passed: time (s) {}; tiles {}; tiles walked again {}; wild battles {}; s lost per battle {}", + passed, runs.size(), mean_p90(seconds), mean_p90(tiles), mean_p90(again), mean_p90(battles), mean_p90(lost) + ); +} + +// The land encounter rates of the maps 08.01 and 08.02 walk (pokefirered +// src/data/wild_encounters.json, FireRed). +const std::map ROCK_TUNNEL_ENCOUNTER_RATES{ + {ROCK_TUNNEL_1F, 7}, + {ROCK_TUNNEL_B1F, 7}, + {ROUTE10, 21}, +}; + +constexpr unsigned GAME_ODDS_SEEDS = 30; + +// Rock Tunnel's floors as 08.01 walks them, in order: its steps on Route 10, +// then each visit to 1F or B1F, which ends where the next starts. A test +// on a floor fits STAGE_BUDGET where one on the whole row ran past it +// (Fork Draft CI, 2026-11-16: 30 seeds at the game's odds took 314 s). +const std::string_view ROCK_TUNNEL_FLOOR_NAMES[] = { + "Route 10 to the tunnel", + "1F, Ashton, down the south ladder", + "B1F, Winston, Martha and Allen", + "1F, Lenny", + "B1F, Sofia and Dudley", + "1F, Dana, out of the south mouth", +}; + +// One floor of 08.01: steps [first, end) of the row, from where a clean +// run of the whole row stood at `first`, to where it stood at `end`. +struct RockTunnelFloor{ + size_t first = 0; + size_t end = 0; + StoryPose at = {}; + MapPosition start = {}; + Direction facing = Direction::SOUTH; + // The trainers fought before it (trainer_id()), on any floor. + std::set beaten = {}; + // The trainers it fights, by name, in order. + std::vector fought = {}; + MapPosition finish = {}; +}; + +// The trainers of `sim`'s current map that are no longer trainers, as +// trainer_id() names them on `maps`, the maps the sim started on. +std::set trainers_gone(const OverworldSim& sim, const std::vector& maps){ + std::set gone; + const auto map = std::find_if(maps.begin(), maps.end(), [&](const MapData& data){ return data.name == sim.state().position.map; }); + if (map == maps.end()){ + return gone; + } + const std::vector& now = sim.objects(); + for (size_t c = 0; c < map->objects.size() && c < now.size(); c++){ + if (map->objects[c].trainer && !now[c].trainer){ + gone.insert(trainer_id(*map, map->objects[c])); + } + } + return gone; +} + +// 08.01's floors, from one clean run of the row. +std::vector find_rock_tunnel_floors(){ + const StoryCheckpoint& row = checkpoint("08.01"); + const std::vector maps = maps_after_route10(); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); + OverworldSim sim(maps, MapPosition{at.map, at.tile}, *at.facing, SimScript{}); + std::vector floors; + std::set beaten; + size_t fought_before = 0; + const auto close_floor = [&](size_t end){ + RockTunnelFloor& floor = floors.back(); + floor.end = end; + floor.finish = sim.state().position; + const std::vector& all = sim.state().trainers_beaten; + floor.fought.assign(all.begin() + (std::ptrdiff_t)fought_before, all.end()); + fought_before = all.size(); + }; + for (size_t c = 0; c < row.steps.size(); c++){ + const std::string& map = sim.state().position.map; + if (floors.empty() || (map != floors.back().start.map && ROCK_TUNNEL_DARK.contains(map))){ + if (!floors.empty()){ + close_floor(c); + } + floors.push_back({.first = c, .at = at, .start = sim.state().position, .facing = sim.state().facing, .beaten = beaten}); + } + if (const std::string failure = row_step_on_sim(sim, at, row.steps[c], row.id); !failure.empty()){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("08.01's clean run, finding its floors: {}", failure)); + } + beaten.merge(trainers_gone(sim, maps)); + } + close_floor(row.steps.size()); + return floors; +} + +// find_rock_tunnel_floors(), run once for all the floor tests. +const std::vector& rock_tunnel_floors(){ + static const std::vector FLOORS = find_rock_tunnel_floors(); + return FLOORS; +} + +// The sim at `floor`'s start, its earlier trainers beaten, with `script`. +OverworldSim floor_start_sim(const RockTunnelFloor& floor, SimScript script){ + return OverworldSim(with_trainers_beaten(maps_after_route10(), floor.beaten), floor.start, floor.facing, std::move(script)); +} + +// `floor`'s steps on `sim`, from its start: the failure, or empty if it +// ended where the clean run did, with no violation on the way, having +// fought the same trainers. +std::string floor_checked(const RockTunnelFloor& floor, OverworldSim& sim){ + const StoryCheckpoint& row = checkpoint("08.01"); + StoryPose at = floor.at; + for (size_t c = floor.first; c < floor.end; c++){ + if (const std::string failure = row_step_on_sim(sim, at, row.steps[c], row.id); !failure.empty()){ + return std::format("ended on {}; {}", to_string(sim.state().position), failure); + } + } + if (sim.state().trainers_beaten != floor.fought){ + std::string fought; + for (const std::string& name : sim.state().trainers_beaten){ + fought += std::format(" {}", name); + } + return std::format("fought{}.", fought.empty() ? " no one" : fought); + } + if (!sim.state().violations.empty()){ + return std::format("a violation on the way: {}", sim.state().violations.back()); + } + if (!(sim.state().position == floor.finish)){ + return std::format("ended on {}, not {}.", to_string(sim.state().position), to_string(floor.finish)); + } + return ""; +} + +// Floor `index` of rock_tunnel_floors(), checked to be the one +// ROCK_TUNNEL_FLOOR_NAMES names by count. +const RockTunnelFloor& rock_tunnel_floor(size_t index){ + const std::vector& floors = rock_tunnel_floors(); + if (floors.size() != std::size(ROCK_TUNNEL_FLOOR_NAMES)){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format( + "08.01 walks {} floors, but ROCK_TUNNEL_FLOOR_NAMES names {}.", floors.size(), std::size(ROCK_TUNNEL_FLOOR_NAMES) + )); + } + return floors[index]; +} + +// A floor of 08.01 with a wild battle every 7 to 25 steps on the tunnel's +// floor, the gaps drawn from each of these seeds: it ends where it should. +UnitTestResult test_floor_frequent_battles(size_t index){ + const RockTunnelFloor& floor = rock_tunnel_floor(index); + std::string failures; + for (unsigned seed = 1; seed <= 12; seed++){ + std::mt19937 random(seed); + std::uniform_int_distribution gap(7, 25); + std::vector gaps; + for (int c = 0; c < 400; c++){ + gaps.push_back(gap(random)); + } + OverworldSim sim = floor_start_sim(floor, battles_every(gaps)); + if (const std::string failure = floor_checked(floor, sim); !failure.empty()){ + failures += std::format("{}Seed {}: {}", failures.empty() ? "" : " | ", seed, failure); + } + } + if (!failures.empty()){ + return failures; + } + return true; +} + +// A floor of 08.01, its wild battles at the game's own odds (OverworldSim:: +// rolls_encounter()), from each of these seeds: every run ends where it +// should. Logs the runs' numbers and the step taps the game ignored. +UnitTestResult test_floor_game_odds(Logger& logger, size_t index){ + const RockTunnelFloor& floor = rock_tunnel_floor(index); + OverworldSim clean_sim = floor_start_sim(floor, SimScript{}); + if (const std::string clean = floor_checked(floor, clean_sim); !clean.empty()){ + return std::format("With no wild battle: {}", clean); + } + std::vector runs; + std::string failures; + int ignored = 0; + for (unsigned seed = 1; seed <= GAME_ODDS_SEEDS; seed++){ + SimScript script; + script.encounter_rates = ROCK_TUNNEL_ENCOUNTER_RATES; + script.encounter_seed = seed; + script.dark_maps = ROCK_TUNNEL_DARK; + OverworldSim sim = floor_start_sim(floor, script); + const std::string failure = floor_checked(floor, sim); + runs.push_back(row_numbers(sim.state(), failure.empty(), clean_sim.state())); + ignored += sim.state().step_taps_ignored; + if (!failure.empty()){ + failures += std::format("{}Seed {}: {}", failures.empty() ? "" : " | ", seed, failure); + } + } + logger.log(std::format( + "08.01 {} at the game's encounter odds, {} step taps ignored: {}", + ROCK_TUNNEL_FLOOR_NAMES[index], ignored, numbers_summary(runs) + )); + if (!failures.empty()){ + return failures; + } + return true; +} + +struct RockTunnelFloorInput{ + size_t floor = 0; + // The floor at the game's odds (test_floor_game_odds()), or with a + // battle every few steps (test_floor_frequent_battles()). + bool game_odds = false; +}; + +struct RockTunnelFloorExpectation{ + std::string description; +}; + +struct RockTunnelFloorCase{ + std::string name; + RockTunnelFloorInput input; + RockTunnelFloorExpectation expectation; +}; + +class Test_AutoStoryRockTunnel : public UnitTest{ +public: + explicit Test_AutoStoryRockTunnel(RockTunnelFloorCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - Simulation: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + try{ + return timed_case(logger, m_case.name, [&]{ + return m_case.input.game_odds + ? test_floor_game_odds(logger, m_case.input.floor) + : test_floor_frequent_battles(m_case.input.floor); + }); + }catch (Exception& e){ + return std::format("{}: {}", e.name(), e.message()); + } + } + +private: + RockTunnelFloorCase m_case; +}; + +// Each floor with a battle every few steps and at the game's odds +// (GAME_ODDS_SEEDS), floor by floor in ROCK_TUNNEL_FLOOR_NAMES' order. +const RockTunnelFloorCase ROCK_TUNNEL_FLOOR_CASES[] = { + {.name = "08.01 Route 10 to the tunnel: a wild battle every 7 to 25 steps, 12 seeds", .input = {.floor = 0, .game_odds = false}, .expectation = {.description = "every seed ends the floor where a clean run does"}}, + {.name = "08.01 Route 10 to the tunnel: wild battles at the game's odds, 30 seeds", .input = {.floor = 0, .game_odds = true}, .expectation = {.description = "every seed ends the floor where a clean run does; logs the numbers"}}, + {.name = "08.01 1F, Ashton, down the south ladder: a wild battle every 7 to 25 steps, 12 seeds", .input = {.floor = 1, .game_odds = false}, .expectation = {.description = "every seed ends the floor where a clean run does"}}, + {.name = "08.01 1F, Ashton, down the south ladder: wild battles at the game's odds, 30 seeds", .input = {.floor = 1, .game_odds = true}, .expectation = {.description = "every seed ends the floor where a clean run does; logs the numbers"}}, + {.name = "08.01 B1F, Winston, Martha and Allen: a wild battle every 7 to 25 steps, 12 seeds", .input = {.floor = 2, .game_odds = false}, .expectation = {.description = "every seed ends the floor where a clean run does"}}, + {.name = "08.01 B1F, Winston, Martha and Allen: wild battles at the game's odds, 30 seeds", .input = {.floor = 2, .game_odds = true}, .expectation = {.description = "every seed ends the floor where a clean run does; logs the numbers"}}, + {.name = "08.01 1F, Lenny: a wild battle every 7 to 25 steps, 12 seeds", .input = {.floor = 3, .game_odds = false}, .expectation = {.description = "every seed ends the floor where a clean run does"}}, + {.name = "08.01 1F, Lenny: wild battles at the game's odds, 30 seeds", .input = {.floor = 3, .game_odds = true}, .expectation = {.description = "every seed ends the floor where a clean run does; logs the numbers"}}, + {.name = "08.01 B1F, Sofia and Dudley: a wild battle every 7 to 25 steps, 12 seeds", .input = {.floor = 4, .game_odds = false}, .expectation = {.description = "every seed ends the floor where a clean run does"}}, + {.name = "08.01 B1F, Sofia and Dudley: wild battles at the game's odds, 30 seeds", .input = {.floor = 4, .game_odds = true}, .expectation = {.description = "every seed ends the floor where a clean run does; logs the numbers"}}, + {.name = "08.01 1F, Dana, out of the south mouth: a wild battle every 7 to 25 steps, 12 seeds", .input = {.floor = 5, .game_odds = false}, .expectation = {.description = "every seed ends the floor where a clean run does"}}, + {.name = "08.01 1F, Dana, out of the south mouth: wild battles at the game's odds, 30 seeds", .input = {.floor = 5, .game_odds = true}, .expectation = {.description = "every seed ends the floor where a clean run does; logs the numbers"}}, +}; + +} // namespace + + +void add_tests_AutoStoryRockTunnel(UnitTestDatabase& database){ + for (const RockTunnelFloorCase& item : ROCK_TUNNEL_FLOOR_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.h new file mode 100644 index 0000000000..5ed8b19640 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.h @@ -0,0 +1,29 @@ +/* AutoStory Rock Tunnel Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of 08.01's Rock Tunnel tests, one floor at a time. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryRockTunnel_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryRockTunnel_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// 08.01 one Rock Tunnel floor at a time, with wild battles +// (PokemonFRLG_AutoStoryRockTunnel_Tests.cpp); registered by +// add_tests_AutoStoryLavender(). +void add_tests_AutoStoryRockTunnel(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp index f7a9fb0998..cbf2894b22 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp @@ -16,6 +16,7 @@ #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "PokemonFRLG_AutoStoryBoulders.h" #include "PokemonFRLG_AutoStoryLegs.h" +#include "PokemonFRLG_AutoStoryMovedBoulders.h" #include "PokemonFRLG_AutoStoryLineTrainer.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryActions.h" @@ -146,7 +147,7 @@ Pokemon::StoryAction played(Pokemon::StoryActionFunction act){ StoryMapsSim::StoryMapsSim(StorySimKnobs knobs) - : Pokemon::TableExecutor(m_table, m_guard) + : Pokemon::TableExecutor(m_table, m_guard, knobs.checks) , m_table(make_story_action_table([this](StoryActionId id){ return action(id); })) , m_knobs(std::move(knobs)) , m_interrupts(step_interrupts([this](bool){ return look(); }, sim_interrupt_actions())) @@ -666,24 +667,74 @@ std::string OverworldStepSim::cut(const StoryStep& step){ return ""; } -// A PUSH_BOULDER_VARIANT step: turned to the boulder, and `tiles` pushes, -// each followed by the step onto the tile the boulder left. +namespace{ + +// A boulder push's taps on `sim`, as the game answers them: a tap into a +// boulder pushes it (SimField::PUSH_BOULDER) and the player stays; any +// other tap is a step (sim_step_once()). +class SimBoulderPresses : public BoulderPresses{ +public: + explicit SimBoulderPresses(OverworldSim& sim) + : m_sim(sim) + {} + + BoulderPressRead press(Direction direction) override{ + if (m_sim.state().facing != direction){ + sim_turn_to(m_sim, direction); + } + const MapPosition from = m_sim.state().position; + const TilePos ahead = from.point.next(direction); + const bool boulder_ahead = std::any_of(m_sim.objects().begin(), m_sim.objects().end(), [&](const MapObject& object){ + return object.name == "pushable_boulder" && object.x == ahead.x && object.y == ahead.y; + }); + if (boulder_ahead){ + return {.scrolled = false, .boulder_moved = m_sim.use_field(SimField::PUSH_BOULDER)}; + } + sim_step_once(m_sim, direction); + return {.scrolled = !(m_sim.state().position == from), .boulder_moved = false}; + } + + // As the console's: waits for the quiet overworld (a switch's script + // lock ends). + bool clear_interrupt() override{ + const Pokemon::ScreenSettle settle = wait_for_quiet_overworld(sim_screen_look(m_sim), MovementMechanics::AFTER_BATTLE_QUIET, BATTLE_EXIT_TIMEOUT); + return quiet_overworld(settle, MovementMechanics::AFTER_BATTLE_QUIET); + } + +private: + OverworldSim& m_sim; +}; + +} // namespace + +// A PUSH_BOULDER_VARIANT step: turned to the boulder, Strength used if +// the step says so, and the taps that push it `tiles` tiles +// (push_boulder_tiles()), as on the console. std::string OverworldStepSim::push_boulder(const StoryStep& step){ const Direction direction = Pokemon::story_arg(step.args, "direction"); const int64_t tiles = Pokemon::story_arg(step.args, "tiles"); - if (m_sim.state().facing != direction){ - sim_turn_to(m_sim, direction); - } - for (int64_t c = 0; c < tiles; c++){ - if (!m_sim.use_field(SimField::PUSH_BOULDER)){ - return "no boulder to push."; + if (Pokemon::story_arg(step.args, "activate")){ + if (m_sim.state().facing != direction){ + sim_turn_to(m_sim, direction); } - sim_step_once(m_sim, direction); - m_at = StoryPose{m_at.map, m_at.tile.next(direction), direction}; - if (!(m_sim.state().position == MapPosition{m_at.map, m_at.tile})){ - return "expected to step onto the boulder's tile " + to_string(MapPosition{m_at.map, m_at.tile}) + "."; + if (!m_sim.use_field(SimField::STRENGTH)){ + return std::format("no boulder {} of {}.", direction_name(direction), to_string(MapPosition{m_at.map, m_at.tile})); } } + SimBoulderPresses presses(m_sim); + const MapPosition start{m_at.map, m_at.tile}; + const BoulderPush push = push_boulder_tiles(direction, tiles, presses); + m_at.facing = direction; + for (int64_t c = 0; c < push.walked; c++){ + m_at.tile = m_at.tile.next(direction); + } + if (push.failure){ + return *push.failure; + } + if (!(m_sim.state().position == MapPosition{m_at.map, m_at.tile})){ + return std::format("expected to stand behind the boulder on {}.", to_string(MapPosition{m_at.map, m_at.tile})); + } + note_boulder_pushed(start, direction, tiles, m_flags); return ""; } @@ -869,6 +920,7 @@ std::string row_step_carrying_flags( at = executor.at(); run_flags = std::move(state.flags); trainers_back_after_map_change(map_before, at.map, run_flags); + boulders_back_after_map_change(map_before, at.map, run_flags); if (outcome.succeeded()){ // The step that picks the Card Key up (flags_after) opens the doors the // next ones walk to. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h index 13edd5973c..0da80d09d2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h @@ -20,6 +20,7 @@ #include #include #include "Pokemon/AutoStory/Pokemon_StoryActions.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" #include "Pokemon/Navigation/Pokemon_GatedTypes.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" @@ -46,6 +47,9 @@ struct StorySimKnobs{ // The maps the story is planned and walked on, with the gates of the // run state; the story's (story_maps()) if null. const std::vector* maps = nullptr; + // The run's check level: a check step it doesn't run is skipped, as on + // the console. TESTING (every check) by default. + Pokemon::StoryCheckLevel checks = Pokemon::StoryCheckLevel::TESTING; }; // The whole story on the story maps, without a walker: each ROUTE planned diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows20_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows20_Tests.h index 77001f9bff..024ecda089 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows20_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows20_Tests.h @@ -17,7 +17,7 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Rows 20.01a to 20.05 on the overworld sim (PokemonFRLG_AutoStoryLeague_Tests.cpp). +// Rows 20.01a and 20.01 on the overworld sim (PokemonFRLG_AutoStoryLeague_Tests.cpp). void add_tests_AutoStoryLeague(UnitTestDatabase& database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp index e0f4e8a237..8661a7786a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp @@ -145,7 +145,7 @@ class Test_RunPlan : public UnitTest{ const RunPlanScenario m_scenario; }; -const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"; +const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01"; const RunPlanScenario RUN_PLAN_CASES[] = { { @@ -236,11 +236,11 @@ const RunPlanScenario RUN_PLAN_CASES[] = { }, { .input = {.name = "Gift RNG off: 04.03 is passed over", .first = "04.01"}, - .expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"}, + .expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01"}, }, { .input = {.name = "Gift RNG off: 04.03 runs when started at", .first = "04.03"}, - .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"}, + .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01"}, }, { .input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman", @@ -279,7 +279,7 @@ const RunPlanScenario RUN_PLAN_CASES[] = { }, { .input = {.name = "Starter RNG alone: 04.03 runs when started at", .first = "04.03", .handoffs = {.starter_rng = true}}, - .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"}, + .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 16.06b 18.01 18.02 18.02b 18.03 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01"}, }, { .input = { .name = "Starter RNG first, with both on", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp index 5698cef90f..cbcae7246c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp @@ -201,15 +201,15 @@ UnitTestResult test_rope_out_to_center(){ // The control for the two above: the sim does see Cameron (24, 18). Row 21, // where the planner would walk (20, 21) from (28, 23) if the row did not // stop on row 22 first, is in his line (24, 19 to 21), so a walk along it -// is seen and fails. +// is seen and fails. Legs, not a route: the story's routes now plan round +// his line (RouteCost::LINE_TILE). UnitTestResult test_cameron_sees_row_21(){ OverworldSim sim(story_maps(), MapPosition{"SaffronCity_Gym", {28, 21}}, Direction::WEST); StoryPose at{"SaffronCity_Gym", {28, 21}, Direction::WEST}; StoryStep along; - along.kind = StoryStepKind::ROUTE; + along.kind = StoryStepKind::LEGS; along.name = "along_row_21"; - const Pokemon::GridPose target{"SaffronCity_Gym", {{20, 21}}, Direction::WEST}; - along.args = {{"target", target}, {"fight_wild", false}}; + along.args = {{"legs", std::vector{{Direction::WEST, 8}}}}; const std::string failure = row_step_on_sim(sim, at, along, "18.01"); if (failure.empty() && sim.state().trainers_beaten.empty() && sim.state().violations.empty()){ return "A walk along row 21 was not seen by Cameron (24, 18)."; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimBudget.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimBudget.h index 3068b9c5ad..35da730f13 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimBudget.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimBudget.h @@ -19,6 +19,7 @@ #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Time.h" +#include "Common/Cpp/TestRunners/UnitTest.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -61,6 +62,20 @@ inline bool slow_tests_enabled(){ return value != nullptr && value[0] != '\0' && std::string_view(value) != "0"; } +// `body`'s result, after logging how long it took against STAGE_BUDGET +// under `name`: the test logs show which cases are slow. +template +UnitTestResult timed_case(Logger& logger, std::string_view name, Body&& body); + +template +UnitTestResult timed_case(Logger& logger, std::string_view name, Body&& body){ + const auto start = std::chrono::steady_clock::now(); + UnitTestResult result = body(); + const std::chrono::duration took = std::chrono::steady_clock::now() - start; + logger.log(std::format("{}: {:.1f} s (budget {} s).", name, took.count(), STAGE_BUDGET.count())); + return result; +} + } // namespace PokemonFRLG } // namespace NintendoSwitch diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp index 31d49c56cf..85fa1af2a9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp @@ -186,7 +186,6 @@ struct Simulation{ } }; - struct AutoStorySimulationInput{ UnitTestResult (*body)(); // A body that logs, run instead of `body` if given. @@ -874,10 +873,11 @@ UnitTestResult test_dialog_left_up_stops_a_walk(){ } // Dialogs pop up at random before one step in five: how many whole runs -// pass with them cleared between steps, and with them left up. +// pass with them cleared between steps, and with them left up. Each run +// has its own STAGE_BUDGET (one for all ten ran out on Fork Draft CI, 40 +// to 80 s a run); a slow test, as with it CI ran past 60 min (2026-11-16). UnitTestResult check_dialogs_at_random(Logger& logger, const Pokemon::SegmentRange& range){ constexpr uint32_t SEEDS = 5; - const TimeBudget budget = budget_from_now(STAGE_BUDGET); size_t passes[2] = {0, 0}; for (uint32_t seed = 1; seed <= SEEDS; seed++){ for (bool clear : {false, true}){ @@ -887,7 +887,7 @@ UnitTestResult check_dialogs_at_random(Logger& logger, const Pokemon::SegmentRan return std::bernoulli_distribution(0.2)(*rng); }, .clear_interrupts = clear, - }, budget); + }); passes[clear] += sim.run(range).completed ? 1 : 0; } } @@ -931,13 +931,14 @@ struct StageCheck{ std::string_view what; std::string_view description; UnitTestResult (*check)(Logger&, const Pokemon::SegmentRange&); + bool slow; // run only with the slow tests on }; const StageCheck STAGE_CHECKS[] = { - {"in order, each start where the last save stood", "runs the stage's checkpoints one-shot, each from where the one before saved", [](Logger&, const Pokemon::SegmentRange& range){ return check_story_run(range, budget_from_now(STAGE_BUDGET)); }}, - {"the steps it stubs need the console", "stubs each needs-console step of the stage and plays the rest", check_stubbed_steps}, - {"a dialog before every step, cleared", "the stage passes with each dialog cleared between steps", [](Logger&, const Pokemon::SegmentRange& range){ return check_dialog_before_every_step(range); }}, - {"dialogs before one step in five, over 5 seeds", "every run of the stage passes with them cleared", check_dialogs_at_random}, + {"in order, each start where the last save stood", "runs the stage's checkpoints one-shot, each from where the one before saved", [](Logger&, const Pokemon::SegmentRange& range){ return check_story_run(range, budget_from_now(STAGE_BUDGET)); }, false}, + {"the steps it stubs need the console", "stubs each needs-console step of the stage and plays the rest", check_stubbed_steps, false}, + {"a dialog before every step, cleared", "the stage passes with each dialog cleared between steps", [](Logger&, const Pokemon::SegmentRange& range){ return check_dialog_before_every_step(range); }, false}, + {"dialogs before one step in five, over 5 seeds", "every run of the stage passes with them cleared", check_dialogs_at_random, true}, }; // `check` on `stage`. `check` is one of STAGE_CHECKS, which outlive it. @@ -945,7 +946,7 @@ AutoStorySimulationTestCase stage_case(const StoryStage& stage, const StageCheck const Pokemon::SegmentRange range{.from = stage.first, .to = stage.last}; return { .name = std::format("stage {} ({} to {}), {}", stage.first.substr(0, 2), stage.first, stage.last, check.what), - .input = {.body = nullptr, .logged = [&check, range](Logger& logger){ return check.check(logger, range); }}, + .input = {.body = nullptr, .logged = [&check, range](Logger& logger){ return check.check(logger, range); }, .slow = check.slow}, .expectation = {.description = check.description}, }; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenu.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenu.h index 9f7f5e8a23..f8af5c2cb0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenu.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenu.h @@ -30,16 +30,6 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Whether the shared check level (Types/Pokemon_StoryCheckLevel.h, set by -// StoryRunOptions) has the story check the screen before and after it -// acts: DEFAULT and above (TESTING, THOROUGH). Then FRLG reads a Mart -// row's item before buying it, the bag's Items pocket after shopping (the -// counts the story then keeps), and an item's name in the bag before -// using it. FAST and SPEEDRUN trust the counts it keeps and the timings. -inline bool checks_screen(Pokemon::StoryCheckLevel level){ - return level <= Pokemon::StoryCheckLevel::DEFAULT; -} - // The START menu as the story grows it. Before the starter: BAG, the // player, SAVE, OPTION, EXIT; the starter adds POKEMON on top, the Pokedex // POKEDEX above that. In the Safari Zone it is RETIRE, POKEDEX, POKEMON, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.cpp new file mode 100644 index 0000000000..7ed39d1391 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.cpp @@ -0,0 +1,138 @@ +/* AutoStory Start Menu Opening + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_MovementMechanics.h" +#include "PokemonFRLG_AutoStoryStepInterrupts.h" +#include "PokemonFRLG_AutoStoryStartMenuOpening.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +StartOpenAction StartMenuOpening::next(StartOpenScreen screen){ + switch (screen){ + case StartOpenScreen::START_MENU: + return StartOpenAction::OPENED; + case StartOpenScreen::BATTLE: + return StartOpenAction::FAIL_BATTLE; + case StartOpenScreen::BOX: + return StartOpenAction::CLOSE_BOX; + case StartOpenScreen::QUIET_OVERWORLD: + if (m_presses >= MAX_PRESSES){ + return StartOpenAction::FAIL_NO_MENU; + } + m_presses++; + return StartOpenAction::PRESS_START; + case StartOpenScreen::SETTLING: + return StartOpenAction::WAIT; + } + return StartOpenAction::WAIT; +} + +namespace{ + +// How long the overworld shows nothing before START: past a warp's +// fade-in, as after a battle's black (MovementMechanics::AFTER_BATTLE_QUIET). +constexpr Milliseconds START_QUIET = MovementMechanics::AFTER_BATTLE_QUIET; +// One wait for that quiet; a look that hasn't settled by then is judged +// as it is, and the next one waits again. +constexpr Milliseconds START_SETTLE_TIMEOUT = 3000ms; +// All of it: two scenes' worth of settling, and the presses. +constexpr Milliseconds START_OPEN_TIMEOUT = 20000ms; +// From START to the menu drawn. +constexpr Milliseconds START_MENU_WATCH = 2000ms; + +StartOpenScreen read_start_open_screen(const Pokemon::ScreenSettle& settle, const ImageViewRGB32& screen){ + if (screen && StartMenuDetector(COLOR_RED).detect(screen)){ + return StartOpenScreen::START_MENU; + } + if (settle.showing.has(ScreenEvent::BATTLE_STARTED)){ + return StartOpenScreen::BATTLE; + } + if (settle.showing.has(ScreenEvent::DIALOG_BOX) || settle.showing.has(ScreenEvent::CHOICE_BOX)){ + return StartOpenScreen::BOX; + } + if (quiet_overworld(settle, START_QUIET)){ + return StartOpenScreen::QUIET_OVERWORLD; + } + return StartOpenScreen::SETTLING; +} + +// START, watched for the menu. +bool press_start(ConsoleHandle& console, ProControllerContext& context){ + StartMenuWatcher start_menu(COLOR_RED); + context.wait_for_all_requests(); + const int ret = run_until( + console, context, + [](ProControllerContext& context){ + pbf_press_button(context, BUTTON_PLUS, /*hold=*/200ms, /*release=*/START_MENU_WATCH); + }, + {start_menu} + ); + return ret == 0; +} + +} // namespace + +void open_start_menu_settled(ConsoleHandle& console, ProControllerContext& context){ + ConsoleScreenLook eyes(console, context); + StartMenuOpening opening; + const WallClock deadline = current_time() + START_OPEN_TIMEOUT; + while (current_time() < deadline){ + const Pokemon::ScreenSettle settle = wait_for_quiet_overworld( + [&eyes](bool fresh){ return eyes.look(fresh); }, START_QUIET, START_SETTLE_TIMEOUT + ); + context.wait_for_all_requests(); + const VideoSnapshot screen = console.video().snapshot(); + switch (opening.next(read_start_open_screen(settle, screen))){ + case StartOpenAction::OPENED: + console.log("Start menu opened."); + return; + case StartOpenAction::WAIT: + console.log(std::format("START menu: not yet, {}.", Pokemon::describe(settle))); + break; + case StartOpenAction::CLOSE_BOX: + console.log(std::format("START menu: a box first, {}: B.", Pokemon::describe(settle)), COLOR_ORANGE); + pbf_press_button(context, BUTTON_B, /*hold=*/160ms, /*release=*/500ms); + break; + case StartOpenAction::PRESS_START: + if (press_start(console, context)){ + console.log("Start menu opened."); + return; + } + console.log(std::format("START menu: START on {} opened nothing.", Pokemon::describe(settle)), COLOR_ORANGE); + break; + case StartOpenAction::FAIL_BATTLE: + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, "START menu: a battle shows, not the overworld.", console + ); + case StartOpenAction::FAIL_NO_MENU: + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::format("START menu: {} START presses on a quiet overworld opened nothing.", StartMenuOpening::MAX_PRESSES), + console + ); + } + } + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::format("START menu: no quiet overworld in {} s.", START_OPEN_TIMEOUT.count() / 1000), + console + ); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.h new file mode 100644 index 0000000000..672f98e274 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.h @@ -0,0 +1,70 @@ +/* AutoStory Start Menu Opening + * + * From: https://github.com/PokemonAutomation/ + * + * Opening the START menu for the story's menus (SAVE, OPTION), only once + * the overworld is at rest. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryStartMenuOpening_H +#define PokemonAutomation_PokemonFRLG_AutoStoryStartMenuOpening_H + +#include +#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// What a look before START shows, in the order it is judged: the START +// menu, a battle, a box (message or choice), the overworld at rest +// (quiet_overworld()), or anything else still moving (a warp's fade-in, +// the map's name popping up, the player walking out of a door). +enum class StartOpenScreen{ + START_MENU, + BATTLE, + BOX, + QUIET_OVERWORLD, + SETTLING, +}; +// What open_start_menu_settled() does after a look (StartMenuOpening). +enum class StartOpenAction{ + WAIT, + // B: a message or a choice left open would take START's place. + CLOSE_BOX, + PRESS_START, + OPENED, + // START does nothing in a battle; the save can't be made here. + FAIL_BATTLE, + // START was pressed on a quiet overworld MAX_PRESSES times, no menu. + FAIL_NO_MENU, +}; +// What open_start_menu_settled() does on each look until the START menu +// shows: START only on a quiet overworld, never blind. Pressed in a +// warp's fade-in, START is lost (19.04d, console B, 2026-11-16 04:24), +// and the B presses after a blind START that missed can't leave a +// battle (04:14: six misses, the save failed). +class StartMenuOpening{ +public: + static constexpr size_t MAX_PRESSES = 3; + + StartOpenAction next(StartOpenScreen screen); + +private: + size_t m_presses = 0; +}; + +// From the overworld, once it is at rest: the START menu open. Throws +// OperationFailedException (with the frame) on a battle, on no menu +// after StartMenuOpening::MAX_PRESSES, or when the screen never settles. +void open_start_menu_settled(ConsoleHandle& console, ProControllerContext& context); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStats.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStats.h index e279c0b474..220108d263 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStats.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStats.h @@ -10,6 +10,7 @@ #define PokemonAutomation_PokemonFRLG_AutoStoryStats_H #include +#include namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -26,6 +27,28 @@ struct Stats{ uint16_t speed = 0; }; +// A foe's Defense and Sp. Def, and its HP where the plan has it, from its +// trainer's party data (a battle step's "foe_stats"). +struct FoeStats{ + int defense = 0; + int sp_defense = 0; + std::optional hp = std::nullopt; +}; + +// A stat stage's multiplier: (2 + stage) / 2 up, 2 / (2 - stage) down. +inline double stage_multiplier(int stage){ + return stage >= 0 ? (2.0 + stage) / 2.0 : 2.0 / (2.0 - stage); +} + +// What the damage estimate knows beyond the member itself. +struct AttackContext{ + // The member's Attack and Sp. Atk stages: X Attacks and X Specials used. + int attack_stage = 0; + int sp_attack_stage = 0; + // The foe's stats, for a single foe; else even Defense and Sp. Def. + std::optional foe = std::nullopt; +}; + } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.cpp index eea0c21c44..c2c8b13d63 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.cpp @@ -185,14 +185,18 @@ Pokemon::ScreenSettle wait_for_quiet_overworld( void InterruptLogGuard::on_failure(const Pokemon::StoryStep& step, const OperationFailedException& error){ + save_frame(step.name, error); +} + +void InterruptLogGuard::save_frame(std::string_view name, const OperationFailedException& error){ const OperationFailedExceptionWithScreenshot* shot = dynamic_cast(&error); const std::shared_ptr frame = shot == nullptr ? nullptr : shot->screenshot(); if (!frame || !*frame){ - m_logger.log(std::format("Story: {} failed with no frame to save.", step.name), COLOR_ORANGE); + m_logger.log(std::format("Story: {} failed with no frame to save.", name), COLOR_ORANGE); return; } Filesystem::create_directories(Filesystem::Path(m_failures_folder)); - const std::string path = std::format("{}{}-{}.png", m_failures_folder, now_to_filestring(), step.name); + const std::string path = std::format("{}{}-{}.png", m_failures_folder, now_to_filestring(), name); if (frame->save(path)){ m_logger.log(std::format("Failure screenshot: {}", path), COLOR_RED); }else{ @@ -212,6 +216,10 @@ void InterruptLogGuard::on_screen(const Pokemon::StoryStep& step, const Pokemon: m_logger.log(std::format("[Screen] before {}: {}", step.name, Pokemon::describe(screen))); } +void InterruptLogGuard::on_check_skipped(const Pokemon::StoryStep&, const std::string& line){ + m_logger.log(std::format("Story: {}", line)); +} + } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h index 47c7b1e8d5..8b5a2033b2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h @@ -24,6 +24,7 @@ #include #include +#include #include #include "Common/Cpp/Logging/AbstractLogger.h" #include "Common/Cpp/Time.h" @@ -114,8 +115,13 @@ class InterruptLogGuard : public Pokemon::StepGuard{ {} virtual void on_failure(const Pokemon::StoryStep& step, const OperationFailedException& error) override; + // The frame `error` carries, saved as -.png: also for + // a failure outside a step (a checkpoint's save: 19.04d's left no frame, + // console B, 2026-11-16 04:15). + void save_frame(std::string_view name, const OperationFailedException& error); virtual void on_interrupt(const Pokemon::StoryStep& step, const Pokemon::InterruptCheck& check) override; virtual void on_screen(const Pokemon::StoryStep& step, const Pokemon::ScreenSettle& screen) override; + virtual void on_check_skipped(const Pokemon::StoryStep& step, const std::string& line) override; private: Logger& m_logger; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp index 37261b04bd..f70506aab3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp @@ -12,6 +12,7 @@ #include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryHealingSteps.h" +#include "PokemonFRLG_AutoStoryLeagueSteps.h" #include "PokemonFRLG_AutoStoryHideout.h" #include "PokemonFRLG_AutoStoryItemUse.h" #include "PokemonFRLG_AutoStoryLegs.h" @@ -115,8 +116,8 @@ Pokemon::StoryActionSpec fossil_action_spec(){ Pokemon::StoryActionSpec level_action_spec(){ return {.kind = StoryStepKind::GAME, .name = LEVEL_ACTION, .args = { required_arg("slot", StoryArgType::INTEGER, "the party slot, from 1"), - required_arg("min", StoryArgType::INTEGER, "the level it must have"), - }}; + required_arg("min", StoryArgType::INTEGER, "the level it should have; up to Pokemon::LEVEL_CHECK_TOLERANCE below still passes"), + }, .check = Pokemon::StoryCheckKind::PARTY_STATS}; } Pokemon::StoryActionSpec mart_action_spec(){ @@ -212,7 +213,7 @@ std::vector policy_arg_specs(){ }); args.push_back(Pokemon::StoryArgSpec{ .key = "foe_threats", .type = Pokemon::StoryArgType::INTEGER_ROWS, .required = false, .fallback = std::vector>(), - .why = "one row per foe, [speed, likely, mean, max, normal_max, lowers_accuracy, explodes]: what it does to the lead, from the doc's stats", + .why = "one row per foe, [speed, likely, mean, max, normal_max, lowers_accuracy, explodes], and phazes (Roar, Whirlwind) as an eighth column where it has one: what it does to the lead, from the doc's stats", }); return args; } @@ -228,6 +229,10 @@ std::vector battle_arg_specs(){ .key = "foes", .type = Pokemon::StoryArgType::WORDS, .required = false, .fallback = std::vector(), .why = "the trainer's party in order; attacks are chosen against the one out", }); + args.push_back(Pokemon::StoryArgSpec{ + .key = "foe_stats", .type = Pokemon::StoryArgType::INTEGER_ROWS, .required = false, .fallback = std::vector>(), + .why = "one row per foe, [defense, sp_defense] or [defense, sp_defense, hp], from the trainer's party data: the damage each attack would do, and with hp whether the best one KOs (no X item then)", + }); args.push_back(Pokemon::StoryArgSpec{ .key = "use_items", .type = Pokemon::StoryArgType::ITEMS, .required = false, .fallback = std::vector(), .why = "items used on the lead from the first turn, in order, before any attack (X Specials)", @@ -278,7 +283,7 @@ std::span story_action_specs(){ }){ specs.push_back(std::move(spec)); } - for (const std::vector& more : {field_action_specs(), healing_action_specs()}){ + for (const std::vector& more : {field_action_specs(), healing_action_specs(), league_action_specs()}){ specs.insert(specs.end(), more.begin(), more.end()); } return specs; @@ -292,6 +297,7 @@ Pokemon::StoryActionTable make_story_action_table(const StoryActionBinding& bind Pokemon::StoryAction action = bind(row.id); if (const Pokemon::StoryActionSpec* spec = Pokemon::find_story_action(story_action_specs(), row.kind, row.variant)){ action.args = spec->args; + action.check = spec->check; } table.add(row.kind, row.variant, std::move(action)); } @@ -306,6 +312,7 @@ Pokemon::StoryActionTable make_story_action_table(const StoryActionBinding& bind } Pokemon::StoryAction action = bind(StoryActionId::GAME); action.args = spec.args; + action.check = spec.check; table.add(StoryStepKind::GAME, spec.name, std::move(action)); } return table; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp index 011846af59..d87b6e002c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp @@ -23,8 +23,19 @@ #include "PokemonFRLG_AutoStoryFlyLanding.h" #include "PokemonFRLG_AutoStoryHideout.h" #include "PokemonFRLG_AutoStoryRooms.h" +#include "PokemonFRLG_AutoStoryBattleBag.h" +#include "PokemonFRLG_AutoStoryBattleTrack.h" +#include "PokemonFRLG_AutoStoryLeagueParity_Tests.h" +#include "PokemonFRLG_AutoStoryPlannedBattle.h" +#include "PokemonFRLG_AutoStoryPlannedPolicy.h" #include "PokemonFRLG_AutoStoryItemUse.h" +#include "PokemonFRLG_AutoStoryItemsPocketChange.h" +#include "PokemonFRLG_AutoStoryMartPlan.h" +#include "PokemonFRLG_AutoStoryHealingSteps.h" +#include "PokemonFRLG_AutoStoryPoses.h" +#include "PokemonFRLG_AutoStorySlopeRun.h" #include "PokemonFRLG_AutoStoryTable.h" +#include "PokemonFRLG_AutoStoryTeachPlan.h" #include "PokemonFRLG_AutoStoryTrashCans.h" namespace PokemonAutomation{ @@ -202,6 +213,18 @@ UnitTestResult test_every_step_bound(){ } +// Every action a step can name says what it does to the Items pocket: a +// new one without a row would leave a battle on rows it changed. +UnitTestResult test_every_action_declares_pocket_change(){ + for (const Pokemon::StoryActionSpec& spec : story_action_specs()){ + if (!items_pocket_change(spec.kind, spec.name)){ + return std::format("{} \"{}\" has no Items pocket change.", Pokemon::story_step_kind_name(spec.kind), spec.name); + } + } + return true; +} + + struct StepTableInput{ std::string name; UnitTestResult (*body)(); @@ -247,6 +270,56 @@ const StepTableTestCase STEP_TABLE_CASES[] = { .input = {.name = "every checkpoint's steps have an action", .body = test_every_step_bound}, .expectation = {.description = "lint_story_checkpoint finds no unbound step"}, }, + { + .input = {.name = "every action declares its Items pocket change", .body = test_every_action_declares_pocket_change}, + .expectation = {.description = "items_pocket_change() has a row for each action spec"}, + }, +}; + +struct PocketChangeInput{ + StoryStepKind kind; + std::string action; +}; +struct PocketChangeExpectation{ + ItemsPocketChange change; +}; +struct PocketChangeCase{ + std::string name; + PocketChangeInput input; + PocketChangeExpectation expectation; +}; + +class Test_ItemsPocketChange : public UnitTest{ +public: + explicit Test_ItemsPocketChange(PocketChangeCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStoryStepTable - Items pocket change: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const std::optional change = items_pocket_change(m_case.input.kind, m_case.input.action); + if (change != m_case.expectation.change){ + return std::format("Got {}; expected {}.", change ? static_cast(*change) : -1, static_cast(m_case.expectation.change)); + } + return true; + } + +private: + PocketChangeCase m_case; +}; + +// The places the story changes the Items pocket, each as it is kept. +const PocketChangeCase POCKET_CHANGE_CASES[] = { + {.name = "a Mart buys and sells", .input = {StoryStepKind::GAME, MART_ACTION}, .expectation = {ItemsPocketChange::STALE}}, + {.name = "Viridian's shop", .input = {StoryStepKind::SHOP, ""}, .expectation = {ItemsPocketChange::STALE}}, + {.name = "a use_item step", .input = {StoryStepKind::GAME, USE_ITEM_VARIANT}, .expectation = {ItemsPocketChange::STALE}}, + {.name = "a talk: a gift or an item ball", .input = {StoryStepKind::TALK, ""}, .expectation = {ItemsPocketChange::STALE}}, + {.name = "a wanderer's talk", .input = {StoryStepKind::TALK, TALK_WANDERER_VARIANT}, .expectation = {ItemsPocketChange::STALE}}, + {.name = "a battle counts its items", .input = {StoryStepKind::BATTLE, "fight"}, .expectation = {ItemsPocketChange::COUNTED}}, + {.name = "a ready step counts its items", .input = {StoryStepKind::READY, ""}, .expectation = {ItemsPocketChange::COUNTED}}, + {.name = "heal_to_full counts its items", .input = {StoryStepKind::GAME, HEAL_TO_FULL_ACTION}, .expectation = {ItemsPocketChange::COUNTED}}, + {.name = "count_items reads the pocket", .input = {StoryStepKind::GAME, COUNT_ITEMS_VARIANT}, .expectation = {ItemsPocketChange::COUNTED}}, + {.name = "a TM taught: the TM Case", .input = {StoryStepKind::GAME, TEACH_ACTION}, .expectation = {ItemsPocketChange::NONE}}, + {.name = "a walk", .input = {StoryStepKind::ROUTE, RUN_VARIANT}, .expectation = {ItemsPocketChange::NONE}}, }; } // namespace @@ -256,6 +329,9 @@ void add_tests_AutoStoryStepTable(UnitTestDatabase& database){ for (const auto& scenario : STEP_TABLE_CASES){ database.add(scenario); } + for (const PocketChangeCase& test_case : POCKET_CHANGE_CASES){ + database.add(test_case); + } add_tests_AutoStoryStepInterrupts(database); // The GAME variants with logic of their own. add_tests_AutoStoryHideout(database); @@ -263,6 +339,11 @@ void add_tests_AutoStoryStepTable(UnitTestDatabase& database){ add_tests_AutoStoryFlyLanding(database); add_tests_AutoStoryRooms(database); add_tests_AutoStoryItemUse(database); + add_tests_AutoStoryBattleBag(database); + add_tests_AutoStoryPlannedPolicy(database); + add_tests_AutoStoryPlannedBattle(database); + add_tests_AutoStoryLeagueParity(database); + add_tests_AutoStoryBattleTrack(database); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.cpp new file mode 100644 index 0000000000..2a22062d3f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.cpp @@ -0,0 +1,48 @@ +/* AutoStory Supplies + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "PokemonFRLG_AutoStorySupplies.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +std::string_view status_name(StatusCondition status){ + switch (status){ + case StatusCondition::NONE: + return "no status"; + case StatusCondition::POISON: + return "PSN"; + case StatusCondition::PARALYSIS: + return "PAR"; + case StatusCondition::SLEEP: + return "SLP"; + case StatusCondition::OTHER: + return "a status"; + } + return "?"; +} + +std::string_view cure_of(StatusCondition status){ + switch (status){ + case StatusCondition::SLEEP: + return "awakening"; + case StatusCondition::POISON: + return "antidote"; + case StatusCondition::PARALYSIS: + return "parlyz-heal"; + case StatusCondition::NONE: + case StatusCondition::OTHER: + return ""; + } + return ""; +} + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.h index d57d5f6e3b..2d272bf5bb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.h @@ -16,15 +16,11 @@ #include #include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" -#include "CommonFramework/ImageTypes/ImageViewRGB32.h" -#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" -#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" #include "Pokemon/AutoStory/Types/Pokemon_StoryActionArg.h" -#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_ItemListReader.h" -#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryBattleData.h" #include "PokemonFRLG_AutoStoryBattlePolicyData.h" +#include "PokemonFRLG_AutoStoryLeaguePlan.h" #include "PokemonFRLG_AutoStoryParty.h" #include "PokemonFRLG_AutoStoryStartMenu.h" @@ -44,6 +40,10 @@ enum class StatusCondition{ }; // String representation of a status condition. std::string_view status_name(StatusCondition status); +// The cure for a status, by PokemonSimulation's pokeguy-conditions.md CURES +// table ("parlyz-heal" for PARALYSIS); "" for none. The battle policy and +// the story's own battles both cure by it. +std::string_view cure_of(StatusCondition status); // The healing items in the Items pocket, in the order they were bought: // Potions, Antidotes, then Parlyz Heals; Awakenings from Cerulean's Mart. @@ -64,6 +64,14 @@ struct Supplies{ // The counts the bag read for the items the story doesn't count (an // X Special), by slug; an item missing here has an unknown count. std::map other_counts = {}; + // The counts above come from a read of the Items pocket in this run by + // a step that acts on them (set_from_bag()), kept since by the story's + // own counting. False for the counts a checkpoint's row guesses or a + // reloaded save carries, and after any step that changes the pocket + // uncounted (items_pocket_change()): a battle or a recovery reads the + // pocket itself before it uses them. A check's read + // (read_bag_supplies()) never sets them. + bool counts_read = false; // The starter's status at the last battle screen that showed it, and // not cured since. StatusCondition status = StatusCondition::NONE; @@ -102,12 +110,21 @@ struct Supplies{ // How that battle is fought by PokeGuy's policy, if its step names one // (BattlePolicyKind::NONE otherwise: the story's own recovery). BattlePolicy policy = {}; + // The League's plan and what its fights have left, from the bag read + // at its start (league_start); none outside the League. + std::optional league = std::nullopt; + // The items the battle going on may spend (its League budget plus + // what the fights before left); none: no cap. + std::optional budget = std::nullopt; // How carefully that battle is fought (default_battle_risk()). BattleRisk risk = BattleRisk::LOW; // The species of the trainer's Pokemon out, as read at the last battle // menu (read_trainer_foe()), "" if not read: the lead's attacks are // chosen against it. std::string foe_out = {}; + // The species of the player's Pokemon out at the last battle menu of a + // trainer's battle (read_own_battler()), "" if not read. + std::string own_out = {}; // The wild Pokemon of the battle going on, as read at its first battle // menu (read_wild_foes()): the lead's attacks are chosen against it. // Empty when it wasn't read; trainer battles never use it. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index bad23e952d..14e9c0e63c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -249,7 +249,7 @@ constexpr std::string_view STORY_ORDER[] = { "14.03", "14.04", "14.04b", "15.01", "16.01", "16.02", "16.03", "16.03b", "16.04", "16.05", "16.05b", "16.06", "16.06b", "18.01", "18.02", "18.02b", "18.03", "17.02", "17.03", "17.04", "17.04b", "19.01a", "19.01", "19.02", "19.03", "19.04", "19.04b", "19.04c", "19.04d", "19.05", - "20.01a", "20.01", "20.02", "20.03", "20.04", "20.05", + "20.01a", "20.01", }; // Where checkpoint `id` plays in STORY_ORDER; past its end if it is not @@ -258,6 +258,21 @@ size_t story_position(std::string_view id){ return (size_t)(std::find(std::begin(STORY_ORDER), std::end(STORY_ORDER), id) - std::begin(STORY_ORDER)); } +// StoryData's checkpoint files: every one but the League plan +// (league_plan_data()). +const std::vector>& checkpoint_files(){ + static const std::vector> FILES = []{ + std::vector> files; + for (const auto& file : autostory_checkpoint_json()){ + if (file.first.ends_with(".plan")){ + files.push_back(file); + } + } + return files; + }(); + return FILES; +} + } // namespace StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source){ @@ -265,7 +280,7 @@ StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_v } Pokemon::StoryData load_frlg_story(std::span dev_files){ - Pokemon::StoryData story = Pokemon::load_story_data(autostory_checkpoint_json(), dev_files, { + Pokemon::StoryData story = Pokemon::load_story_data(checkpoint_files(), dev_files, { .read = [](std::string_view text, std::string_view source){ return read_story_file(parse_json(std::string(text)), source); }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable_Tests.cpp index b7c2659ce5..10f725a5cc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable_Tests.cpp @@ -38,7 +38,7 @@ const std::vector PINNED_ORDER = { "14.03", "14.04", "14.04b", "15.01", "16.01", "16.02", "16.03", "16.03b", "16.04", "16.05", "16.05b", "16.06", "16.06b", "18.01", "18.02", "18.02b", "18.03", "17.02", "17.03", "17.04", "17.04b", "19.01a", "19.01", "19.02", "19.03", "19.04", "19.04b", "19.04c", "19.04d", "19.05", - "20.01a", "20.01", "20.02", "20.03", "20.04", "20.05", + "20.01a", "20.01", }; // The marks of every authored row that has one, as before the shared diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTower_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTower_Tests.cpp index 9a25fae360..90e0efb4b0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTower_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTower_Tests.cpp @@ -24,6 +24,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_HideoutLiftRoom.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldObjects.h" @@ -260,8 +261,9 @@ UnitTestResult test_tower_7f_and_fuji(Logger&){ // Battle checkpoint `id`'s precondition: a LEVEL step on the lead before // its battle `battle`, at least `pokeguy`, pokeguy's level there (whose -// sims stand for the fight at that level or above). A lead at that level -// passes it; one a level below stops the checkpoint before the fight. +// sims stand for the fight at that level or above). A lead up to +// LEVEL_CHECK_TOLERANCE below it passes; one more below stops the +// checkpoint before the fight. UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id, std::string_view battle, unsigned pokeguy){ std::optional check; for (const StoryStep& step : checkpoint(id).steps){ @@ -275,7 +277,8 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id if (!check || check->slot != 0 || check->level != pokeguy){ return std::format("{}: expected a LEVEL step on the lead, at least Lv{}, before {}.", id, pokeguy, battle); } - for (const unsigned level : {pokeguy, pokeguy - 1}){ + const unsigned lowest_passing = pokeguy - Pokemon::LEVEL_CHECK_TOLERANCE; + for (const unsigned level : {pokeguy, lowest_passing, lowest_passing - 1}){ const MemberReader lead = [level](size_t slot) -> std::optional{ if (slot != 0){ return std::nullopt; @@ -283,9 +286,9 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id return MemberInfo{.species = "blastoise", .level = level}; }; const LevelResult result = run_level_check(logger, lead, *check); - const LevelEnd expected = level >= pokeguy ? LevelEnd::REACHED : LevelEnd::BELOW; + const LevelEnd expected = level >= lowest_passing ? LevelEnd::REACHED : LevelEnd::BELOW; if (result.end != expected || result.level != level){ - return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= pokeguy ? "fails" : "passes", pokeguy); + return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= lowest_passing ? "fails" : "passes", pokeguy); } } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp index df0be63067..d57debbbed 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -271,28 +272,21 @@ UnitTestResult test_strength_teach_and_cave_mouth(){ return true; } -// A Victory Road floor's row on the sim from its start_gates, its boulder -// pushes included: it starts where `previous` ends, turns on the switch -// `switch_key`, meets no trainer, breaks no rule and ends on `end`. -UnitTestResult cave_floor(std::string_view previous, std::string_view id, std::string_view switch_key, const MapPosition& end){ - const StoryCheckpoint& before = checkpoint(previous); - const StoryCheckpoint& row = checkpoint(id); - const StoryPose at_start = *story_pose(Pokemon::pose_of(*row.start)); - const std::optional before_pose = Pokemon::checkpoint_end_pose(before); - const std::optional before_end = before_pose ? story_pose(Pokemon::pose_of(*before_pose)) : std::nullopt; - if (!before_end || before_end->map != at_start.map || !(before_end->tile == at_start.tile)){ - return std::format("{} doesn't start where {} ends.", id, previous); - } - StoryPose at = at_start; - SimScript script; - script.gates = row.start_gates.value_or(Pokemon::GateState()); - OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, at.facing.value_or(Direction::NORTH), script); +// `row`'s walks and boulder pushes on `sim`, which starts at its start: the first +// failure, a rule broken or a trainer met, or empty. The run flags carry +// from step to step from the row's start_flags, as the program's do: the +// walks after a push plan round the boulder where it now stands +// (moved_boulders()). +std::string floor_steps_on_sim(const StoryCheckpoint& row, OverworldSim& sim){ + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); + const std::string& id = row.id; + std::set flags(row.start_flags.begin(), row.start_flags.end()); for (const StoryStep& step : row.steps){ const bool push = step.kind == StoryStepKind::GAME && step.action == PUSH_BOULDER_VARIANT; if (!push && step.kind != StoryStepKind::ROUTE && step.kind != StoryStepKind::LEGS && step.kind != StoryStepKind::STEP){ continue; } - if (const std::string failure = row_step_on_sim(sim, at, step, row.id); !failure.empty()){ + if (const std::string failure = row_step_carrying_flags(sim, at, step, row.id, flags); !failure.empty()){ return std::format("{} {}: ended on {}; {}", id, step.name, to_string(sim.state().position), failure); } if (!sim.state().violations.empty()){ @@ -302,6 +296,42 @@ UnitTestResult cave_floor(std::string_view previous, std::string_view id, std::s return std::format("{} {}: met a trainer: {}", id, step.name, sim.state().trainers_beaten.front()); } } + return ""; +} + +// A row's sim from its start pose and start_gates, Strength on as given. +OverworldSim floor_sim(const StoryCheckpoint& row, bool strength_on){ + const StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); + SimScript script; + script.gates = row.start_gates.value_or(Pokemon::GateState()); + script.strength_on = strength_on; + return OverworldSim(story_maps(), MapPosition{at.map, at.tile}, at.facing.value_or(Direction::NORTH), script); +} + +// A Victory Road floor's row on the sim from its start_gates, its boulder +// pushes included: it starts where `previous` ends, with Strength on if +// `previous` (on the sim, Strength off at its start) left it on, as the +// save between them keeps it (SimScript::strength_on); it turns on the +// switch `switch_key`, meets no trainer, breaks no rule and ends on `end`. +// 19.04c used Strength on 3F and saved there; 19.04d's hold east to the +// boulder (33, 18) pushed it into the hole (console B, 2026-11-16). +UnitTestResult cave_floor(std::string_view previous, std::string_view id, std::string_view switch_key, const MapPosition& end){ + const StoryCheckpoint& before = checkpoint(previous); + const StoryCheckpoint& row = checkpoint(id); + const StoryPose at_start = *story_pose(Pokemon::pose_of(*row.start)); + const std::optional before_pose = Pokemon::checkpoint_end_pose(before); + const std::optional before_end = before_pose ? story_pose(Pokemon::pose_of(*before_pose)) : std::nullopt; + if (!before_end || before_end->map != at_start.map || !(before_end->tile == at_start.tile)){ + return std::format("{} doesn't start where {} ends.", id, previous); + } + OverworldSim before_sim = floor_sim(before, /*strength_on=*/false); + if (const std::string failure = floor_steps_on_sim(before, before_sim); !failure.empty()){ + return failure; + } + OverworldSim sim = floor_sim(row, before_sim.state().strength_on); + if (const std::string failure = floor_steps_on_sim(row, sim); !failure.empty()){ + return failure; + } if (!sim.state().gates.switch_on(std::string(switch_key))){ return std::format("{}: the switch {} is not on.", id, switch_key); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp index 0c02e86a0d..66dcaad9e0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp @@ -7,6 +7,7 @@ #include #include #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryBattle.h" #include "PokemonFRLG_AutoStoryViridianMart.h" @@ -56,21 +57,25 @@ Pokemon::Outcome viridian_shop(StoryEnv& env, const StoryStep& step){ for (const Pokemon::StoryItem& item : Pokemon::story_arg>(step.args, "items")){ env.supplies.*viridian_mart_item(item.item)->count += (int)item.quantity; } - if (!checks_screen(env.checks)){ + if (!Pokemon::runs_check(env.checks, Pokemon::StoryCheckKind::BAG_CONTENTS)){ return Pokemon::outcome_ok(); } - // The counts from the bag, not from the orders: a wrong row once bought - // Parlyz Heals for Antidotes unnoticed (console B, 2026-11-01). + // A check of what was bought: a wrong row once bought Parlyz Heals for + // Antidotes unnoticed (console B, 2026-11-01). It changes no count: + // the next battle that doesn't know them reads the pocket itself. const std::vector rows = read_items_pocket(env.console, env.context, env.language); if (rows.empty()){ - env.console.log("Story: couldn't read the Items pocket; keeping the counts ordered.", COLOR_ORANGE); + env.console.log("Story: couldn't read the Items pocket to check the order.", COLOR_ORANGE); return Pokemon::outcome_ok(); } - for (const std::string& item : set_from_bag(env.supplies, rows)){ - env.console.log(std::format( - "Story: couldn't read how many {} the bag holds; counting {}.", - item, item_count(env.supplies, item) - ), COLOR_ORANGE); + Supplies read = env.supplies; + set_from_bag(read, rows); + for (const Pokemon::StoryItem& item : Pokemon::story_arg>(step.args, "items")){ + const int counted = env.supplies.*viridian_mart_item(item.item)->count; + const int held = read.*viridian_mart_item(item.item)->count; + if (held != counted){ + env.console.log(std::format("Story: the bag holds {} {}, the story counts {}.", held, item.item, counted), COLOR_ORANGE); + } } return Pokemon::outcome_ok(); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index 88eb14b621..f7ecd9ce84 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -30,6 +30,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldTileRules.h" #include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryStartMenuOpening.h" #include "PokemonFRLG_AutoStoryCapture.h" #include "PokemonFRLG_AutoStoryGenderMenu.h" #include "PokemonFRLG_AutoStoryBag.h" @@ -423,8 +424,8 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po // start: starts_after_unauthored_rows()), and adds the plans to `golden`. UnitTestResult chain_story_routes(std::vector& golden){ const std::vector& checkpoints = story_checkpoints(); - if (checkpoints.size() != 97 || checkpoints[0].start){ - return "Expected 97 checkpoints, the first from a new game."; + if (checkpoints.size() != 93 || checkpoints[0].start){ + return "Expected 93 checkpoints, the first from a new game."; } StoryPose pose; walk_state() = WalkGates{}; @@ -1413,6 +1414,70 @@ UnitTestResult test_save_dialog(){ return true; } +std::string_view start_open_action_name(StartOpenAction action){ + switch (action){ + case StartOpenAction::WAIT: + return "WAIT"; + case StartOpenAction::CLOSE_BOX: + return "CLOSE_BOX"; + case StartOpenAction::PRESS_START: + return "PRESS_START"; + case StartOpenAction::OPENED: + return "OPENED"; + case StartOpenAction::FAIL_BATTLE: + return "FAIL_BATTLE"; + case StartOpenAction::FAIL_NO_MENU: + return "FAIL_NO_MENU"; + } + return "?"; +} + +// Opening the START menu for a save, look by look. 19.04d's save came +// right after exit_route23's warp: START, pressed blind 0.5 s after the +// fade, was lost in the fade-in; on attempt 1 the screen was no overworld +// at all and six blind START and B presses failed the save (console B, +// 2026-11-16 04:14). +UnitTestResult test_start_menu_opening(){ + using S = StartOpenScreen; + using A = StartOpenAction; + struct Case{ + std::string name; + struct Input{ + std::vector screens; + } input; + struct Expectation{ + std::vector actions; + } expectation; + }; + const std::vector CASES = { + {.name = "right after a warp: the fade-in and the map's popup, then the quiet overworld", + .input = {.screens = {S::SETTLING, S::SETTLING, S::QUIET_OVERWORLD, S::START_MENU}}, + .expectation = {.actions = {A::WAIT, A::WAIT, A::PRESS_START, A::OPENED}}}, + {.name = "a box left open is closed first", + .input = {.screens = {S::BOX, S::SETTLING, S::QUIET_OVERWORLD, S::START_MENU}}, + .expectation = {.actions = {A::CLOSE_BOX, A::WAIT, A::PRESS_START, A::OPENED}}}, + {.name = "a battle: no START into it", + .input = {.screens = {S::SETTLING, S::BATTLE}}, + .expectation = {.actions = {A::WAIT, A::FAIL_BATTLE}}}, + {.name = "a lost START is pressed again", + .input = {.screens = {S::QUIET_OVERWORLD, S::QUIET_OVERWORLD, S::START_MENU}}, + .expectation = {.actions = {A::PRESS_START, A::PRESS_START, A::OPENED}}}, + {.name = "a quiet overworld that never opens the menu", + .input = {.screens = {S::QUIET_OVERWORLD, S::QUIET_OVERWORLD, S::QUIET_OVERWORLD, S::QUIET_OVERWORLD}}, + .expectation = {.actions = {A::PRESS_START, A::PRESS_START, A::PRESS_START, A::FAIL_NO_MENU}}}, + }; + for (const Case& c : CASES){ + StartMenuOpening opening; + for (size_t i = 0; i < c.input.screens.size(); i++){ + const StartOpenAction action = opening.next(c.input.screens[i]); + if (action != c.expectation.actions[i]){ + return std::format("{}, look {}: expected {}, got {}.", c.name, i + 1, start_open_action_name(c.expectation.actions[i]), start_open_action_name(action)); + } + } + } + return true; +} + UnitTestResult test_lint(){ // FRLG's own action args (a battle's trainer and foes), with no console. const Pokemon::StoryActionTable table = make_story_action_table([](StoryActionId){ @@ -1650,6 +1715,10 @@ const AutoStoryTestCase AUTO_STORY_CASES[] = { .input = {.name = "save dialogs: every YES/NO is YES, a cancel fails", .body = test_save_dialog}, .expectation = {.description = "verifies save confirmation prompt interactions"}, }, + { + .input = {.name = "the START menu opens for a save only on a quiet overworld", .body = test_start_menu_opening}, + .expectation = {.description = "waits out a warp's fade-in, closes a box, refuses a battle, presses START at most three times"}, + }, { .input = {.name = "every checkpoint lints clean", .body = test_lint}, .expectation = {.description = "validates semantic lint rules across story step sequence"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp index 3125211e69..ffeb3f04d8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp @@ -373,7 +373,7 @@ Pokemon::Outcome ReplayExecutor::replay_route(const StoryStep& step, Pokemon::Ru calls.walk = [this](const RouteStep& leg, std::optional){ return walk_leg(leg); }; calls.log = [this](const std::string& line){ m_route_logs.push_back(line); }; calls.fail = [](const std::string&){ throw ReplayStopped{}; }; - calls.hold_to_warp = [](const RouteStep&){ throw ReplayStopped{}; }; + calls.hold_to_warp = [](const RouteStep&) -> std::optional{ throw ReplayStopped{}; }; try{ run_route(route, m_pose.facing, nullptr, calls); }catch (const ReplayStopped&){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json index 40ad9b42bb..cffbcadc91 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json @@ -69,20 +69,27 @@ "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[17, 19]]}}, "why": "down x 17, east of Caroline's line, to the south room's bottom row" }, + { + "id": "below_hole", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[34, 19]]}}, + "why": "east along row 19 to its wall, below the hole (34, 18). Strength is on from 19.04c (Continue keeps FLAG_SYS_USE_STRENGTH; only a warp clears it), so a walk east along row 18 into the boulder (33, 18) pushes it into the hole: the hold 'to wall' did, and push_into_hole found no boulder (console B, 2026-11-16)" + }, { "id": "behind_hole_boulder", "kind": "route", "action": "run", "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[32, 18]]}}, - "why": "east along row 19 to below, then west of, the boulder (33, 18) beside the hole" + "why": "west of the boulder (33, 18), reached from below: no step toward the boulder until the push" }, { "id": "push_into_hole", "kind": "game_action", "action": "push_boulder", - "args": {"direction": "east", "tiles": 1, "activate": true}, + "args": {"direction": "east", "tiles": 1}, "declared_after": {"map": "VictoryRoad_3F", "tiles": [[33, 18]], "facing": "east"}, - "why": "Strength on (the map was left for the save), the boulder into the hole (34, 18); it falls to 2F (33, 19), where the game now shows it (FLAG_HIDE_VICTORY_ROAD_2F_BOULDER cleared)" + "why": "Strength still on from 19.04c's save (A would show only a message, no YES/NO), the boulder into the hole (34, 18); it falls to 2F (33, 19), where the game now shows it (FLAG_HIDE_VICTORY_ROAD_2F_BOULDER cleared)" }, { "id": "drop_to_2f", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01.plan.json index 9f07cc2e08..25aa0b7da2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "20.01", - "title": "The Elite Four's first room: Lorelei", + "title": "The Elite Four and the Champion, then the Hall of Fame", "start": { "map": "IndigoPlateau_PokemonCenter_1F", "tiles": [ @@ -25,6 +25,13 @@ }, "why": "the precondition for Lorelei: the lead at least Lv51, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md lorelei; the Route 22 rival takes it from 49 to 51)" }, + { + "id": "league_start", + "kind": "game_action", + "action": "league_start", + "args": {}, + "why": "the Items pocket read once for the whole League: stops before the door if the bag holds less than the League's minimum (the bag of 2026-11-16, LEAGUE_MINIMUM), else plans each fight's item budget from it (plan_league()) and logs the plan" + }, { "id": "below_league_door", "kind": "route", @@ -101,7 +108,7 @@ "jynx", "lapras" ], - "policy": "goal-based-setup", + "policy": "budgeted-setup", "setup_spa": 4, "setup_accuracy": 0, "setup_outspeed": true, @@ -109,53 +116,461 @@ "foe_threats": [ [ 93, - 21, - 13, + 17, + 10, + 37, + 30, + 0, + 0 + ], + [ + 91, + 0, + 0, + 0, + 12, + 0, + 0, + 0, + 1 + ], + [ 45, + 21, + 7, + 49, + 24, + 0, + 0 + ], + [ + 110, 22, + 10, + 48, + 24, 0, 0 ], [ - 91, + 94, + 28, + 12, + 62, + 31, + 0, + 0 + ] + ], + "foe_stats": [ + [ + 103, + 119, + 171 + ], + [ + 203, + 72, + 127 + ], + [ + 135, + 103, + 176 + ], + [ + 59, + 135, + 150 + ], + [ + 107, + 123, + 220 + ] + ] + }, + "declared_after": { + "map": "PokemonLeague_LoreleisRoom", + "tiles": [ + [ + 6, + 6 + ] + ], + "facing": "north" + }, + "why": "Lorelei (TRAINER_ELITE_FOUR_LORELEI): Dewgong Lv52, Cloyster Lv51, Slowbro Lv52, Jynx Lv54, Lapras Lv54, two Full Restores; fought by budgeted C2 (budgeted-setup, the League plan's per-fight item budget; before that goal-based-setup: Sp. Atk +4 by X Specials, X Speed until faster, Guard Spec first against an accuracy drop; the doc's lorelei row, 94.3% at 159/159); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against console B's Lv54 Blastoise (171 HP, Def 135, Sp. Def 150) at full HP: the 80th percentile of the foe's move choice, its mean, its worst case and its worst normal hit. Lapras's worst case is 62. Cloyster's only hit, Dive, hides a turn first (its row's ninth column): no KO risk until it is underwater. Dewgong's worst normal hit is 30, not the generator's 18: console B, 2026-11-16, took 30 of 162 in one turn. foe_stats are each foe's Defense, Sp. Def and HP from the doc's table, for the damage each attack would do and whether the best one KOs (no X item then). Then her door north (6, 2) opens" + }, + { + "id": "lead_lv52_for_bruno", + "kind": "game_action", + "action": "level", + "args": { + "slot": 1, + "min": 52 + }, + "why": "the precondition for Bruno: the lead at least Lv52, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md bruno; Lorelei's fight takes it a level up)" + }, + { + "id": "items_before_bruno", + "kind": "game_action", + "action": "league_between_fights", + "args": { + "next": "TRAINER_ELITE_FOUR_BRUNO", + "max_hp": 165 + }, + "why": "the League plan's rules between fights (PokemonFRLG_AutoStoryLeaguePlan.h, between_fight_item()): a status cured, Super Potions up to Bruno's entry HP, a Full Restore only when they run out, an Elixir or Max Elixir when Surf or Blizzard is under its PP floor. Replaces the per-checkpoint heal_to_full, whose HP was unknown after a load (Bruno entered at 71%, console B, 2026-11-16)" + }, + { + "id": "below_loreleis_door", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_LoreleisRoom", + "tiles": [ + [ + 6, + 3 + ] + ], + "facing": "north" + } + }, + "why": "from in front of Lorelei (6, 5) around her to below her door (6, 2), open since her defeat" + }, + { + "id": "loreleis_door", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "into the door (6, 2), the warp into Bruno's room at its south entrance (6, 12)" + }, + { + "id": "enter_brunos_room", + "kind": "scene", + "declared_after": { + "map": "PokemonLeague_BrunosRoom", + "tiles": [ + [ + 6, + 7 + ] + ], + "facing": "north" + }, + "why": "the room's OnFrame script (PokemonLeague_EventScript_EnterRoom) walks the player five tiles north from (6, 12) to (6, 7) and closes the entrance behind; no text" + }, + { + "id": "before_bruno", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_BrunosRoom", + "tiles": [ + [ + 6, + 6 + ] + ], + "facing": "north" + } + }, + "why": "to (6, 6) facing Bruno (6, 5), planned from where the room's walk left the player: a tile north, or a step round if the walk ended a tile off" + }, + { + "id": "challenge_bruno", + "kind": "talk", + "why": "Bruno (6, 5): the intro, then the battle (trainerbattle_no_intro)" + }, + { + "id": "bruno", + "kind": "battle", + "args": { + "trainer": "TRAINER_ELITE_FOUR_BRUNO", + "foes": [ + "onix", + "hitmonchan", + "hitmonlee", + "onix", + "machamp" + ], + "policy": "budgeted-setup", + "setup_spa": 2, + "setup_accuracy": 0, + "setup_outspeed": true, + "setup_guard_accuracy": true, + "setup_target_torrent": true, + "foe_threats": [ + [ + 81, + 26, + 16, + 63, + 31, + 0, 0, + 1 + ], + [ + 101, + 43, + 24, + 108, + 54, 0, + 0 + ], + [ + 113, + 54, + 44, + 114, + 57, 0, - 15, + 0 + ], + [ + 96, + 33, + 33, + 69, + 34, 0, 0 ], [ - 45, - 27, - 9, + 83, + 0, + 4, + 150, + 75, + 0, + 0 + ] + ], + "foe_stats": [ + [ + 183, + 72, + 112 + ], + [ + 104, + 137, + 131 + ], + [ + 77, + 137, + 131 + ], + [ + 194, + 75, + 118 + ], + [ + 111, + 117, + 183 + ] + ] + }, + "declared_after": { + "map": "PokemonLeague_BrunosRoom", + "tiles": [ + [ + 6, + 6 + ] + ], + "facing": "north" + }, + "why": "Bruno (TRAINER_ELITE_FOUR_BRUNO): Onix Lv51, Hitmonchan Lv53, Hitmonlee Lv53, Onix Lv54, Machamp Lv56, two Full Restores; fought by budgeted C2 (budgeted-setup, the League plan's per-fight item budget; before that goal-based-setup: Sp. Atk +2 by X Specials, X Speed until faster, Guard Spec first against an accuracy drop; the doc's bruno row, 95.9% at 130/162. The doc's target_torrent (stalling to Torrent in the opening) is the C++ policy's extra X Specials against the first Onix, up to +4 while Torrent is off; its weaker-move stall needs the foe's HP and is not modelled (PokemonFRLG_AutoStoryBattlePolicy.h)); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against console B's Lv54 Blastoise (171 HP, Def 135, Sp. Def 150) at full HP: Machamp's worst case (crit Cross Chop) is 150, Hitmonlee's 114. The first Onix has Roar (marked as phazing in its row): console B, 2026-11-16, its Roar sent Blastoise out after four X Specials. foe_stats are each foe's Defense, Sp. Def and HP from the doc's table: Surf KOs both Onix at +0, so no X item is spent on them and setup waits for Hitmonchan. Then the door north (6, 2) opens" + }, + { + "id": "lead_lv53_for_agatha", + "kind": "game_action", + "action": "level", + "args": { + "slot": 1, + "min": 53 + }, + "why": "the precondition for Agatha: the lead at least Lv53, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md agatha; Bruno's fight takes it a level up)" + }, + { + "id": "items_before_agatha", + "kind": "game_action", + "action": "league_between_fights", + "args": { + "next": "TRAINER_ELITE_FOUR_AGATHA", + "max_hp": 165 + }, + "why": "the League plan's rules between fights (PokemonFRLG_AutoStoryLeaguePlan.h, between_fight_item()): a status cured, Super Potions up to Agatha's entry HP, a Full Restore only when they run out, an Elixir or Max Elixir when Surf or Blizzard is under its PP floor. Replaces the per-checkpoint heal_to_full, whose HP was unknown after a load (Bruno entered at 71%, console B, 2026-11-16)" + }, + { + "id": "below_brunos_door", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_BrunosRoom", + "tiles": [ + [ + 6, + 3 + ] + ], + "facing": "north" + } + }, + "why": "from in front of Bruno (6, 5) around him to below his door (6, 2), open since his defeat" + }, + { + "id": "brunos_door", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "into the door (6, 2), the warp into Agatha's room at its south entrance (6, 12)" + }, + { + "id": "enter_agathas_room", + "kind": "scene", + "declared_after": { + "map": "PokemonLeague_AgathasRoom", + "tiles": [ + [ + 6, + 7 + ] + ], + "facing": "north" + }, + "why": "the room's OnFrame script (PokemonLeague_EventScript_EnterRoom) walks the player five tiles north from (6, 12) to (6, 7) and closes the entrance behind; no text" + }, + { + "id": "before_agatha", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_AgathasRoom", + "tiles": [ + [ + 6, + 6 + ] + ], + "facing": "north" + } + }, + "why": "to (6, 6) facing Agatha (6, 5), planned from where the room's walk left the player: a tile north, or a step round if the walk ended a tile off" + }, + { + "id": "challenge_agatha", + "kind": "talk", + "why": "Agatha (6, 5): the intro, then the battle (trainerbattle_no_intro)" + }, + { + "id": "agatha", + "kind": "battle", + "args": { + "trainer": "TRAINER_ELITE_FOUR_AGATHA", + "foes": [ + "gengar", + "golbat", + "haunter", + "arbok", + "gengar" + ], + "policy": "budgeted-setup", + "setup_spa": 1, + "setup_accuracy": 0, + "setup_outspeed": true, + "setup_guard_accuracy": true, + "setup_torrent_power": true, + "foe_threats": [ + [ + 126, + 0, + 3, 60, 30, 0, 0 ], [ - 110, - 25, - 9, - 57, + 129, 28, + 17, + 60, + 30, 0, 0 ], [ - 94, - 36, - 15, - 78, - 39, + 108, + 0, + 0, + 0, + 41, + 0, + 0 + ], + [ + 111, + 51, + 31, + 108, + 54, + 0, + 0 + ], + [ + 150, + 40, + 24, + 84, + 42, 0, 0 ] + ], + "foe_stats": [ + [ + 86, + 102, + 145 + ], + [ + 96, + 91, + 161 + ], + [ + 68, + 86, + 126 + ], + [ + 108, + 110, + 150 + ], + [ + 92, + 109, + 155 + ] ] }, "declared_after": { - "map": "PokemonLeague_LoreleisRoom", + "map": "PokemonLeague_AgathasRoom", "tiles": [ [ 6, @@ -164,7 +579,379 @@ ], "facing": "north" }, - "why": "Lorelei (TRAINER_ELITE_FOUR_LORELEI): Dewgong Lv52, Cloyster Lv51, Slowbro Lv52, Jynx Lv54, Lapras Lv54, two Full Restores; fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +4 by X Specials, X Speed until faster, Guard Spec first against an accuracy drop; the doc's lorelei row, 94.3% at 159/159); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against the doc's lorelei entry state (159/159), as 19.01's: the 80th percentile of the foe's move choice, its mean, its worst case and its worst normal hit. Lapras's worst case is 78. Then her door north (6, 2) opens" + "why": "Agatha (TRAINER_ELITE_FOUR_AGATHA): Gengar Lv54, Golbat Lv54, Haunter Lv53, Arbok Lv56, Gengar Lv58, two Full Restores; fought by budgeted C2 (budgeted-setup, the League plan's per-fight item budget; before that goal-based-setup: Sp. Atk +1 by X Specials, +3 while Torrent is off (torrent_power), X Speed until faster, Guard Spec first against an accuracy drop; the doc's agatha row, 95.3% at 45/165, its opening a heal); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against console B's Lv54 Blastoise (171 HP, Def 135, Sp. Def 150) at full HP: Arbok's worst case is 108. foe_stats are each foe's Defense, Sp. Def and HP from the doc's table, for the damage each attack would do and whether the best one KOs (no X item then). Then the door north (6, 2) opens" + }, + { + "id": "items_before_lance", + "kind": "game_action", + "action": "league_between_fights", + "args": { + "next": "TRAINER_ELITE_FOUR_LANCE", + "max_hp": 168 + }, + "why": "the League plan's rules between fights (PokemonFRLG_AutoStoryLeaguePlan.h, between_fight_item()): a status cured, Super Potions up to Lance's entry HP, a Full Restore only when they run out, an Elixir or Max Elixir when Surf or Blizzard is under its PP floor. Replaces the per-checkpoint heal_to_full, whose HP was unknown after a load (Bruno entered at 71%, console B, 2026-11-16)" + }, + { + "id": "lead_lv54_for_lance", + "kind": "game_action", + "action": "level", + "args": { + "slot": 1, + "min": 54 + }, + "why": "the precondition for Lance: the lead at least Lv54, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md lance)" + }, + { + "id": "below_agathas_door", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_AgathasRoom", + "tiles": [ + [ + 6, + 3 + ] + ], + "facing": "north" + } + }, + "why": "from in front of Agatha (6, 5) around her to below her door (6, 2), open since her defeat" + }, + { + "id": "agathas_door", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "into the door (6, 2), the warp into Lance's room at the east end of its corridor (23, 13)" + }, + { + "id": "lances_corridor", + "kind": "scene", + "declared_after": { + "map": "PokemonLeague_LancesRoom", + "tiles": [ + [ + 6, + 10 + ] + ], + "facing": "north" + }, + "why": "the room's OnFrame script walks the player through the corridor (PokemonLeague_LancesRoom_Movement_WalkThroughCorridor: 2 north, 6 west, 7 south, 11 west, 8 north) from (23, 13) to (6, 10) and closes the entrance behind; no text" + }, + { + "id": "before_lance", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_LancesRoom", + "tiles": [ + [ + 6, + 9 + ] + ], + "facing": "north" + } + }, + "why": "to (6, 9) facing Lance (6, 8), planned from where the room's walk left the player: a tile north, or a step round if the walk ended a tile off" + }, + { + "id": "challenge_lance", + "kind": "talk", + "why": "Lance (6, 8): the intro, then the battle (trainerbattle_no_intro)" + }, + { + "id": "lance", + "kind": "battle", + "args": { + "trainer": "TRAINER_ELITE_FOUR_LANCE", + "foes": [ + "gyarados", + "dragonair", + "dragonair", + "aerodactyl", + "dragonite" + ], + "policy": "budgeted-setup", + "setup_spa": 3, + "setup_accuracy": 2, + "setup_outspeed": true, + "setup_guard_accuracy": true, + "foe_threats": [ + [ + 112, + 40, + 31, + 40, + 80, + 0, + 0 + ], + [ + 96, + 40, + 16, + 78, + 53, + 0, + 0 + ], + [ + 96, + 0, + 0, + 0, + 53, + 0, + 0 + ], + [ + 173, + 41, + 41, + 84, + 67, + 0, + 0 + ], + [ + 107, + 56, + 19, + 126, + 98, + 0, + 0 + ] + ], + "foe_stats": [ + [ + 110, + 119, + 189 + ], + [ + 91, + 96, + 146 + ], + [ + 91, + 96, + 146 + ], + [ + 106, + 109, + 178 + ], + [ + 137, + 157, + 197 + ] + ] + }, + "declared_after": { + "map": "PokemonLeague_LancesRoom", + "tiles": [ + [ + 6, + 9 + ] + ], + "facing": "north" + }, + "why": "Lance (TRAINER_ELITE_FOUR_LANCE): Gyarados Lv56, Dragonair Lv54, Dragonair Lv54, Aerodactyl Lv58, Dragonite Lv60, two Full Restores; fought by budgeted C2 (budgeted-setup, the League plan's per-fight item budget; before that goal-based-setup: Sp. Atk +3 and Accuracy +2 by X Specials and X Accuracies, X Speed until faster, Guard Spec first against an accuracy drop; the doc's lance row, 99.2% at 168/168); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against console B's Lv54 Blastoise (171 HP, Def 135, Sp. Def 150) at full HP: Dragonite's worst case is 126 and its worst normal hit (Hyper Beam) 98. foe_stats are each foe's Defense, Sp. Def and HP from the doc's table, for the damage each attack would do and whether the best one KOs (no X item then). Then the Champion's door north (6, 5) opens" + }, + { + "id": "items_before_champion", + "kind": "game_action", + "action": "league_between_fights", + "args": { + "next": "TRAINER_CHAMPION_FIRST_BULBASAUR", + "max_hp": 171 + }, + "why": "the League plan's rules between fights (PokemonFRLG_AutoStoryLeaguePlan.h, between_fight_item()): a status cured, Super Potions up to the Champion's entry HP, a Full Restore only when they run out, an Elixir or Max Elixir when Surf or Blizzard is under its PP floor. Replaces the per-checkpoint heal_to_full, whose HP was unknown after a load (Bruno entered at 71%, console B, 2026-11-16)" + }, + { + "id": "lead_lv55_for_champion", + "kind": "game_action", + "action": "level", + "args": { + "slot": 1, + "min": 55 + }, + "why": "the precondition for the Champion: the lead at least Lv55, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md champion)" + }, + { + "id": "below_champions_door", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "PokemonLeague_LancesRoom", + "tiles": [ + [ + 6, + 6 + ] + ], + "facing": "north" + } + }, + "why": "from in front of Lance (6, 8) around him to below the Champion's door (6, 5), open since his defeat" + }, + { + "id": "champions_door", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "into the door (6, 5), the warp into the Champion's room at its south end (6, 19). The room's OnFrame script walks the player ten tiles north to (6, 9), in front of the rival (6, 8), and his intro runs straight into the battle: no talk" + }, + { + "id": "champion", + "kind": "battle", + "args": { + "trainer": "TRAINER_CHAMPION_FIRST_BULBASAUR", + "foes": [ + "pidgeot", + "alakazam", + "rhydon", + "gyarados", + "arcanine", + "venusaur" + ], + "policy": "budgeted-setup", + "setup_spa": 2, + "setup_accuracy": 2, + "setup_outspeed": true, + "setup_guard_accuracy": true, + "foe_threats": [ + [ + 130, + 35, + 24, + 75, + 37, + 1, + 0, + 1 + ], + [ + 159, + 70, + 64, + 144, + 72, + 0, + 0 + ], + [ + 70, + 0, + 8, + 183, + 91, + 0, + 0 + ], + [ + 118, + 44, + 43, + 96, + 48, + 0, + 0 + ], + [ + 139, + 45, + 45, + 92, + 46, + 0, + 0, + 1 + ], + [ + 125, + 194, + 182, + 396, + 198, + 0, + 0, + 0, + 1 + ] + ], + "foe_stats": [ + [ + 111, + 105, + 185 + ], + [ + 73, + 130, + 147 + ], + [ + 147, + 76, + 211 + ], + [ + 127, + 141, + 199 + ], + [ + 121, + 108, + 199 + ], + [ + 129, + 135, + 193 + ] + ] + }, + "declared_after": { + "map": "PokemonLeague_ChampionsRoom", + "tiles": [ + [ + 6, + 9 + ] + ], + "facing": "north" + }, + "why": "the Champion (TRAINER_CHAMPION_FIRST_BULBASAUR for a player who took Squirtle): Pidgeot Lv59, Alakazam Lv57, Rhydon Lv59, Gyarados Lv59, Arcanine Lv61, Venusaur Lv63, four Full Restores; fought by budgeted C2 (budgeted-setup, the League plan's per-fight item budget; before that goal-based-setup: Sp. Atk +2 and Accuracy +2 by X Specials and X Accuracies, X Speed until faster, Guard Spec first against Pidgeot's Sand Attack; the doc's champion row, 95.6% at 171/171, its opening a Guard Spec); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against console B's Lv54 Blastoise (171 HP, Def 135, Sp. Def 150) at full HP, Pidgeot's row marked as lowering accuracy: Venusaur's Solar Beam worst normal hit is 198 (a one-hit KO from full), Rhydon's worst case 183; Solar Beam without sun charges a turn first (Venusaur's row's ninth column), so it is a KO risk only while Venusaur is charging or the sun is out (the battle text), else setup goes on; Pidgeot (Whirlwind) and Arcanine (Roar) are marked as phazing, so no X item is spent on them (their stages would go with a forced switch). foe_stats are each foe's Defense, Sp. Def and HP from the doc's table: Surf KOs Rhydon, so it is attacked at once" + }, + { + "id": "hall_of_fame", + "kind": "scene", + "declared_after": { + "map": "PokemonLeague_HallOfFame", + "tiles": [ + [ + 5, + 4 + ] + ], + "facing": "north" + }, + "why": "the rival's last words, Oak's entrance and his talk, and Oak leading the player out north (PokemonLeague_ChampionsRoom_Movement_PlayerExit) to the Hall of Fame (5, 12); its OnFrame script walks the player eight tiles north to (5, 4), Oak's congratulations, then the record (FLDEFF_HALL_OF_FAME_RECORD) and the Hall of Fame (special EnterHallOfFame), which saves the game itself and rolls the credits" } ] }, @@ -172,9 +959,10 @@ "menu": "full", "notes": { "checkpoint": [ - "Starts at Indigo Plateau's Mart counter, where 20.01a ends. A boss battle is its own checkpoint (user, 2026-11-12): the walk in and Lorelei's fight. PokeGuy has this fight at 1:46:37 (docs/battles/pokeguy-conditions.md, lorelei) at 159/159 HP; 19.05's heal is that entry.", + "Starts at Indigo Plateau's Mart counter, where 20.01a ends. The whole League is one checkpoint, with no save between the fights until the Hall of Fame (user, 2026-11-16; overrides a boss battle per checkpoint): league_start reads the bag once and plans every fight's items from it (PokemonFRLG_AutoStoryLeaguePlan.h), and each battle spends its budget plus what the fights before left. A failed fight goes back to this row's start.", "The League rooms are one-way: the entrance closes behind the player, and the next room's door opens only when the room's trainer is beaten.", - "Ends in front of Lorelei at (6, 6) facing north, saved there (the League lets the player save): 20.02 walks through her door north to Bruno." + "PokeGuy's fights: Lorelei 1:46:37, Bruno 1:49:15, Agatha 1:51:12, Lance 1:53:07, the Champion 1:55:44 (docs/battles/pokeguy-conditions.md); his turns: ~/BDSPLab/notes/pokeguy-league-turns.md.", + "Ends in the Hall of Fame (5, 4) facing north. The Hall of Fame saves the game itself (respawn at Pallet Town) and the credits follow: the row's own save at its end is not one the game offers there." ] } }, @@ -182,11 +970,11 @@ "phase": "testing", "postconditions": { "position": { - "map": "PokemonLeague_LoreleisRoom", + "map": "PokemonLeague_HallOfFame", "tiles": [ [ - 6, - 6 + 5, + 4 ] ], "facing": "north" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01a.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01a.plan.json index 95e18b81f2..ccd36795ed 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01a.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.01a.plan.json @@ -22,9 +22,10 @@ "args": { "map": "IndigoPlateau_PokemonCenter_1F", "items": [{"item": "full-restore", "quantity": 13}], - "fill_to": 13 + "fill_to": 13, + "if_affordable": true }, - "why": "Full Restores up to 13 in the bag, as in PokeGuy's bag at Lorelei (fullrestore x13, potion x4, superpotion x4, xaccuracy x3, xspecial x15, xspeed x4, guardspec x2, elixir x1; PokemonSimulation docs/battles/pokeguy-conditions.md, lorelei): the C policy's heals in the League's five fights come from the bag. Buys 13 less what the bag holds (3000 each), skipped at 13; a short purse stops the row here, before the League" + "why": "Full Restores up to 13 in the bag, as in PokeGuy's bag at Lorelei (fullrestore x13, potion x4, superpotion x4, xaccuracy x3, xspecial x15, xspeed x4, guardspec x2, elixir x1; PokemonSimulation docs/battles/pokeguy-conditions.md, lorelei): the C policy's heals in the League's five fights come from the bag. Buys 13 less what the bag holds (3000 each), skipped at 13. if_affordable (user, 2026-11-16: no money left for the next run): a short purse skips the line, and 20.01 plans the League from the bag as it is" }, { "id": "buy_full_heals", @@ -32,10 +33,10 @@ "action": "mart", "args": { "map": "IndigoPlateau_PokemonCenter_1F", - "items": [{"item": "full-heal", "quantity": 2}], + "items": [{"item": "full-heal", "quantity": 4}], "if_affordable": true }, - "why": "2 Full Heals (600 each) at the same counter after the Full Restores, only if the money left covers them (user's decision 2026-11-15: keep the Full Restores at 13 and their money check; the Full Heals are extra): not in PokeGuy's bag at Lorelei (PokemonSimulation docs/battles/pokeguy-conditions.md, lorelei: antidote x1 and parlyzheal x2 only, which 19.01a buys): they cure the sleep and freeze those don't without spending a Full Restore. if_affordable: a refused buy, or a quantity box that can't reach 2, is skipped with a log line and the row goes on. The console buys blind (no money reader), so there the skip is the game's refusal dialog passed by the presses, not a read" + "why": "4 Full Heals (600 each; with the 2 from earlier rows, the League plan's 6: two each for Lorelei's Lapras and Agatha's Hypnosis, one each for Lance and the Champion; user, 2026-11-16) at the same counter after the Full Restores, only if the money left covers them (user's decision 2026-11-15: keep the Full Restores at 13 and their money check; the Full Heals are extra): not in PokeGuy's bag at Lorelei (PokemonSimulation docs/battles/pokeguy-conditions.md, lorelei: antidote x1 and parlyzheal x2 only, which 19.01a buys): they cure the sleep and freeze those don't without spending a Full Restore. if_affordable: a refused buy, or a quantity box that can't reach 2, is skipped with a log line and the row goes on. The console buys blind (no money reader), so there the skip is the game's refusal dialog passed by the presses, not a read" } ] }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.02.plan.json deleted file mode 100644 index ef5a053d60..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.02.plan.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "format": "pokesim-authored-checkpoint/1", - "game": "frlg", - "checkpoint": { - "id": "20.02", - "title": "The Elite Four: Bruno", - "start": { - "map": "PokemonLeague_LoreleisRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - }, - "events": [ - { - "id": "lead_lv52_for_bruno", - "kind": "game_action", - "action": "level", - "args": { - "slot": 1, - "min": 52 - }, - "why": "the precondition for Bruno: the lead at least Lv52, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md bruno; Lorelei's fight takes it a level up)" - }, - { - "id": "below_loreleis_door", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "PokemonLeague_LoreleisRoom", - "tiles": [ - [ - 6, - 3 - ] - ], - "facing": "north" - } - }, - "why": "from in front of Lorelei (6, 5) around her to below her door (6, 2), open since her defeat" - }, - { - "id": "loreleis_door", - "kind": "step", - "args": { - "direction": "north" - }, - "why": "into the door (6, 2), the warp into Bruno's room at its south entrance (6, 12)" - }, - { - "id": "enter_brunos_room", - "kind": "scene", - "declared_after": { - "map": "PokemonLeague_BrunosRoom", - "tiles": [ - [ - 6, - 7 - ] - ], - "facing": "north" - }, - "why": "the room's OnFrame script (PokemonLeague_EventScript_EnterRoom) walks the player five tiles north from (6, 12) to (6, 7) and closes the entrance behind; no text" - }, - { - "id": "before_bruno", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "PokemonLeague_BrunosRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - } - }, - "why": "to (6, 6) facing Bruno (6, 5), planned from where the room's walk left the player: a tile north, or a step round if the walk ended a tile off" - }, - { - "id": "challenge_bruno", - "kind": "talk", - "why": "Bruno (6, 5): the intro, then the battle (trainerbattle_no_intro)" - }, - { - "id": "bruno", - "kind": "battle", - "args": { - "trainer": "TRAINER_ELITE_FOUR_BRUNO", - "foes": [ - "onix", - "hitmonchan", - "hitmonlee", - "onix", - "machamp" - ], - "policy": "goal-based-setup", - "setup_spa": 2, - "setup_accuracy": 0, - "setup_outspeed": true, - "setup_guard_accuracy": true, - "setup_target_torrent": true, - "foe_threats": [ - [ - 81, - 32, - 19, - 75, - 37, - 0, - 0 - ], - [ - 101, - 51, - 28, - 132, - 66, - 0, - 0 - ], - [ - 113, - 65, - 52, - 136, - 68, - 0, - 0 - ], - [ - 96, - 41, - 41, - 84, - 42, - 0, - 0 - ], - [ - 83, - 0, - 5, - 183, - 91, - 0, - 0 - ] - ] - }, - "declared_after": { - "map": "PokemonLeague_BrunosRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - }, - "why": "Bruno (TRAINER_ELITE_FOUR_BRUNO): Onix Lv51, Hitmonchan Lv53, Hitmonlee Lv53, Onix Lv54, Machamp Lv56, two Full Restores; fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +2 by X Specials, X Speed until faster, Guard Spec first against an accuracy drop; the doc's bruno row, 95.9% at 130/162. The doc's target_torrent (stalling to Torrent in the opening) is the C++ policy's extra X Specials against the first Onix, up to +4 while Torrent is off; its weaker-move stall needs the foe's HP and is not modelled (PokemonFRLG_AutoStoryBattlePolicy.h)); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against the doc's bruno entry state (130/162), as 19.01's: Machamp's worst case (crit Cross Chop) is 183, Hitmonlee's 136. Then the door north (6, 2) opens" - } - ] - }, - "execution": { - "menu": "full", - "notes": { - "checkpoint": [ - "Starts in front of Lorelei at (6, 6) facing north, where 20.01 ends. A boss battle is its own checkpoint: the walk on and Bruno's fight. PokeGuy has this fight at 1:49:15 (docs/battles/pokeguy-conditions.md, bruno).", - "No heal before Bruno: PokeGuy enters at 130/162 from Lorelei's fight (the doc keeps that entry: a heal changes the Torrent setup, pokeguy-preparation.md).", - "Ends in front of Bruno at (6, 6) facing north, saved there." - ] - } - }, - "metadata": { - "phase": "testing", - "postconditions": { - "position": { - "map": "PokemonLeague_BrunosRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - } - } - } -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.03.plan.json deleted file mode 100644 index 03cbffff22..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.03.plan.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "format": "pokesim-authored-checkpoint/1", - "game": "frlg", - "checkpoint": { - "id": "20.03", - "title": "The Elite Four: Agatha", - "start": { - "map": "PokemonLeague_BrunosRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - }, - "events": [ - { - "id": "lead_lv53_for_agatha", - "kind": "game_action", - "action": "level", - "args": { - "slot": 1, - "min": 53 - }, - "why": "the precondition for Agatha: the lead at least Lv53, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md agatha; Bruno's fight takes it a level up)" - }, - { - "id": "below_brunos_door", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "PokemonLeague_BrunosRoom", - "tiles": [ - [ - 6, - 3 - ] - ], - "facing": "north" - } - }, - "why": "from in front of Bruno (6, 5) around him to below his door (6, 2), open since his defeat" - }, - { - "id": "brunos_door", - "kind": "step", - "args": { - "direction": "north" - }, - "why": "into the door (6, 2), the warp into Agatha's room at its south entrance (6, 12)" - }, - { - "id": "enter_agathas_room", - "kind": "scene", - "declared_after": { - "map": "PokemonLeague_AgathasRoom", - "tiles": [ - [ - 6, - 7 - ] - ], - "facing": "north" - }, - "why": "the room's OnFrame script (PokemonLeague_EventScript_EnterRoom) walks the player five tiles north from (6, 12) to (6, 7) and closes the entrance behind; no text" - }, - { - "id": "before_agatha", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "PokemonLeague_AgathasRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - } - }, - "why": "to (6, 6) facing Agatha (6, 5), planned from where the room's walk left the player: a tile north, or a step round if the walk ended a tile off" - }, - { - "id": "challenge_agatha", - "kind": "talk", - "why": "Agatha (6, 5): the intro, then the battle (trainerbattle_no_intro)" - }, - { - "id": "agatha", - "kind": "battle", - "args": { - "trainer": "TRAINER_ELITE_FOUR_AGATHA", - "foes": [ - "gengar", - "golbat", - "haunter", - "arbok", - "gengar" - ], - "policy": "goal-based-setup", - "setup_spa": 1, - "setup_accuracy": 0, - "setup_outspeed": true, - "setup_guard_accuracy": true, - "setup_torrent_power": true, - "foe_threats": [ - [ - 126, - 32, - 10, - 72, - 36, - 0, - 0 - ], - [ - 129, - 33, - 31, - 69, - 34, - 0, - 0 - ], - [ - 108, - 0, - 0, - 0, - 48, - 0, - 0 - ], - [ - 111, - 61, - 61, - 126, - 63, - 0, - 0 - ], - [ - 150, - 47, - 40, - 99, - 49, - 0, - 0 - ] - ] - }, - "declared_after": { - "map": "PokemonLeague_AgathasRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - }, - "why": "Agatha (TRAINER_ELITE_FOUR_AGATHA): Gengar Lv54, Golbat Lv54, Haunter Lv53, Arbok Lv56, Gengar Lv58, two Full Restores; fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +1 by X Specials, +3 while Torrent is off (torrent_power), X Speed until faster, Guard Spec first against an accuracy drop; the doc's agatha row, 95.3% at 45/165, its opening a heal); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against the doc's agatha entry state (45/165), as 19.01's: Arbok's worst case is 126. Then the door north (6, 2) opens" - } - ] - }, - "execution": { - "menu": "full", - "notes": { - "checkpoint": [ - "Starts in front of Bruno at (6, 6) facing north, where 20.02 ends. A boss battle is its own checkpoint: the walk on and Agatha's fight. PokeGuy has this fight at 1:51:12 (docs/battles/pokeguy-conditions.md, agatha).", - "No heal before Agatha: PokeGuy enters at 45/165 from Bruno's fight and heals in the battle (its first turn); the C policy's recovery does that from the bag's Full Restores (20.01a).", - "Ends in front of Agatha at (6, 6) facing north, saved there." - ] - } - }, - "metadata": { - "phase": "testing", - "postconditions": { - "position": { - "map": "PokemonLeague_AgathasRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - } - } - } -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.04.plan.json deleted file mode 100644 index 787bb34e00..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.04.plan.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "format": "pokesim-authored-checkpoint/1", - "game": "frlg", - "checkpoint": { - "id": "20.04", - "title": "The Elite Four: Lance", - "start": { - "map": "PokemonLeague_AgathasRoom", - "tiles": [ - [ - 6, - 6 - ] - ], - "facing": "north" - }, - "events": [ - { - "id": "heal_after_agatha", - "kind": "game_action", - "action": "heal_to_full", - "args": { - "max_hp": 168, - "full_restore": true - }, - "why": "full HP into Lance, as PokeGuy enters him (168/168, docs/battles/pokeguy-conditions.md lance) after Agatha's fight: a Full Restore if any HP is missing (from the battle's last HP bar), as PokeGuy spends one here (his bag's 12 to 11), then Super Potions and Potions for what is left (none, or all of it when the bag has no Full Restore)" - }, - { - "id": "lead_lv54_for_lance", - "kind": "game_action", - "action": "level", - "args": { - "slot": 1, - "min": 54 - }, - "why": "the precondition for Lance: the lead at least Lv54, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md lance)" - }, - { - "id": "below_agathas_door", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "PokemonLeague_AgathasRoom", - "tiles": [ - [ - 6, - 3 - ] - ], - "facing": "north" - } - }, - "why": "from in front of Agatha (6, 5) around her to below her door (6, 2), open since her defeat" - }, - { - "id": "agathas_door", - "kind": "step", - "args": { - "direction": "north" - }, - "why": "into the door (6, 2), the warp into Lance's room at the east end of its corridor (23, 13)" - }, - { - "id": "lances_corridor", - "kind": "scene", - "declared_after": { - "map": "PokemonLeague_LancesRoom", - "tiles": [ - [ - 6, - 10 - ] - ], - "facing": "north" - }, - "why": "the room's OnFrame script walks the player through the corridor (PokemonLeague_LancesRoom_Movement_WalkThroughCorridor: 2 north, 6 west, 7 south, 11 west, 8 north) from (23, 13) to (6, 10) and closes the entrance behind; no text" - }, - { - "id": "before_lance", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "PokemonLeague_LancesRoom", - "tiles": [ - [ - 6, - 9 - ] - ], - "facing": "north" - } - }, - "why": "to (6, 9) facing Lance (6, 8), planned from where the room's walk left the player: a tile north, or a step round if the walk ended a tile off" - }, - { - "id": "challenge_lance", - "kind": "talk", - "why": "Lance (6, 8): the intro, then the battle (trainerbattle_no_intro)" - }, - { - "id": "lance", - "kind": "battle", - "args": { - "trainer": "TRAINER_ELITE_FOUR_LANCE", - "foes": [ - "gyarados", - "dragonair", - "dragonair", - "aerodactyl", - "dragonite" - ], - "policy": "goal-based-setup", - "setup_spa": 3, - "setup_accuracy": 2, - "setup_outspeed": true, - "setup_guard_accuracy": true, - "foe_threats": [ - [ - 112, - 40, - 32, - 42, - 93, - 0, - 0 - ], - [ - 96, - 40, - 17, - 87, - 62, - 0, - 0 - ], - [ - 96, - 0, - 0, - 0, - 62, - 0, - 0 - ], - [ - 173, - 47, - 47, - 96, - 78, - 0, - 0 - ], - [ - 107, - 64, - 24, - 144, - 114, - 0, - 0 - ] - ] - }, - "declared_after": { - "map": "PokemonLeague_LancesRoom", - "tiles": [ - [ - 6, - 9 - ] - ], - "facing": "north" - }, - "why": "Lance (TRAINER_ELITE_FOUR_LANCE): Gyarados Lv56, Dragonair Lv54, Dragonair Lv54, Aerodactyl Lv58, Dragonite Lv60, two Full Restores; fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +3 and Accuracy +2 by X Specials and X Accuracies, X Speed until faster, Guard Spec first against an accuracy drop; the doc's lance row, 99.2% at 168/168); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against the doc's lance entry state (168/168), as 19.01's: Dragonite's worst case is 144 and its worst normal hit (Hyper Beam) 114. Then the Champion's door north (6, 5) opens" - } - ] - }, - "execution": { - "menu": "full", - "notes": { - "checkpoint": [ - "Starts in front of Agatha at (6, 6) facing north, where 20.03 ends. A boss battle is its own checkpoint: the heal after Agatha, the corridor and Lance's fight. PokeGuy has this fight at 1:53:07 (docs/battles/pokeguy-conditions.md, lance).", - "Lance's Blizzard budget: the doc's League PP contract (league-pp-requirements.md) has Blizzard 5/5 into Lance; nothing before him casts it.", - "Ends in front of Lance at (6, 9) facing north, saved there." - ] - } - }, - "metadata": { - "phase": "testing", - "postconditions": { - "position": { - "map": "PokemonLeague_LancesRoom", - "tiles": [ - [ - 6, - 9 - ] - ], - "facing": "north" - } - } - } -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.05.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.05.plan.json deleted file mode 100644 index 8ccac54521..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-20.05.plan.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "format": "pokesim-authored-checkpoint/1", - "game": "frlg", - "checkpoint": { - "id": "20.05", - "title": "The Champion, then the Hall of Fame", - "start": {"map": "PokemonLeague_LancesRoom", "tiles": [[6, 9]], "facing": "north"}, - "events": [ - { - "id": "heal_after_lance", - "kind": "game_action", - "action": "heal_to_full", - "args": { - "max_hp": 171 - }, - "why": "full HP into the Champion, as PokeGuy enters him (171/171, docs/battles/pokeguy-conditions.md champion) after Lance's fight: Super Potions and Potions until the HP the fight left missing (from the battle's last HP bar) is healed" - }, - { - "id": "elixir_after_lance", - "kind": "game_action", - "action": "restore_pp", - "args": { - "item": "elixir" - }, - "why": "PokeGuy's one Elixir after Lance (league-pp-requirements.md: Surf 3 to 13, Blizzard 0 to 5): FRLG's Elixir restores 10 PP to every move, with no move to pick" - }, - { - "id": "lead_lv55_for_champion", - "kind": "game_action", - "action": "level", - "args": { - "slot": 1, - "min": 55 - }, - "why": "the precondition for the Champion: the lead at least Lv55, pokeguy's Blastoise here (docs/battles/pokeguy-conditions.md champion)" - }, - { - "id": "below_champions_door", - "kind": "route", - "action": "run", - "args": { - "target": {"map": "PokemonLeague_LancesRoom", "tiles": [[6, 6]], "facing": "north"} - }, - "why": "from in front of Lance (6, 8) around him to below the Champion's door (6, 5), open since his defeat" - }, - { - "id": "champions_door", - "kind": "step", - "args": {"direction": "north"}, - "why": "into the door (6, 5), the warp into the Champion's room at its south end (6, 19). The room's OnFrame script walks the player ten tiles north to (6, 9), in front of the rival (6, 8), and his intro runs straight into the battle: no talk" - }, - { - "id": "champion", - "kind": "battle", - "args": { - "trainer": "TRAINER_CHAMPION_FIRST_BULBASAUR", - "foes": [ - "pidgeot", - "alakazam", - "rhydon", - "gyarados", - "arcanine", - "venusaur" - ], - "policy": "goal-based-setup", - "setup_spa": 2, - "setup_accuracy": 2, - "setup_outspeed": true, - "setup_guard_accuracy": true, - "foe_threats": [ - [130, 41, 27, 87, 43, 1, 0], - [159, 77, 70, 159, 79, 0, 0], - [70, 0, 10, 210, 105, 0, 0], - [118, 51, 46, 110, 55, 0, 0], - [139, 50, 51, 104, 52, 0, 0], - [125, 217, 218, 444, 222, 0, 0] - ] - }, - "declared_after": {"map": "PokemonLeague_ChampionsRoom", "tiles": [[6, 9]], "facing": "north"}, - "why": "the Champion (TRAINER_CHAMPION_FIRST_BULBASAUR for a player who took Squirtle): Pidgeot Lv59, Alakazam Lv57, Rhydon Lv59, Gyarados Lv59, Arcanine Lv61, Venusaur Lv63, four Full Restores; fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +2 and Accuracy +2 by X Specials and X Accuracies, X Speed until faster, Guard Spec first against Pidgeot's Sand Attack; the doc's champion row, 95.6% at 171/171, its opening a Guard Spec); foe_threats are the rows PokemonSimulation's player-strategy planning_risk() gives for each foe leading against the doc's champion entry state (171/171), as 19.01's, Pidgeot's row marked as lowering accuracy: Venusaur's Solar Beam worst case is 444 (a one-hit KO from full), Rhydon's 210" - }, - { - "id": "hall_of_fame", - "kind": "scene", - "declared_after": {"map": "PokemonLeague_HallOfFame", "tiles": [[5, 4]], "facing": "north"}, - "why": "the rival's last words, Oak's entrance and his talk, and Oak leading the player out north (PokemonLeague_ChampionsRoom_Movement_PlayerExit) to the Hall of Fame (5, 12); its OnFrame script walks the player eight tiles north to (5, 4), Oak's congratulations, then the record (FLDEFF_HALL_OF_FAME_RECORD) and the Hall of Fame (special EnterHallOfFame), which saves the game itself and rolls the credits" - } - ] - }, - "execution": { - "menu": "full", - "notes": { - "checkpoint": [ - "Starts in front of Lance at (6, 9) facing north, where 20.04 ends. A boss battle is its own checkpoint: the heal after Lance, the Champion's fight and what the game plays after it, which the player can not stop or save in. PokeGuy has this fight at 1:55:44 (docs/battles/pokeguy-conditions.md, champion).", - "PokeGuy uses one Elixir after Lance (Surf 3 to 13, Blizzard 0 to 5; league-pp-requirements.md); so does this row (restore_pp), which fails if the bag has none.", - "Ends in the Hall of Fame (5, 4) facing north. The Hall of Fame saves the game itself (respawn at Pallet Town) and the credits follow: the row's own save at its end is not one the game offers there." - ] - } - }, - "metadata": { - "phase": "testing", - "postconditions": { - "position": {"map": "PokemonLeague_HallOfFame", "tiles": [[5, 4]], "facing": "north"} - } - } -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-foes.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-foes.json new file mode 100644 index 0000000000..d150e0678e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-foes.json @@ -0,0 +1,322 @@ +{ + "format": "frlg-league-foes/1", + "source": "PokemonSimulation 4a79ccc data/runs/pokeguy-leafgreen-15934/battle-reference.json; stats from engines/frlg-showdown (pokemon-showdown Gen 3, teamMember)", + "moves": { + "aerial-ace": { "type": "flying", "power": 60, "accuracy": 101, "priority": 0, "physical": true, "two_turn": false }, + "air-cutter": { "type": "flying", "power": 55, "accuracy": 95, "priority": 0, "physical": true, "two_turn": false }, + "amnesia": { "type": "psychic", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "ancient-power": { "type": "rock", "power": 60, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "attract": { "type": "normal", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "bite": { "type": "dark", "power": 60, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "blizzard": { "type": "ice", "power": 120, "accuracy": 70, "priority": 0, "physical": false, "two_turn": false }, + "body-slam": { "type": "normal", "power": 85, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "brick-break": { "type": "fighting", "power": 75, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "bulk-up": { "type": "fighting", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "confuse-ray": { "type": "ghost", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "counter": { "type": "fighting", "power": 0, "accuracy": 100, "priority": -5, "physical": true, "two_turn": false }, + "cross-chop": { "type": "fighting", "power": 100, "accuracy": 80, "priority": 0, "physical": true, "two_turn": false }, + "curse": { "type": "???", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "dive": { "type": "water", "power": 60, "accuracy": 100, "priority": 0, "physical": false, "two_turn": true }, + "double-edge": { "type": "normal", "power": 120, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "double-slap": { "type": "normal", "power": 15, "accuracy": 85, "priority": 0, "physical": true, "two_turn": false, "hits": [ 2, 5 ] }, + "double-team": { "type": "normal", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "dragon-rage": { "type": "dragon", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false, "fixed_damage": 40 }, + "dream-eater": { "type": "psychic", "power": 100, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "earthquake": { "type": "ground", "power": 100, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "extreme-speed": { "type": "normal", "power": 80, "accuracy": 100, "priority": 1, "physical": true, "two_turn": false }, + "facade": { "type": "normal", "power": 70, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "feather-dance": { "type": "flying", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "flamethrower": { "type": "fire", "power": 95, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "foresight": { "type": "normal", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "future-sight": { "type": "psychic", "power": 80, "accuracy": 90, "priority": 0, "physical": false, "two_turn": false }, + "growth": { "type": "normal", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "hail": { "type": "ice", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "hydro-pump": { "type": "water", "power": 120, "accuracy": 80, "priority": 0, "physical": false, "two_turn": false }, + "hyper-beam": { "type": "normal", "power": 150, "accuracy": 90, "priority": 0, "physical": true, "two_turn": false }, + "hypnosis": { "type": "psychic", "power": 0, "accuracy": 60, "priority": 0, "physical": false, "two_turn": false }, + "ice-beam": { "type": "ice", "power": 95, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "ice-punch": { "type": "ice", "power": 75, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "iron-tail": { "type": "steel", "power": 100, "accuracy": 75, "priority": 0, "physical": true, "two_turn": false }, + "lovely-kiss": { "type": "normal", "power": 0, "accuracy": 75, "priority": 0, "physical": false, "two_turn": false }, + "mach-punch": { "type": "fighting", "power": 40, "accuracy": 100, "priority": 1, "physical": true, "two_turn": false }, + "mean-look": { "type": "normal", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "mega-kick": { "type": "normal", "power": 120, "accuracy": 75, "priority": 0, "physical": true, "two_turn": false }, + "nightmare": { "type": "ghost", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "outrage": { "type": "dragon", "power": 90, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "poison-fang": { "type": "poison", "power": 50, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "protect": { "type": "normal", "power": 0, "accuracy": 101, "priority": 3, "physical": false, "two_turn": false }, + "psychic": { "type": "psychic", "power": 90, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "recover": { "type": "normal", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "reflect": { "type": "psychic", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "roar": { "type": "normal", "power": 0, "accuracy": 100, "priority": -6, "physical": false, "two_turn": false }, + "rock-tomb": { "type": "rock", "power": 50, "accuracy": 80, "priority": 0, "physical": true, "two_turn": false }, + "safeguard": { "type": "normal", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "sand-attack": { "type": "ground", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "sand-tomb": { "type": "ground", "power": 15, "accuracy": 70, "priority": 0, "physical": true, "two_turn": false }, + "scary-face": { "type": "normal", "power": 0, "accuracy": 90, "priority": 0, "physical": false, "two_turn": false }, + "screech": { "type": "normal", "power": 0, "accuracy": 85, "priority": 0, "physical": false, "two_turn": false }, + "shadow-ball": { "type": "ghost", "power": 80, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "shadow-punch": { "type": "ghost", "power": 60, "accuracy": 101, "priority": 0, "physical": true, "two_turn": false }, + "sky-uppercut": { "type": "fighting", "power": 85, "accuracy": 90, "priority": 0, "physical": true, "two_turn": false }, + "sludge-bomb": { "type": "poison", "power": 90, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "solar-beam": { "type": "grass", "power": 120, "accuracy": 100, "priority": 0, "physical": false, "two_turn": true }, + "spikes": { "type": "ground", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "strength": { "type": "normal", "power": 80, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "sunny-day": { "type": "fire", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "surf": { "type": "water", "power": 95, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "synthesis": { "type": "grass", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false }, + "take-down": { "type": "normal", "power": 90, "accuracy": 85, "priority": 0, "physical": true, "two_turn": false }, + "thrash": { "type": "normal", "power": 90, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "thunder-wave": { "type": "electric", "power": 0, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "toxic": { "type": "poison", "power": 0, "accuracy": 85, "priority": 0, "physical": false, "two_turn": false }, + "twister": { "type": "dragon", "power": 40, "accuracy": 100, "priority": 0, "physical": false, "two_turn": false }, + "whirlwind": { "type": "normal", "power": 0, "accuracy": 100, "priority": -6, "physical": false, "two_turn": false }, + "wing-attack": { "type": "flying", "power": 60, "accuracy": 100, "priority": 0, "physical": true, "two_turn": false }, + "yawn": { "type": "normal", "power": 0, "accuracy": 101, "priority": 0, "physical": false, "two_turn": false } + }, + "trainers": { + "TRAINER_ELITE_FOUR_LORELEI": { + "items": { + "full-restore": 2 + }, + "party": [ + { + "species": "dewgong", + "level": 52, + "ability": "thickfat", + "stats": { "hp": 171, "atk": 93, "def": 103, "spa": 93, "spd": 119, "spe": 93 }, + "held_item": null, + "moves": [ "ice-beam", "surf", "hail", "safeguard" ] + }, + { + "species": "cloyster", + "level": 51, + "ability": "shellarmor", + "stats": { "hp": 127, "atk": 117, "def": 203, "spa": 96, "spd": 72, "spe": 91 }, + "held_item": null, + "moves": [ "spikes", "protect", "hail", "dive" ] + }, + { + "species": "slowbro", + "level": 52, + "ability": "oblivious", + "stats": { "hp": 176, "atk": 107, "def": 135, "spa": 124, "spd": 103, "spe": 45 }, + "held_item": null, + "moves": [ "ice-beam", "surf", "amnesia", "yawn" ] + }, + { + "species": "jynx", + "level": 54, + "ability": "oblivious", + "stats": { "hp": 150, "atk": 75, "def": 59, "spa": 145, "spd": 135, "spe": 110 }, + "held_item": null, + "moves": [ "ice-punch", "double-slap", "lovely-kiss", "attract" ] + }, + { + "species": "lapras", + "level": 54, + "ability": "waterabsorb", + "stats": { "hp": 220, "atk": 113, "def": 107, "spa": 101, "spd": 123, "spe": 94 }, + "held_item": "sitrus-berry", + "moves": [ "confuse-ray", "ice-beam", "surf", "body-slam" ] + } + ] + }, + "TRAINER_ELITE_FOUR_BRUNO": { + "items": { + "full-restore": 2 + }, + "party": [ + { + "species": "onix", + "level": 51, + "ability": "rockhead", + "stats": { "hp": 112, "atk": 66, "def": 183, "spa": 50, "spd": 72, "spe": 81 }, + "held_item": null, + "moves": [ "earthquake", "rock-tomb", "iron-tail", "roar" ] + }, + { + "species": "hitmonchan", + "level": 53, + "ability": "keeneye", + "stats": { "hp": 131, "atk": 132, "def": 104, "spa": 58, "spd": 137, "spe": 101 }, + "held_item": null, + "moves": [ "sky-uppercut", "mach-punch", "rock-tomb", "counter" ] + }, + { + "species": "hitmonlee", + "level": 53, + "ability": "limber", + "stats": { "hp": 131, "atk": 148, "def": 77, "spa": 58, "spd": 137, "spe": 113 }, + "held_item": null, + "moves": [ "mega-kick", "foresight", "brick-break", "facade" ] + }, + { + "species": "onix", + "level": 54, + "ability": "rockhead", + "stats": { "hp": 118, "atk": 69, "def": 194, "spa": 47, "spd": 75, "spe": 96 }, + "held_item": null, + "moves": [ "double-edge", "earthquake", "iron-tail", "sand-tomb" ] + }, + { + "species": "machamp", + "level": 56, + "ability": "guts", + "stats": { "hp": 183, "atk": 150, "def": 111, "spa": 103, "spd": 117, "spe": 83 }, + "held_item": "sitrus-berry", + "moves": [ "cross-chop", "bulk-up", "scary-face", "rock-tomb" ] + } + ] + }, + "TRAINER_ELITE_FOUR_AGATHA": { + "items": { + "full-restore": 2 + }, + "party": [ + { + "species": "gengar", + "level": 54, + "ability": "levitate", + "stats": { "hp": 145, "atk": 100, "def": 86, "spa": 161, "spd": 102, "spe": 126 }, + "held_item": null, + "moves": [ "shadow-punch", "confuse-ray", "toxic", "double-team" ] + }, + { + "species": "golbat", + "level": 54, + "ability": "innerfocus", + "stats": { "hp": 161, "atk": 107, "def": 96, "spa": 91, "spd": 91, "spe": 129 }, + "held_item": null, + "moves": [ "confuse-ray", "poison-fang", "air-cutter", "bite" ] + }, + { + "species": "haunter", + "level": 53, + "ability": "levitate", + "stats": { "hp": 126, "atk": 73, "def": 68, "spa": 142, "spd": 86, "spe": 108 }, + "held_item": null, + "moves": [ "hypnosis", "dream-eater", "curse", "mean-look" ] + }, + { + "species": "arbok", + "level": 56, + "ability": "intimidate", + "stats": { "hp": 150, "atk": 117, "def": 108, "spa": 84, "spd": 110, "spe": 111 }, + "held_item": null, + "moves": [ "sludge-bomb", "screech", "iron-tail", "bite" ] + }, + { + "species": "gengar", + "level": 58, + "ability": "levitate", + "stats": { "hp": 155, "atk": 87, "def": 92, "spa": 190, "spd": 109, "spe": 150 }, + "held_item": "sitrus-berry", + "moves": [ "shadow-ball", "sludge-bomb", "hypnosis", "nightmare" ] + } + ] + }, + "TRAINER_ELITE_FOUR_LANCE": { + "items": { + "full-restore": 2 + }, + "party": [ + { + "species": "gyarados", + "level": 56, + "ability": "intimidate", + "stats": { "hp": 189, "atk": 161, "def": 110, "spa": 97, "spd": 119, "spe": 112 }, + "held_item": null, + "moves": [ "hyper-beam", "dragon-rage", "twister", "bite" ] + }, + { + "species": "dragonair", + "level": 54, + "ability": "shedskin", + "stats": { "hp": 146, "atk": 111, "def": 91, "spa": 96, "spd": 96, "spe": 96 }, + "held_item": null, + "moves": [ "hyper-beam", "safeguard", "dragon-rage", "outrage" ] + }, + { + "species": "dragonair", + "level": 54, + "ability": "shedskin", + "stats": { "hp": 146, "atk": 111, "def": 91, "spa": 96, "spd": 96, "spe": 96 }, + "held_item": null, + "moves": [ "hyper-beam", "safeguard", "thunder-wave", "outrage" ] + }, + { + "species": "aerodactyl", + "level": 58, + "ability": "rockhead", + "stats": { "hp": 178, "atk": 129, "def": 106, "spa": 92, "spd": 109, "spe": 173 }, + "held_item": null, + "moves": [ "hyper-beam", "ancient-power", "wing-attack", "scary-face" ] + }, + { + "species": "dragonite", + "level": 60, + "ability": "innerfocus", + "stats": { "hp": 197, "atk": 183, "def": 137, "spa": 143, "spd": 157, "spe": 107 }, + "held_item": "sitrus-berry", + "moves": [ "hyper-beam", "safeguard", "outrage", "wing-attack" ] + } + ] + }, + "TRAINER_CHAMPION_FIRST_BULBASAUR": { + "items": { + "full-restore": 4 + }, + "party": [ + { + "species": "pidgeot", + "level": 59, + "ability": "keeneye", + "stats": { "hp": 185, "atk": 117, "def": 111, "spa": 105, "spd": 105, "spe": 130 }, + "held_item": null, + "moves": [ "aerial-ace", "feather-dance", "sand-attack", "whirlwind" ] + }, + { + "species": "alakazam", + "level": 57, + "ability": "synchronize", + "stats": { "hp": 147, "atk": 71, "def": 73, "spa": 176, "spd": 130, "spe": 159 }, + "held_item": null, + "moves": [ "psychic", "future-sight", "recover", "reflect" ] + }, + { + "species": "rhydon", + "level": 59, + "ability": "lightningrod", + "stats": { "hp": 211, "atk": 176, "def": 147, "spa": 83, "spd": 76, "spe": 70 }, + "held_item": null, + "moves": [ "take-down", "earthquake", "rock-tomb", "scary-face" ] + }, + { + "species": "gyarados", + "level": 59, + "ability": "intimidate", + "stats": { "hp": 199, "atk": 153, "def": 127, "spa": 94, "spd": 141, "spe": 118 }, + "held_item": null, + "moves": [ "hydro-pump", "dragon-rage", "bite", "thrash" ] + }, + { + "species": "arcanine", + "level": 61, + "ability": "intimidate", + "stats": { "hp": 199, "atk": 158, "def": 121, "spa": 159, "spd": 108, "spe": 139 }, + "held_item": null, + "moves": [ "extreme-speed", "flamethrower", "roar", "bite" ] + }, + { + "species": "venusaur", + "level": 63, + "ability": "overgrow", + "stats": { "hp": 193, "atk": 127, "def": 129, "spa": 165, "spd": 135, "spe": 125 }, + "held_item": "sitrus-berry", + "moves": [ "solar-beam", "synthesis", "sunny-day", "growth" ] + } + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-parity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-parity.json new file mode 100644 index 0000000000..bdf830413d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-parity.json @@ -0,0 +1,630 @@ +{"format": "frlg-league-parity/1", "chains": 10, "seed": "parity", "decisions": [ +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":154,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":144,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":134,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":107,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":82,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":77,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":13,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":82,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":51,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":24,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":2,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":111,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":67,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"full-heal"},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":9}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":8,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.3958333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"status_ko","item":"full-restore"},"hidden":{"foe_hp":88,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":8}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.3958333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":88,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":14,"body-slam":8}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":17,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":18,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":19,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":20,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"turn","chain":0,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":21,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":8,"hail":10,"dive":10}}}, +{"kind":"between","chain":0,"fight":"bruno","carry":{"hp":152,"max_hp":171,"status":"none","pp":{"bite":17,"surf":14,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":[]}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":152,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":139,"status":"none","stages":{"spa":1,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":109,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":78,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":63,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":0,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":0,"fight":"agatha","carry":{"hp":35,"max_hp":174,"status":"none","pp":{"bite":17,"surf":9,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":145,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":145,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":10,"double-team":14}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":135,"status":"poison","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"cure","item":"antidote"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":9,"double-team":14}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":135,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":9,"double-team":13}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":120,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":9,"double-team":12}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":120,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":9,"double-team":11}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":120,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":8,"toxic":9,"double-team":11}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":120,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":5},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":8,"toxic":9,"double-team":10}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":120,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":6},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":8,"toxic":9,"double-team":9}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":78,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":6},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":18,"confuse-ray":8,"toxic":9,"double-team":9}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":13,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":51,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":6},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":17,"confuse-ray":8,"toxic":9,"double-team":9}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":14,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":51,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":15,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":51,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":16,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":51,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":0,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":17,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":51,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":9},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":0,"fight":"lance","carry":{"hp":51,"max_hp":174,"status":"none","pp":{"bite":9,"surf":7,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":9},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":157,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":9},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":5,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":24}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":117,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":9},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":24}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":77,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":8},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":121,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":24}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":8},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":121,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":24}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":0,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":98,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":6},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"between","chain":0,"fight":"champion","carry":{"hp":98,"max_hp":177,"status":"none","pp":{"bite":7,"surf":6,"blizzard":2,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":147,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":4,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":117,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":4,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":3,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":87,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":4,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup_heal","item":"full-restore"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":147,"status":"none","stages":{"spa":2},"mist_turns":1,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":147,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":147,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":4,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":112,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":3,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":15,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":42,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":14,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":42,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":42,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":42,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":42,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":3,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"thrash","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":0.2916666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":62,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":0,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":12},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":155,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":145,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":135,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":108,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":83,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.3958333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":71,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":13,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":83,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":83,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":138,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":52,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":25,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":143,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":129,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":68,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.020833333333333332,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":6,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":68,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":135,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":135,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":9}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":17,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":141,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":135,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":8}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":18,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":141,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":97,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":8,"ice-beam":10,"surf":15,"body-slam":8}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":19,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":97,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":97,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":8,"ice-beam":10,"surf":15,"body-slam":7}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":20,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":69,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":97,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":8,"ice-beam":10,"surf":15,"body-slam":6}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":21,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":42,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"lapras","slot":4,"fill":0.25,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"full-heal"},"hidden":{"foe_hp":58,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":8,"ice-beam":10,"surf":15,"body-slam":5}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":22,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":14,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"lapras","slot":4,"fill":0.25,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":58,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":8,"ice-beam":10,"surf":15,"body-slam":4}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":23,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":14,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":24,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":14,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":25,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":14,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":26,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":14,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"turn","chain":1,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":27,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":14,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":8,"hail":10,"dive":10}}}, +{"kind":"between","chain":1,"fight":"bruno","carry":{"hp":14,"max_hp":171,"status":"none","pp":{"bite":15,"surf":14,"blizzard":5,"strength":11},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":164,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":135,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":120,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":81,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":7,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":1,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":1,"fight":"agatha","carry":{"hp":26,"max_hp":174,"status":"none","pp":{"bite":15,"surf":9,"blizzard":5,"strength":11},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"poison","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":0,"choice":{"row":"cure","item":"antidote"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":9,"double-team":15}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":1,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":9,"double-team":14}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":9,"double-team":13}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":9,"double-team":12}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":150,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":9,"double-team":11}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":150,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":150,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":150,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":1,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":150,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":1,"fight":"lance","carry":{"hp":150,"max_hp":174,"status":"none","pp":{"bite":12,"surf":7,"blizzard":5,"strength":11},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1}},"used":["full-restore"]}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":156,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":5,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":24}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":116,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":24}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":76,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gyarados","slot":0,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":24}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":96,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"gyarados","slot":0,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"dragon-rage":8,"twister":20,"bite":24}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":96,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gyarados","slot":0,"fill":0.4791666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":94,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"dragon-rage":8,"twister":20,"bite":24}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":79,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"gyarados","slot":0,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":71,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"dragon-rage":8,"twister":20,"bite":23}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"gyarados","slot":0,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":71,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":3,"dragon-rage":8,"twister":20,"bite":23}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"gyarados","slot":0,"fill":0.020833333333333332,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":2,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":3,"dragon-rage":8,"twister":20,"bite":23}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":9},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"gyarados","slot":0,"fill":0.6666666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":3,"dragon-rage":8,"twister":20,"bite":23}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":8},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"gyarados","slot":0,"fill":0.2916666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":59,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":3,"dragon-rage":8,"twister":20,"bite":23}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":13,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":9}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":14,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":9}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":15,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":7},{"id":"blizzard","pp":2},{"id":"strength","pp":9}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":1,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":16,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":61,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":7},{"id":"surf","pp":6},{"id":"blizzard","pp":2},{"id":"strength","pp":9}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"between","chain":1,"fight":"champion","carry":{"hp":61,"max_hp":177,"status":"none","pp":{"bite":7,"surf":6,"blizzard":1,"strength":9},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"elixir":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":3,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":112,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":1,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"guard-spec":1,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":80,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":2,"guard-spec":1,"max-elixir":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup_heal","item":"full-restore"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"guard-spec":1,"max-elixir":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":147,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":4,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":117,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":3,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":15,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":55,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":14,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":55,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":55,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":55,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":55,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":15,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"thrash","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"full-restore":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":144,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"max-elixir":1,"x-special":2},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":144,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":12},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"gyarados","slot":3,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":87,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":1,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":18,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":12},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"full-heal":1,"max-elixir":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":161,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":135,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":14,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":68,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":13,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":51,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":77,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":12,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":51,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":51,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":132,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":22,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":124,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":124,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":128,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":124,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":101,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":124,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":71,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":87,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":42,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":87,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":42,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":27,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":9}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":17,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":27,"status":"sleep","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sleep_cure","item":"full-heal"},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":18,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":27,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":14}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":19,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":5,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":14,"double-slap":10,"lovely-kiss":10,"attract":14}}}, +{"kind":"turn","chain":2,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":20,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":5,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"between","chain":2,"fight":"bruno","carry":{"hp":5,"max_hp":171,"status":"none","pp":{"bite":19,"surf":14,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":155,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":155,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"machamp","slot":4,"fill":0.8125,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":9,"rock-tomb":10}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"machamp","slot":4,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":116,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":8,"rock-tomb":10}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":45,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"hitmonlee","slot":2,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":7,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":83,"foe_sleep_turns":0,"foe_pp":{"mega-kick":4,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":118,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"hitmonlee","slot":2,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":1,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":83,"foe_sleep_turns":0,"foe_pp":{"mega-kick":3,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":118,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":63,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"hitmonchan","slot":1,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":94,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":14,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":2,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":63,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":161,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":151,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4791666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":82,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":67,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":130,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":39,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5416666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":120,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":9,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"status_ko","item":"full-restore"},"hidden":{"foe_hp":84,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":84,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":3,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"between","chain":3,"fight":"bruno","carry":{"hp":142,"max_hp":171,"status":"none","pp":{"bite":18,"surf":14,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":[]}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":115,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":102,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":88,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":60,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":7,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":3,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":3,"fight":"agatha","carry":{"hp":34,"max_hp":174,"status":"none","pp":{"bite":18,"surf":9,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"poison","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":0,"choice":{"row":"cure","item":"antidote"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":9,"double-team":15}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":1,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":9,"double-team":14}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":9,"double-team":13}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":9,"double-team":12}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":9,"double-team":11}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":8,"double-team":11}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":3,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":164,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":3,"fight":"lance","carry":{"hp":164,"max_hp":174,"status":"none","pp":{"bite":14,"surf":7,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1}},"used":["super-potion"]}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":157,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":5,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":24}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":117,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":24}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":77,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.6458333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":125,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":24}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.6458333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":125,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":24}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":118,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.3125,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":61,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":23}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":118,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":118,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":61,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":14,"wing-attack":35}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":121,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":14,"wing-attack":35}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":62,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":2},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":14,"wing-attack":35}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":2},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":0.8541666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":14,"wing-attack":35}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":13,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":14,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":137,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":6},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":15,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":102,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":3,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":16,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":67,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":12}]},"foe":{"species":"dragonair","slot":1,"fill":0.7708333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":113,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":14}}}, +{"kind":"between","chain":3,"fight":"champion","carry":{"hp":67,"max_hp":177,"status":"none","pp":{"bite":11,"surf":6,"blizzard":0,"strength":11},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":3,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":3,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":14,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":112,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":1,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":14,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":81,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup_heal","item":"full-restore"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":14,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":14,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":4,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":14,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":3,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":14,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":79,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"alakazam","slot":1,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":91,"foe_sleep_turns":0,"foe_pp":{"psychic":9,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":79,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":79,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":144,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":39,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"thrash","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":85,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":3,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":39,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":2},{"id":"strength","pp":14}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":161,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":151,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":126,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4791666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":85,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":70,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":133,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":43,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":133,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":12,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":153,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":9,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.3958333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":90,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":9,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":4,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"between","chain":4,"fight":"bruno","carry":{"hp":125,"max_hp":171,"status":"none","pp":{"bite":18,"surf":14,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":["super-potion"]}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":143,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":128,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":114,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":71,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":71,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":9,"rock-tomb":10}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"machamp","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{"atk":1,"def":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":106,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":19,"scary-face":9,"rock-tomb":10}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":67,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":67,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"hitmonlee","slot":2,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":76,"foe_sleep_turns":0,"foe_pp":{"mega-kick":4,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":16,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":146,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":29,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"hitmonchan","slot":1,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":95,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":14,"mach-punch":29,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":4,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":4,"fight":"agatha","carry":{"hp":61,"max_hp":174,"status":"none","pp":{"bite":18,"surf":9,"blizzard":5,"strength":10},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":2}},"used":["super-potion","super-potion"]}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":161,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":161,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":14}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":161,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":13}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":161,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":12}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":161,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":11}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":161,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":10,"double-team":11}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":145,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":5},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":10,"double-team":10}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":130,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":6},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":9,"toxic":10,"double-team":9}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":87,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":6},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":9,"toxic":10,"double-team":9}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":59,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":6},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":18,"confuse-ray":9,"toxic":10,"double-team":9}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":59,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":59,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":13,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":59,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":4,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":14,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":59,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":4,"fight":"lance","carry":{"hp":59,"max_hp":174,"status":"none","pp":{"bite":13,"surf":7,"blizzard":5,"strength":10},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":5,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gyarados","slot":0,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":120,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"gyarados","slot":0,"fill":0.2916666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":56,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":25}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"paralysis","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":10}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":19,"outrage":15}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":10}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"thunder-wave":19,"outrage":15}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":10}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":122,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":10}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":34}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":122,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":2},{"id":"strength","pp":10}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":4,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":85,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":6},{"id":"blizzard","pp":2},{"id":"strength","pp":10}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"between","chain":4,"fight":"champion","carry":{"hp":85,"max_hp":177,"status":"none","pp":{"bite":10,"surf":6,"blizzard":1,"strength":10},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"guard-spec":2,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":146,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":3,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":116,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":82,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":1,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"guard-spec":1,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup_heal","item":"full-restore"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":113,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":79,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":4,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup_heal","item":"full-restore"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":15,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":3,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":14,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":109,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":13,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":109,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":13,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":109,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":109,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":109,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":46,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"alakazam","slot":1,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"psychic":9,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":46,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":137,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":9,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":137,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.6875,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":139,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":9,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":18,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":137,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":87,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":9,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":4,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":19,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":137,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":2},{"id":"strength","pp":14}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"max-elixir":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":24}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":155,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":14,"hail":10,"safeguard":24}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":145,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":119,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":13,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":94,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":75,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":12,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":84,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":22,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":137,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":144,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":137,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":114,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":129,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":82,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":94,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":55,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.020833333333333332,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":1,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":55,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":129,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":23,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.3958333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":89,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":9}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.3958333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":89,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":8}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":17,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":18,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":5,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":19,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"between","chain":5,"fight":"bruno","carry":{"hp":140,"max_hp":171,"status":"none","pp":{"bite":16,"surf":14,"blizzard":5,"strength":12},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":[]}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":1,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":98,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":98,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":5,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":76,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"machamp","slot":4,"fill":0.8125,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":149,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":9}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":134,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":14,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":117,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":13,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":107,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":13,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":80,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":12,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":70,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4791666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":84,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":12,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":60,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":2,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":153,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":9,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":124,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5416666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":122,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":9,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":124,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":87,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":124,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.020833333333333332,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":4,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":124,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":137,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":96,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":99,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":49,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":12}]},"foe":{"species":"lapras","slot":4,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":99,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":20,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"lapras","slot":4,"fill":0.2708333333333333,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":60,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":17,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":20,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":18,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":20,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":19,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":20,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":6,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":20,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":20,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"between","chain":6,"fight":"bruno","carry":{"hp":20,"max_hp":171,"status":"none","pp":{"bite":16,"surf":14,"blizzard":5,"strength":11},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":170,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":155,"status":"none","stages":{"spa":1,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":141,"status":"none","stages":{"spa":2,"spe":-2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":111,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":111,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":81,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":7,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":81,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":11}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":81,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":10}]},"foe":{"species":"machamp","slot":4,"fill":0.8125,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":149,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":9,"rock-tomb":10}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":81,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"machamp","slot":4,"fill":0.6041666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":8,"rock-tomb":10}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":81,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":9}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":26,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":8}]},"foe":{"species":"hitmonlee","slot":2,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":79,"foe_sleep_turns":0,"foe_pp":{"mega-kick":4,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":139,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":8}]},"foe":{"species":"hitmonlee","slot":2,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":1,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":79,"foe_sleep_turns":0,"foe_pp":{"mega-kick":4,"foresight":40,"brick-break":15,"facade":19}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":139,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":8}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":139,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"hitmonchan","slot":1,"fill":0.7291666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":96,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":14,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":6,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":139,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":6,"fight":"agatha","carry":{"hp":108,"max_hp":174,"status":"none","pp":{"bite":16,"surf":9,"blizzard":5,"strength":7},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2}},"used":["super-potion"]}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":14}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":13}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":12}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":4},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":11}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":6,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":158,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":6,"fight":"lance","carry":{"hp":158,"max_hp":174,"status":"none","pp":{"bite":13,"surf":7,"blizzard":5,"strength":7},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1}},"used":["super-potion"]}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":5,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":54,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gyarados","slot":0,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":120,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":96,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":12},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gyarados","slot":0,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":120,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"dragon-rage":7,"twister":20,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":96,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":11},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"gyarados","slot":0,"fill":0.2916666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":58,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"dragon-rage":7,"twister":20,"bite":25}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":96,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":7}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":96,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":7}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":78,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":7}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":78,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":7}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":42,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":6},{"id":"blizzard","pp":3},{"id":"strength","pp":7}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"turn","chain":6,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":125,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":10},{"id":"surf","pp":6},{"id":"blizzard","pp":3},{"id":"strength","pp":7}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":3,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"between","chain":6,"fight":"champion","carry":{"hp":125,"max_hp":177,"status":"none","pp":{"bite":10,"surf":6,"blizzard":2,"strength":7},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":3,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":3,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":1,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":142,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"guard-spec":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":109,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":4,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":75,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":3,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":75,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":75,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":75,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":7,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"alakazam","slot":1,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"psychic":9,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":7,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":2,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":161,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":24,"thrash":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":121,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":141,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":9,"bite":24,"thrash":20}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":31,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"thrash","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":83,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":9,"bite":24,"thrash":19}}}, +{"kind":"turn","chain":6,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":31,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":1,"max-elixir":1,"parlyz-heal":2,"super-potion":1,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":161,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":136,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":126,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":78,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":99,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":70,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":42,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5208333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":119,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":11,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5208333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"status_ko","item":"full-restore"},"hidden":{"foe_hp":119,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5208333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":2,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":119,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":9,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.3541666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":82,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":9,"ice-beam":9,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":7,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"between","chain":7,"fight":"bruno","carry":{"hp":150,"max_hp":171,"status":"none","pp":{"bite":18,"surf":14,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":[]}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":150,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":134,"status":"none","stages":{"spa":1,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":104,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":77,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":63,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":7,"rock-tomb":8,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":7,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":34,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":7,"fight":"agatha","carry":{"hp":34,"max_hp":174,"status":"none","pp":{"bite":18,"surf":9,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":9,"x-speed":2}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":8,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":14}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":7,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":13}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":10,"toxic":10,"double-team":13}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":10,"toxic":10,"double-team":12}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":7,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":7,"fight":"lance","carry":{"hp":148,"max_hp":174,"status":"none","pp":{"bite":15,"surf":7,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":3,"x-accuracy":3,"x-special":6,"x-speed":1}},"used":["super-potion"]}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":5,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":54,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.6666666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":95,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.6666666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"dragon-rage":7,"twister":20,"bite":25}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":95,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":95,"status":"paralysis","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":19,"outrage":15}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":95,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":4},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"thunder-wave":19,"outrage":15}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":95,"status":"paralysis","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"cure","item":"full-heal"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"thunder-wave":18,"outrage":15}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":63,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"thunder-wave":18,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":63,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":2},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":88,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":2},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":true,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":4,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":13,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":88,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":14,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":51,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":15,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"dragon-rage":10,"outrage":15}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":16,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":140,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":17,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":105,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":12}]},"foe":{"species":"dragonair","slot":1,"fill":0.7708333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":113,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":18,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":69,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":11}]},"foe":{"species":"dragonair","slot":1,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":83,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":19,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":69,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":10}]},"foe":{"species":"dragonair","slot":1,"fill":0.1875,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":29,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":20,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":69,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":9}]},"foe":{"species":"dragonair","slot":1,"fill":0.7708333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":114,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":24,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":21,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":69,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":8}]},"foe":{"species":"dragonair","slot":1,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":84,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":23,"dragon-rage":10,"outrage":14}}}, +{"kind":"turn","chain":7,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":22,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":35,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":0},{"id":"strength","pp":7}]},"foe":{"species":"dragonair","slot":1,"fill":0.3541666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":1},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":53,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":23,"dragon-rage":10,"outrage":13}}}, +{"kind":"between","chain":7,"fight":"champion","carry":{"hp":35,"max_hp":177,"status":"none","pp":{"bite":12,"surf":6,"blizzard":0,"strength":7},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":1,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"guard-spec":2,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":146,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":4,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":146,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":3,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":146,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"super-potion":2,"x-accuracy":3,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":146,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":1,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"super-potion":2,"x-accuracy":2,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":111,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"guard-spec":1,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":80,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":4,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":3,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:setup_heal","item":"full-restore"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":3,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":16,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"alakazam","slot":1,"fill":0.5833333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":4,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":86,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":19}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":144,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":3,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":104,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.6875,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":2,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":140,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":9,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":64,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.4166666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":1,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":83,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":8,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":7,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":64,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":2},{"id":"strength","pp":14}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"full-heal":1,"full-restore":2,"max-elixir":1,"super-potion":2,"x-accuracy":1,"x-special":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":24}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":161,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":134,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":89,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":14,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":62,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":75,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":13,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":62,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":32,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.3125,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":72,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":32,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":32,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":32,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":32,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"turn","chain":8,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":32,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":8,"hail":10,"dive":10}}}, +{"kind":"between","chain":8,"fight":"bruno","carry":{"hp":32,"max_hp":171,"status":"none","pp":{"bite":17,"surf":14,"blizzard":5,"strength":15},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":142,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":115,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":72,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":7,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":72,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":9,"rock-tomb":10}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"machamp","slot":4,"fill":0.8125,"status":"none","sleep_min_left":0,"stages":{"atk":1,"def":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"kill_order","move_slot":0},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":19,"scary-face":9,"rock-tomb":10}}}, +{"kind":"turn","chain":8,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{"spa":2,"spe":-3},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"machamp","slot":4,"fill":0.6458333333333334,"status":"none","sleep_min_left":0,"stages":{"atk":1,"def":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":3,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":120,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":19,"scary-face":8,"rock-tomb":10}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":171,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":15,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":10,"safeguard":25}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":161,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":4},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":14,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":25}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":151,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":3},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":13,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":125,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":2},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":12,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":9,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":25},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"hail","weather_turns":1},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":171,"foe_sleep_turns":0,"foe_pp":{"ice-beam":8,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":24},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"dewgong","slot":0,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":77,"foe_sleep_turns":0,"foe_pp":{"ice-beam":8,"surf":15,"hail":9,"safeguard":24}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":100,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":23},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":220,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":15}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":69,"status":"paralysis","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":2,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":14}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":37,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"lapras","slot":4,"fill":0.5625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":128,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":13}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":10,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":5,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5416666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":8,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":123,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":12}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":11,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":140,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":14}]},"foe":{"species":"lapras","slot":4,"fill":0.5416666666666666,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":1,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":123,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":11}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":12,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":110,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"lapras","slot":4,"fill":0.3541666666666667,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":82,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"ice-beam":10,"surf":15,"body-slam":10}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":13,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":110,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"slowbro","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":176,"foe_sleep_turns":0,"foe_pp":{"ice-beam":10,"surf":15,"amnesia":20,"yawn":10}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":14,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":110,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"jynx","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"ice-punch":15,"double-slap":10,"lovely-kiss":10,"attract":15}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":15,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":110,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":10,"hail":10,"dive":10}}}, +{"kind":"turn","chain":9,"fight":"lorelei","trainer":"TRAINER_ELITE_FOUR_LORELEI","turn":16,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":110,"status":"none","stages":{"spa":4},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"cloyster","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":127,"foe_sleep_turns":0,"foe_pp":{"spikes":20,"protect":9,"hail":10,"dive":10}}}, +{"kind":"between","chain":9,"fight":"bruno","carry":{"hp":110,"max_hp":171,"status":"none","pp":{"bite":18,"surf":14,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":6,"x-accuracy":3,"x-special":11,"x-speed":5}},"used":["super-potion"]}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":1,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":160,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":11,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":10,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":2,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":146,"status":"none","stages":{"spa":1,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":10,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":10,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":3,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":93,"status":"none","stages":{"spa":2,"spe":-1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":5},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":9,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":4,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":65,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":4},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":8,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":5,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":14},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":112,"foe_sleep_turns":0,"foe_pp":{"earthquake":7,"rock-tomb":9,"iron-tail":15,"roar":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":6,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":13},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"machamp","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":183,"foe_sleep_turns":0,"foe_pp":{"cross-chop":5,"bulk-up":20,"scary-face":10,"rock-tomb":10}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":7,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":12},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonlee","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"mega-kick":5,"foresight":40,"brick-break":15,"facade":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":8,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":11},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"hitmonchan","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":131,"foe_sleep_turns":0,"foe_pp":{"sky-uppercut":15,"mach-punch":30,"rock-tomb":10,"counter":20}}}, +{"kind":"turn","chain":9,"fight":"bruno","trainer":"TRAINER_ELITE_FOUR_BRUNO","turn":9,"own":{"species":"blastoise","level":54,"stats":{"hp":171,"atk":104,"def":134,"spa":118,"spd":149,"spe":117},"hp":35,"status":"none","stages":{"spa":2,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":10},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"onix","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":118,"foe_sleep_turns":0,"foe_pp":{"double-edge":15,"earthquake":10,"iron-tail":15,"sand-tomb":15}}}, +{"kind":"between","chain":9,"fight":"agatha","carry":{"hp":35,"max_hp":174,"status":"none","pp":{"bite":18,"surf":9,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":5,"x-accuracy":3,"x-special":9,"x-speed":3}},"used":["super-potion","super-potion","super-potion"]}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":9,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":15}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":8,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":20,"confuse-ray":10,"toxic":10,"double-team":14}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":1},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":7,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":10,"toxic":10,"double-team":14}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"spa":3},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":2},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":3},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":10,"toxic":10,"double-team":13}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":18},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{"evasion":3},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":145,"foe_sleep_turns":0,"foe_pp":{"shadow-punch":19,"confuse-ray":10,"toxic":10,"double-team":12}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":9},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"arbok","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":150,"foe_sleep_turns":0,"foe_pp":{"sludge-bomb":10,"screech":40,"iron-tail":15,"bite":25}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":17},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gengar","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":155,"foe_sleep_turns":0,"foe_pp":{"shadow-ball":15,"sludge-bomb":10,"hypnosis":20,"nightmare":15}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":16},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"haunter","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":126,"foe_sleep_turns":0,"foe_pp":{"hypnosis":20,"dream-eater":15,"curse":10,"mean-look":5}}}, +{"kind":"turn","chain":9,"fight":"agatha","trainer":"TRAINER_ELITE_FOUR_AGATHA","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":148,"status":"none","stages":{"atk":-1,"spa":3,"spe":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":8},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"golbat","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":161,"foe_sleep_turns":0,"foe_pp":{"confuse-ray":10,"poison-fang":15,"air-cutter":25,"bite":25}}}, +{"kind":"between","chain":9,"fight":"lance","carry":{"hp":148,"max_hp":174,"status":"none","pp":{"bite":15,"surf":7,"blizzard":5,"strength":13},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":2,"x-accuracy":3,"x-special":6,"x-speed":2}},"used":["super-potion"]}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":1,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":174,"status":"none","stages":{"atk":-1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":6,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":10,"twister":20,"bite":25}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":2,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":1},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":5,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":9,"twister":20,"bite":25}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":3,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":94,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":15},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":189,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":25}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":4,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":78,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.6458333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":7,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":123,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":8,"twister":20,"bite":24}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":5,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":14},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.6458333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":123,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":24}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":6,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":7},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"gyarados","slot":0,"fill":0.3125,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":62,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"dragon-rage":7,"twister":20,"bite":24}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":7,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":5},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":20,"outrage":15}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":8,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":134,"status":"paralysis","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":4},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"parlyz-heal":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"cure","item":"parlyz-heal"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":19,"outrage":15}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":9,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":4},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"thunder-wave":19,"outrage":14}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":10,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":3},{"id":"strength","pp":13}]},"foe":{"species":"dragonite","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":197,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"outrage":15,"wing-attack":35}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":11,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":99,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":6},{"id":"blizzard","pp":2},{"id":"strength","pp":13}]},"foe":{"species":"aerodactyl","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":1},"hidden":{"foe_hp":178,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"ancient-power":5,"wing-attack":35,"scary-face":10}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":12,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":61,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":5},{"id":"blizzard","pp":2},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":10,"outrage":15}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":13,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":21,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":5},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":6,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":9,"outrage":15}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":14,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":141,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":5},{"id":"blizzard","pp":1},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"outrage","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":1,"choice":{"row":"plan:move","move_slot":2},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":9,"outrage":14}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":15,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":109,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":5},{"id":"blizzard","pp":0},{"id":"strength","pp":13}]},"foe":{"species":"dragonair","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":146,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":9,"outrage":14}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":16,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":109,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":5},{"id":"blizzard","pp":0},{"id":"strength","pp":12}]},"foe":{"species":"dragonair","slot":1,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:move","move_slot":3},"hidden":{"foe_hp":93,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":9,"outrage":14}}}, +{"kind":"turn","chain":9,"fight":"lance","trainer":"TRAINER_ELITE_FOUR_LANCE","turn":17,"own":{"species":"blastoise","level":55,"stats":{"hp":174,"atk":105,"def":137,"spa":120,"spd":153,"spe":119},"hp":109,"status":"none","stages":{"atk":-1,"spa":2},"mist_turns":0,"moves":[{"id":"bite","pp":13},{"id":"surf","pp":5},{"id":"blizzard","pp":0},{"id":"strength","pp":11}]},"foe":{"species":"dragonair","slot":1,"fill":0.25,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":38,"foe_sleep_turns":0,"foe_pp":{"hyper-beam":5,"safeguard":25,"dragon-rage":9,"outrage":14}}}, +{"kind":"between","chain":9,"fight":"champion","carry":{"hp":109,"max_hp":177,"status":"none","pp":{"bite":12,"surf":5,"blizzard":0,"strength":11},"full_pp":{"bite":25,"surf":15,"blizzard":5,"strength":15},"bag":{"antidote":1,"elixir":1,"full-heal":2,"full-restore":5,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2}},"used":["full-restore","elixir"]}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":1,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":177,"status":"none","stages":{},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"guard-spec":2,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":20,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":2,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{},"mist_turns":4,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"guard-spec":1,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":4,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":15,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":3,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":1},"mist_turns":3,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"guard-spec":1,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":3,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-special"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":14,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":4,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2},"mist_turns":2,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"guard-spec":1,"max-elixir":1,"super-potion":1,"x-accuracy":3,"x-special":2,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":13,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":5,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"accuracy":1},"mist_turns":1,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"guard-spec":1,"max-elixir":1,"super-potion":1,"x-accuracy":2,"x-special":2,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-accuracy"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":12,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":6,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":145,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"guard-spec":1,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"guard-spec"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":19,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":7,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":113,"status":"none","stages":{"spa":2,"accuracy":2},"mist_turns":4,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":2},"streak":0,"choice":{"row":"plan:setup","item":"x-speed"},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":18,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":8,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":82,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":3,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":5},{"id":"strength","pp":15}]},"foe":{"species":"pidgeot","slot":0,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":6,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":185,"foe_sleep_turns":0,"foe_pp":{"aerial-ace":17,"feather-dance":15,"sand-attack":11,"whirlwind":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":9,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":82,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":2,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":4},{"id":"strength","pp":15}]},"foe":{"species":"venusaur","slot":5,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":5,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":193,"foe_sleep_turns":0,"foe_pp":{"solar-beam":10,"synthesis":5,"sunny-day":5,"growth":40}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":10,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":82,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":1,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":15},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"rhydon","slot":2,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":4,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":211,"foe_sleep_turns":0,"foe_pp":{"take-down":20,"earthquake":10,"rock-tomb":10,"scary-face":10}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":11,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":82,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":15}]},"foe":{"species":"alakazam","slot":1,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"kill_order","move_slot":3},"hidden":{"foe_hp":147,"foe_sleep_turns":0,"foe_pp":{"psychic":10,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":12,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":24,"status":"none","stages":{"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":22},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"alakazam","slot":1,"fill":0.625,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":3,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":0},"hidden":{"foe_hp":92,"foe_sleep_turns":0,"foe_pp":{"psychic":9,"future-sight":15,"recover":20,"reflect":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":13,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":24,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":4,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"ko_heal","item":"full-restore"},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":20}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":14,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":21},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":"thrash","reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":1,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":15,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":20},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.7083333333333334,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"plan:move","move_slot":0},"hidden":{"foe_hp":144,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":16,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-1,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":3},{"id":"strength","pp":14}]},"foe":{"species":"gyarados","slot":3,"fill":0.4375,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":2,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":2},"hidden":{"foe_hp":91,"foe_sleep_turns":0,"foe_pp":{"hydro-pump":5,"dragon-rage":10,"bite":25,"thrash":19}}}, +{"kind":"turn","chain":9,"fight":"champion","trainer":"TRAINER_CHAMPION_FIRST_BULBASAUR","turn":17,"own":{"species":"blastoise","level":56,"stats":{"hp":177,"atk":106,"def":140,"spa":123,"spd":157,"spe":121},"hp":134,"status":"none","stages":{"atk":-2,"spa":2,"spe":1,"accuracy":2},"mist_turns":0,"moves":[{"id":"bite","pp":19},{"id":"surf","pp":14},{"id":"blizzard","pp":2},{"id":"strength","pp":14}]},"foe":{"species":"arcanine","slot":4,"fill":1.0,"status":"none","sleep_min_left":0,"stages":{},"recharging":false,"charging":null,"reflect_turns":0,"light_screen_turns":0},"field":{"weather":"none","weather_turns":0},"trainer_state":{"foes_left":1,"full_restores_used":0},"bag":{"antidote":1,"full-heal":2,"full-restore":3,"max-elixir":1,"super-potion":1,"x-accuracy":1,"x-special":2,"x-speed":1},"streak":0,"choice":{"row":"sure_ko","move_slot":1},"hidden":{"foe_hp":199,"foe_sleep_turns":0,"foe_pp":{"extreme-speed":5,"flamethrower":15,"roar":20,"bite":25}}} +]} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-plan.json new file mode 100644 index 0000000000..91a6b5cd0c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-league-plan.json @@ -0,0 +1,100 @@ +{ + "format": "frlg-league-plan/1", + "fights": { + "lorelei": { + "foes": [ + {"species": "dewgong", "moves": ["bite", "surf"], "setup": [{"item": "xspecial", "stage": 4, "serves": "bite"}]}, + {"species": "cloyster", "moves": ["bite", "surf"], "setup": []}, + {"species": "slowbro", "moves": ["bite", "surf"], "setup": []}, + {"species": "jynx", "moves": ["bite", "surf", "strength"], "setup": []}, + {"species": "lapras", "moves": ["bite", "strength"], "setup": []} + ], + "between": {}, + "reserve": { + "pp": {"blizzard": 5}, + "items": {"xspecial": 9, "xspeed": 3, "xaccuracy": 2, "guardspec": 1, "fullrestore": 6, "maxelixir": 1} + } + }, + "bruno": { + "foes": [ + { + "species": "onix", + "moves": ["surf"], + "setup": [ + {"item": "xspecial", "stage": 2, "serves": "surf"}, + {"item": "xspeed", "stage": 1, "serves": "surf"} + ] + }, + {"species": "hitmonchan", "moves": ["surf", "blizzard"], "setup": []}, + {"species": "hitmonlee", "moves": ["surf", "strength"], "setup": []}, + {"species": "onix", "moves": ["surf"], "setup": []}, + {"species": "machamp", "moves": ["surf", "strength"], "setup": []} + ], + "between": {"hp": 0.8, "pp": {"surf": 8}}, + "reserve": { + "pp": {"blizzard": 5}, + "items": {"xspecial": 7, "xspeed": 2, "xaccuracy": 2, "guardspec": 1, "fullrestore": 5, "maxelixir": 1} + } + }, + "agatha": { + "foes": [ + { + "species": "gengar", + "moves": ["bite", "surf"], + "setup": [ + {"item": "xspecial", "stage": 3, "serves": "bite"}, + {"item": "xspeed", "stage": 1, "serves": "bite"} + ] + }, + {"species": "golbat", "moves": ["surf", "bite"], "setup": []}, + {"species": "haunter", "moves": ["bite", "surf"], "setup": []}, + {"species": "arbok", "moves": ["surf", "bite"], "setup": []}, + {"species": "gengar", "moves": ["bite", "surf"], "setup": []} + ], + "between": {"hp": 0.8, "pp": {"surf": 6}}, + "reserve": { + "pp": {"blizzard": 5}, + "items": {"xspecial": 4, "xspeed": 1, "xaccuracy": 2, "guardspec": 1, "fullrestore": 4, "maxelixir": 1} + } + }, + "lance": { + "foes": [ + { + "species": "gyarados", + "moves": ["bite", "surf"], + "setup": [{"item": "xspecial", "stage": 2, "serves": "blizzard"}] + }, + {"species": "dragonair", "moves": ["blizzard", "strength"], "setup": []}, + {"species": "dragonair", "moves": ["blizzard", "strength"], "setup": []}, + {"species": "aerodactyl", "moves": ["surf"], "setup": []}, + {"species": "dragonite", "moves": ["blizzard", "bite"], "setup": []} + ], + "between": {"hp": 1.0, "pp": {"surf": 4, "blizzard": 4}}, + "reserve": { + "pp": {}, + "items": {"xspecial": 2, "xspeed": 1, "xaccuracy": 2, "guardspec": 1, "fullrestore": 2, "maxelixir": 1} + } + }, + "champion": { + "foes": [ + { + "species": "pidgeot", + "moves": ["surf"], + "setup": [ + {"item": "guardspec", "stage": 1}, + {"item": "xspecial", "stage": 2, "serves": "blizzard"}, + {"item": "xaccuracy", "stage": 2, "serves": "blizzard"}, + {"item": "xspeed", "stage": 1, "serves": "blizzard"} + ] + }, + {"species": "alakazam", "moves": ["bite", "surf"], "setup": []}, + {"species": "rhydon", "moves": ["surf"], "setup": []}, + {"species": "gyarados", "moves": ["bite", "surf"], "setup": []}, + {"species": "arcanine", "moves": ["surf"], "setup": []}, + {"species": "venusaur", "moves": ["blizzard"], "setup": []} + ], + "between": {"hp": 1.0, "pp": {"surf": 8, "blizzard": 4}}, + "reserve": {"pp": {}, "items": {}} + } + } +} diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 2cb35cb748..6275686416 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1722,6 +1722,9 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/AutoStory/Types/Pokemon_StoryBreakpoints.h Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.cpp Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h + Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.cpp + Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel_Tests.h + Source/Pokemon/AutoStory/Types/Pokemon_StoryLevelCheck.h Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckpoint.h Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckpointGates.cpp Source/Pokemon/AutoStory/Types/Pokemon_StoryCheckpointMetadata.cpp @@ -2052,6 +2055,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BikeSpinMechanics.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BikeSpinPresses.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_BoulderPushReader.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_CodedRooms.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_CodedRooms.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_FlyMap.cpp @@ -2065,6 +2070,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBike_Tests.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldHeldInPlace.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldHeldInPlace.h @@ -2107,6 +2113,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldStairs_Tests.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimScreens.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteCosts.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRouteSteps.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldStepChecks.h @@ -2127,6 +2134,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkOptions.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkTimes.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalkWatches.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpBattle.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWildTiles.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h @@ -2152,6 +2160,9 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleBag_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData_Tests.cpp @@ -2161,7 +2172,12 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicyData.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleSwitch.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleText.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureConsole.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureRun.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureStep.h @@ -2169,6 +2185,14 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFoes.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBattle_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTrack_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimBudget.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepLint_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepLint_Tests.h @@ -2188,11 +2212,25 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMansion_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulderPresses.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeague_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueBudget.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueParity_Tests.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlan_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeaguePlanData.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueFightData.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeagueSteps.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows13_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp @@ -2200,6 +2238,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleRisk.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleTurns.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckLevel_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCheckpoints.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -2227,6 +2267,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGameArgs.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGen3Damage.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGrind.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHealing.cpp @@ -2245,6 +2287,14 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPocketList.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedPolicy_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedRisk.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedState.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlannedBetween.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGenderMenu.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGenderMenu.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItems_Tests.cpp @@ -2255,10 +2305,15 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFailureClasses_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRockTunnel_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLaunch.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLaunch.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLaunch_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLaunch_Tests.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLeadOut_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTower_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySnorlax_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPartyRoster_Tests.cpp @@ -2276,6 +2331,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMart_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMember.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedBoulders.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedTrainers.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMovedTrainers.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPacedRoute.cpp @@ -2288,6 +2345,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryIntro.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocket.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemsPocketChange.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLevelUps.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMemberInfo.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMoveData.h @@ -2352,6 +2411,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartFrameStore.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenu.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenu.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStartMenuOpening.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldMoveUsers.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldMoveUsers.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPartyRoster.cpp @@ -2381,6 +2442,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/LegacyJsonFormat.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySupplies.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h