From 858676f24f29ccde88b3a8beaeb5937a2bf7dd4f Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 20:43:29 -0800 Subject: [PATCH 1/6] PokemonFRLG: S12, Fuchsia Gym and Koga (12.01, 12.02) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Menus/PokemonFRLG_SaveCardReader.cpp | 1 + .../Overworld/PokemonFRLG_OverworldMaps.cpp | 4 + .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 1 + .../PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp | 211 ++++++++++++++++++ .../PokemonFRLG_AutoStoryRows_Tests.h | 12 + .../PokemonFRLG_AutoStoryRunPlan_Tests.cpp | 8 +- .../PokemonFRLG_AutoStorySimulation_Tests.cpp | 7 +- .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 12 +- .../AutoStory/StoryData/frlg-12.01.plan.json | 125 +++++++++++ .../AutoStory/StoryData/frlg-12.02.plan.json | 83 +++++++ SerialPrograms/cmake/SourceFiles.cmake | 1 + 12 files changed, 457 insertions(+), 9 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp index 3933913e12..56aadd3bf0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp @@ -80,6 +80,7 @@ class PlaceNameMatcher : public OCR::SmallDictionaryMatcher{ {"vermilion-city", "Vermilion City"}, {"celadon-city", "Celadon City"}, {"rocket-hideout", "Rocket Hideout"}, + {"fuchsia-city", "Fuchsia City"}, }){ JsonArray names; names.push_back(std::string(name)); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index f6d168d32a..d22d14caee 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -99,6 +99,10 @@ constexpr std::string_view MAP_NAMES[] = { "RocketHideout_B2F", "RocketHideout_B3F", "RocketHideout_B4F", + // Fuchsia City's Center, Koga's gym and the Warden's house. + "FuchsiaCity", + "FuchsiaCity_Gym", + "FuchsiaCity_WardensHouse", "CeruleanCave_1F", "CeruleanCave_2F", "CeruleanCave_B1F", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index a3511b6d22..a6c3e12312 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -326,6 +326,7 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryVermilion(database); add_tests_AutoStoryVermilionGym(database); add_tests_AutoStoryCeladon(database); + add_tests_AutoStoryFuchsiaGym(database); } void add_tests(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index fff6d558f3..43db6a5a9c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -357,6 +357,7 @@ std::string save_card_place(const std::string& map){ {"LavenderTown", "lavender-town"}, {"CeladonCity", "celadon-city"}, {"RocketHideout", "rocket-hideout"}, + {"FuchsiaCity", "fuchsia-city"}, }; for (const auto& [prefix, place] : PLACES){ if (map == prefix || map.rfind(prefix + "_", 0) == 0){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp new file mode 100644 index 0000000000..04f5894815 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp @@ -0,0 +1,211 @@ +/* AutoStory Fuchsia Gym Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Rows 12.01 and 12.02 (StoryData/frlg-12.01.plan.json, 12.02) on the + * overworld sim: from Fly's landing in Fuchsia to the nurse, into the + * gym past Juggler Kirk and round its top edge to west of Koga; and from + * Koga out to the Warden and back to the nurse. And the lead's attacks + * against Kirk's and Koga's parties. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryRooms.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +const std::string GYM = "FuchsiaCity_Gym"; + +struct AutoStoryFuchsiaGymInput{ + std::string name; + std::function body; +}; + +struct AutoStoryFuchsiaGymExpectation{ + std::string_view description; +}; + +struct AutoStoryFuchsiaGymCase{ + AutoStoryFuchsiaGymInput input; + AutoStoryFuchsiaGymExpectation expectation; +}; + +class Test_AutoStoryFuchsiaGym : public UnitTest{ +public: + explicit Test_AutoStoryFuchsiaGym(AutoStoryFuchsiaGymCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - Simulation: {}", test_case.input.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + return m_case.input.body(); + }catch (Exception& e){ + return std::format("{}: {}", e.name(), e.message()); + } + } + +private: + AutoStoryFuchsiaGymCase m_case; +}; + +const StoryCheckpoint& checkpoint(std::string_view id){ + for (const StoryCheckpoint& row : story_checkpoints()){ + if (row.id == id){ + return row; + } + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No checkpoint {}.", id)); +} + +// The rows on the sim, which can't walk into a Center with no map. Kept +// across sims: the trainers fought. +struct GymWalk{ + StoryPose at; + std::optional sim; + std::vector fought; + + explicit GymWalk(StoryPose start) + : at(std::move(start)) + { + place(); + } + // A fresh sim on `at`, after a step it can't walk. + void place(){ + if (sim){ + const std::vector& beaten = sim->state().trainers_beaten; + fought.insert(fought.end(), beaten.begin(), beaten.end()); + } + sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + } + std::vector all_fought() const{ + std::vector all = fought; + const std::vector& beaten = sim->state().trainers_beaten; + all.insert(all.end(), beaten.begin(), beaten.end()); + return all; + } +}; + +// A step of a row on the sim: row_step_on_sim(), but the way into a +// Center, which has no map, and Koga's battle, which a talk starts, leave +// the player where the table says. +std::string gym_step_on_sim(const StoryStep& step, const std::string& id, GymWalk& walk){ + const bool center = step.action == CENTER_ENTER_VARIANT; + if (center || (step.kind == StoryStepKind::BATTLE && step.name == "koga")){ + walk.at = *story_pose(Pokemon::pose_of(*step.pose_after)); + if (center){ + walk.place(); + } + return ""; + } + return row_step_on_sim(*walk.sim, walk.at, step, id); +} + +// Row `id`'s steps on the sim from `walk.at`: the failure, or empty. +std::string row_on_sim(std::string_view id, GymWalk& walk){ + const StoryCheckpoint& row = checkpoint(id); + for (const StoryStep& step : row.steps){ + if (const std::string failure = gym_step_on_sim(step, row.id, walk); !failure.empty()){ + return std::format("{}: ended on {}; {}", id, to_string(walk.sim->state().position), failure); + } + if (!walk.sim->state().violations.empty()){ + return std::format("{}/{}: a violation on the way: {}", id, step.name, walk.sim->state().violations.back()); + } + } + return ""; +} + +// 12.01 from Fly's landing: the nurse, the gym, Kirk fought from (14, 11), +// round the top edge to west of Koga, where 12.02 starts; then 12.02 from +// there to the Warden and the nurse, meeting no one else. +UnitTestResult test_gym_rows(){ + GymWalk walk(*story_pose(Pokemon::pose_of(*checkpoint("12.01").start))); + if (const std::string failure = row_on_sim("12.01", walk); !failure.empty()){ + return failure; + } + const MapPosition west_of_koga{GYM, {6, 13}}; + if (!(walk.sim->state().position == west_of_koga) || walk.sim->state().facing != Direction::EAST){ + return std::format("12.01: ended on {}, not west of Koga {} facing east.", to_string(walk.sim->state().position), to_string(west_of_koga)); + } + if (walk.all_fought() != std::vector{"rocker"}){ + return std::format("12.01: fought {} trainers, not Kirk alone.", walk.all_fought().size()); + } + const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("12.02").start)); + if (next.map != GYM || !(next.tile == west_of_koga.point)){ + return "12.02 doesn't start where 12.01 ends."; + } + if (const std::string failure = row_on_sim("12.02", walk); !failure.empty()){ + return failure; + } + if (walk.all_fought().size() != 1){ + return "12.02: fought a trainer after Koga."; + } + if (walk.at.map != "FuchsiaCity_PokemonCenter_1F"){ + return std::format("12.02: ended on {}, not at Fuchsia's nurse.", walk.at.map); + } + return true; +} + +// The lead as pokeguy brings it to the gym after HM03 (12.01): Surf over +// Water Gun, Water Pulse, Bite, Mega Kick. It picks Surf against Kirk's +// Psychic types and Koga's Poison types (pokeguy: Surf throughout). +UnitTestResult test_lead_moves_in_gym(){ + PartyMember lead; + lead.species = "blastoise"; + lead.moves_read = true; + lead.level = 39; + lead.moves = {{"surf", 15}, {"water-pulse", 20}, {"bite", 25}, {"mega-kick", 5}}; + for (std::string_view foe : {"drowzee", "kadabra", "koffing", "muk", "weezing"}){ + if (attack_slot_against(lead, {std::string(foe)}) != 0){ + return std::format("Against {}: expected Surf.", foe); + } + } + return true; +} + +const AutoStoryFuchsiaGymCase AUTO_STORY_FUCHSIA_GYM_CASES[] = { + { + .input = {.name = "12.01 past Kirk to west of Koga and 12.02 to the Warden and the nurse", .body = test_gym_rows}, + .expectation = {.description = "Kirk fought where the table steps into his line, no one else; ends at Fuchsia's nurse"}, + }, + { + .input = {.name = "the lead's attacks in Fuchsia Gym", .body = test_lead_moves_in_gym}, + .expectation = {.description = "Surf against Kirk's and Koga's Pokemon"}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryFuchsiaGym(UnitTestDatabase& database){ + for (const auto& item : AUTO_STORY_FUCHSIA_GYM_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h index 6b15acaab2..f4de691d69 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -10,6 +10,7 @@ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H #define PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H +#include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" namespace PokemonAutomation{ @@ -26,6 +27,17 @@ void add_tests_AutoStoryVermilionGym(UnitTestDatabase& database); void add_tests_AutoStoryCeladon(UnitTestDatabase& database); // Rows from 08.01 on on the overworld sim (PokemonFRLG_AutoStoryLavender_Tests.cpp). void add_tests_AutoStoryLavender(UnitTestDatabase& database); +// Rows 12.01 and 12.02, Fuchsia Gym, on the overworld sim (PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp). +void add_tests_AutoStoryFuchsiaGym(UnitTestDatabase& database); + +// Whether checkpoint `id` was authored before the rows that lead up to it: +// it starts from its own declared pose, not where the row before it in +// the table ends. 12.01 starts from Fly's landing in Fuchsia, after the +// Safari Zone (11.02); segments 10 and 11 are authored separately. An id leaves +// this list once the rows before it are in. +inline bool starts_after_unauthored_rows(std::string_view id){ + return id == "12.01"; +} } // namespace PokemonFRLG 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 1bfb846f94..c51bfab90f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp @@ -139,7 +139,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"; +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 12.01 12.02"; const RunPlanScenario RUN_PLAN_CASES[] = { { @@ -230,11 +230,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"}, + .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 12.01 12.02"}, }, { .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"}, + .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 12.01 12.02"}, }, { .input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman", @@ -259,7 +259,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"}, + .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 12.01 12.02"}, }, { .input = { .name = "Starter RNG first, with both on", 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 6a3d5e0278..dc4c899f6c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp @@ -36,6 +36,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryPaceSim.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -224,9 +225,13 @@ UnitTestResult test_whole_story(){ if (sim.begun() != ids || sim.saves.size() != ids.size()){ return "Expected each checkpoint once, in order, each saving at its end:" + joined(sim.game.trace); } - // Each checkpoint starts where the save before it stands. + // Each checkpoint starts where the save before it stands, but one + // authored before the rows that lead up to it. for (size_t c = 1; c < sim.rows.size(); c++){ const StoryCheckpoint& data = sim.rows[c]; + if (starts_after_unauthored_rows(data.id)){ + continue; + } const std::optional start = story_pose(*start_pose(data)); const std::optional saved = story_pose(sim.saves[c - 1].second); const bool same = start && saved && start->map == saved->map && start->tile == saved->tile 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 0a5f768539..0878014331 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -32,6 +32,7 @@ #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryPcStorage.h" #include "PokemonFRLG_AutoStoryPlanGolden.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryMoveData.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -275,16 +276,19 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po } // Plans every route of the story, each checkpoint from where the one -// before leaves the player, and adds the plans to `golden`. +// before leaves the player (or, past rows not authored yet, from its own +// 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() != 39 || checkpoints[0].start){ - return "Expected 39 checkpoints, the first from a new game."; + if (checkpoints.size() != 41 || checkpoints[0].start){ + return "Expected 41 checkpoints, the first from a new game."; } StoryPose pose; for (size_t c = 0; c < checkpoints.size(); c++){ const StoryCheckpoint& checkpoint = checkpoints[c]; - if (c > 0){ + if (c > 0 && starts_after_unauthored_rows(checkpoint.id)){ + pose = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); + }else if (c > 0){ const StoryPose start = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); const bool same_facing = !start.facing || start.facing == pose.facing; if (start.map != pose.map || !(start.tile == pose.tile) || !same_facing){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json new file mode 100644 index 0000000000..006dbb6def --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json @@ -0,0 +1,125 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "12.01", + "title": "Fuchsia: heal, HM03 Surf over Water Gun, the gym past Juggler Kirk and round the top edge to west of Koga", + "start": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "south"}, + "events": [ + { + "id": "below_center_door", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "north"} + }, + "why": "Fly's landing on Fuchsia's heal spot (25, 32) (pokefirered heal_locations.json, HEAL_LOCATION_FUCHSIA_CITY) is below the Center's door (25, 31): turn to it" + }, + { + "id": "fuchsia_nurse", + "kind": "game_action", + "action": "center_enter", + "declared_after": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "why": "the Center script in: through the door and up to the nurse; no map of the Center" + }, + { + "id": "heal_fuchsia", + "kind": "heal", + "why": "full HP and PP (pokeguy uses an Oran Berry in the gym instead, 1:14:38; healing is the safe side)" + }, + { + "id": "teach_surf", + "kind": "game_action", + "action": "teach", + "args": { + "item": "hm03", + "move": "surf", + "slot": 1, + "forget": "water-gun" + }, + "why": "HM03 Surf in place of Water Gun, as pokeguy (1:14:55 to 1:15:13: Surf, Water Pulse, Bite, Mega Kick after it), unless the lead knows it; an HM, so not a one-shot TM" + }, + { + "id": "gym_east_wall", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "FuchsiaCity_Gym", "tiles": [[14, 21]], "facing": "north"} + }, + "why": "out of the Center, west along row 32 to the gym's door (9, 32), and in the gym (no running) from the mat (7, 21) east along row 21 to the east wall: below Rocker Kayden's south line (12, 17..20) and Nate's (2, 17..20)" + }, + { + "id": "east_column_to_kirk", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 9}] + }, + "why": "up column 14 from (14, 21) to (14, 12), a tile below Juggler Kirk's line (12..14, 11): it crosses Kayden's east line (13..14, 16) when he looks east (he looks south and east); pokeguy passed him (1:15:14)" + }, + { + "id": "kirk_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (14, 11), the end of Kirk's line (sight 3, facing east): he walks east to (13, 11) (pokeguy 1:15:14)" + }, + { + "id": "kirk", + "kind": "battle", + "args": { + "trainer": "TRAINER_JUGGLER_KIRK", + "foes": ["drowzee", "drowzee", "kadabra", "drowzee"] + }, + "declared_after": {"map": "FuchsiaCity_Gym", "tiles": [[14, 11]], "facing": "north"}, + "why": "Juggler Kirk (TRAINER_JUGGLER_KIRK): Drowzee, Drowzee, Kadabra, Drowzee, all Lv31 (pokeguy: one Surf each, 1:15:14 to 1:16:17)" + }, + { + "id": "east_column_to_wall", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "north", "tiles": 9}] + }, + "why": "up column 14 from (14, 11) to the wall at (14, 2): past Tamer Edgar's east line (14, 4) when he looks east (he looks every way), on a leg the wall stops" + }, + { + "id": "top_row_to_wall", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "west", "tiles": 14}] + }, + "why": "west along row 2 to the wall at (0, 2), the gym's top edge (pokeguy's invisible-wall corridor, 1:16:18): past Edgar's north line (13, 2..3) when he looks north, on a leg the wall stops" + }, + { + "id": "west_of_koga", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "FuchsiaCity_Gym", "tiles": [[6, 13]], "facing": "east"} + }, + "why": "back east along row 2 to column 8, down columns 8..10 to row 10, west along it to (2, 10), round Rocker Shawn (2, 9), who looks west at (1, 9) only, and into the middle box by row 12 to west of Koga (7, 13), facing him: out of Tamer Phil's lines round (4, 6) (pokeguy approaches Koga from the west, 1:16:33)" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts from the pose Fly leaves the player on, Fuchsia's heal spot (25, 32) facing south: 11.02 (the Safari Zone, HM03 SURF and the GOLD TEETH) ends with a Fly to Fuchsia and is authored separately; until it is in, this row's start is its own (starts_after_unauthored_rows()).", + "PokeGuy's way (1:14:38 to 1:16:33): into the gym, Surf taught over Water Gun, Juggler Kirk fought (forced), round the top edge, Koga from the west. He fights nobody else.", + "The gym (FuchsiaCity_Gym map.json), 15 x 23, no running, its invisible walls in the map: Koga (7, 13) in the middle box, entered only from row 12 on the west. Its trainers and lines: Kayden (12, 16) south and east 4, Shawn (2, 9) west 1, Kirk (11, 11) east 3, Edgar (13, 4) every way 2, Phil (4, 6) every way 2, Nate (2, 16) south 4. Every way north crosses Kirk's line and one of Kayden's and Edgar's; the legs across a looker's line end on walls.", + "Ends west of Koga and saves there: his own pre-battle checkpoint (battle-checkpoint-retry), 12.02. Koga is a D7 fight: pokeguy entered at 34/122 HP and the PokemonSimulation benchmark wins 70.1% from that; this row enters at full HP and PP after the Center (the full-heal comparison is still pending there)." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "FuchsiaCity_Gym", "tiles": [[6, 13]], "facing": "east"} + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json new file mode 100644 index 0000000000..ec206fc166 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json @@ -0,0 +1,83 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "12.02", + "title": "Koga, the SOULBADGE; the GOLD TEETH to the Warden for HM04 STRENGTH; heal at Fuchsia's Center", + "start": {"map": "FuchsiaCity_Gym", "tiles": [[6, 13]], "facing": "east"}, + "events": [ + { + "id": "challenge_koga", + "kind": "talk", + "why": "Koga (7, 13)" + }, + { + "id": "koga", + "kind": "battle", + "args": { + "trainer": "TRAINER_LEADER_KOGA", + "foes": ["koffing", "muk", "koffing", "weezing"] + }, + "declared_after": {"map": "FuchsiaCity_Gym", "tiles": [[6, 13]], "facing": "east"}, + "why": "Koga (TRAINER_LEADER_KOGA): Koffing Lv37, Muk Lv39, Koffing Lv37, Weezing Lv43 (pokeguy: Surf, two on Muk through Minimize, Weezing at 4 HP, 1:16:34 to 1:18:03); then the SOULBADGE and TM06 Toxic, read to the overworld with the battle's text" + }, + { + "id": "below_warden", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "FuchsiaCity_WardensHouse", "tiles": [[3, 6]], "facing": "north"} + }, + "why": "out of the gym by the way in, Koga's win having beaten every gym trainer (FuchsiaCity_Gym_EventScript_DefeatedKoga, set_gym_trainers 5); east along the city's south row to the Warden's door (33, 31) and up to below the Warden (3, 5) (pokeguy 1:18:04 to 1:18:24)" + }, + { + "id": "talk_warden", + "kind": "talk", + "why": "the Warden (3, 5): the GOLD TEETH from the Safari Zone (11.02)" + }, + { + "id": "hm04_strength", + "kind": "scene", + "declared_after": {"map": "FuchsiaCity_WardensHouse", "tiles": [[3, 6]], "facing": "north"}, + "why": "he takes the GOLD TEETH and gives HM04 STRENGTH (FuchsiaCity_WardensHouse_EventScript_GiveGoldTeeth; no YES/NO with the teeth; pokeguy 1:18:25 to 1:18:39)" + }, + { + "id": "below_center_door", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "north"} + }, + "why": "out of the Warden's door and west along row 32 to below the Center's door (25, 31)" + }, + { + "id": "fuchsia_nurse", + "kind": "game_action", + "action": "center_enter", + "declared_after": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "why": "the Center script in: through the door and up to the nurse; no map of the Center" + }, + { + "id": "heal_fuchsia", + "kind": "heal", + "why": "full HP and PP (pokeguy uses a Potion and flies on at 24/126, 1:18:40)" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Koga (7, 13), talked to from the west, from the save beside him (12.01): Koffing, Muk, Koffing, Weezing; his NPC medicine is two Hyper Potions and a Full Heal. The lead picks Surf (2x nothing here, the strongest move); pokeguy's Weezing took him to 4/126 HP with Sludge while Koga healed it.", + "Strength is not taught here: pokeguy teaches it over Water Pulse at Victory Road (19.02, D3).", + "Ends at Fuchsia's nurse, where 13.01 starts (Fly to Pallet Town, Surf down Route 21)." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + } + } +} diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 6be5941899..66316eef8c 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -2048,6 +2048,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCaptureTurns.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCapture_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice_Tests.cpp From 8bf7c713bebb980dbbdab8835b386214368c2d86 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 20:46:38 -0800 Subject: [PATCH 2/6] PokemonFRLG: 12.01 from Fuchsia's nurse, Kayden fought, legs round Phil and Shawn --- .../PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp | 43 ++++++++----- .../AutoStory/StoryData/frlg-12.01.plan.json | 64 +++++++++++-------- 2 files changed, 64 insertions(+), 43 deletions(-) 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 04f5894815..8ed4e8b873 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp @@ -3,10 +3,10 @@ * From: https://github.com/PokemonAutomation/ * * Rows 12.01 and 12.02 (StoryData/frlg-12.01.plan.json, 12.02) on the - * overworld sim: from Fly's landing in Fuchsia to the nurse, into the - * gym past Juggler Kirk and round its top edge to west of Koga; and from - * Koga out to the Warden and back to the nurse. And the lead's attacks - * against Kirk's and Koga's parties. + * overworld sim: from Fuchsia's nurse into the gym past Jugglers Kayden + * and Kirk and round its top edge to west of Koga; and from Koga out to + * the Warden and back to the nurse. And the lead's attacks against the + * gym's parties. * */ @@ -136,9 +136,9 @@ std::string row_on_sim(std::string_view id, GymWalk& walk){ return ""; } -// 12.01 from Fly's landing: the nurse, the gym, Kirk fought from (14, 11), -// round the top edge to west of Koga, where 12.02 starts; then 12.02 from -// there to the Warden and the nurse, meeting no one else. +// 12.01 from the nurse: the gym, Kayden fought from (14, 16) and Kirk from +// (14, 11), round the top edge to west of Koga, where 12.02 starts; then +// 12.02 from there to the Warden and the nurse, meeting no one else. UnitTestResult test_gym_rows(){ GymWalk walk(*story_pose(Pokemon::pose_of(*checkpoint("12.01").start))); if (const std::string failure = row_on_sim("12.01", walk); !failure.empty()){ @@ -148,8 +148,8 @@ UnitTestResult test_gym_rows(){ if (!(walk.sim->state().position == west_of_koga) || walk.sim->state().facing != Direction::EAST){ return std::format("12.01: ended on {}, not west of Koga {} facing east.", to_string(walk.sim->state().position), to_string(west_of_koga)); } - if (walk.all_fought() != std::vector{"rocker"}){ - return std::format("12.01: fought {} trainers, not Kirk alone.", walk.all_fought().size()); + if (walk.all_fought() != std::vector{"rocker", "rocker"}){ + return std::format("12.01: fought {} trainers, not Kayden and Kirk.", walk.all_fought().size()); } const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("12.02").start)); if (next.map != GYM || !(next.tile == west_of_koga.point)){ @@ -158,7 +158,7 @@ UnitTestResult test_gym_rows(){ if (const std::string failure = row_on_sim("12.02", walk); !failure.empty()){ return failure; } - if (walk.all_fought().size() != 1){ + if (walk.all_fought().size() != 2){ return "12.02: fought a trainer after Koga."; } if (walk.at.map != "FuchsiaCity_PokemonCenter_1F"){ @@ -168,30 +168,39 @@ UnitTestResult test_gym_rows(){ } // The lead as pokeguy brings it to the gym after HM03 (12.01): Surf over -// Water Gun, Water Pulse, Bite, Mega Kick. It picks Surf against Kirk's -// Psychic types and Koga's Poison types (pokeguy: Surf throughout). +// Water Gun, Water Pulse, Bite, Mega Kick. It picks Surf against Koga's +// Poison types (pokeguy: Surf throughout) and Surf or Bite, never Mega +// Kick (5 PP) or Water Pulse, against the Jugglers' Psychic types. UnitTestResult test_lead_moves_in_gym(){ PartyMember lead; lead.species = "blastoise"; lead.moves_read = true; lead.level = 39; lead.moves = {{"surf", 15}, {"water-pulse", 20}, {"bite", 25}, {"mega-kick", 5}}; - for (std::string_view foe : {"drowzee", "kadabra", "koffing", "muk", "weezing"}){ - if (attack_slot_against(lead, {std::string(foe)}) != 0){ + constexpr size_t SURF = 0; + constexpr size_t BITE = 2; + for (std::string_view foe : {"koffing", "muk", "weezing"}){ + if (attack_slot_against(lead, {std::string(foe)}) != SURF){ return std::format("Against {}: expected Surf.", foe); } } + for (std::string_view foe : {"drowzee", "kadabra", "hypno"}){ + const std::optional slot = attack_slot_against(lead, {std::string(foe)}); + if (slot != SURF && slot != BITE){ + return std::format("Against {}: expected Surf or Bite.", foe); + } + } return true; } const AutoStoryFuchsiaGymCase AUTO_STORY_FUCHSIA_GYM_CASES[] = { { - .input = {.name = "12.01 past Kirk to west of Koga and 12.02 to the Warden and the nurse", .body = test_gym_rows}, - .expectation = {.description = "Kirk fought where the table steps into his line, no one else; ends at Fuchsia's nurse"}, + .input = {.name = "12.01 past Kayden and Kirk to west of Koga and 12.02 to the Warden and the nurse", .body = test_gym_rows}, + .expectation = {.description = "Kayden and Kirk fought where the table steps into their lines, no one else; ends at Fuchsia's nurse"}, }, { .input = {.name = "the lead's attacks in Fuchsia Gym", .body = test_lead_moves_in_gym}, - .expectation = {.description = "Surf against Kirk's and Koga's Pokemon"}, + .expectation = {.description = "Surf against Koga's Pokemon, Surf or Bite against the Jugglers'"}, }, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json index 006dbb6def..0cfb366344 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json @@ -3,25 +3,9 @@ "game": "frlg", "checkpoint": { "id": "12.01", - "title": "Fuchsia: heal, HM03 Surf over Water Gun, the gym past Juggler Kirk and round the top edge to west of Koga", - "start": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "south"}, + "title": "Fuchsia: heal, HM03 Surf over Water Gun, the gym past Jugglers Kayden and Kirk and round the top edge to west of Koga", + "start": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, "events": [ - { - "id": "below_center_door", - "kind": "route", - "action": "run", - "args": { - "target": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "north"} - }, - "why": "Fly's landing on Fuchsia's heal spot (25, 32) (pokefirered heal_locations.json, HEAL_LOCATION_FUCHSIA_CITY) is below the Center's door (25, 31): turn to it" - }, - { - "id": "fuchsia_nurse", - "kind": "game_action", - "action": "center_enter", - "declared_after": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, - "why": "the Center script in: through the door and up to the nurse; no map of the Center" - }, { "id": "heal_fuchsia", "kind": "heal", @@ -40,22 +24,41 @@ "why": "HM03 Surf in place of Water Gun, as pokeguy (1:14:55 to 1:15:13: Surf, Water Pulse, Bite, Mega Kick after it), unless the lead knows it; an HM, so not a one-shot TM" }, { - "id": "gym_east_wall", + "id": "below_kayden_line", "kind": "route", "action": "run", "args": { - "target": {"map": "FuchsiaCity_Gym", "tiles": [[14, 21]], "facing": "north"} + "target": {"map": "FuchsiaCity_Gym", "tiles": [[14, 17]], "facing": "north"} }, - "why": "out of the Center, west along row 32 to the gym's door (9, 32), and in the gym (no running) from the mat (7, 21) east along row 21 to the east wall: below Rocker Kayden's south line (12, 17..20) and Nate's (2, 17..20)" + "why": "out of the Center (its ground floor coded), west along row 32 to the gym's door (9, 32), and in the gym (no running) from the mat (7, 21) east along row 21 and up column 14 to (14, 17), a tile below Juggler Kayden's east line (13..14, 16): out of his south line (12, 17..20) and Nate's (2, 17..20)" + }, + { + "id": "kayden_sight", + "kind": "step", + "action": "trainer_wait", + "args": { + "direction": "north" + }, + "why": "onto (14, 16), the second tile of Kayden's east line: he faces south or east (MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT), and once he faces east he walks to (13, 16). Every way north crosses his line and none ends on a wall there, so he is fought, not passed (pokeguy passed him while he faced south, 1:15:14)" + }, + { + "id": "kayden", + "kind": "battle", + "args": { + "trainer": "TRAINER_JUGGLER_KAYDEN", + "foes": ["hypno"] + }, + "declared_after": {"map": "FuchsiaCity_Gym", "tiles": [[14, 16]], "facing": "north"}, + "why": "Juggler Kayden (TRAINER_JUGGLER_KAYDEN): Hypno Lv38" }, { "id": "east_column_to_kirk", "kind": "legs", "action": "run", "args": { - "legs": [{"direction": "north", "tiles": 9}] + "legs": [{"direction": "north", "tiles": 4}] }, - "why": "up column 14 from (14, 21) to (14, 12), a tile below Juggler Kirk's line (12..14, 11): it crosses Kayden's east line (13..14, 16) when he looks east (he looks south and east); pokeguy passed him (1:15:14)" + "why": "up column 14 from (14, 16) to (14, 12), a tile below Juggler Kirk's line (12..14, 11)" }, { "id": "kirk_line", @@ -94,6 +97,15 @@ }, "why": "west along row 2 to the wall at (0, 2), the gym's top edge (pokeguy's invisible-wall corridor, 1:16:18): past Edgar's north line (13, 2..3) when he looks north, on a leg the wall stops" }, + { + "id": "down_to_koga", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "east", "tiles": 8}, {"direction": "south", "tiles": 8}, {"direction": "west", "tiles": 6}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 4}, {"direction": "south", "tiles": 1}] + }, + "why": "east along row 2 to (8, 2), down column 8 to the wall at (8, 10), west along row 10 to (2, 10), below Rocker Shawn (2, 9), who looks west at (1, 9) only, down to (2, 12) and into the middle box along row 12 to (6, 12) and (6, 13): out of Tamer Phil's lines round (4, 6), which a planned route crosses" + }, { "id": "west_of_koga", "kind": "route", @@ -101,7 +113,7 @@ "args": { "target": {"map": "FuchsiaCity_Gym", "tiles": [[6, 13]], "facing": "east"} }, - "why": "back east along row 2 to column 8, down columns 8..10 to row 10, west along it to (2, 10), round Rocker Shawn (2, 9), who looks west at (1, 9) only, and into the middle box by row 12 to west of Koga (7, 13), facing him: out of Tamer Phil's lines round (4, 6) (pokeguy approaches Koga from the west, 1:16:33)" + "why": "turn to Koga (7, 13): pokeguy approaches him from the west (1:16:33)" } ] }, @@ -109,8 +121,8 @@ "menu": "full", "notes": { "checkpoint": [ - "Starts from the pose Fly leaves the player on, Fuchsia's heal spot (25, 32) facing south: 11.02 (the Safari Zone, HM03 SURF and the GOLD TEETH) ends with a Fly to Fuchsia and is authored separately; until it is in, this row's start is its own (starts_after_unauthored_rows()).", - "PokeGuy's way (1:14:38 to 1:16:33): into the gym, Surf taught over Water Gun, Juggler Kirk fought (forced), round the top edge, Koga from the west. He fights nobody else.", + "Starts at Fuchsia's nurse, facing her: 11.02 (the Safari Zone, HM03 SURF and the GOLD TEETH) flies to Fuchsia and is expected to end there, and is authored separately; until it is in, this row's start is its own (starts_after_unauthored_rows()). Starting at the nurse keeps the walk out of the coded Center at a row's start, where a nurse pose a tile off can't come from a scene before it.", + "PokeGuy's way (1:14:38 to 1:16:33): into the gym, Surf taught over Water Gun, Juggler Kirk fought (forced), round the top edge, Koga from the west. He fights nobody else; this row also fights Juggler Kayden (Hypno Lv38), whose east line every way north crosses with no wall to end a leg on (a deviation, for the user).", "The gym (FuchsiaCity_Gym map.json), 15 x 23, no running, its invisible walls in the map: Koga (7, 13) in the middle box, entered only from row 12 on the west. Its trainers and lines: Kayden (12, 16) south and east 4, Shawn (2, 9) west 1, Kirk (11, 11) east 3, Edgar (13, 4) every way 2, Phil (4, 6) every way 2, Nate (2, 16) south 4. Every way north crosses Kirk's line and one of Kayden's and Edgar's; the legs across a looker's line end on walls.", "Ends west of Koga and saves there: his own pre-battle checkpoint (battle-checkpoint-retry), 12.02. Koga is a D7 fight: pokeguy entered at 34/122 HP and the PokemonSimulation benchmark wins 70.1% from that; this row enters at full HP and PP after the Center (the full-heal comparison is still pending there)." ] From d020a303c12737939f8112cf9515036d8605ec09 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 20:50:35 -0800 Subject: [PATCH 3/6] PokemonFRLG: 12.01 taps up the gym's east wall to Kayden's line; column 9 down to Koga --- .../AutoStory/StoryData/frlg-12.01.plan.json | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json index 0cfb366344..51d1215755 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.01.plan.json @@ -24,13 +24,22 @@ "why": "HM03 Surf in place of Water Gun, as pokeguy (1:14:55 to 1:15:13: Surf, Water Pulse, Bite, Mega Kick after it), unless the lead knows it; an HM, so not a one-shot TM" }, { - "id": "below_kayden_line", + "id": "gym_east_wall", "kind": "route", "action": "run", "args": { - "target": {"map": "FuchsiaCity_Gym", "tiles": [[14, 17]], "facing": "north"} + "target": {"map": "FuchsiaCity_Gym", "tiles": [[14, 21]], "facing": "north"} + }, + "why": "out of the Center (its ground floor coded), west along row 32 to the gym's door (9, 32), and in the gym (no running) from the mat (7, 21) east along row 21 to the east wall: below Juggler Kayden's south line (12, 17..20) and Nate's (2, 17..20)" + }, + { + "id": "below_kayden_line", + "kind": "legs", + "action": "taps", + "args": { + "legs": [{"direction": "north", "tiles": 4}] }, - "why": "out of the Center (its ground floor coded), west along row 32 to the gym's door (9, 32), and in the gym (no running) from the mat (7, 21) east along row 21 and up column 14 to (14, 17), a tile below Juggler Kayden's east line (13..14, 16): out of his south line (12, 17..20) and Nate's (2, 17..20)" + "why": "up column 14 from (14, 21) to (14, 17), a tile below Kayden's east line (13..14, 16): a planned route here goes up column 12 or 13 and meets his south line" }, { "id": "kayden_sight", @@ -102,9 +111,9 @@ "kind": "legs", "action": "run", "args": { - "legs": [{"direction": "east", "tiles": 8}, {"direction": "south", "tiles": 8}, {"direction": "west", "tiles": 6}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 4}, {"direction": "south", "tiles": 1}] + "legs": [{"direction": "east", "tiles": 9}, {"direction": "south", "tiles": 8}, {"direction": "west", "tiles": 7}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 4}, {"direction": "south", "tiles": 1}] }, - "why": "east along row 2 to (8, 2), down column 8 to the wall at (8, 10), west along row 10 to (2, 10), below Rocker Shawn (2, 9), who looks west at (1, 9) only, down to (2, 12) and into the middle box along row 12 to (6, 12) and (6, 13): out of Tamer Phil's lines round (4, 6), which a planned route crosses" + "why": "east along row 2 to (9, 2), down column 9 to the wall at (9, 10), west along row 10 to (2, 10), below Rocker Shawn (2, 9), who looks west at (1, 9) only, down to (2, 12) and into the middle box along row 12 to (6, 12) and (6, 13): out of Tamer Phil's lines round (4, 6), which a planned route crosses" }, { "id": "west_of_koga", From ec0e36ff07c14954ea59855af707ad8aff37727d Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 20:52:58 -0800 Subject: [PATCH 4/6] PokemonFRLG: Surf first in the lead's attacks, as pokeguy from Koga on; Kayden and Kirk in the trainer count --- .../PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp | 11 +++++++---- .../Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp | 3 +++ .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) 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 8ed4e8b873..dd2d3f7c95 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp @@ -138,7 +138,10 @@ std::string row_on_sim(std::string_view id, GymWalk& walk){ // 12.01 from the nurse: the gym, Kayden fought from (14, 16) and Kirk from // (14, 11), round the top edge to west of Koga, where 12.02 starts; then -// 12.02 from there to the Warden and the nurse, meeting no one else. +// 12.02 from there to the Warden and the nurse, meeting no one else. The +// sim's lookers see every way at once, so Edgar, whose lines the legs to +// the walls cross, always stops the walk there: the worst case, which +// the console meets only when he looks that way. UnitTestResult test_gym_rows(){ GymWalk walk(*story_pose(Pokemon::pose_of(*checkpoint("12.01").start))); if (const std::string failure = row_on_sim("12.01", walk); !failure.empty()){ @@ -148,8 +151,8 @@ UnitTestResult test_gym_rows(){ if (!(walk.sim->state().position == west_of_koga) || walk.sim->state().facing != Direction::EAST){ return std::format("12.01: ended on {}, not west of Koga {} facing east.", to_string(walk.sim->state().position), to_string(west_of_koga)); } - if (walk.all_fought() != std::vector{"rocker", "rocker"}){ - return std::format("12.01: fought {} trainers, not Kayden and Kirk.", walk.all_fought().size()); + if (walk.all_fought() != std::vector{"rocker", "rocker", "man"}){ + return std::format("12.01: fought {} trainers, not Kayden, Kirk and Edgar.", walk.all_fought().size()); } const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("12.02").start)); if (next.map != GYM || !(next.tile == west_of_koga.point)){ @@ -158,7 +161,7 @@ UnitTestResult test_gym_rows(){ if (const std::string failure = row_on_sim("12.02", walk); !failure.empty()){ return failure; } - if (walk.all_fought().size() != 2){ + if (walk.all_fought().size() != 3){ return "12.02: fought a trainer after Koga."; } if (walk.at.map != "FuchsiaCity_PokemonCenter_1F"){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp index c769fe016c..2d234983ea 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp @@ -116,6 +116,9 @@ struct Attack{ std::string_view move; }; constexpr Attack ATTACKS[] = { + // From HM03 (12.01) on, as pokeguy: Surf on everything it is not + // resisted by (1:15:14 on). + {.line = "squirtle", .move = "surf"}, {.line = "squirtle", .move = "water-gun"}, {.line = "squirtle", .move = "bite"}, {.line = "squirtle", .move = "bubble"}, 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 0878014331..4bc561e81f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -691,7 +691,7 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set Date: Wed, 11 Nov 2026 20:53:50 -0800 Subject: [PATCH 5/6] PokemonFRLG: S12 route golden --- .../PokemonFRLG_AutoStoryPlanGolden.h | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h index 4cd5d9abe1..28ffc843d2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h @@ -849,6 +849,49 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN[] = { "09.02 face north -> RocketHideout_B4F (19, 5)", "09.02 face_silph_scope from RocketHideout_B4F (19, 5) facing south to RocketHideout_B4F (19, 5) facing east", "09.02 face east -> RocketHideout_B4F (19, 5)", + "12.01 gym_east_wall from FuchsiaCity_PokemonCenter_1F (7, 4) facing north to FuchsiaCity_Gym (14, 21) facing north", + "12.01 walk south 5 (warp) -> FuchsiaCity (25, 32) [walk only]", + "12.01 walk south 1 -> FuchsiaCity (25, 33)", + "12.01 walk west 16 -> FuchsiaCity (9, 33)", + "12.01 walk north 1 (warp) -> FuchsiaCity_Gym (7, 21)", + "12.01 walk east 7 (to wall) -> FuchsiaCity_Gym (14, 21) [walk only]", + "12.01 face north -> FuchsiaCity_Gym (14, 21) [walk only]", + "12.01 west_of_koga from FuchsiaCity_Gym (6, 13) facing south to FuchsiaCity_Gym (6, 13) facing east", + "12.01 face east -> FuchsiaCity_Gym (6, 13) [walk only]", + "12.02 below_warden from FuchsiaCity_Gym (6, 13) facing east to FuchsiaCity_WardensHouse (3, 6) facing north", + "12.02 walk north 1 (to wall) -> FuchsiaCity_Gym (6, 12) [walk only]", + "12.02 walk west 6 (to wall) -> FuchsiaCity_Gym (0, 12) [walk only]", + "12.02 walk north 1 (to wall) -> FuchsiaCity_Gym (0, 11) [walk only]", + "12.02 walk east 2 (to wall) -> FuchsiaCity_Gym (2, 11) [walk only]", + "12.02 walk north 1 -> FuchsiaCity_Gym (2, 10) [walk only]", + "12.02 walk east 7 (to wall) -> FuchsiaCity_Gym (9, 10) [walk only]", + "12.02 walk north 8 (to wall) -> FuchsiaCity_Gym (9, 2) [walk only]", + "12.02 walk east 5 (to wall) -> FuchsiaCity_Gym (14, 2) [walk only]", + "12.02 walk south 19 (to wall) -> FuchsiaCity_Gym (14, 21) [walk only]", + "12.02 walk west 7 -> FuchsiaCity_Gym (7, 21) [walk only]", + "12.02 walk south 1 (warp) -> FuchsiaCity (9, 33) [walk only]", + "12.02 walk south 4 (to wall) -> FuchsiaCity (9, 37)", + "12.02 walk west 7 (to wall) -> FuchsiaCity (2, 37)", + "12.02 walk north 12 -> FuchsiaCity (2, 25)", + "12.02 walk east 28 (to wall) -> FuchsiaCity (30, 25)", + "12.02 walk south 7 -> FuchsiaCity (30, 32)", + "12.02 walk east 3 -> FuchsiaCity (33, 32)", + "12.02 walk north 1 (warp) -> FuchsiaCity_WardensHouse (6, 9)", + "12.02 walk west 5 (to wall) -> FuchsiaCity_WardensHouse (1, 9) [walk only]", + "12.02 walk north 3 (to wall) -> FuchsiaCity_WardensHouse (1, 6) [walk only]", + "12.02 walk east 2 -> FuchsiaCity_WardensHouse (3, 6) [walk only]", + "12.02 face north -> FuchsiaCity_WardensHouse (3, 6) [walk only]", + "12.02 below_center_door from FuchsiaCity_WardensHouse (3, 6) facing north to FuchsiaCity (25, 32) facing north", + "12.02 walk east 3 -> FuchsiaCity_WardensHouse (6, 6) [walk only]", + "12.02 walk south 4 (warp) -> FuchsiaCity (33, 32) [walk only]", + "12.02 walk west 4 -> FuchsiaCity (29, 32)", + "12.02 walk north 7 -> FuchsiaCity (29, 25)", + "12.02 walk west 27 (to wall) -> FuchsiaCity (2, 25)", + "12.02 walk south 12 (to wall) -> FuchsiaCity (2, 37)", + "12.02 walk east 9 (to wall) -> FuchsiaCity (11, 37)", + "12.02 walk north 5 (to wall) -> FuchsiaCity (11, 32)", + "12.02 walk east 14 -> FuchsiaCity (25, 32)", + "12.02 face north -> FuchsiaCity (25, 32)", }; } // namespace PokemonFRLG From 2bb6a005d5e0a8956d22129509cbfdf32bdf3f90 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 21:06:50 -0800 Subject: [PATCH 6/6] PokemonFRLG: 12.02 checks the lead is at least pokeguy's Lv39 before Koga A LEVEL step on the lead before the talk to Koga. pokeguy's Blastoise is Lv39 here, and PokemonSimulation's docs/battles/pokeguy-conditions.md sims that entry (C2 setup, 34/122 HP: 1191/1700 wins, 70.1%); at his level or above those sims stand for this fight, below it the run stops before the fight. A sim test runs the step with a Lv39 and a Lv38 lead. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp | 47 +++++++++++++++++++ .../AutoStory/StoryData/frlg-12.02.plan.json | 7 +++ 2 files changed, 54 insertions(+) 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 dd2d3f7c95..c461dd1832 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp @@ -25,6 +25,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryParty.h" #include "PokemonFRLG_AutoStoryRooms.h" +#include "PokemonFRLG_AutoStoryMember.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -196,6 +197,45 @@ UnitTestResult test_lead_moves_in_gym(){ return true; } +class QuietLogger : public Logger{ +public: + using Logger::log; + virtual void log(const std::string&, Color) override{} +}; + +// 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. +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){ + if (step.kind == StoryStepKind::BATTLE && step.name == battle){ + break; + } + if (step.action == LEVEL_ACTION){ + check = level_check_of(step.args); + } + } + 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 MemberReader lead = [level](size_t slot) -> std::optional{ + if (slot != 0){ + return std::nullopt; + } + return MemberInfo{.species = "blastoise", .level = level}; + }; + const LevelResult result = run_level_check(logger, lead, *check); + const LevelEnd expected = level >= pokeguy ? 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 true; +} + const AutoStoryFuchsiaGymCase AUTO_STORY_FUCHSIA_GYM_CASES[] = { { .input = {.name = "12.01 past Kayden and Kirk to west of Koga and 12.02 to the Warden and the nurse", .body = test_gym_rows}, @@ -205,6 +245,13 @@ const AutoStoryFuchsiaGymCase AUTO_STORY_FUCHSIA_GYM_CASES[] = { .input = {.name = "the lead's attacks in Fuchsia Gym", .body = test_lead_moves_in_gym}, .expectation = {.description = "Surf against Koga's Pokemon, Surf or Bite against the Jugglers'"}, }, + { + .input = {.name = "12.02 stops before Koga unless the lead is at least pokeguy's Lv39", .body = []{ + QuietLogger logger; + return check_lead_level_precondition(logger, "12.02", "koga", 39); + }}, + .expectation = {.description = "a Lv39 lead passes the LEVEL step, a Lv38 one stops there"}, + }, }; } // namespace diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json index ec206fc166..9e66f678a8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.02.plan.json @@ -6,6 +6,13 @@ "title": "Koga, the SOULBADGE; the GOLD TEETH to the Warden for HM04 STRENGTH; heal at Fuchsia's Center", "start": {"map": "FuchsiaCity_Gym", "tiles": [[6, 13]], "facing": "east"}, "events": [ + { + "id": "lead_lv39_for_koga", + "kind": "game_action", + "action": "level", + "args": {"slot": 1, "min": 39}, + "why": "the precondition for Koga: the lead at least Lv39, pokeguy's Blastoise here (PokemonSimulation docs/battles/pokeguy-conditions.md, koga: C2 setup to Sp. Atk +1 and outspeed with X items, from 34/122 HP: 1191/1700 wins, 70.1%, 64.5% to 75.2%); at his level or above, those sims stand for this fight and no new one is needed; below it, the run stops here, before the fight" + }, { "id": "challenge_koga", "kind": "talk",