From c5c18c4c24e8bda29be9d189dde22c37381488cb Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 20:19:23 -0800 Subject: [PATCH 01/20] PokemonFRLG: 14.03 and 14.04, Celadon Gym to Erika and back to the nurse 14.03 starts from Fly's landing in Celadon (48, 12), cuts the yard's tree, takes the gym's west aisle into Beauty Tamia's line, goes round her by column 1, cuts the inner tree and steps into Beauty Lori's line, and ends below Erika for her own save. 14.04 fights Erika, walks out over the cut tree's tile, cuts the yard's tree again and heals. Celadon Gym joins the loaded maps. The chain checks skip 14.03's start, whose rows before it (10 to 14.02) are authored separately. Sim tests run both rows and the lead's attacks against the gym's parties. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Overworld/PokemonFRLG_OverworldMaps.cpp | 2 + .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 + .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 215 ++++++++++++++++++ .../PokemonFRLG_AutoStoryPlanGolden.h | 31 +++ .../PokemonFRLG_AutoStoryRows_Tests.h | 12 + .../PokemonFRLG_AutoStoryRunPlan_Tests.cpp | 8 +- .../PokemonFRLG_AutoStorySimulation_Tests.cpp | 7 +- .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 19 +- .../AutoStory/StoryData/frlg-14.03.plan.json | 150 ++++++++++++ .../AutoStory/StoryData/frlg-14.04.plan.json | 145 ++++++++++++ SerialPrograms/cmake/SourceFiles.cmake | 1 + 11 files changed, 579 insertions(+), 12 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index f6d168d32a..74cce93e02 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -93,6 +93,8 @@ constexpr std::string_view MAP_NAMES[] = { "UndergroundPath_WestEntrance", "Route7", "CeladonCity", + // Celadon Gym, past the tree Cut fells. + "CeladonCity_Gym", // The Game Corner's poster and the Rocket Hideout down to B4F. "CeladonCity_GameCorner", "RocketHideout_B1F", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index a3511b6d22..6b76b48d56 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_AutoStoryCeladonGym(database); } void add_tests(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp new file mode 100644 index 0000000000..6633e6f265 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -0,0 +1,215 @@ +/* AutoStory Celadon Gym Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Rows 14.03 and 14.04 (StoryData/frlg-14.03.plan.json, 14.04) on the + * overworld sim: from Fly's landing in Celadon past the yard's tree, up + * the gym's west aisle into Beauty Tamia's line, round her by column 1, + * the inner tree, Beauty Lori, to below Erika; and from Erika back out + * the same way, past the tree, to the nurse. And the lead's attacks against the + * gym's three parties. + * + */ + +#include +#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_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +const std::string GYM = "CeladonCity_Gym"; +const std::string CELADON = "CeladonCity"; + +struct AutoStoryCeladonGymInput{ + std::string name; + std::function body; +}; + +struct AutoStoryCeladonGymExpectation{ + std::string_view description; +}; + +struct AutoStoryCeladonGymCase{ + AutoStoryCeladonGymInput input; + AutoStoryCeladonGymExpectation expectation; +}; + +class Test_AutoStoryCeladonGym : public UnitTest{ +public: + explicit Test_AutoStoryCeladonGym(AutoStoryCeladonGymCase test_case) + : UnitTest("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::string(e.name()) + ": " + e.message(); + } + } + +private: + AutoStoryCeladonGymCase m_case; +}; + +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; +} + +// A step of a row on the sim: row_step_on_sim(), but Erika's battle, +// which a talk starts, leaves the player where the table says. The +// Center's way in and the nurse, which the sim hasn't got, pass. +std::string gym_step_on_sim(OverworldSim& sim, StoryPose& at, const StoryStep& step, const std::string& id){ + if (step.kind == StoryStepKind::BATTLE && step.name == "erika"){ + at = *story_pose(Pokemon::pose_of(*step.pose_after)); + return ""; + } + return row_step_on_sim(sim, at, step, id); +} + +// Row `id`'s steps from the one named `first` on, on `sim` from `at`: +// the failure, or empty. +std::string row_from(OverworldSim& sim, StoryPose& at, std::string_view id, std::string_view first){ + const StoryCheckpoint& row = checkpoint(id); + bool started = false; + for (const StoryStep& step : row.steps){ + started = started || step.name == first; + if (!started){ + continue; + } + if (const std::string failure = gym_step_on_sim(sim, at, step, row.id); !failure.empty()){ + return std::format("ended on {}; {}", to_string(sim.state().position), failure); + } + } + if (!started){ + return std::format("{} has no step {}.", id, first); + } + if (!sim.state().violations.empty()){ + return std::format("{}: a violation on the way: {}", id, sim.state().violations.back()); + } + return ""; +} + +std::string fought(const OverworldSim& sim){ + std::string names; + for (const std::string& name : sim.state().trainers_beaten){ + names += " " + name; + } + return names.empty() ? " no one" : names; +} + +// 14.03 on the sim, from Fly's landing (48, 12): the yard's tree cut, +// into the gym and up the west aisle; Tamia walks down to (2, 9) and is fought, the walk goes +// round her by column 1, the inner tree (3, 5) is cut, and Lori is +// fought from (5, 5). Then 14.04 on the same sim, the gym as 14.03 +// leaves it (Tamia on (2, 9), the inner tree cut): out along row 5, a +// step onto the cut tree's tile, down column 1 past Tamia and column 2 +// to the wall, out of the gym, the tree again and back below the +// Center's door (the Center's way in and the nurse need the console), +// meeting no one else. +UnitTestResult test_gym_rows(){ + StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint("14.03").start)); + OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + if (const std::string failure = row_from(sim, at, "14.03", "above_gym_tree"); !failure.empty()){ + return "14.03: " + failure; + } + const MapPosition below_erika{GYM, {6, 5}}; + if (!(sim.state().position == below_erika) || sim.state().facing != Direction::NORTH){ + return std::format("14.03: ended on {}, not below Erika {} facing north.", to_string(sim.state().position), to_string(below_erika)); + } + if (sim.state().trainers_beaten != std::vector{"beauty", "beauty"}){ + return "14.03: fought" + fought(sim) + ", not Tamia and Lori."; + } + const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("14.04").start)); + if (next.map != GYM || !(next.tile == below_erika.point)){ + return "14.04 doesn't start where 14.03 ends."; + } + if (const std::string failure = row_from(sim, at, "14.04", "challenge_erika"); !failure.empty()){ + return "14.04: " + failure; + } + if (sim.state().trainers_beaten.size() != 2){ + return "14.04: fought" + fought(sim) + " after Tamia and Lori."; + } + const MapPosition below_center{CELADON, {48, 12}}; + if (!(sim.state().position == below_center)){ + return std::format("14.04: ended on {}, not below the Center's door {}.", to_string(sim.state().position), to_string(below_center)); + } + return true; +} + +// The lead as pokeguy brings it to Erika, without the Blizzard he +// teaches there (left out: no TM spent without the user): Surf, Water +// Pulse, Bite, Mega Kick. Against Tamia's, Lori's and Erika's Grass +// types it never picks a Water move, which they resist; against Lori's +// Exeggcute (Grass, Psychic) it picks Bite. +UnitTestResult test_lead_moves_against_grass(){ + PartyMember lead; + lead.species = "blastoise"; + lead.moves_read = true; + lead.level = 42; + lead.moves = {{"surf", 15}, {"water-pulse", 20}, {"bite", 25}, {"mega-kick", 5}}; + constexpr size_t SURF = 0; + constexpr size_t WATER_PULSE = 1; + constexpr size_t BITE = 2; + for (std::string_view foe : {"bellsprout", "exeggcute", "victreebel", "tangela", "vileplume"}){ + const std::optional slot = attack_slot_against(lead, {std::string(foe)}); + if (!slot || *slot == SURF || *slot == WATER_PULSE){ + return std::format("Against {}: picked a Water move or none.", foe); + } + } + if (attack_slot_against(lead, {"exeggcute"}) != BITE){ + return "Expected Bite against Lori's Exeggcute."; + } + return true; +} + +const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { + { + .input = {.name = "14.03 to below Erika and 14.04 back to the nurse", .body = test_gym_rows}, + .expectation = {.description = "Tamia and Lori fought where the table steps into their lines, no one else"}, + }, + { + .input = {.name = "the lead's attacks against Celadon Gym", .body = test_lead_moves_against_grass}, + .expectation = {.description = "no Water move against Grass; Bite against Exeggcute"}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryCeladonGym(UnitTestDatabase& database){ + for (const auto& item : AUTO_STORY_CELADON_GYM_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h index 4cd5d9abe1..aa4e8d06e0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h @@ -849,6 +849,37 @@ 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)", + "14.03 above_gym_tree from CeladonCity (48, 12) facing south to CeladonCity (40, 34) facing south", + "14.03 walk west 7 -> CeladonCity (41, 12)", + "14.03 walk south 13 (to wall) -> CeladonCity (41, 25)", + "14.03 walk west 10 -> CeladonCity (31, 25)", + "14.03 walk south 8 (to wall) -> CeladonCity (31, 33)", + "14.03 walk east 9 -> CeladonCity (40, 33)", + "14.03 walk south 1 -> CeladonCity (40, 34)", + "14.03 below_tamia_line from CeladonCity (40, 35) facing south to CeladonCity_Gym (2, 11) facing north", + "14.03 walk south 2 (to wall) -> CeladonCity (40, 37)", + "14.03 walk west 29 -> CeladonCity (11, 37)", + "14.03 walk north 7 (warp) -> CeladonCity_Gym (6, 18)", + "14.03 walk west 4 -> CeladonCity_Gym (2, 18) [walk only]", + "14.03 walk north 7 -> CeladonCity_Gym (2, 11) [walk only]", + "14.03 below_erika from CeladonCity_Gym (6, 5) facing east to CeladonCity_Gym (6, 5) facing north", + "14.03 face north -> CeladonCity_Gym (6, 5) [walk only]", + "14.04 below_gym_tree_out from CeladonCity_Gym (2, 18) facing south to CeladonCity (40, 36) facing north", + "14.04 walk east 4 -> CeladonCity_Gym (6, 18) [walk only]", + "14.04 walk south 1 (warp) -> CeladonCity (11, 31) [walk only]", + "14.04 walk south 6 (to wall) -> CeladonCity (11, 37)", + "14.04 walk east 30 (to wall) -> CeladonCity (41, 37)", + "14.04 walk north 1 (to wall) -> CeladonCity (41, 36)", + "14.04 walk west 1 -> CeladonCity (40, 36)", + "14.04 face north -> CeladonCity (40, 36)", + "14.04 celadon_below_center from CeladonCity (40, 35) facing north to CeladonCity (48, 12) facing north", + "14.04 walk north 3 -> CeladonCity (40, 32)", + "14.04 walk west 9 -> CeladonCity (31, 32)", + "14.04 walk north 8 (to wall) -> CeladonCity (31, 24)", + "14.04 walk east 12 -> CeladonCity (43, 24)", + "14.04 walk north 12 (to wall) -> CeladonCity (43, 12)", + "14.04 walk east 5 -> CeladonCity (48, 12)", + "14.04 face north -> CeladonCity (48, 12)", }; } // namespace PokemonFRLG 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..0384260317 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 14.03 and 14.04, Celadon Gym, on the overworld sim (PokemonFRLG_AutoStoryCeladonGym_Tests.cpp). +void add_tests_AutoStoryCeladonGym(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. 14.03 starts from Fly's landing in Celadon, after Blaine +// (14.02); segments 10 to 14.02 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 == "14.03"; +} } // 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..c183740325 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 14.03 14.04"; 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 14.03 14.04"}, }, { .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 14.03 14.04"}, }, { .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 14.03 14.04"}, }, { .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..d1699805c5 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){ @@ -687,7 +691,7 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set Date: Wed, 11 Nov 2026 20:20:52 -0800 Subject: [PATCH 02/20] PokemonFRLG: Celadon Gym sim tests, one helper per row Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) 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 6633e6f265..9c4357d2da 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -57,14 +57,14 @@ struct AutoStoryCeladonGymCase{ class Test_AutoStoryCeladonGym : public UnitTest{ public: explicit Test_AutoStoryCeladonGym(AutoStoryCeladonGymCase test_case) - : UnitTest("PokemonFRLG::AutoStory - Simulation: " + test_case.input.name) + : 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::string(e.name()) + ": " + e.message(); + return std::format("{}: {}", e.name(), e.message()); } } @@ -84,7 +84,7 @@ const StoryCheckpoint& checkpoint(std::string_view id){ // A step of a row on the sim: row_step_on_sim(), but Erika's battle, // which a talk starts, leaves the player where the table says. The // Center's way in and the nurse, which the sim hasn't got, pass. -std::string gym_step_on_sim(OverworldSim& sim, StoryPose& at, const StoryStep& step, const std::string& id){ +std::string gym_step_on_sim(const StoryStep& step, const std::string& id, StoryPose& at, OverworldSim& sim){ if (step.kind == StoryStepKind::BATTLE && step.name == "erika"){ at = *story_pose(Pokemon::pose_of(*step.pose_after)); return ""; @@ -92,22 +92,13 @@ std::string gym_step_on_sim(OverworldSim& sim, StoryPose& at, const StoryStep& s return row_step_on_sim(sim, at, step, id); } -// Row `id`'s steps from the one named `first` on, on `sim` from `at`: -// the failure, or empty. -std::string row_from(OverworldSim& sim, StoryPose& at, std::string_view id, std::string_view first){ +// Row `id`'s steps on `sim` from `at`: the failure, or empty. +std::string row_on_sim(std::string_view id, StoryPose& at, OverworldSim& sim){ const StoryCheckpoint& row = checkpoint(id); - bool started = false; for (const StoryStep& step : row.steps){ - started = started || step.name == first; - if (!started){ - continue; + if (const std::string failure = gym_step_on_sim(step, row.id, at, sim); !failure.empty()){ + return std::format("{}: ended on {}; {}", id, to_string(sim.state().position), failure); } - if (const std::string failure = gym_step_on_sim(sim, at, step, row.id); !failure.empty()){ - return std::format("ended on {}; {}", to_string(sim.state().position), failure); - } - } - if (!started){ - return std::format("{} has no step {}.", id, first); } if (!sim.state().violations.empty()){ return std::format("{}: a violation on the way: {}", id, sim.state().violations.back()); @@ -118,42 +109,51 @@ std::string row_from(OverworldSim& sim, StoryPose& at, std::string_view id, std: std::string fought(const OverworldSim& sim){ std::string names; for (const std::string& name : sim.state().trainers_beaten){ - names += " " + name; + names += std::format(" {}", name); } return names.empty() ? " no one" : names; } -// 14.03 on the sim, from Fly's landing (48, 12): the yard's tree cut, -// into the gym and up the west aisle; Tamia walks down to (2, 9) and is fought, the walk goes -// round her by column 1, the inner tree (3, 5) is cut, and Lori is -// fought from (5, 5). Then 14.04 on the same sim, the gym as 14.03 -// leaves it (Tamia on (2, 9), the inner tree cut): out along row 5, a -// step onto the cut tree's tile, down column 1 past Tamia and column 2 -// to the wall, out of the gym, the tree again and back below the -// Center's door (the Center's way in and the nurse need the console), -// meeting no one else. -UnitTestResult test_gym_rows(){ - StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint("14.03").start)); - OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); - if (const std::string failure = row_from(sim, at, "14.03", "above_gym_tree"); !failure.empty()){ - return "14.03: " + failure; +// 14.03 on `sim` from its start, Fly's landing (48, 12): the yard's tree +// cut, into the gym and up the west aisle; Tamia walks down to (2, 9) +// and is fought, the walk goes round her by column 1, the inner tree +// (3, 5) is cut, and Lori is fought from (5, 5). Ends below Erika, where +// 14.04 starts. The failure, or empty. +std::string to_erika(StoryPose& at, OverworldSim& sim){ + if (const std::string failure = row_on_sim("14.03", at, sim); !failure.empty()){ + return failure; } const MapPosition below_erika{GYM, {6, 5}}; if (!(sim.state().position == below_erika) || sim.state().facing != Direction::NORTH){ return std::format("14.03: ended on {}, not below Erika {} facing north.", to_string(sim.state().position), to_string(below_erika)); } if (sim.state().trainers_beaten != std::vector{"beauty", "beauty"}){ - return "14.03: fought" + fought(sim) + ", not Tamia and Lori."; + return std::format("14.03: fought{}, not Tamia and Lori.", fought(sim)); } const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("14.04").start)); if (next.map != GYM || !(next.tile == below_erika.point)){ return "14.04 doesn't start where 14.03 ends."; } - if (const std::string failure = row_from(sim, at, "14.04", "challenge_erika"); !failure.empty()){ - return "14.04: " + failure; + return ""; +} + +// 14.03 on the sim (to_erika()), then 14.04 on the same sim, the gym as +// 14.03 leaves it (Tamia on (2, 9), the inner tree cut): out along row +// 5, a step onto the cut tree's tile, down column 1 past Tamia and +// column 2 to the wall, out of the gym, the tree again and back below +// the Center's door (the Center's way in and the nurse need the +// console), meeting no one else. +UnitTestResult test_gym_rows(){ + StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint("14.03").start)); + OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + if (const std::string failure = to_erika(at, sim); !failure.empty()){ + return failure; + } + if (const std::string failure = row_on_sim("14.04", at, sim); !failure.empty()){ + return failure; } if (sim.state().trainers_beaten.size() != 2){ - return "14.04: fought" + fought(sim) + " after Tamia and Lori."; + return std::format("14.04: fought{} after Tamia and Lori.", fought(sim)); } const MapPosition below_center{CELADON, {48, 12}}; if (!(sim.state().position == below_center)){ From 0fbf7efcb948b33677117607bd92c3936742ca11 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 21:06:59 -0800 Subject: [PATCH 03/20] PokemonFRLG: 14.04 checks the lead is at least pokeguy's Lv44 before Erika A LEVEL step on the lead before the fight. pokeguy's Blastoise is Lv44 here, and PokemonSimulation's docs/battles/pokeguy-conditions.md sims that entry (C2 setup, 35/137 HP: 567/620 wins, 91.5%); 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 Lv44 and a Lv43 lead. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 47 +++++++++++++++++++ .../AutoStory/StoryData/frlg-14.04.plan.json | 7 +++ 2 files changed, 54 insertions(+) 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 9c4357d2da..100f3f6296 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 "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryMember.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -188,6 +189,45 @@ UnitTestResult test_lead_moves_against_grass(){ 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 AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { { .input = {.name = "14.03 to below Erika and 14.04 back to the nurse", .body = test_gym_rows}, @@ -197,6 +237,13 @@ const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { .input = {.name = "the lead's attacks against Celadon Gym", .body = test_lead_moves_against_grass}, .expectation = {.description = "no Water move against Grass; Bite against Exeggcute"}, }, + { + .input = {.name = "14.04 stops before Erika unless the lead is at least pokeguy's Lv44", .body = []{ + QuietLogger logger; + return check_lead_level_precondition(logger, "14.04", "erika", 44); + }}, + .expectation = {.description = "a Lv44 lead passes the LEVEL step, a Lv43 one stops there"}, + }, }; } // namespace diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json index 5a8ff54d75..e19d261fb2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json @@ -6,6 +6,13 @@ "title": "Celadon Gym: Erika, the RAINBOWBADGE and TM19, then out past the tree to the nurse", "start": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, "events": [ + { + "id": "lead_lv44_for_erika", + "kind": "game_action", + "action": "level", + "args": {"slot": 1, "min": 44}, + "why": "the precondition for Erika: the lead at least Lv44, pokeguy's Blastoise here (PokemonSimulation docs/battles/pokeguy-conditions.md, erika: C2 setup to Sp. Atk +1, accuracy +2 and outspeed, Guard Spec first, from 35/137 HP: 567/620 wins, 91.5%, 85.2% to 95.8%); 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_erika", "kind": "talk", From dcedc74c329371fccaa211c4eafb64e671df3aed Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:35:05 -0800 Subject: [PATCH 04/20] PokemonFRLG: 12.03, Fuchsia's Center and Fly to Celadon, before 14.03 Row 12.03 leaves Fuchsia's nurse (where 12.02 ends), walks out of the Center and Flies to Celadon's heal spot, where 14.03 starts, so 14.03 is no longer authored apart from the rows before it: starts_after_unauthored_rows() goes. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 32 ++++++++++- .../PokemonFRLG_AutoStoryRows_Tests.h | 9 --- .../PokemonFRLG_AutoStoryRunPlan_Tests.cpp | 8 +-- .../PokemonFRLG_AutoStorySimulation_Tests.cpp | 6 +- .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 12 ++-- .../AutoStory/StoryData/frlg-12.03.plan.json | 55 +++++++++++++++++++ 6 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json 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 100f3f6296..be8f3312d0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -2,8 +2,9 @@ * * From: https://github.com/PokemonAutomation/ * - * Rows 14.03 and 14.04 (StoryData/frlg-14.03.plan.json, 14.04) on the - * overworld sim: from Fly's landing in Celadon past the yard's tree, up + * Rows 12.03, 14.03 and 14.04 (StoryData/frlg-12.03.plan.json, 14.03, 14.04) + * on the overworld sim: from Fuchsia's nurse out of the Center and Fly to + * Celadon; from Fly's landing in Celadon past the yard's tree, up * the gym's west aisle into Beauty Tamia's line, round her by column 1, * the inner tree, Beauty Lori, to below Erika; and from Erika back out * the same way, past the tree, to the nurse. And the lead's attacks against the @@ -115,6 +116,29 @@ std::string fought(const OverworldSim& sim){ return names.empty() ? " no one" : names; } +// 12.03 on a sim from Fuchsia's nurse: out of the Center, the Fly, and +// the landing on Celadon's heal spot (48, 12) facing south, where 14.03 +// starts. No one is fought on the way. +UnitTestResult test_fly_to_celadon(){ + StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint("12.03").start)); + OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + if (const std::string failure = row_on_sim("12.03", at, sim); !failure.empty()){ + return failure; + } + const MapPosition landing{CELADON, {48, 12}}; + if (!(sim.state().position == landing) || sim.state().facing != Direction::SOUTH){ + return std::format("12.03: ended on {}, not Celadon's heal spot {} facing south.", to_string(sim.state().position), to_string(landing)); + } + if (!sim.state().trainers_beaten.empty()){ + return std::format("12.03: fought{}.", fought(sim)); + } + const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("14.03").start)); + if (next.map != CELADON || !(next.tile == landing.point) || next.facing != Direction::SOUTH){ + return "14.03 doesn't start where 12.03 ends."; + } + return true; +} + // 14.03 on `sim` from its start, Fly's landing (48, 12): the yard's tree // cut, into the gym and up the west aisle; Tamia walks down to (2, 9) // and is fought, the walk goes round her by column 1, the inner tree @@ -229,6 +253,10 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id } const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { + { + .input = {.name = "12.03 out of Fuchsia's Center and Fly to Celadon", .body = test_fly_to_celadon}, + .expectation = {.description = "lands on Celadon's heal spot facing south, where 14.03 starts"}, + }, { .input = {.name = "14.03 to below Erika and 14.04 back to the nurse", .body = test_gym_rows}, .expectation = {.description = "Tamia and Lori fought where the table steps into their lines, no one else"}, 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 7e7f648a76..a8b9232219 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -38,15 +38,6 @@ void add_tests_AutoStorySafari(UnitTestDatabase& database); // Rows 14.03 and 14.04, Celadon Gym, on the overworld sim (PokemonFRLG_AutoStoryCeladonGym_Tests.cpp). void add_tests_AutoStoryCeladonGym(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. 14.03 starts from Fly's landing in Celadon, after Blaine -// (14.02); segments 10 to 14.02 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 == "14.03"; -} - } // namespace PokemonFRLG } // namespace NintendoSwitch 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 9fae202476..e629599e39 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 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 14.03 14.04"; +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.03 14.03 14.04"; 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 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 14.03 14.04"}, + .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.03 14.03 14.04"}, }, { .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 14.03 14.04"}, + .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.03 14.03 14.04"}, }, { .input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman", @@ -273,7 +273,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 14.03 14.04"}, + .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.03 14.03 14.04"}, }, { .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 8d2a861040..8c655a9757 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp @@ -226,13 +226,9 @@ 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, but one - // authored before the rows that lead up to it. + // Each checkpoint starts where the save before it stands. 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 a58f4e1fa2..be8b40e57c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -35,7 +35,6 @@ #include "PokemonFRLG_AutoStoryItemUse.h" #include "PokemonFRLG_AutoStoryPcStorage.h" #include "PokemonFRLG_AutoStoryPlanGolden.h" -#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryPlanGolden10.h" #include "PokemonFRLG_AutoStoryPlanGolden11.h" #include "PokemonFRLG_AutoStoryPlanGolden12.h" @@ -282,19 +281,16 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po } // Plans every route of the story, each checkpoint from where the one -// before leaves the player (or, past rows not authored yet, from its own -// start: starts_after_unauthored_rows()), and adds the plans to `golden`. +// before leaves the player, and adds the plans to `golden`. UnitTestResult chain_story_routes(std::vector& golden){ const std::vector& checkpoints = story_checkpoints(); - if (checkpoints.size() != 54 || checkpoints[0].start){ - return "Expected 54 checkpoints, the first from a new game."; + if (checkpoints.size() != 55 || checkpoints[0].start){ + return "Expected 55 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 && starts_after_unauthored_rows(checkpoint.id)){ - pose = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); - }else if (c > 0){ + 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.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json new file mode 100644 index 0000000000..714ffe1260 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json @@ -0,0 +1,55 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "12.03", + "title": "Fuchsia's Center out to the street and Fly to Celadon City, for Erika", + "start": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "center_northwest_corner", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "west", "tiles": 7}, {"direction": "north", "tiles": 2}] + }, + "why": "from the nurse to the Center's wall west (0, 4) and up to the wall (0, 2), as 12.01 does: legs to walls, so the walk out starts from a known tile even if the Center script left the player a tile off the nurse" + }, + { + "id": "outside_fuchsia_center", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "south"} + }, + "why": "out of the Center's door onto Fuchsia City, where Fly works" + }, + { + "id": "fly_celadon", + "kind": "game_action", + "action": "fly", + "args": { + "town": "CeladonCity", + "species": "pidgey" + }, + "declared_after": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"}, + "why": "the Pidgey (Fly, 10.01), found in the party by its summary's species, flies to Celadon City (pokeguy flies there after Koga, 1:23:45), landing below the Pokemon Center's door (48, 11) on its heal spot, where 14.03 starts" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "From Fuchsia's nurse, where 12.02 ends healed, to Celadon for Erika (14.03): out of the Center on foot (Fly works outdoors only) and Fly. Celadon's landing, its heal spot (48, 12) facing south, is where 14.03 starts, so no walk follows.", + "Fuchsia and Celadon are both Fly towns the Pidgey already knows (11.01, 11.03); no new step or measurement." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"} + } + } +} From e27c7fc75c1ebaa964bc3d897141d97e05c0a496 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:35:39 -0800 Subject: [PATCH 05/20] PokemonFRLG: pass the player's gender to read_facing and get_on_bike in the bike recovery Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index 388d21ffbb..9711faaeb0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -143,11 +143,11 @@ StepWalk walk_bike_taps( calls.log = [&](const std::string& message){ console.log(message, COLOR_ORANGE); }; // On foot if the player's standing sprite reads. const auto remount = [&]{ - if (!read_facing(console, context)){ + if (!read_facing(console, context, player)){ return false; } console.log("Bike: a tap didn't move and the player is on foot.", COLOR_ORANGE); - get_on_bike(console, context); + get_on_bike(console, context, player); return true; }; const StepOutcome outcome = count_bike_taps_remounting(step, calls, remount); From 85f38e1badca5eb34568830438fe79458cd2bf7c Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:36:02 -0800 Subject: [PATCH 06/20] PokemonFRLG: thread the player's gender into walk_bike_taps Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index 9711faaeb0..cd3de8ff97 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -317,7 +317,7 @@ StepOutcome walk_and_watch( if (counts_step_taps(step)){ walked = walk_step_taps(console, context, step, interrupts, player); }else if (counts_bike_taps(step, speed)){ - walked = walk_bike_taps(console, context, step, interrupts); + walked = walk_bike_taps(console, context, step, interrupts, player); }else{ walked = walk_step(console, context, step, facing, interrupts, speed, player); } From 12dead4b4fe4e400007a68d2bc41165b4da53bd8 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:36:36 -0800 Subject: [PATCH 07/20] PokemonFRLG: thread the player's gender into walk_bike_taps (signature) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index cd3de8ff97..47639d1887 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -133,7 +133,7 @@ BikeTap console_bike_tap( // An open leg on the Bicycle, a tap at a time (count_bike_taps()). StepWalk walk_bike_taps( ConsoleHandle& console, ProControllerContext& context, - const RouteStep& step, const OverworldInterruptSet& interrupts + const RouteStep& step, const OverworldInterruptSet& interrupts, PlayerGender player ){ StepWalk out{std::nullopt, current_time(), false, false}; const OverworldInterrupts& watched = step.wild ? interrupts.wild : interrupts.other; From dd6f97cc44678e3224c481660ad98710827a6336 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:38:55 -0800 Subject: [PATCH 08/20] PokemonFRLG: 12.03 golden plan lines and fault sweep note; 14.03's Lori battle leaves the player facing east Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp | 2 ++ .../Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h | 4 ++++ .../Programs/AutoStory/StoryData/frlg-14.03.plan.json | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) 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 432b29894e..38fd5d3fab 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -128,6 +128,8 @@ const std::map KNOWN_FAILING{ "below_fuji_house plans from (4, 7), where Mr. Fuji's script warps the player (warp 4, 7, exact); from a tile off, no wall in his house funnels the walk onto (3, 4): legs that re-anchor, if the console shows the warp can land elsewhere"}, {"PokemonFRLG::AutoStory - Fault sweep: 11.01, warp no-op", "fly_celadon: a Fly that doesn't leave Lavender Town goes unseen, and east_of_snorlax walks from Lavender to Route 16 by Routes 8 and 7 instead: check the fly lands on its town's tile (FlyTown::landing) before the step ends"}, + {"PokemonFRLG::AutoStory - Fault sweep: 12.03, warp no-op", + "fly_celadon: a Fly that doesn't leave Fuchsia City goes unseen, and the row, which walks no further, ends on Celadon's declared tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, {"PokemonFRLG::AutoStory - Fault sweep: 08.03, off the Bicycle at a bike leg", "riding with no fault, route7_underground_exit's warp to UndergroundPath_EastEntrance is not confirmed on the sim (the screen after the fade reads as before the hold): the sim's warp off the Bicycle, before this class can sweep 08.03"}, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h index d4f36be0c1..483ebafaf1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h @@ -87,6 +87,10 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_12[] = { "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)", + "12.03 outside_fuchsia_center from FuchsiaCity_PokemonCenter_1F (0, 2) facing north to FuchsiaCity (25, 32) facing south", + "12.03 walk south 3 (to wall) -> FuchsiaCity_PokemonCenter_1F (0, 5) [walk only]", + "12.03 walk east 7 -> FuchsiaCity_PokemonCenter_1F (7, 5) [walk only]", + "12.03 walk south 4 (warp) -> FuchsiaCity (25, 32) [walk only]", "14.03 above_gym_tree from CeladonCity (48, 12) facing south to CeladonCity (40, 34) facing south", "14.03 walk west 7 -> CeladonCity (41, 12)", "14.03 walk south 13 (to wall) -> CeladonCity (41, 25)", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json index cc438a365e..cd92ebca32 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json @@ -106,8 +106,8 @@ "trainer": "TRAINER_BEAUTY_LORI", "foes": ["exeggcute"] }, - "declared_after": {"map": "CeladonCity_Gym", "tiles": [[5, 5]], "facing": "north"}, - "why": "Beauty Lori (TRAINER_BEAUTY_LORI): Exeggcute Lv24 (pokeguy: one Bite)" + "declared_after": {"map": "CeladonCity_Gym", "tiles": [[5, 5]], "facing": "east"}, + "why": "Beauty Lori (TRAINER_BEAUTY_LORI): Exeggcute Lv24 (pokeguy: one Bite); the player stepped east into her line, so faces east afterwards" }, { "id": "beside_erika", From 78fb23adcf5529cb7b4b98bbf62643c6df4bf16a Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:40:09 -0800 Subject: [PATCH 09/20] PokemonFRLG: 14.04's leg onto the gym's mat is tapped now (golden) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h index 483ebafaf1..2a6f7574bf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h @@ -107,7 +107,7 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_12[] = { "14.03 below_erika from CeladonCity_Gym (6, 5) facing east to CeladonCity_Gym (6, 5) facing north", "14.03 face north -> CeladonCity_Gym (6, 5) [walk only]", "14.04 below_gym_tree_out from CeladonCity_Gym (2, 18) facing south to CeladonCity (40, 36) facing north", - "14.04 walk east 4 -> CeladonCity_Gym (6, 18) [walk only]", + "14.04 walk east 4 -> CeladonCity_Gym (6, 18) [walk only] [tapped]", "14.04 walk south 1 (warp) -> CeladonCity (11, 31) [walk only]", "14.04 walk south 6 (to wall) -> CeladonCity (11, 37)", "14.04 walk east 30 (to wall) -> CeladonCity (41, 37)", From ac18da52b7ac0354f391010e735393f354c58887 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:57:27 -0800 Subject: [PATCH 10/20] PokemonFRLG: the checkpoint table follows the story's order (STORY_ORDER), not the ids' Ids are labels: a gym's rows may be numbered before rows that come first in the story. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryTable.cpp | 39 ++++++++++++++++++- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 3 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 51ddeca644..9646454763 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" @@ -218,13 +220,48 @@ StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_v return checkpoint; } +namespace{ + +// The checkpoints' ids in the order the story plays them. Ids are labels, +// not positions: a gym's rows may be numbered before rows that come first +// in the story (the table is not sorted by id). Every file in StoryData/ +// is listed once; a new checkpoint is added at its place in the story. +constexpr std::string_view STORY_ORDER[] = { + "01.01", "01.02", "01.03", "01.04", "01.05", "01.06", "02.01", "02.02", "02.03", "03.01", + "03.02", "03.03", "04.01", "04.02", "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", + "09.04", "10.01", "10.02", "10.03", "10.04", "10.05", "10.06", "11.01", "11.02", "11.03", + "12.01", "12.02", "12.03", "14.03", "14.04", +}; + +// `checkpoints` in STORY_ORDER's order. Throws ParseException for a +// checkpoint that is not listed there, or listed twice. +std::vector in_story_order(std::vector checkpoints){ + std::vector ordered; + for (std::string_view id : STORY_ORDER){ + for (StoryCheckpoint& checkpoint : checkpoints){ + if (checkpoint.id == id){ + ordered.push_back(std::move(checkpoint)); + checkpoint.id = ""; + } + } + } + if (ordered.size() != checkpoints.size()){ + throw ParseException("Every checkpoint file needs its id once in STORY_ORDER (PokemonFRLG_AutoStoryTable.cpp)."); + } + return ordered; +} + +} // namespace + const std::vector& story_checkpoints(){ static const std::vector checkpoints = []{ std::vector result; for (const auto& [name, text] : autostory_checkpoint_json()){ result.push_back(read_story_checkpoint_file(parse_json(text), name)); } - return result; + return in_story_order(std::move(result)); }(); return checkpoints; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 3c96de3850..83f92808b3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -65,7 +65,8 @@ const std::vector>& autostory_checkpoint_jso // action args it doesn't take, or has notes for a step it doesn't have. StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source); -// Checkpoints 01.01 to 07.02, in order: every file in StoryData/. With +// Every file in StoryData/ in the order the story plays them (STORY_ORDER in +// PokemonFRLG_AutoStoryTable.cpp), not in id order. Checkpoints 01.01 to 07.02 with // 01.02, the way back in after SID Helper, after 01.01, 01.05 split in two at Squirtle's ball for // Starter RNG: 01.05 and 01.06, 04.03, the way back in after Gift RNG, // after 04.02, 04.04, the Magikarp put in BOX 1, after it, 05.01 and From 22a830e013a777d4f3bff97bb80c9e672244c3f0 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 17:22:14 -0800 Subject: [PATCH 11/20] FRLG 14.04: Erika is fought by PokeGuy's policy 14.04 erika names goal-based-setup with the doc's goals (Sp. Atk +1, accuracy +2, outspeed, Guard Spec) and the foe rows from the doc's stats, and a plan test checks them. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp | 8 ++++++++ .../AutoStory/StoryData/frlg-14.04.plan.json | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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 a68d66565e..285f9fbbd5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp @@ -359,6 +359,10 @@ UnitTestResult test_plan_tower_rival(){ return check_policy_step("10.03", "rival_tower", {.spa = 2, .outspeed = true, .guard_accuracy = true, .torrent_power = true}); } +UnitTestResult test_plan_erika(){ + return check_policy_step("14.04", "erika", {.spa = 1, .accuracy = 2, .outspeed = true, .guard_accuracy = true}); +} + struct AutoStoryBattlePolicyInput{ std::string name; @@ -441,6 +445,10 @@ const std::vector AUTO_STORY_BATTLE_POLICY_CASES = { .input = {.name = "plan: 12.02 koga names the policy, goals and foes", .body = test_plan_koga}, .expectation = {.description = "the policy, goals and 4 foe rows"}, }, + { + .input = {.name = "plan: 14.04 erika names the policy, goals and foes", .body = test_plan_erika}, + .expectation = {.description = "the policy, goals and 3 foe rows"}, + }, { .input = {.name = "plan: 10.03 rival_tower names the policy, goals and foes", .body = test_plan_tower_rival}, .expectation = {.description = "the policy, goals and 5 foe rows"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json index e19d261fb2..1c999b58ae 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json @@ -23,10 +23,20 @@ "kind": "battle", "args": { "trainer": "TRAINER_LEADER_ERIKA", - "foes": ["victreebel", "tangela", "vileplume"] + "foes": ["victreebel", "tangela", "vileplume"], + "policy": "goal-based-setup", + "setup_spa": 1, + "setup_accuracy": 2, + "setup_outspeed": true, + "setup_guard_accuracy": true, + "foe_threats": [ + [45, 24, 9, 54, 30, 0, 0], + [33, 18, 5, 36, 20, 0, 0], + [34, 24, 9, 54, 30, 0, 0] + ] }, "declared_after": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, - "why": "Erika (TRAINER_LEADER_ERIKA): Victreebel Lv29, Tangela Lv24, Vileplume Lv29; then the RAINBOWBADGE and TM19, read to the overworld with the battle's text (pokeguy 1:26:04 to 1:27:06)" + "why": "Erika (TRAINER_LEADER_ERIKA), fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +1, accuracy +2 and outspeed by X items; the doc's erika row, foe_threats from its stats): Victreebel Lv29, Tangela Lv24, Vileplume Lv29; then the RAINBOWBADGE and TM19, read to the overworld with the battle's text (pokeguy 1:26:04 to 1:27:06)" }, { "id": "below_lori", From 9e2f5a19080270ab0ebbb222d9baeeac613a2658 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 19:37:03 -0800 Subject: [PATCH 12/20] FRLG 14.04: Erika's foe_threats are PokemonSimulation's planning_risk rows, pinned by a test Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 28 +++++++++++++++++++ .../AutoStory/StoryData/frlg-14.04.plan.json | 8 +++--- 2 files changed, 32 insertions(+), 4 deletions(-) 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 be8f3312d0..023e8515c9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -252,6 +252,30 @@ UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id return true; } +// Erika's rows are PokemonSimulation's planning_risk() for each foe leading +// against the entry state of its erika case (35/137): speed, the 80th +// percentile loss, the mean, the worst case, the worst normal hit, then +// whether it lowers accuracy and whether it explodes. +UnitTestResult test_erika_foe_threats_are_the_generators(){ + for (const StoryStep& step : checkpoint("14.04").steps){ + if (step.name != "erika"){ + continue; + } + const auto found = step.args.find("foe_threats"); + const auto* rows = found == step.args.end() ? nullptr : std::get_if>>(&found->second); + const std::vector> expected = { + {45, 0, 1, 60, 30, 0, 0}, // Victreebel + {33, 18, 8, 42, 20, 0, 0}, // Tangela + {34, 0, 2, 60, 30, 0, 0}, // Vileplume + }; + if (rows == nullptr || *rows != expected){ + return "14.04 erika: foe_threats are not the generator's rows for the erika case."; + } + return true; + } + return "14.04 has no erika battle step."; +} + const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { { .input = {.name = "12.03 out of Fuchsia's Center and Fly to Celadon", .body = test_fly_to_celadon}, @@ -272,6 +296,10 @@ const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { }}, .expectation = {.description = "a Lv44 lead passes the LEVEL step, a Lv43 one stops there"}, }, + { + .input = {.name = "14.04 Erika's foe rows are the generator's", .body = test_erika_foe_threats_are_the_generators}, + .expectation = {.description = "PokemonSimulation planning_risk() rows"}, + }, }; } // namespace diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json index 1c999b58ae..c05ef8a4d4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json @@ -30,13 +30,13 @@ "setup_outspeed": true, "setup_guard_accuracy": true, "foe_threats": [ - [45, 24, 9, 54, 30, 0, 0], - [33, 18, 5, 36, 20, 0, 0], - [34, 24, 9, 54, 30, 0, 0] + [45, 0, 1, 60, 30, 0, 0], + [33, 18, 8, 42, 20, 0, 0], + [34, 0, 2, 60, 30, 0, 0] ] }, "declared_after": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, - "why": "Erika (TRAINER_LEADER_ERIKA), fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +1, accuracy +2 and outspeed by X items; the doc's erika row, foe_threats from its stats): Victreebel Lv29, Tangela Lv24, Vileplume Lv29; then the RAINBOWBADGE and TM19, read to the overworld with the battle's text (pokeguy 1:26:04 to 1:27:06)" + "why": "Erika (TRAINER_LEADER_ERIKA), fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +1, accuracy +2 and outspeed by X items; the doc's erika row, foe_threats the rows PokemonSimulation's planning_risk() gives for each foe leading against the entry state, 35/137): Victreebel Lv29, Tangela Lv24, Vileplume Lv29; then the RAINBOWBADGE and TM19, read to the overworld with the battle's text (pokeguy 1:26:04 to 1:27:06)" }, { "id": "below_lori", From 0062b1848c0d51458cb92d820affcc6f94fb3222 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 20:44:02 -0800 Subject: [PATCH 13/20] FRLG 14.04: Erika alone; the walk out and the heal are 14.04b A boss battle is its own checkpoint (user, 2026-11-12). 14.04 starts in front of Erika and ends there after the RAINBOWBADGE and TM19 text; the new 14.04b starts at the same tile and goes out past the tree and heals at Celadon's Center. Ids are not renumbered; the golden, run-plan, table, count and gym tests follow. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 26 +++- .../PokemonFRLG_AutoStoryPlanGolden12.h | 32 ++--- .../PokemonFRLG_AutoStoryRows_Tests.h | 2 +- .../PokemonFRLG_AutoStoryRunPlan_Tests.cpp | 8 +- .../AutoStory/PokemonFRLG_AutoStoryTable.cpp | 2 +- .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 4 +- .../AutoStory/StoryData/frlg-14.04.plan.json | 110 +-------------- .../AutoStory/StoryData/frlg-14.04b.plan.json | 130 ++++++++++++++++++ 8 files changed, 176 insertions(+), 138 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json 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 023e8515c9..d989528abb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -2,11 +2,12 @@ * * From: https://github.com/PokemonAutomation/ * - * Rows 12.03, 14.03 and 14.04 (StoryData/frlg-12.03.plan.json, 14.03, 14.04) + * Rows 12.03, 14.03, 14.04 and 14.04b (StoryData/frlg-12.03.plan.json, 14.03, + * 14.04, 14.04b) * on the overworld sim: from Fuchsia's nurse out of the Center and Fly to * Celadon; from Fly's landing in Celadon past the yard's tree, up * the gym's west aisle into Beauty Tamia's line, round her by column 1, - * the inner tree, Beauty Lori, to below Erika; and from Erika back out + * the inner tree, Beauty Lori, to below Erika; and from Erika (14.04b) back out * the same way, past the tree, to the nurse. And the lead's attacks against the * gym's three parties. * @@ -162,8 +163,8 @@ std::string to_erika(StoryPose& at, OverworldSim& sim){ return ""; } -// 14.03 on the sim (to_erika()), then 14.04 on the same sim, the gym as -// 14.03 leaves it (Tamia on (2, 9), the inner tree cut): out along row +// 14.03 on the sim (to_erika()), then 14.04, Erika's battle, which ends +// where it starts, then 14.04b on the same sim, the gym as 14.03 leaves it (Tamia on (2, 9), the inner tree cut): out along row // 5, a step onto the cut tree's tile, down column 1 past Tamia and // column 2 to the wall, out of the gym, the tree again and back below // the Center's door (the Center's way in and the nurse need the @@ -177,12 +178,23 @@ UnitTestResult test_gym_rows(){ if (const std::string failure = row_on_sim("14.04", at, sim); !failure.empty()){ return failure; } + const MapPosition below_erika{GYM, {6, 5}}; + if (!(sim.state().position == below_erika)){ + return std::format("14.04: ended on {}, not in front of Erika where 14.04b starts.", to_string(sim.state().position)); + } + const StoryPose after_erika = *story_pose(Pokemon::pose_of(*checkpoint("14.04b").start)); + if (after_erika.map != GYM || !(after_erika.tile == below_erika.point)){ + return "14.04b doesn't start where 14.04 ends."; + } + if (const std::string failure = row_on_sim("14.04b", at, sim); !failure.empty()){ + return failure; + } if (sim.state().trainers_beaten.size() != 2){ - return std::format("14.04: fought{} after Tamia and Lori.", fought(sim)); + return std::format("14.04b: fought{} after Tamia and Lori.", fought(sim)); } const MapPosition below_center{CELADON, {48, 12}}; if (!(sim.state().position == below_center)){ - return std::format("14.04: ended on {}, not below the Center's door {}.", to_string(sim.state().position), to_string(below_center)); + return std::format("14.04b: ended on {}, not below the Center's door {}.", to_string(sim.state().position), to_string(below_center)); } return true; } @@ -282,7 +294,7 @@ const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { .expectation = {.description = "lands on Celadon's heal spot facing south, where 14.03 starts"}, }, { - .input = {.name = "14.03 to below Erika and 14.04 back to the nurse", .body = test_gym_rows}, + .input = {.name = "14.03 to below Erika, 14.04 on the spot and 14.04b back to the nurse", .body = test_gym_rows}, .expectation = {.description = "Tamia and Lori fought where the table steps into their lines, no one else"}, }, { diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h index 7a9d157b83..d40b88c142 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h @@ -106,22 +106,22 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_12[] = { "14.03 walk north 7 -> CeladonCity_Gym (2, 11) [walk only]", "14.03 below_erika from CeladonCity_Gym (6, 5) facing east to CeladonCity_Gym (6, 5) facing north", "14.03 face north -> CeladonCity_Gym (6, 5) [walk only]", - "14.04 below_gym_tree_out from CeladonCity_Gym (2, 18) facing south to CeladonCity (40, 36) facing north", - "14.04 walk east 4 -> CeladonCity_Gym (6, 18) [walk only] [tapped]", - "14.04 walk south 1 (warp) -> CeladonCity (11, 31) [walk only]", - "14.04 walk south 6 (to wall) -> CeladonCity (11, 37)", - "14.04 walk east 30 (to wall) -> CeladonCity (41, 37)", - "14.04 walk north 1 (to wall) -> CeladonCity (41, 36)", - "14.04 walk west 1 -> CeladonCity (40, 36)", - "14.04 face north -> CeladonCity (40, 36)", - "14.04 celadon_below_center from CeladonCity (40, 35) facing north to CeladonCity (48, 12) facing north", - "14.04 walk north 3 -> CeladonCity (40, 32)", - "14.04 walk west 9 -> CeladonCity (31, 32)", - "14.04 walk north 8 (to wall) -> CeladonCity (31, 24)", - "14.04 walk east 12 -> CeladonCity (43, 24)", - "14.04 walk north 12 (to wall) -> CeladonCity (43, 12)", - "14.04 walk east 5 -> CeladonCity (48, 12)", - "14.04 face north -> CeladonCity (48, 12)", + "14.04b below_gym_tree_out from CeladonCity_Gym (2, 18) facing south to CeladonCity (40, 36) facing north", + "14.04b walk east 4 -> CeladonCity_Gym (6, 18) [walk only] [tapped]", + "14.04b walk south 1 (warp) -> CeladonCity (11, 31) [walk only]", + "14.04b walk south 6 (to wall) -> CeladonCity (11, 37)", + "14.04b walk east 30 (to wall) -> CeladonCity (41, 37)", + "14.04b walk north 1 (to wall) -> CeladonCity (41, 36)", + "14.04b walk west 1 -> CeladonCity (40, 36)", + "14.04b face north -> CeladonCity (40, 36)", + "14.04b celadon_below_center from CeladonCity (40, 35) facing north to CeladonCity (48, 12) facing north", + "14.04b walk north 3 -> CeladonCity (40, 32)", + "14.04b walk west 9 -> CeladonCity (31, 32)", + "14.04b walk north 8 (to wall) -> CeladonCity (31, 24)", + "14.04b walk east 12 -> CeladonCity (43, 24)", + "14.04b walk north 12 (to wall) -> CeladonCity (43, 12)", + "14.04b walk east 5 -> CeladonCity (48, 12)", + "14.04b face north -> CeladonCity (48, 12)", }; } // namespace PokemonFRLG 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 a8b9232219..7ba79bbc23 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -35,7 +35,7 @@ void add_tests_AutoStorySnorlax(UnitTestDatabase& database); void add_tests_AutoStorySlope(UnitTestDatabase& database); // Row 11.03 on the sims (PokemonFRLG_AutoStorySafari_Tests.cpp). void add_tests_AutoStorySafari(UnitTestDatabase& database); -// Rows 14.03 and 14.04, Celadon Gym, on the overworld sim (PokemonFRLG_AutoStoryCeladonGym_Tests.cpp). +// Rows 14.03, 14.04 and 14.04b, Celadon Gym, on the overworld sim (PokemonFRLG_AutoStoryCeladonGym_Tests.cpp). void add_tests_AutoStoryCeladonGym(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 7dac508954..9775ae4c39 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 14.03 14.04"; +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 14.03 14.04 14.04b"; 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 14.03 14.04"}, + .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 14.03 14.04 14.04b"}, }, { .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 14.03 14.04"}, + .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 14.03 14.04 14.04b"}, }, { .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 14.03 14.04"}, + .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 14.03 14.04 14.04b"}, }, { .input = { .name = "Starter RNG first, with both on", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 57b02d0740..44ecee7cb2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -234,7 +234,7 @@ constexpr std::string_view STORY_ORDER[] = { "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", "09.04", "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", "14.03", "14.04", + "12.01", "12.02", "12.02b", "12.03", "14.03", "14.04", "14.04b", }; // `checkpoints` in STORY_ORDER's order. Throws ParseException for a 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 7e4bd216e9..c16ab71a55 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -284,8 +284,8 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po // before leaves the player, and adds the plans to `golden`. UnitTestResult chain_story_routes(std::vector& golden){ const std::vector& checkpoints = story_checkpoints(); - if (checkpoints.size() != 56 || checkpoints[0].start){ - return "Expected 56 checkpoints, the first from a new game."; + if (checkpoints.size() != 57 || checkpoints[0].start){ + return "Expected 57 checkpoints, the first from a new game."; } StoryPose pose; for (size_t c = 0; c < checkpoints.size(); c++){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json index c05ef8a4d4..670ccc42d1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "14.04", - "title": "Celadon Gym: Erika, the RAINBOWBADGE and TM19, then out past the tree to the nurse", + "title": "Celadon Gym: Erika, the RAINBOWBADGE and TM19", "start": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, "events": [ { @@ -37,109 +37,6 @@ }, "declared_after": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, "why": "Erika (TRAINER_LEADER_ERIKA), fought by pokeguy's policy C2 (goal-based-setup: Sp. Atk +1, accuracy +2 and outspeed by X items; the doc's erika row, foe_threats the rows PokemonSimulation's planning_risk() gives for each foe leading against the entry state, 35/137): Victreebel Lv29, Tangela Lv24, Vileplume Lv29; then the RAINBOWBADGE and TM19, read to the overworld with the battle's text (pokeguy 1:26:04 to 1:27:06)" - }, - { - "id": "below_lori", - "kind": "legs", - "action": "taps", - "args": { - "legs": [{"direction": "west", "tiles": 1}] - }, - "why": "a tap west from below Erika (6, 5) to below Lori (5, 4), on (5, 5)" - }, - { - "id": "beside_inner_tree_tile", - "kind": "step", - "args": { - "direction": "west" - }, - "declared_after": {"map": "CeladonCity_Gym", "tiles": [[4, 5]], "facing": "west"}, - "why": "a step west to (4, 5), beside the inner tree's tile (3, 5): legs that end here would take the tree, which the map still has, for a wall and hold on over its cut tile to (1, 5)" - }, - { - "id": "onto_inner_tree_tile", - "kind": "step", - "args": { - "direction": "west" - }, - "declared_after": {"map": "CeladonCity_Gym", "tiles": [[3, 5]], "facing": "west"}, - "why": "a step onto the inner tree's tile (3, 5), cut in 14.03 and still cut (a save keeps it; only a warp grows it back): the map still has the tree there, so no planned legs over it" - }, - { - "id": "row_5_to_wall", - "kind": "legs", - "action": "run", - "args": { - "legs": [{"direction": "west", "tiles": 2}] - }, - "why": "run west from (3, 5) to the wall at (1, 5): Erika's win beats every trainer in the gym (set_gym_trainers 4), and the wall stops any overshoot" - }, - { - "id": "column_1_down_to_wall", - "kind": "legs", - "action": "run", - "args": { - "legs": [{"direction": "south", "tiles": 5}] - }, - "why": "run down column 1 to the wall at (1, 10), (1, 11) being wall: past Tamia, who stands on (2, 9) since her battle" - }, - { - "id": "onto_column_2", - "kind": "legs", - "action": "taps", - "args": { - "legs": [{"direction": "east", "tiles": 1}] - }, - "why": "a tap east from the wall (1, 10) onto column 2, (2, 10), right below Tamia (2, 9)" - }, - { - "id": "column_2_to_wall", - "kind": "legs", - "action": "run", - "args": { - "legs": [{"direction": "south", "tiles": 8}] - }, - "why": "run down the west aisle from (2, 10) to the wall at (2, 18): behind Lass Kay (3, 11), who looks east, and clear of Beauty Bridget's line (6..8, 10) that a planned way out through the middle crosses; all are beaten since Erika's win, and the wall stops any overshoot" - }, - { - "id": "below_gym_tree_out", - "kind": "route", - "action": "run", - "args": { - "target": {"map": "CeladonCity", "tiles": [[40, 36]], "facing": "north"} - }, - "why": "east along row 18 and out of the gym's door (6, 18), down through the gap in the ledges to row 36 and east along it to below the tree (40, 35), grown back" - }, - { - "id": "cut_tree_out", - "kind": "game_action", - "action": "cut_tree", - "args": { - "direction": "north" - }, - "declared_after": {"map": "CeladonCity", "tiles": [[40, 35]], "facing": "north"}, - "why": "the tree again; a step onto its tile" - }, - { - "id": "celadon_below_center", - "kind": "route", - "action": "run", - "args": { - "target": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "north"} - }, - "why": "north through the city to below the Center's door (48, 11)" - }, - { - "id": "celadon_nurse", - "kind": "game_action", - "action": "center_enter", - "declared_after": {"map": "CeladonCity_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_celadon", - "kind": "heal", - "why": "full HP and PP" } ] }, @@ -148,15 +45,14 @@ "notes": { "checkpoint": [ "Erika (6, 4), talked to from below, from the save in front of her (14.03): Victreebel Lv29, Tangela Lv24 and Vileplume Lv29 (sParty_LeaderErika); then the RAINBOWBADGE and TM19 Giga Drain. Her win sets every gym trainer beaten (CeladonCity_Gym_EventScript_DefeatedErika, set_gym_trainers 4).", - "Out the way in: row 5, a step at a time over the inner tree's tile, and column 1 to their walls, Tamia standing on (2, 9) where her battle left her, the inner tree (3, 5) still cut (a save keeps the map's objects and temp flags; only a warp clears them). Leaving the gym grows the yard's tree (40, 35) back, so it is cut again from below.", - "PokeGuy flies to Celadon from the gym instead (1:27:07, same-city Fly); the walk back stands in until a Fly step is in. Either way the row ends at the nurse, where 15.01 starts." + "A boss battle is its own checkpoint (user, 2026-11-12): Erika's fight is all this row does. It ends in front of Erika after the RAINBOWBADGE and TM19 text, and saves there; 14.04b goes on out of the gym." ] } }, "metadata": { "phase": "testing", "postconditions": { - "position": {"map": "CeladonCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + "position": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"} } } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json new file mode 100644 index 0000000000..afdbabfc9d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json @@ -0,0 +1,130 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "14.04b", + "title": "Out of the gym past the tree, heal at Celadon's Center", + "start": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, + "events": [ + { + "id": "below_lori", + "kind": "legs", + "action": "taps", + "args": { + "legs": [{"direction": "west", "tiles": 1}] + }, + "why": "a tap west from below Erika (6, 5) to below Lori (5, 4), on (5, 5)" + }, + { + "id": "beside_inner_tree_tile", + "kind": "step", + "args": { + "direction": "west" + }, + "declared_after": {"map": "CeladonCity_Gym", "tiles": [[4, 5]], "facing": "west"}, + "why": "a step west to (4, 5), beside the inner tree's tile (3, 5): legs that end here would take the tree, which the map still has, for a wall and hold on over its cut tile to (1, 5)" + }, + { + "id": "onto_inner_tree_tile", + "kind": "step", + "args": { + "direction": "west" + }, + "declared_after": {"map": "CeladonCity_Gym", "tiles": [[3, 5]], "facing": "west"}, + "why": "a step onto the inner tree's tile (3, 5), cut in 14.03 and still cut (a save keeps it; only a warp grows it back): the map still has the tree there, so no planned legs over it" + }, + { + "id": "row_5_to_wall", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "west", "tiles": 2}] + }, + "why": "run west from (3, 5) to the wall at (1, 5): Erika's win beats every trainer in the gym (set_gym_trainers 4), and the wall stops any overshoot" + }, + { + "id": "column_1_down_to_wall", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 5}] + }, + "why": "run down column 1 to the wall at (1, 10), (1, 11) being wall: past Tamia, who stands on (2, 9) since her battle" + }, + { + "id": "onto_column_2", + "kind": "legs", + "action": "taps", + "args": { + "legs": [{"direction": "east", "tiles": 1}] + }, + "why": "a tap east from the wall (1, 10) onto column 2, (2, 10), right below Tamia (2, 9)" + }, + { + "id": "column_2_to_wall", + "kind": "legs", + "action": "run", + "args": { + "legs": [{"direction": "south", "tiles": 8}] + }, + "why": "run down the west aisle from (2, 10) to the wall at (2, 18): behind Lass Kay (3, 11), who looks east, and clear of Beauty Bridget's line (6..8, 10) that a planned way out through the middle crosses; all are beaten since Erika's win, and the wall stops any overshoot" + }, + { + "id": "below_gym_tree_out", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeladonCity", "tiles": [[40, 36]], "facing": "north"} + }, + "why": "east along row 18 and out of the gym's door (6, 18), down through the gap in the ledges to row 36 and east along it to below the tree (40, 35), grown back" + }, + { + "id": "cut_tree_out", + "kind": "game_action", + "action": "cut_tree", + "args": { + "direction": "north" + }, + "declared_after": {"map": "CeladonCity", "tiles": [[40, 35]], "facing": "north"}, + "why": "the tree again; a step onto its tile" + }, + { + "id": "celadon_below_center", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "north"} + }, + "why": "north through the city to below the Center's door (48, 11)" + }, + { + "id": "celadon_nurse", + "kind": "game_action", + "action": "center_enter", + "declared_after": {"map": "CeladonCity_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_celadon", + "kind": "heal", + "why": "full HP and PP" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts in front of Erika, where 14.04 ends after her battle and saves.", + "Out the way in: row 5, a step at a time over the inner tree's tile, and column 1 to their walls, Tamia standing on (2, 9) where her battle left her, the inner tree (3, 5) still cut (a save keeps the map's objects and temp flags; only a warp clears them). Leaving the gym grows the yard's tree (40, 35) back, so it is cut again from below.", + "PokeGuy flies to Celadon from the gym instead (1:27:07, same-city Fly); the walk back stands in until a Fly step is in. Either way the row ends at the nurse, where 15.01 starts." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "CeladonCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + } + } +} From 29b3c52896716179ddde017dc666cf3fa812a914 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:09:02 -0800 Subject: [PATCH 14/20] FRLG 12.03: Fuchsia to Cinnabar by Fly and Surf; 14.03 starts at Cinnabar and Flies to Celadon 12.03 takes 17.01's events (Fly to Pallet, a Repel, Surf down Route 21, heal at Cinnabar) from Fuchsia's nurse, as PokeGuy goes after Koga; 14.03 now starts at Cinnabar's nurse, steps out and Flies to Celadon. Cinnabar and Route 21 maps join the planner, Pallet's fat man gets a tile, tests and golden follow. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Overworld/PokemonFRLG_OverworldMaps.cpp | 21 ++++++ .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 66 +++++++++++++----- .../PokemonFRLG_AutoStoryFaultSweep_Tests.cpp | 4 +- .../PokemonFRLG_AutoStoryPlanGolden12.h | 22 ++++++ .../AutoStory/StoryData/frlg-12.03.plan.json | 67 ++++++++++++++----- .../AutoStory/StoryData/frlg-14.03.plan.json | 30 +++++++-- 6 files changed, 169 insertions(+), 41 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index 9896be653a..3e5bdbc156 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -143,6 +143,10 @@ constexpr std::string_view MAP_NAMES[] = { // Koga's gym, and the Warden's house (GOLD TEETH for HM04). "FuchsiaCity_Gym", "FuchsiaCity_WardensHouse", + // Cinnabar Island, and Route 21 north of it to Pallet Town (12.03). + "CinnabarIsland", + "Route21_North", + "Route21_South", "CeruleanCave_1F", "CeruleanCave_2F", "CeruleanCave_B1F", @@ -169,11 +173,28 @@ void add_unmapped_centers(std::vector& maps){ } } +// Pallet Town's fat man wanders over (7..19, 15..19), which holds the whole +// shore (7..10, 16) the way onto Route 21's water goes by. A planned route +// never crosses a wanderer's box, so none would reach the water. He stands on +// his own tile (13, 17) in the planner's model: east of the shore, off the +// way; a person in the way on the console is waited out (12.03). +void waive_pallet_fat_man_box(MapData& map){ + if (map.name != "PalletTown"){ + return; + } + for (MapObject& object : map.objects){ + if (object.name == "fat_man"){ + object.wander.reset(); + } + } +} + const std::vector& all_maps(){ static const std::vector MAPS = []{ std::vector maps; for (std::string_view name : MAP_NAMES){ maps.push_back(load_map(std::string(name))); + waive_pallet_fat_man_box(maps.back()); } add_unmapped_centers(maps); return maps; 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 d989528abb..b5e68d0474 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -4,8 +4,9 @@ * * Rows 12.03, 14.03, 14.04 and 14.04b (StoryData/frlg-12.03.plan.json, 14.03, * 14.04, 14.04b) - * on the overworld sim: from Fuchsia's nurse out of the Center and Fly to - * Celadon; from Fly's landing in Celadon past the yard's tree, up + * on the overworld sim: from Fuchsia's nurse out of the Center, Fly to Pallet + * Town and Surf down Route 21 to Cinnabar; from Cinnabar's nurse out of the + * Center and Fly to Celadon, past the yard's tree, up * the gym's west aisle into Beauty Tamia's line, round her by column 1, * the inner tree, Beauty Lori, to below Erika; and from Erika (14.04b) back out * the same way, past the tree, to the nurse. And the lead's attacks against the @@ -117,30 +118,57 @@ std::string fought(const OverworldSim& sim){ return names.empty() ? " no one" : names; } -// 12.03 on a sim from Fuchsia's nurse: out of the Center, the Fly, and -// the landing on Celadon's heal spot (48, 12) facing south, where 14.03 -// starts. No one is fought on the way. +// 12.03 on a sim from Fuchsia's nurse: out of the Center, the Fly to +// Pallet Town, the shore, the Surf onto Route 21 and the way south over it +// to Cinnabar's Center door. No trainer is met and no rule is broken. +UnitTestResult test_fuchsia_to_cinnabar(){ + const StoryCheckpoint& row = checkpoint("12.03"); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); + OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + for (const StoryStep& step : row.steps){ + if (step.action == CENTER_ENTER_VARIANT){ + break; + } + if (const std::string failure = row_step_on_sim(sim, at, step, row.id); !failure.empty()){ + return std::format("12.03: ended on {}; {}", to_string(sim.state().position), failure); + } + } + const MapPosition below_center{"CinnabarIsland", {14, 12}}; + if (!(sim.state().position == below_center)){ + return std::format("12.03: ended on {}, not below Cinnabar's Center door {}.", to_string(sim.state().position), to_string(below_center)); + } + if (!sim.state().trainers_beaten.empty() || !sim.state().violations.empty()){ + return "12.03: met a trainer or broke a rule on the way."; + } + return true; +} + +// 14.03's first steps on a sim from Cinnabar's nurse: out of the Center and +// the Fly to Celadon, landing on its heal spot (48, 12) facing south, where +// the walk to the gym starts. No one is fought on the way. UnitTestResult test_fly_to_celadon(){ - StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint("12.03").start)); + const StoryCheckpoint& row = checkpoint("14.03"); + StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); - if (const std::string failure = row_on_sim("12.03", at, sim); !failure.empty()){ - return failure; + for (const StoryStep& step : row.steps){ + if (step.name == "above_gym_tree"){ + break; + } + if (const std::string failure = row_step_on_sim(sim, at, step, row.id); !failure.empty()){ + return std::format("14.03: ended on {}; {}", to_string(sim.state().position), failure); + } } const MapPosition landing{CELADON, {48, 12}}; if (!(sim.state().position == landing) || sim.state().facing != Direction::SOUTH){ - return std::format("12.03: ended on {}, not Celadon's heal spot {} facing south.", to_string(sim.state().position), to_string(landing)); + return std::format("14.03: ended on {}, not Celadon's heal spot {} facing south.", to_string(sim.state().position), to_string(landing)); } if (!sim.state().trainers_beaten.empty()){ - return std::format("12.03: fought{}.", fought(sim)); - } - const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("14.03").start)); - if (next.map != CELADON || !(next.tile == landing.point) || next.facing != Direction::SOUTH){ - return "14.03 doesn't start where 12.03 ends."; + return std::format("14.03: fought{}.", fought(sim)); } return true; } -// 14.03 on `sim` from its start, Fly's landing (48, 12): the yard's tree +// 14.03 on `sim` from its start, Cinnabar's nurse: the Fly to Celadon's landing (48, 12), the yard's tree // cut, into the gym and up the west aisle; Tamia walks down to (2, 9) // and is fought, the walk goes round her by column 1, the inner tree // (3, 5) is cut, and Lori is fought from (5, 5). Ends below Erika, where @@ -290,8 +318,12 @@ UnitTestResult test_erika_foe_threats_are_the_generators(){ const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { { - .input = {.name = "12.03 out of Fuchsia's Center and Fly to Celadon", .body = test_fly_to_celadon}, - .expectation = {.description = "lands on Celadon's heal spot facing south, where 14.03 starts"}, + .input = {.name = "12.03 Fuchsia to Cinnabar by Fly and Surf", .body = test_fuchsia_to_cinnabar}, + .expectation = {.description = "Pallet Town's shore, Route 21 surfed, below Cinnabar's Center door, nobody met"}, + }, + { + .input = {.name = "14.03 out of Cinnabar's Center and Fly to Celadon", .body = test_fly_to_celadon}, + .expectation = {.description = "lands on Celadon's heal spot facing south, where the walk to the gym starts"}, }, { .input = {.name = "14.03 to below Erika, 14.04 on the spot and 14.04b back to the nurse", .body = test_gym_rows}, 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 38fd5d3fab..a01c2de5c2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -129,7 +129,9 @@ const std::map KNOWN_FAILING{ {"PokemonFRLG::AutoStory - Fault sweep: 11.01, warp no-op", "fly_celadon: a Fly that doesn't leave Lavender Town goes unseen, and east_of_snorlax walks from Lavender to Route 16 by Routes 8 and 7 instead: check the fly lands on its town's tile (FlyTown::landing) before the step ends"}, {"PokemonFRLG::AutoStory - Fault sweep: 12.03, warp no-op", - "fly_celadon: a Fly that doesn't leave Fuchsia City goes unseen, and the row, which walks no further, ends on Celadon's declared tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, + "fly_pallet: a Fly that doesn't leave Fuchsia City goes unseen, and the row, which walks on from Fuchsia's streets to Pallet's shore, ends on Cinnabar's nurse tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, + {"PokemonFRLG::AutoStory - Fault sweep: 14.03, warp no-op", + "fly_celadon: a Fly that doesn't leave Cinnabar Island goes unseen, and the row, which walks on from Celadon's heal spot, ends below Erika: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, {"PokemonFRLG::AutoStory - Fault sweep: 08.03, off the Bicycle at a bike leg", "riding with no fault, route7_underground_exit's warp to UndergroundPath_EastEntrance is not confirmed on the sim (the screen after the fade reads as before the hold): the sim's warp off the Bicycle, before this class can sweep 08.03"}, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h index d40b88c142..424c8fc365 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h @@ -91,6 +91,28 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_12[] = { "12.03 walk south 3 (to wall) -> FuchsiaCity_PokemonCenter_1F (0, 5) [walk only]", "12.03 walk east 7 -> FuchsiaCity_PokemonCenter_1F (7, 5) [walk only]", "12.03 walk south 4 (warp) -> FuchsiaCity (25, 32) [walk only]", + "12.03 pallet_shore from PalletTown (6, 8) facing south to PalletTown (8, 16) facing south", + "12.03 walk south 2 (to wall) -> PalletTown (6, 10)", + "12.03 walk east 4 -> PalletTown (10, 10)", + "12.03 walk south 6 (to wall) -> PalletTown (10, 16)", + "12.03 walk west 2 -> PalletTown (8, 16)", + "12.03 face south -> PalletTown (8, 16)", + "12.03 surf_route_21 from PalletTown (8, 17) facing south to CinnabarIsland (14, 12) facing north", + "12.03 walk south 29 -> Route21_North (8, 26) [surfing] [wild] [connection 3]", + "12.03 walk south 1 -> Route21_North (8, 27) [surfing] [wild]", + "12.03 surf north -> Route21_North (8, 26) [wild]", + "12.03 walk east 5 -> Route21_North (13, 26) [surfing] [wild]", + "12.03 walk east 1 -> Route21_North (14, 26) [surfing] [wild]", + "12.03 surf west -> Route21_North (13, 26) [wild]", + "12.03 walk south 68 -> Route21_South (13, 44) [surfing] [wild] [connection 24]", + "12.03 walk south 1 -> Route21_South (13, 45) [surfing] [wild]", + "12.03 walk south 10 -> CinnabarIsland (13, 5) [connection 5]", + "12.03 walk east 8 (to wall) -> CinnabarIsland (21, 5)", + "12.03 walk south 7 -> CinnabarIsland (21, 12)", + "12.03 walk west 7 -> CinnabarIsland (14, 12)", + "12.03 face north -> CinnabarIsland (14, 12)", + "14.03 cinnabar_outside from CinnabarIsland_PokemonCenter_1F (7, 4) facing north to CinnabarIsland (14, 12) facing south", + "14.03 walk south 5 (warp) -> CinnabarIsland (14, 12) [walk only]", "14.03 above_gym_tree from CeladonCity (48, 12) facing south to CeladonCity (40, 34) facing south", "14.03 walk west 7 -> CeladonCity (41, 12)", "14.03 walk south 13 (to wall) -> CeladonCity (41, 25)", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json index 714ffe1260..28838d8592 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-12.03.plan.json @@ -3,53 +3,84 @@ "game": "frlg", "checkpoint": { "id": "12.03", - "title": "Fuchsia's Center out to the street and Fly to Celadon City, for Erika", + "title": "Fuchsia to Cinnabar: Fly to Pallet Town, Surf down Route 21, heal at Cinnabar's Center", "start": {"map": "FuchsiaCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, "events": [ { "id": "center_northwest_corner", "kind": "legs", "action": "run", - "args": { - "legs": [{"direction": "west", "tiles": 7}, {"direction": "north", "tiles": 2}] - }, + "args": {"legs": [{"direction": "west", "tiles": 7}, {"direction": "north", "tiles": 2}]}, "why": "from the nurse to the Center's wall west (0, 4) and up to the wall (0, 2), as 12.01 does: legs to walls, so the walk out starts from a known tile even if the Center script left the player a tile off the nurse" }, { "id": "outside_fuchsia_center", "kind": "route", "action": "run", - "args": { - "target": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "south"} - }, + "args": {"target": {"map": "FuchsiaCity", "tiles": [[25, 32]], "facing": "south"}}, "why": "out of the Center's door onto Fuchsia City, where Fly works" }, { - "id": "fly_celadon", + "id": "fly_pallet", "kind": "game_action", "action": "fly", - "args": { - "town": "CeladonCity", - "species": "pidgey" - }, - "declared_after": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"}, - "why": "the Pidgey (Fly, 10.01), found in the party by its summary's species, flies to Celadon City (pokeguy flies there after Koga, 1:23:45), landing below the Pokemon Center's door (48, 11) on its heal spot, where 14.03 starts" - } + "args": {"town": "PalletTown", "species": "pidgey"}, + "declared_after": {"map": "PalletTown", "tiles": [[6, 8]], "facing": "south"}, + "why": "the Pidgey (Fly, 10.01), found in the party by its summary's species, flies to Pallet Town, landing below the player's house door (6, 7) (pokeguy 1:18:59, from Fuchsia)" + }, + { + "id": "pallet_shore", + "kind": "route", + "action": "run", + "args": {"target": {"map": "PalletTown", "tiles": [[8, 16]], "facing": "south"}}, + "why": "south through the town to the shore (7..10, 17..19), a tile above the water, facing it (pokeguy bikes to Pallet's water edge, 1:19:00)" + }, + { + "id": "repel_pallet", + "kind": "game_action", + "action": "use_item", + "args": {"item": "repel"}, + "why": "a Repel at the shore before the Surf: Route 21's water has wild Tentacool and Tentacruel on every tile (pokeguy uses one at Pallet Town before surfing to Cinnabar, user's check of the video 2026-11-12); one of 07.01's 5 Repels, which nothing else uses" + }, + { + "id": "surf_off_pallet", + "kind": "game_action", + "action": "surf", + "args": {"direction": "south"}, + "declared_after": {"map": "PalletTown", "tiles": [[8, 17]], "facing": "south"}, + "why": "the lead's Surf (taught in 12.01): A at the water, YES, onto (8, 17)" + }, + { + "id": "surf_route_21", + "kind": "route", + "action": "run", + "args": {"target": {"map": "CinnabarIsland", "tiles": [[14, 12]], "facing": "north"}}, + "why": "south over Route 21's water (Pallet Town, Route21_North, Route21_South) to Cinnabar's north shore, off the water onto land and down to below the Center's door (14, 11); round the swimmers' and tuber's lines (pokeguy avoids them, 1:19:00 to 1:19:23)" + }, + { + "id": "cinnabar_nurse", + "kind": "game_action", + "action": "center_enter", + "declared_after": {"map": "CinnabarIsland_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_cinnabar", "kind": "heal", "why": "full HP and PP before the Mansion's trainers"} ] }, "execution": { "menu": "full", "notes": { "checkpoint": [ - "From Fuchsia's nurse, where 12.02 ends healed, to Celadon for Erika (14.03): out of the Center on foot (Fly works outdoors only) and Fly. Celadon's landing, its heal spot (48, 12) facing south, is where 14.03 starts, so no walk follows.", - "Fuchsia and Celadon are both Fly towns the Pidgey already knows (11.01, 11.03); no new step or measurement." + "Starts at Fuchsia's nurse, facing her, where 12.02b ends healed. Out of the Center on foot (Fly works outdoors only), Fly to Pallet Town, then Surf (HM03, taught to the lead in 12.01) down Route 21 to Cinnabar's Center and its nurse: pokeguy's way after Koga (1:18:59 to 1:19:23), with the Mansion (13.01) next and Blaine after it. No Seafoam Islands (user, 2026-11-12, design section 12). Route 21 is two maps (Route21_North, Route21_South) between Pallet Town and Cinnabar.", + "Route 21's water has wild encounters (Tentacool, Tentacruel) and its swimmers and tuber see one or four ways a tile or more: the planner keeps off their lines where the water allows. A trainer that does see the player is fought with the normal battle code, and the Center's nurse at the end heals.", + "Ends at Cinnabar's nurse, facing her: 13.01's start." ] } }, "metadata": { "phase": "testing", "postconditions": { - "position": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"} + "position": {"map": "CinnabarIsland_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} } } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json index cd92ebca32..986cb5484b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json @@ -3,9 +3,29 @@ "game": "frlg", "checkpoint": { "id": "14.03", - "title": "Celadon after the Fly back from Cinnabar: Cut into the gym's yard, Beauty Tamia, the inner tree, Beauty Lori, to below Erika", - "start": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"}, + "title": "Cinnabar's Center out to the street and Fly to Celadon City, Cut into the gym's yard, Beauty Tamia, the inner tree, Beauty Lori, to below Erika", + "start": {"map": "CinnabarIsland_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, "events": [ + { + "id": "cinnabar_outside", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "CinnabarIsland", "tiles": [[14, 12]], "facing": "south"} + }, + "why": "out of Cinnabar's Center onto the street below its door (14, 11): Fly works outdoors only" + }, + { + "id": "fly_celadon", + "kind": "game_action", + "action": "fly", + "args": { + "town": "CeladonCity", + "species": "pidgey" + }, + "declared_after": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"}, + "why": "the Pidgey (Fly, 10.01), found in the party by its summary's species, flies to Celadon City (pokeguy 1:23:45), landing below the Pokemon Center's door (48, 11) on its heal spot, where the walk to the gym starts" + }, { "id": "above_gym_tree", "kind": "route", @@ -133,9 +153,9 @@ "menu": "full", "notes": { "checkpoint": [ - "Starts from the pose Fly leaves the player on, Celadon's heal spot (48, 12) facing south: Fly is a step type another agent is adding, and the rows before this one (segments 10 to 14.02, Blaine on Cinnabar) are authored separately. 14.02 is expected to end in Cinnabar's Center and fly here; until then this row's start is its own.", - "PokeGuy's way (1:23:45 to 1:26:03): Fly to Celadon, Cut the tree in front of the gym's yard, the west aisle, where Beauty Tamia sees him, the inner tree, Beauty Lori, Erika. No nurse here: 14.02 heals at Cinnabar's Center before the Fly, and the walk out of Celadon's Center, which has no map, from a nurse pose a tile off is a fault the sweep can't recover (no fade on the exit).", - "Left out, for the user to decide (do not spend TMs or change the team): pokeguy's two Rare Candies on the lead (1:25:00; no Rare Candy step exists yet) and TM14 Blizzard over Mega Kick (1:25:00, D4: our lead's moves may differ). The battles below go with Surf, Water Pulse, Bite and whatever else the lead knows: Bite is 1x on Erika's three and 2x on Lori's Exeggcute.", + "Starts at Cinnabar's nurse, facing her, where 14.02b ends healed (Blaine is beaten): out of the Center on foot (Fly works outdoors only) and Fly to Celadon, landing on its heal spot (48, 12) facing south (pokefirered heal_locations.json, HEAL_LOCATION_CELADON_CITY), where the walk to Erika's gym starts.", + "PokeGuy's way (1:23:45 to 1:26:03): Fly to Celadon, Cut the tree in front of the gym's yard, the west aisle, where Beauty Tamia sees him, the inner tree, Beauty Lori, Erika. No nurse here: 14.02b heals at Cinnabar's Center before the Fly, and the walk out of Celadon's Center, which has no map, from a nurse pose a tile off is a fault the sweep can't recover (no fade on the exit).", + "Left out, for the user to decide: pokeguy's two Rare Candies on the lead (1:25:00; no Rare Candy step exists yet). TM14 Blizzard is taught in the Mansion row (13.03), over Dig, so the lead arrives with Surf, Water Pulse, Bite and Blizzard. The battles below go with those and whatever else the lead knows: Bite is 1x on Erika's three and 2x on Lori's Exeggcute.", "The gym (CeladonCity_Gym map.json), 13 x 20, no running, entered on (6, 18): Erika (6, 4); trees (6, 8), (3, 5), (9, 6); its trainers and lines: Lass Kay (3, 11) east 3, Beauty Bridget (9, 10) west 3, Picnicker Tina (10, 7) south 2, Beauty Tamia (2, 6) south 4, Beauty Lori (5, 4) south 3, Lass Lisa (7, 4) south 2, Cooltrainer Mary (8, 7) west 2. Every way to Erika crosses a line; pokeguy's crosses only Tamia's and Lori's.", "Ends in front of Erika and saves there: her own pre-battle checkpoint (battle-checkpoint-retry), 14.04." ] From 46eab6b1edbfe1065638b3e36444e7f6400ff787 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:10:31 -0800 Subject: [PATCH 15/20] FRLG 12.03: include Rooms header in the Celadon Gym tests --- .../Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 1 + 1 file changed, 1 insertion(+) 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 b5e68d0474..0f3c486bb0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -30,6 +30,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryParty.h" #include "PokemonFRLG_AutoStoryMember.h" +#include "PokemonFRLG_AutoStoryRooms.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" From e88d61b80d6172a3a9e35f80021b69c1d030a0d2 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:12:40 -0800 Subject: [PATCH 16/20] FRLG 12.03: Cinnabar Island is a save card place Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp | 1 + .../Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp index d00e6e19eb..e4e8ec10be 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp @@ -83,6 +83,7 @@ class PlaceNameMatcher : public OCR::SmallDictionaryMatcher{ {"pokemon-tower", "Pokemon Tower"}, {"route-16", "Route 16"}, {"fuchsia-city", "Fuchsia City"}, + {"cinnabar-island", "Cinnabar Island"}, }){ JsonArray names; names.push_back(std::string(name)); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 4a78c87682..217c6fe91f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -370,6 +370,7 @@ std::string save_card_place(const std::string& map){ {"PokemonTower", "pokemon-tower"}, {"Route16", "route-16"}, {"FuchsiaCity", "fuchsia-city"}, + {"CinnabarIsland", "cinnabar-island"}, }; for (const auto& [prefix, place] : PLACES){ if (map == prefix || map.rfind(prefix + "_", 0) == 0){ From d67c835ff9f64d3f804c418d1364508b9d308b0b Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:14:59 -0800 Subject: [PATCH 17/20] FRLG golden: Erika's rows get their own array, so Blaine's rows can sit between 12.03 and 14.03 Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h | 7 ++++++- .../Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h index 424c8fc365..626b3c2668 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h @@ -17,7 +17,7 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonFRLG{ -// The stored plan lines from segment 12 on, after FRLG_PLAN_GOLDEN_11's. +// The stored plan lines of segment 12 (12.01 to 12.03, Fuchsia to Cinnabar), after FRLG_PLAN_GOLDEN_11's. inline constexpr std::string_view FRLG_PLAN_GOLDEN_12[] = { "12.01 face_center_door from FuchsiaCity (25, 32) facing south to FuchsiaCity (25, 32) facing north", "12.01 face north -> FuchsiaCity (25, 32)", @@ -111,6 +111,11 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_12[] = { "12.03 walk south 7 -> CinnabarIsland (21, 12)", "12.03 walk west 7 -> CinnabarIsland (14, 12)", "12.03 face north -> CinnabarIsland (14, 12)", +}; + +// The stored plan lines of Erika's rows, 14.03 to 14.04b, after the rows of Blaine's +// (14.01 to 14.02b) in the story's order. +inline constexpr std::string_view FRLG_PLAN_GOLDEN_12_CELADON[] = { "14.03 cinnabar_outside from CinnabarIsland_PokemonCenter_1F (7, 4) facing north to CinnabarIsland (14, 12) facing south", "14.03 walk south 5 (warp) -> CinnabarIsland (14, 12) [walk only]", "14.03 above_gym_tree from CeladonCity (48, 12) facing south to CeladonCity (40, 34) facing south", 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 c16ab71a55..bef60a8766 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -327,6 +327,7 @@ UnitTestResult test_golden_plans(){ golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_10), std::end(FRLG_PLAN_GOLDEN_10)); golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_11), std::end(FRLG_PLAN_GOLDEN_11)); golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_12), std::end(FRLG_PLAN_GOLDEN_12)); + golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_12_CELADON), std::end(FRLG_PLAN_GOLDEN_12_CELADON)); const size_t stored = golden.size(); size_t first_diff = 0; while (first_diff < actual.size() && first_diff < stored && actual[first_diff] == golden[first_diff]){ From 626bfe5faa287a5eda32c825b6939f2c707b820a Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:57:30 -0800 Subject: [PATCH 18/20] FRLG AutoStory: use_item takes count; Rare Candy on the lead with level-up text, new move declined; 14.03 uses two after Tamia Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryBag.h | 12 +- .../AutoStory/PokemonFRLG_AutoStoryBagUse.h | 9 ++ .../PokemonFRLG_AutoStoryHideout.cpp | 3 +- .../PokemonFRLG_AutoStoryItemUse.cpp | 110 ++++++++++++++++++ .../AutoStory/PokemonFRLG_AutoStoryItemUse.h | 10 +- .../PokemonFRLG_AutoStoryItemUse_Tests.cpp | 64 +++++++++- .../AutoStory/StoryData/frlg-14.03.plan.json | 9 +- 7 files changed, 209 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBag.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBag.h index 9bd80334fb..4fa024dbcf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBag.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBag.h @@ -30,13 +30,17 @@ enum class BagPocket{ }; // The pocket of an item the story uses from the bag: repel, super-repel, -// max-repel, escape-rope (Items) or bicycle (Key Items); nothing for +// max-repel, escape-rope, rare-candy (Items) or bicycle (Key Items); nothing for // another. std::optional usable_item_pocket(std::string_view item); // Whether `item` is a Repel of any kind. bool is_repel(std::string_view item); +// Whether `item` is used on a Pokemon, the lead (the party list opens on +// it, as for a Potion in battle): the Rare Candy. +bool is_party_item(std::string_view item); + // The row of `item` in `rows` (read_bag_pocket()'s, from the top), if it // has one left: a count of -1 (unread) counts as some. std::optional bag_row_of(const std::vector& rows, std::string_view item); @@ -51,6 +55,10 @@ class ItemUseActions{ virtual std::vector read_pocket() = 0; // Moves to row `row`, USE, and through what the item says. virtual void use_row(size_t row) = 0; + // Moves to row `row`, USE, the lead, and through the level-up text + // (the stats window; a new move declined) back to the bag. False if + // the party list or the level-up never showed. + virtual bool use_row_on_lead(size_t row) = 0; // Moves to row `row` and REGISTERs it for SELECT. virtual void register_row(size_t row) = 0; // Back to the overworld (nothing to do if the item closed the bag). @@ -66,6 +74,8 @@ enum class ItemUseEnd{ NO_BAG, // Not an item the story uses from the bag. UNKNOWN_ITEM, + // The item was chosen but its use on the lead never showed its text. + NOT_USED, }; // "used", "none_left": the end's name in logs and failures. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h index 3d150e2084..17351971d1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h @@ -28,6 +28,14 @@ namespace PokemonFRLG{ // overworld. ItemUseEnd use_item_from_bag(Logger& logger, ItemUseActions& actions, std::string_view item); +// `item` used up to `count` times, one bag visit each: as many as the bag +// has. `end` is USED if any was used and the bag ran out; else why none was. +struct ItemUses{ + ItemUseEnd end; + size_t used; +}; +ItemUses use_items_from_bag(Logger& logger, ItemUseActions& actions, std::string_view item, size_t count); + // The same, REGISTERing it for SELECT (the Bicycle) instead of USE. ItemUseEnd register_item_in_bag(Logger& logger, ItemUseActions& actions, std::string_view item); @@ -44,6 +52,7 @@ class ConsoleItemUseActions : public ItemUseActions{ virtual bool open_pocket(BagPocket pocket) override; virtual std::vector read_pocket() override; virtual void use_row(size_t row) override; + virtual bool use_row_on_lead(size_t row) override; virtual void register_row(size_t row) override; virtual void close_bag() override; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout.cpp index c4dc392fab..bbcb4bf697 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout.cpp @@ -116,6 +116,7 @@ std::vector field_action_specs(){ {.kind = StoryStepKind::GAME, .name = USE_ITEM_VARIANT, .args = { required_arg("item", StoryArgType::WORD, "the item's slug, as read_item_list_name() names it"), optional_arg("safari", StoryArgType::BOOLEAN, false, "in the Safari Zone, whose START menu has RETIRE on top"), + optional_arg("count", StoryArgType::INTEGER, int64_t(1), "how often to use it, as many as the bag has (a Rare Candy on the lead each)"), }}, {.kind = StoryStepKind::GAME, .name = RIDE_BIKE_VARIANT, .args = {}}, {.kind = StoryStepKind::GAME, .name = REGISTER_BIKE_VARIANT, .args = {}}, @@ -213,7 +214,7 @@ std::optional run_field_game_step( ConsoleItemUseActions bag(console, context, language, step_start_menu(step.args)); const ItemUseEnd end = step.action == REGISTER_BIKE_VARIANT ? register_item_in_bag(console.logger(), bag, "bicycle") - : use_item_from_bag(console.logger(), bag, *parse_use_item_step(step)); + : use_items_from_bag(console.logger(), bag, *parse_use_item_step(step), use_item_count(step)).end; if (end != ItemUseEnd::USED){ return Pokemon::outcome_failed(std::string("use_item_") + item_use_end_name(end), step.action); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp index 01928a6573..ddc1e11e64 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp @@ -5,7 +5,12 @@ */ #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_PartyDialogs.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_PartyMenuDetector.h" #include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -22,6 +27,9 @@ namespace PokemonFRLG{ using namespace std::chrono_literals; +// The most a use_item step's count may be. +constexpr size_t MAX_USE_COUNT = 99; + MoveSpeed move_speed(const StoryStep& step){ if (step.action == BIKE_VARIANT){ return MoveSpeed::BIKE; @@ -33,11 +41,17 @@ std::optional usable_item_pocket(std::string_view item){ if (is_repel(item) || item == "escape-rope"){ return BagPocket::ITEMS; } + if (is_party_item(item)){ + return BagPocket::ITEMS; + } if (item == "bicycle"){ return BagPocket::KEY_ITEMS; } return std::nullopt; } +bool is_party_item(std::string_view item){ + return item == "rare-candy"; +} bool is_repel(std::string_view item){ return item == "repel" || item == "super-repel" || item == "max-repel"; } @@ -47,8 +61,14 @@ std::optional parse_use_item_step(const Pokemon::StoryStep& step){ if (item == nullptr || step.args.contains("slot") || !usable_item_pocket(*item)){ return std::nullopt; } + if (step.args.contains("count") && !number_arg(step.args, "count", 1, MAX_USE_COUNT)){ + return std::nullopt; + } return *item; } +size_t use_item_count(const Pokemon::StoryStep& step){ + return number_arg(step.args, "count", 1, MAX_USE_COUNT).value_or(1); +} bool is_item_use_step(const Pokemon::StoryStep& step){ const bool bike = step.action == RIDE_BIKE_VARIANT || step.action == REGISTER_BIKE_VARIANT; return (bike && step.args.empty()) || parse_use_item_step(step).has_value(); @@ -73,6 +93,8 @@ std::string item_use_end_name(ItemUseEnd end){ return "no_bag"; case ItemUseEnd::UNKNOWN_ITEM: return "unknown_item"; + case ItemUseEnd::NOT_USED: + return "not_used"; } return "?"; } @@ -101,6 +123,12 @@ ItemUseEnd with_bag_row( logger.log("Bag: " + std::string(registers ? "registering" : "using") + " the " + std::string(item) + " on row " + std::to_string(*row + 1) + "."); if (registers){ actions.register_row(*row); + }else if (is_party_item(item)){ + if (!actions.use_row_on_lead(*row)){ + logger.log("Bag: the " + std::string(item) + " showed no level-up."); + actions.close_bag(); + return ItemUseEnd::NOT_USED; + } }else{ actions.use_row(*row); } @@ -113,6 +141,21 @@ ItemUseEnd with_bag_row( ItemUseEnd use_item_from_bag(Logger& logger, ItemUseActions& actions, std::string_view item){ return with_bag_row(logger, actions, item, false); } +ItemUses use_items_from_bag(Logger& logger, ItemUseActions& actions, std::string_view item, size_t count){ + size_t used = 0; + while (used < count){ + const ItemUseEnd end = use_item_from_bag(logger, actions, item); + if (end == ItemUseEnd::NONE_LEFT && used != 0){ + logger.log("Bag: " + std::to_string(used) + " of " + std::to_string(count) + " " + std::string(item) + " used: no more in the bag."); + break; + } + if (end != ItemUseEnd::USED){ + return {end, used}; + } + used++; + } + return {ItemUseEnd::USED, used}; +} ItemUseEnd register_item_in_bag(Logger& logger, ItemUseActions& actions, std::string_view item){ return with_bag_row(logger, actions, item, true); } @@ -139,6 +182,10 @@ constexpr Milliseconds POCKET_SWITCH_WAIT = 600ms; // A cursor step in a pocket, press and wait: 250 ms in all. constexpr Milliseconds CURSOR_TAP = 100ms; constexpr Milliseconds CURSOR_WAIT = 150ms; +// A presses to the stats window, 800 ms each, and the tries (15 B +// presses each) to get from it back to the bag. +constexpr int LEVEL_UP_PRESSES = 30; +constexpr int BACK_TO_BAG_ATTEMPTS = 8; // Out of the bag and its messages, or the Escape Rope's warp. constexpr Milliseconds BAG_CLOSE_TIMEOUT = 30000ms; @@ -185,6 +232,69 @@ void ConsoleItemUseActions::use_row(size_t row){ pbf_press_button(m_context, BUTTON_A, 160ms, 1500ms); } +bool ConsoleItemUseActions::use_row_on_lead(size_t row){ + for (size_t c = 0; c < row; c++){ + pbf_press_dpad(m_context, DPAD_DOWN, CURSOR_TAP, CURSOR_WAIT); + } + // The item's menu, USE, then the party list, whose cursor is on the + // lead, as for a Potion in battle. + pbf_press_button(m_context, BUTTON_A, 160ms, 800ms); + pbf_press_button(m_context, BUTTON_A, 160ms, 1500ms); + pbf_press_button(m_context, BUTTON_A, 160ms, 1000ms); + + // " grew to Lv. N!", then the stats window (the RNG loop's + // waits, console-proven there). + PartyLevelUpWatcher level_up(COLOR_RED, PartyLevelUpDialog::stats, m_language); + m_context.wait_for_all_requests(); + const int stats = run_until( + m_console, m_context, + [](ProControllerContext& context){ + for (int c = 0; c < LEVEL_UP_PRESSES; c++){ + pbf_press_button(context, BUTTON_A, 200ms, 800ms); + } + }, + {level_up} + ); + if (stats < 0){ + m_console.log("Bag: no level-up stats window after the Rare Candy.", COLOR_RED); + return false; + } + // Out of the stats window and the party list back to the bag. A new + // move is declined: B on "Delete a move?" asks "Stop learning?", A + // answers YES. An evolution is stopped with B. + for (int attempt = 0; attempt < BACK_TO_BAG_ATTEMPTS; attempt++){ + BagWatcher bag(COLOR_RED); + PartyMoveLearnWatcher move_learn(COLOR_RED); + BattleDialogWatcher evolution(COLOR_RED); + m_context.wait_for_all_requests(); + const int seen = run_until( + m_console, m_context, + [](ProControllerContext& context){ + pbf_wait(context, 1000ms); + for (int c = 0; c < 15; c++){ + pbf_press_button(context, BUTTON_B, 200ms, 1800ms); + } + }, + {bag, move_learn, evolution} + ); + if (seen == 0){ + return true; + } + if (seen == 1){ + m_console.log("Bag: a new move to learn: declined."); + pbf_press_button(m_context, BUTTON_B, 200ms, 1800ms); + pbf_press_button(m_context, BUTTON_A, 200ms, 2800ms); + }else if (seen == 2){ + m_console.log("Bag: an evolution: stopped."); + pbf_press_button(m_context, BUTTON_B, 200ms, 2800ms); + }else{ + break; + } + } + m_console.log("Bag: never back at the bag after the Rare Candy.", COLOR_RED); + return false; +} + void ConsoleItemUseActions::register_row(size_t row){ for (size_t c = 0; c < row; c++){ pbf_press_dpad(m_context, DPAD_DOWN, CURSOR_TAP, CURSOR_WAIT); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.h index 8315a6e5d0..0cfb819c55 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.h @@ -33,8 +33,8 @@ namespace PokemonFRLG{ // The GAME step that uses an item from the bag on the overworld, its -// args the item's slug as read_item_list_name() names it, and for an item -// used on a Pokemon the party slot (none the story uses yet). +// args the item's slug as read_item_list_name() names it and, for an item +// used up more than once (the Rare Candy), its count. inline const std::string USE_ITEM_VARIANT = "use_item"; // The GAME step that gets on the registered Bicycle with SELECT // (OverworldWalkSteps::get_on_bike()). The ROUTE steps after it ride @@ -53,8 +53,12 @@ inline const std::string REGISTER_BIKE_VARIANT = "register_bike"; // The item a use_item step uses (with "safari", from the Safari Zone's // START menu, step_start_menu()), or nothing if it isn't one, the item -// isn't one the story uses from the bag, or it names a slot. +// isn't one the story uses from the bag, or it names a slot or a count +// that is out of range. An item for a Pokemon (is_party_item()) goes on +// the lead. std::optional parse_use_item_step(const Pokemon::StoryStep& step); +// How often the step uses its item ("count", 1 to 99; 1 if left out). +size_t use_item_count(const Pokemon::StoryStep& step); // Whether `step` is one of this file's steps. bool is_item_use_step(const Pokemon::StoryStep& step); 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 111969c447..44bf15c547 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp @@ -38,7 +38,10 @@ class SimBag : public ItemUseActions{ public: std::map> pockets; bool opens = true; + // The lead's level-up text never shows. + bool no_level_up = false; std::vector used; + std::vector used_on_lead; std::vector registered; bool open = false; @@ -57,6 +60,14 @@ class SimBag : public ItemUseActions{ item.count--; } } + virtual bool use_row_on_lead(size_t row) override{ + if (no_level_up){ + return false; + } + use_row(row); + used_on_lead.push_back(pockets[m_pocket][row].item); + return true; + } virtual void register_row(size_t row) override{ registered.push_back(pockets[m_pocket][row].item); } @@ -76,6 +87,9 @@ struct ItemUseInput{ bool opens = true; // renew_repel() instead of use_item_from_bag(). bool renew = false; + // The step's count (use_items_from_bag()). + size_t count = 1; + bool no_level_up = false; }; struct ItemUseExpectation{ ItemUseEnd end; @@ -97,10 +111,14 @@ class Test_AutoStoryItemUse : public UnitTest{ bag.pockets[BagPocket::ITEMS] = m_case.input.items; bag.pockets[BagPocket::KEY_ITEMS] = m_case.input.key_items; bag.opens = m_case.input.opens; + bag.no_level_up = m_case.input.no_level_up; const std::string variant = m_case.input.variant; const std::string item = variant == RIDE_BIKE_VARIANT ? "bicycle" : parse_use_item_step(game_step_of(variant, ITEM)).value_or(variant); - const ItemUseEnd end = m_case.input.renew ? renew_repel(logger, bag, item) : use_item_from_bag(logger, bag, item); - if (end != m_case.expectation.end || bag.used != m_case.expectation.used || bag.open){ + const ItemUseEnd end = m_case.input.renew + ? renew_repel(logger, bag, item) + : use_items_from_bag(logger, bag, item, m_case.input.count).end; + const bool lead_ok = is_party_item(item) ? bag.used_on_lead == bag.used : bag.used_on_lead.empty(); + if (end != m_case.expectation.end || bag.used != m_case.expectation.used || bag.open || !lead_ok){ return std::format( "\"{}\": {} using {} item(s), bag {}; expected {} using {}.", variant, item_use_end_name(end), bag.used.size(), bag.open ? "open" : "closed", @@ -175,6 +193,43 @@ const ItemUseCase ITEM_USE_CASES[] = { }, .expectation = {.end = ItemUseEnd::NONE_LEFT, .used = {}}, }, + { + .input = { + .name = "two Rare Candies on the lead, the bag holding five", + .variant = "use_item rare-candy", + .items = {{"potion", 3}, {"rare-candy", 5}}, + .count = 2, + }, + .expectation = {.end = ItemUseEnd::USED, .used = {"rare-candy", "rare-candy"}}, + }, + { + .input = { + .name = "two Rare Candies asked, one in the bag: the one is used", + .variant = "use_item rare-candy", + .items = {{"rare-candy", 1}}, + .count = 2, + }, + .expectation = {.end = ItemUseEnd::USED, .used = {"rare-candy"}}, + }, + { + .input = { + .name = "no Rare Candy in the bag", + .variant = "use_item rare-candy", + .items = {{"potion", 3}}, + .count = 2, + }, + .expectation = {.end = ItemUseEnd::NONE_LEFT, .used = {}}, + }, + { + .input = { + .name = "a Rare Candy whose level-up never shows", + .variant = "use_item rare-candy", + .items = {{"rare-candy", 2}}, + .count = 2, + .no_level_up = true, + }, + .expectation = {.end = ItemUseEnd::NOT_USED, .used = {}}, + }, { .input = { .name = "an Escape Rope is no Repel to renew", @@ -190,6 +245,11 @@ UnitTestResult test_variants_and_bike(){ if (parse_use_item_step(game_step_of("use_item potion", ITEM)) || parse_use_item_step(game_step_of("use_item", ITEM)) || parse_use_item_step(game_step_of("use_item repel slot=1", ITEM)) || !parse_use_item_step(game_step_of("use_item super-repel", ITEM)) + || parse_use_item_step(game_step_of("use_item rare-candy slot=1", ITEM)) + || parse_use_item_step(game_step_of("use_item rare-candy count=0", ITEM)) + || !parse_use_item_step(game_step_of("use_item rare-candy count=2", ITEM)) + || use_item_count(game_step_of("use_item rare-candy count=2", ITEM)) != 2 + || use_item_count(game_step_of("use_item rare-candy", ITEM)) != 1 ){ return "Expected only the story's bag items as use_item steps."; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json index 986cb5484b..d745304459 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.03.plan.json @@ -73,6 +73,13 @@ "declared_after": {"map": "CeladonCity_Gym", "tiles": [[2, 10]], "facing": "north"}, "why": "Beauty Tamia (TRAINER_BEAUTY_TAMIA): two Bellsprout Lv24 (pokeguy: one Bite each)" }, + { + "id": "rare_candies_lead", + "kind": "game_action", + "action": "use_item", + "args": {"item": "rare-candy", "count": 2}, + "why": "two Rare Candies on the lead after Tamia (pokeguy 1:25:00, PokemonSimulation docs/progression/pokeguy-route.md section 12), from 09.01's and 10.05's pickups: as many as the bag has, a new move declined so the lead keeps Bite, Water Pulse, Surf and Blizzard; 14.04's Lv44 check decides if it is enough" + }, { "id": "column_1_west", "kind": "legs", @@ -155,7 +162,7 @@ "checkpoint": [ "Starts at Cinnabar's nurse, facing her, where 14.02b ends healed (Blaine is beaten): out of the Center on foot (Fly works outdoors only) and Fly to Celadon, landing on its heal spot (48, 12) facing south (pokefirered heal_locations.json, HEAL_LOCATION_CELADON_CITY), where the walk to Erika's gym starts.", "PokeGuy's way (1:23:45 to 1:26:03): Fly to Celadon, Cut the tree in front of the gym's yard, the west aisle, where Beauty Tamia sees him, the inner tree, Beauty Lori, Erika. No nurse here: 14.02b heals at Cinnabar's Center before the Fly, and the walk out of Celadon's Center, which has no map, from a nurse pose a tile off is a fault the sweep can't recover (no fade on the exit).", - "Left out, for the user to decide: pokeguy's two Rare Candies on the lead (1:25:00; no Rare Candy step exists yet). TM14 Blizzard is taught in the Mansion row (13.03), over Dig, so the lead arrives with Surf, Water Pulse, Bite and Blizzard. The battles below go with those and whatever else the lead knows: Bite is 1x on Erika's three and 2x on Lori's Exeggcute.", + "Two Rare Candies on the lead after Tamia (pokeguy 1:25:00), a new move declined. TM14 Blizzard is taught in the Mansion row (13.03), over Dig, so the lead arrives with Surf, Water Pulse, Bite and Blizzard. The battles below go with those and whatever else the lead knows: Bite is 1x on Erika's three and 2x on Lori's Exeggcute.", "The gym (CeladonCity_Gym map.json), 13 x 20, no running, entered on (6, 18): Erika (6, 4); trees (6, 8), (3, 5), (9, 6); its trainers and lines: Lass Kay (3, 11) east 3, Beauty Bridget (9, 10) west 3, Picnicker Tina (10, 7) south 2, Beauty Tamia (2, 6) south 4, Beauty Lori (5, 4) south 3, Lass Lisa (7, 4) south 2, Cooltrainer Mary (8, 7) west 2. Every way to Erika crosses a line; pokeguy's crosses only Tamia's and Lori's.", "Ends in front of Erika and saves there: her own pre-battle checkpoint (battle-checkpoint-retry), 14.04." ] From a56b3b15602d8b7e9e6fc798a38f62c2b34a06a5 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:59:33 -0800 Subject: [PATCH 19/20] FRLG AutoStory: Rare Candy count test builds its step with an integer count Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryItemUse_Tests.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 44bf15c547..5fce0c1118 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse_Tests.cpp @@ -241,14 +241,21 @@ const ItemUseCase ITEM_USE_CASES[] = { }, }; +// "use_item rare-candy" with its count, an integer as the plans give it. +StoryStep candy_step(int64_t count){ + StoryStep step = game_step_of("use_item rare-candy", ITEM); + step.args["count"] = count; + return step; +} + UnitTestResult test_variants_and_bike(){ if (parse_use_item_step(game_step_of("use_item potion", ITEM)) || parse_use_item_step(game_step_of("use_item", ITEM)) || parse_use_item_step(game_step_of("use_item repel slot=1", ITEM)) || !parse_use_item_step(game_step_of("use_item super-repel", ITEM)) || parse_use_item_step(game_step_of("use_item rare-candy slot=1", ITEM)) - || parse_use_item_step(game_step_of("use_item rare-candy count=0", ITEM)) - || !parse_use_item_step(game_step_of("use_item rare-candy count=2", ITEM)) - || use_item_count(game_step_of("use_item rare-candy count=2", ITEM)) != 2 + || parse_use_item_step(candy_step(0)) + || !parse_use_item_step(candy_step(2)) + || use_item_count(candy_step(2)) != 2 || use_item_count(game_step_of("use_item rare-candy", ITEM)) != 1 ){ return "Expected only the story's bag items as use_item steps."; From e7c3b15a1a3d5ee370f980752b7401bc92be6860 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:06:30 -0800 Subject: [PATCH 20/20] FRLG AutoStory: split the Rare Candy level-up flow into two helpers Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryBagUse.h | 5 +++ .../PokemonFRLG_AutoStoryItemUse.cpp | 35 +++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h index 17351971d1..051d56df9f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBagUse.h @@ -34,6 +34,7 @@ struct ItemUses{ ItemUseEnd end; size_t used; }; +// Uses `item` up to `count` times from the bag. ItemUses use_items_from_bag(Logger& logger, ItemUseActions& actions, std::string_view item, size_t count); // The same, REGISTERing it for SELECT (the Bicycle) instead of USE. @@ -57,6 +58,10 @@ class ConsoleItemUseActions : public ItemUseActions{ virtual void close_bag() override; private: + // The two halves of use_row_on_lead(). + bool wait_for_level_up_stats(); + bool back_to_bag_declining_moves(); + ConsoleHandle& m_console; ProControllerContext& m_context; Language m_language; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp index ddc1e11e64..4d2d5250dc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryItemUse.cpp @@ -232,16 +232,8 @@ void ConsoleItemUseActions::use_row(size_t row){ pbf_press_button(m_context, BUTTON_A, 160ms, 1500ms); } -bool ConsoleItemUseActions::use_row_on_lead(size_t row){ - for (size_t c = 0; c < row; c++){ - pbf_press_dpad(m_context, DPAD_DOWN, CURSOR_TAP, CURSOR_WAIT); - } - // The item's menu, USE, then the party list, whose cursor is on the - // lead, as for a Potion in battle. - pbf_press_button(m_context, BUTTON_A, 160ms, 800ms); - pbf_press_button(m_context, BUTTON_A, 160ms, 1500ms); - pbf_press_button(m_context, BUTTON_A, 160ms, 1000ms); - +// Past the party list to the stats window of a Rare Candy. +bool ConsoleItemUseActions::wait_for_level_up_stats(){ // " grew to Lv. N!", then the stats window (the RNG loop's // waits, console-proven there). PartyLevelUpWatcher level_up(COLOR_RED, PartyLevelUpDialog::stats, m_language); @@ -257,11 +249,14 @@ bool ConsoleItemUseActions::use_row_on_lead(size_t row){ ); if (stats < 0){ m_console.log("Bag: no level-up stats window after the Rare Candy.", COLOR_RED); - return false; } - // Out of the stats window and the party list back to the bag. A new - // move is declined: B on "Delete a move?" asks "Stop learning?", A - // answers YES. An evolution is stopped with B. + return stats >= 0; +} + +// Out of the stats window and the party list back to the bag. A new move +// is declined: B on "Delete a move?" asks "Stop learning?", A answers YES. +// An evolution is stopped with B. +bool ConsoleItemUseActions::back_to_bag_declining_moves(){ for (int attempt = 0; attempt < BACK_TO_BAG_ATTEMPTS; attempt++){ BagWatcher bag(COLOR_RED); PartyMoveLearnWatcher move_learn(COLOR_RED); @@ -295,6 +290,18 @@ bool ConsoleItemUseActions::use_row_on_lead(size_t row){ return false; } +bool ConsoleItemUseActions::use_row_on_lead(size_t row){ + for (size_t c = 0; c < row; c++){ + pbf_press_dpad(m_context, DPAD_DOWN, CURSOR_TAP, CURSOR_WAIT); + } + // The item's menu, USE, then the party list, whose cursor is on the + // lead, as for a Potion in battle. + pbf_press_button(m_context, BUTTON_A, 160ms, 800ms); + pbf_press_button(m_context, BUTTON_A, 160ms, 1500ms); + pbf_press_button(m_context, BUTTON_A, 160ms, 1000ms); + return wait_for_level_up_stats() && back_to_bag_declining_moves(); +} + void ConsoleItemUseActions::register_row(size_t row){ for (size_t c = 0; c < row; c++){ pbf_press_dpad(m_context, DPAD_DOWN, CURSOR_TAP, CURSOR_WAIT);