From 1d619d9347ee1279150a8aa872d2ac3c30c3d925 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 00:07:12 -0800 Subject: [PATCH 01/23] FRLG AutoStory 00.31: Celadon Game Corner to the Rocket Hideout's LIFT KEY as an authored plan From Celadon's Pokemon Center: the Game Corner's poster Grunt, the poster switch, the hideout down to B4F's Lift Key Grunt, the LIFT KEY, and back up to B3F below its Rare Candy. Celadon's Center has no map file, so its coded ground floor is added to the story maps and the plan walks out of it as 00.30 walks out of Lavender's. A step north onto the Grunt's tile after his battle (he is removed by the script); B2F goes round east of the turning Grunt (20, 6) and up column 21 to the stairs. The fault sweep and the row test hide a talk-started battle's trainer once the script removes them (talk_battle_hide_flag()). The story-wide tests count 00.31; the sim trace golden gains its lines only. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Overworld/PokemonFRLG_OverworldMaps.cpp | 28 +++++++++ .../PokemonFRLG_AutoStoryFaultSweep_Tests.cpp | 30 +++++++++- .../PokemonFRLG_AutoStoryFaultSweep_Tests.h | 8 +++ .../PokemonFRLG_AutoStoryLavender_Tests.cpp | 43 +++++++++++++ .../PokemonFRLG_AutoStoryRunPlan_Tests.cpp | 8 +-- .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 10 ++-- .../ReplayData/frlg-story-sim-trace.json | 60 +++++++++++++++++-- .../AutoStory/StoryData/Draft/README.md | 2 +- .../{Draft => }/frlg-00.31.plan.json | 36 +++++++---- 9 files changed, 197 insertions(+), 28 deletions(-) rename SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/{Draft => }/frlg-00.31.plan.json (67%) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index 69ac64c188..4c9eeb3f6c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -8,6 +8,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Json/JsonValue.h" #include "PokemonFRLG_OverworldMaps.h" +#include "PokemonFRLG_PokemonCenterRoom.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -92,18 +93,45 @@ const char* const MAP_NAMES[] = { "UndergroundPath_WestEntrance", "Route7", "CeladonCity", + // The Game Corner's poster and the Rocket Hideout down to B4F. + "CeladonCity_GameCorner", + "RocketHideout_B1F", + "RocketHideout_B2F", + "RocketHideout_B3F", + "RocketHideout_B4F", "CeruleanCave_1F", "CeruleanCave_2F", "CeruleanCave_B1F", }; +// Whether `maps` has a map named `name`. +bool has_map(const std::vector& maps, const std::string& name){ + return std::any_of(maps.begin(), maps.end(), [&](const MapData& map){ return map.name == name; }); +} + +// The coded room (pokemon_center_room()) of each Pokemon Center whose +// door is on one of `maps` but which has no map file of its own: +// Celadon City's. +void add_unmapped_centers(std::vector& maps){ + const size_t towns = maps.size(); + for (size_t town = 0; town < towns; town++){ + for (const MapWarp& warp : maps[town].warps){ + if (warp.to && is_pokemon_center(warp.to->map) && !has_map(maps, warp.to->map)){ + add_pokemon_center_room(maps, town); + break; + } + } + } +} + const std::vector& all_maps(){ static const std::vector MAPS = []{ std::vector maps; for (const char* name : MAP_NAMES){ maps.push_back(load_map(name)); } + add_unmapped_centers(maps); return maps; }(); return MAPS; 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 61a208d570..4292dcbf93 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -174,6 +174,12 @@ bool walks_after(const StoryCheckpoint& row, size_t c){ }); } +// By the battle's map and name. The Game Corner's Grunt walks off once +// beaten (CeladonCity_GameCorner_Text_DefeatedGrunt: removeobject). +const std::map, std::string> TALK_BATTLE_HIDE_FLAGS{ + {{"CeladonCity_GameCorner", "rocket_grunt"}, "FLAG_HIDE_GAME_CORNER_ROCKET"}, +}; + // Whether `failure` is a script the sim does not have: a scene's trigger // stepped onto (no trainer sees the player there) or a leader's battle // after a talk (no trainer's message up). @@ -195,7 +201,8 @@ RowRun run_row( RowRun out; std::optional off_maps; StoryPose at = *story_pose(*row.start); - auto sim = std::make_unique(sweep_maps(), MapPosition{at.map, at.tile}, at.facing.value_or(Direction::SOUTH), script); + std::vector maps = sweep_maps(); + auto sim = std::make_unique(maps, MapPosition{at.map, at.tile}, at.facing.value_or(Direction::SOUTH), script); const auto add = [&out](const SimState& state){ out.time += state.time; out.steps += state.steps; @@ -216,6 +223,12 @@ RowRun run_row( continue; } at = *story_pose(*step.pose_after); + const std::optional hidden = talk_battle_hide_flag(step); + if (let_pass && hidden){ + for (MapData& map : maps){ + hide_objects(map, {*hidden}); + } + } const auto landing = landings.find(c); const MapPosition land{at.map, landing == landings.end() ? at.tile : landing->second}; if (!map_loaded(land.map)){ @@ -224,9 +237,9 @@ RowRun run_row( out.failure = walks_after(row, c) ? std::format("{}/{}: ends on {}, which has no map, with a walk after it.", row.id, step.name, land.map) : ""; break; } - if (!(sim->state().position == land)){ + if (!(sim->state().position == land) || (let_pass && hidden)){ add(sim->state()); - sim = std::make_unique(sweep_maps(), land, at.facing.value_or(sim->state().facing), script); + sim = std::make_unique(maps, land, at.facing.value_or(sim->state().facing), script); } } if (out.failure.empty() && !sim->state().violations.empty()){ @@ -545,6 +558,17 @@ const FaultSweepCase FAULT_SWEEP_CASES[] = { {.input = {.fault = FaultClass::LOST_TAP}, .expectation = {}}, }; +std::optional talk_battle_hide_flag(const StoryStep& step){ + if (step.kind != StoryStepKind::BATTLE || !step.pose_after){ + return std::nullopt; + } + const auto found = TALK_BATTLE_HIDE_FLAGS.find({step.pose_after->map, step.name}); + if (found == TALK_BATTLE_HIDE_FLAGS.end()){ + return std::nullopt; + } + return found->second; +} + void add_tests_AutoStoryFaultSweep(UnitTestDatabase& database){ for (const FaultSweepCase& item : FAULT_SWEEP_CASES){ for (const StoryCheckpoint& row : story_checkpoints()){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.h index cda979a2f3..32f3fd1951 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.h @@ -7,13 +7,21 @@ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryFaultSweep_Tests_H #define PokemonAutomation_PokemonFRLG_AutoStoryFaultSweep_Tests_H +#include +#include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "Pokemon/AutoStory/Pokemon_StorySteps.h" namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonFRLG{ +// The hide flag the script of `step`, a battle a talk starts, sets when +// the trainer leaves after it: the sim, which plays no such battle, must +// hide them for the row to go on. +std::optional talk_battle_hide_flag(const Pokemon::StoryStep& step); + // Each class of console failure injected at every row of the story on the // overworld sim; the rows the program still fails are known failing // (PokemonFRLG_AutoStoryFaultSweep_Tests.cpp). diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp index 3b4c0f3fc6..8c3bb9795f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -709,6 +710,47 @@ UnitTestResult test_celadon_save_place(Logger&){ return true; } +// 00.31 on the sim: out of Celadon's Center, the Game Corner's poster +// Grunt, the switch, the Rocket Hideout down to B4F's Lift Key Grunt, the +// LIFT KEY, and back up to B3F below its Rare Candy. +// A battle a talk starts (the poster Grunt's) is the sim's to skip: it +// leaves the player where the plan says, and the trainer walks off +// (talk_battle_hide_flag()). +UnitTestResult test_hideout_row(Logger&){ + const StoryCheckpoint& row = checkpoint("00.31"); + StoryPose at = *story_pose(*row.start); + std::vector maps = maps_after_route10(); + auto sim = std::make_unique(maps, MapPosition{at.map, at.tile}, *at.facing); + std::vector fought; + for (const StoryStep& step : row.steps){ + const std::optional hidden = talk_battle_hide_flag(step); + if (!hidden){ + if (const std::string failure = row_step_on_sim(*sim, at, step, row.id); !failure.empty()){ + return "00.31: ended on " + to_string(sim->state().position) + "; " + failure; + } + continue; + } + at = *story_pose(*step.pose_after); + for (MapData& map : maps){ + hide_objects(map, {*hidden}); + } + fought = sim->state().trainers_beaten; + sim = std::make_unique(maps, MapPosition{at.map, at.tile}, *at.facing); + } + fought.insert(fought.end(), sim->state().trainers_beaten.begin(), sim->state().trainers_beaten.end()); + if (fought != std::vector{"rocket_m"}){ + return std::format("00.31: fought {} trainers on the sim, not the Lift Key Grunt alone.", fought.size()); + } + if (!sim->state().violations.empty()){ + return "00.31: a violation on the way: " + sim->state().violations.back(); + } + const MapPosition end{"RocketHideout_B3F", {12, 13}}; + if (!(sim->state().position == end)){ + return "00.31: ended on " + to_string(sim->state().position) + ", not " + to_string(end) + "."; + } + return true; +} + } // namespace @@ -731,6 +773,7 @@ const AutoStoryLavenderCase AUTO_STORY_LAVENDER_CASES[] = { {.input = {"00.30 a wild battle on the step into Route 7's grass", test_route7_grass_battles}, .expectation = {}}, {.input = {"00.30 Route 8 west from a start up to 3 tiles off", test_route8_west_off_start}, .expectation = {}}, {.input = {"00.30 saves in Celadon City's Pokemon Center", test_celadon_save_place}, .expectation = {}}, + {.input = {"00.31 the Game Corner's poster, the Rocket Hideout to B4F's LIFT KEY and B3F's Rare Candy", test_hideout_row}, .expectation = {}}, }; void add_tests_AutoStoryLavender(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 430c754d9e..a5d02a435d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp @@ -138,7 +138,7 @@ class Test_RunPlan : public UnitTest{ const RunPlanScenario m_scenario; }; -const std::string TODAY = "00.01 00.02 00.03 00.04 00.05 00.06 00.07 00.08 00.09 00.10 00.11 00.12 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30"; +const std::string TODAY = "00.01 00.02 00.03 00.04 00.05 00.06 00.07 00.08 00.09 00.10 00.11 00.12 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30 00.31"; const RunPlanScenario RUN_PLAN_CASES[] = { { @@ -229,11 +229,11 @@ const RunPlanScenario RUN_PLAN_CASES[] = { }, { .input = {.name = "Gift RNG off: 00.12b is passed over", .first = "00.11"}, - .expectation = {.expected_ids = "00.11 00.12 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30"}, + .expectation = {.expected_ids = "00.11 00.12 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30 00.31"}, }, { .input = {.name = "Gift RNG off: 00.12b runs when started at", .first = "00.12b"}, - .expectation = {.expected_ids = "00.12b 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30"}, + .expectation = {.expected_ids = "00.12b 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30 00.31"}, }, { .input = { .name = "Gift RNG: started at 00.12b, from the save beside the salesman", @@ -258,7 +258,7 @@ const RunPlanScenario RUN_PLAN_CASES[] = { }, { .input = {.name = "Starter RNG alone: 00.12b runs when started at", .first = "00.12b", .handoffs = {.starter_rng = true}}, - .expectation = {.expected_ids = "00.12b 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30"}, + .expectation = {.expected_ids = "00.12b 00.12c 00.13 00.14 00.14b 00.14c 00.15 00.15b 00.16 00.17 00.18 00.19 00.20 00.21 00.22 00.23 00.24 00.25 00.26 00.27 00.28 00.29 00.30 00.31"}, }, { .input = { .name = "Starter RNG first, with both on", 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 174473bdc1..d81c8fe481 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -230,8 +230,8 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po UnitTestResult test_routes_and_chain(){ const std::vector& checkpoints = story_checkpoints(); - if (checkpoints.size() != 37 || checkpoints[0].start){ - return "Expected 37 checkpoints, the first from a new game."; + if (checkpoints.size() != 38 || checkpoints[0].start){ + return "Expected 38 checkpoints, the first from a new game."; } StoryPose pose; for (size_t c = 0; c < checkpoints.size(); c++){ @@ -603,7 +603,7 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set Date: Tue, 10 Nov 2026 00:07:38 -0800 Subject: [PATCH 02/23] FRLG AutoStory: the fault sweep's trainer hiding in its own function, for code health Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryFaultSweep_Tests.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 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 4292dcbf93..288a6c4fb7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -188,6 +188,19 @@ bool unscripted(const std::string& failure){ || failure.find(": no_battle.") != std::string::npos; } +// Hides from `maps` the trainer who leaves after `step`, a battle a talk +// starts (talk_battle_hide_flag()). Returns whether there was one. +bool hide_talk_battle_trainer(std::vector& maps, const StoryStep& step){ + const std::optional hidden = talk_battle_hide_flag(step); + if (!hidden){ + return false; + } + for (MapData& map : maps){ + hide_objects(map, {*hidden}); + } + return true; +} + // Row `row` on the sim with `script`, from its start. After a step the sim // does not play, the player is put on its pose_after, or on `landings`' // tile for it, the program going on from the pose_after either way. A @@ -223,12 +236,7 @@ RowRun run_row( continue; } at = *story_pose(*step.pose_after); - const std::optional hidden = talk_battle_hide_flag(step); - if (let_pass && hidden){ - for (MapData& map : maps){ - hide_objects(map, {*hidden}); - } - } + const bool hidden = let_pass && hide_talk_battle_trainer(maps, step); const auto landing = landings.find(c); const MapPosition land{at.map, landing == landings.end() ? at.tile : landing->second}; if (!map_loaded(land.map)){ @@ -237,7 +245,7 @@ RowRun run_row( out.failure = walks_after(row, c) ? std::format("{}/{}: ends on {}, which has no map, with a walk after it.", row.id, step.name, land.map) : ""; break; } - if (!(sim->state().position == land) || (let_pass && hidden)){ + if (!(sim->state().position == land) || hidden){ add(sim->state()); sim = std::make_unique(maps, land, at.facing.value_or(sim->state().facing), script); } From 3ed6b4cb3bbcbc234c4e65b684435833db2633ba Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 00:25:15 -0800 Subject: [PATCH 03/23] FRLG Overworld: red sim test, a short first leg off the Rocket Hideout B3F stairs Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_OverworldSim_Tests.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp index 25d6f4bfc4..c8fd3a9d07 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp @@ -488,6 +488,23 @@ UnitTestResult test_short_leg_unseen(){ return true; } +// 00.31 r1 (console B, 2026-11-10), Rocket Hideout B3F: off the stairs from +// B2F, the open leg west along the top corridor ended short, so the hold +// south to the wall stayed in the corridor, and the legs through the +// spinners after it all ran there: the walk ended a few tiles west of the +// stairs it came down, with no warp to B4F. +UnitTestResult test_short_leg_off_hideout_stairs(){ + SimCase c{.start = at("RocketHideout_B3F", 18, 2), .facing = Direction::EAST, .goal = arrival("RocketHideout_B4F", "warp_0")}; + for (const int short_by : {1, 2}){ + c.script.short_holds = {{1, short_by}}; + const SimRun now = run_case(c); + if (!arrived(now, c.goal)){ + return std::format("Expected B4F reached with the first leg {} tile(s) short:", short_by) + describe(now); + } + } + return true; +} + // r18 (console B, 2026-11-01), Pewter Gym: after Brock, Camper Liam sees // the player on the walk south to the door, walks up and battles. The // route holds on south to the door's mat; finding the player again at @@ -963,6 +980,7 @@ const OverworldSimCase OVERWORLD_SIM_CASES[] = { {.input = {"no hold over a ledge", test_no_hold_over_ledge}, .expectation = {},}, {.input = {"a short leg, then a sign", test_short_leg_then_sign}, .expectation = {},}, {.input = {"a short leg, nothing seen", test_short_leg_unseen}, .expectation = {},}, + {.input = {"a short leg off the hideout's stairs", test_short_leg_off_hideout_stairs}, .expectation = {},}, {.input = {"a trainer on the way out of Pewter Gym", test_trainer_on_way_out}, .expectation = {},}, {.input = {"out of Viridian Mart from the clerk's scene", test_mart_exit}, .expectation = {},}, {.input = {"Mt. Moon: down the ladders to B2F", test_mt_moon_ladders}, .expectation = {},}, From 9da5d77e560bc587b3efaa92e75933c680627f3c Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 00:28:41 -0800 Subject: [PATCH 04/23] FRLG Overworld: check open legs whose wall holds and way back walk up to 3 tiles per tile Rocket Hideout B3F's west 7 off the stairs from B2F ended short on console B (00.31 r1); the check skipped it since the hold to the west wall and back walks 18, over 2 per tile. The red sim test now passes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Overworld/PokemonFRLG_OverworldRecovery.cpp | 6 +++--- .../PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index 8cec6277b7..9ef2a168a9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -417,7 +417,7 @@ class RouteRun{ // with nothing to show it (r16), unless it ends on its tile from // wherever the leg left the player. If it doesn't, finds the player at // walls first; without such holds, or if they and the way back walk - // farther than the leg there and back, trusts the leg. Only there, and + // farther than OPEN_LEG_CHECK_TILES_PER_TILE times the leg, trusts the leg. Only there, and // only that far, to keep the check cheap: in Viridian Forest (r16) it // walks 10 tiles after "west 6", while after Route 1's "west 4" the // only holds walk 30. An open leg after a short one walks on off the @@ -434,8 +434,8 @@ class RouteRun{ return; } const std::optional anchor = plan_reanchor(*maps(), candidates, step, m_planning->costs); - if (!anchor || anchor->holds.empty() || reanchor_tiles(*anchor) > 2 * step.tiles){ - m_calls.log("Route: no holds to walls within " + std::to_string(2 * step.tiles) + " tiles find the player if " + to_string(step) + " ended short; taken as walked."); + if (!anchor || anchor->holds.empty() || reanchor_tiles(*anchor) > OPEN_LEG_CHECK_TILES_PER_TILE * step.tiles){ + m_calls.log("Route: no holds to walls within " + std::to_string(OPEN_LEG_CHECK_TILES_PER_TILE * step.tiles) + " tiles find the player if " + to_string(step) + " ended short; taken as walked."); return; } m_calls.log(std::format( diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h index 88e18a679b..a26d9e9332 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h @@ -87,6 +87,13 @@ enum class WallCheck{ // known (the forest drift), so this is what was seen, not a bound. constexpr int OPEN_LEG_SHORTFALL = 2; +// How far the holds that find the player after an open leg, and the way +// back, may walk, per tile of the leg. 2 left Rocket Hideout B3F's "west +// 7" off the stairs unchecked: the hold to its west wall and back walk up +// to 18, and the leg ended short (00.31 r1, console B, 2026-11-10). Route +// 1's "west 4", whose holds walk 30, stays unchecked. +constexpr int OPEN_LEG_CHECK_TILES_PER_TILE = 3; + // Where a leg onto a warp stopped when its fade was a wild battle's: the // battle's wipe passes for the fade (console B, 2026-11-03, Mt. Moon 1F), // so the stop isn't timed. The battle started on one of the leg's steps From e81230c92294b8ad223a4dbf317a4532abb21c84 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 00:30:31 -0800 Subject: [PATCH 05/23] FRLG Overworld: the B3F short-leg sim test in the spinner tests, keeping the sim tests under 1000 lines Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_OverworldSim_Tests.cpp | 18 ---------- .../PokemonFRLG_OverworldSpin_Tests.cpp | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp index c8fd3a9d07..25d6f4bfc4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp @@ -488,23 +488,6 @@ UnitTestResult test_short_leg_unseen(){ return true; } -// 00.31 r1 (console B, 2026-11-10), Rocket Hideout B3F: off the stairs from -// B2F, the open leg west along the top corridor ended short, so the hold -// south to the wall stayed in the corridor, and the legs through the -// spinners after it all ran there: the walk ended a few tiles west of the -// stairs it came down, with no warp to B4F. -UnitTestResult test_short_leg_off_hideout_stairs(){ - SimCase c{.start = at("RocketHideout_B3F", 18, 2), .facing = Direction::EAST, .goal = arrival("RocketHideout_B4F", "warp_0")}; - for (const int short_by : {1, 2}){ - c.script.short_holds = {{1, short_by}}; - const SimRun now = run_case(c); - if (!arrived(now, c.goal)){ - return std::format("Expected B4F reached with the first leg {} tile(s) short:", short_by) + describe(now); - } - } - return true; -} - // r18 (console B, 2026-11-01), Pewter Gym: after Brock, Camper Liam sees // the player on the walk south to the door, walks up and battles. The // route holds on south to the door's mat; finding the player again at @@ -980,7 +963,6 @@ const OverworldSimCase OVERWORLD_SIM_CASES[] = { {.input = {"no hold over a ledge", test_no_hold_over_ledge}, .expectation = {},}, {.input = {"a short leg, then a sign", test_short_leg_then_sign}, .expectation = {},}, {.input = {"a short leg, nothing seen", test_short_leg_unseen}, .expectation = {},}, - {.input = {"a short leg off the hideout's stairs", test_short_leg_off_hideout_stairs}, .expectation = {},}, {.input = {"a trainer on the way out of Pewter Gym", test_trainer_on_way_out}, .expectation = {},}, {.input = {"out of Viridian Mart from the clerk's scene", test_mart_exit}, .expectation = {},}, {.input = {"Mt. Moon: down the ladders to B2F", test_mt_moon_ladders}, .expectation = {},}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp index e17a69bda4..0a52517442 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp @@ -193,6 +193,37 @@ UnitTestResult test_sim_walker_walks_slide(){ } +// 00.31 r1 (console B, 2026-11-10), Rocket Hideout B3F: off the stairs from +// B2F, the open leg west along the top corridor ended short, so the hold +// south to the wall stayed in the corridor, and the legs through the +// spinners after it all ran there: the walk ended a few tiles west of the +// stairs it came down, with no warp to B4F. +UnitTestResult test_short_leg_off_hideout_stairs(){ + static const std::vector maps = overworld_maps(); + const MapPosition start{"RocketHideout_B3F", {18, 2}}; + const MapPosition goal{"RocketHideout_B4F", map_point(maps, "RocketHideout_B4F", "warp_0")}; + const auto route = plan_overworld_route(maps, start, RouteGoal{goal, std::nullopt}, default_route_costs(), Direction::EAST); + if (!route){ + return std::string("No route from B3F's stairs to B4F."); + } + for (const int short_by : {1, 2}){ + SimScript script; + script.short_holds = {{1, short_by}}; + OverworldSim sim(maps, start, Direction::EAST, script); + OverworldSimWalker walker(sim); + const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = start, .label = "Sim"}; + const std::string failure = walker.run(*route, planning); + if (!failure.empty() || !(sim.state().position == goal)){ + return std::format( + "With the first leg {} tile(s) short, walked to {}, failure \"{}\".", + short_by, to_string(sim.state().position), failure + ); + } + } + return true; +} + + // A lift whose door, the exit mat (1, 2), lets out on the floor picked. std::vector lift_maps(){ const std::string FLOOR = R"({ @@ -304,6 +335,10 @@ const SpinCase SPIN_CASES[] = { .input = {.name = "sim walker walks a slide", .body = test_sim_walker_walks_slide}, .expectation = {.description = "sim walker walks a slide"}, }, + { + .input = {.name = "a short leg off the hideout's stairs", .body = test_short_leg_off_hideout_stairs}, + .expectation = {.description = "B4F reached after a short first leg on B3F"}, + }, { .input = {.name = "lift lets out on the floor picked", .body = test_lift_floor}, .expectation = {.description = "lift lets out on the floor picked"}, From 95626157c314030eab2804775209650f470a613b Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 00:32:23 -0800 Subject: [PATCH 06/23] FRLG Overworld: the open-leg check's tiles-per-tile limit in the .cpp, off the header's symbol count Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Overworld/PokemonFRLG_OverworldRecovery.cpp | 7 +++++++ .../PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index 9ef2a168a9..20b343f9c1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -59,6 +59,13 @@ int sight_onto(const std::vector& maps, const MapPosition& tile){ return sight; } +// How far the holds that find the player after an open leg, and the way +// back, may walk, per tile of the leg. 2 left Rocket Hideout B3F's "west +// 7" off the stairs unchecked: the hold to its west wall and back walk up +// to 18, and the leg ended short (00.31 r1, console B, 2026-11-10). Route +// 1's "west 4", whose holds walk 30, stays unchecked. +constexpr int OPEN_LEG_CHECK_TILES_PER_TILE = 3; + // The tiles an open `step` from `start` may have ended on with nothing // seen: its end, and up to OPEN_LEG_SHORTFALL tiles before it. std::vector short_candidates(const std::vector& maps, const MapPosition& start, const RouteStep& step){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h index a26d9e9332..88e18a679b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h @@ -87,13 +87,6 @@ enum class WallCheck{ // known (the forest drift), so this is what was seen, not a bound. constexpr int OPEN_LEG_SHORTFALL = 2; -// How far the holds that find the player after an open leg, and the way -// back, may walk, per tile of the leg. 2 left Rocket Hideout B3F's "west -// 7" off the stairs unchecked: the hold to its west wall and back walk up -// to 18, and the leg ended short (00.31 r1, console B, 2026-11-10). Route -// 1's "west 4", whose holds walk 30, stays unchecked. -constexpr int OPEN_LEG_CHECK_TILES_PER_TILE = 3; - // Where a leg onto a warp stopped when its fade was a wild battle's: the // battle's wipe passes for the fade (console B, 2026-11-03, Mt. Moon 1F), // so the stop isn't timed. The battle started on one of the leg's steps From 3484975e513566374dded6219a1a1206295fa851 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 00:52:48 -0800 Subject: [PATCH 07/23] FRLG Overworld: check an open leg before a step onto a spinner 00.31 r1 run 3 (console B): on Rocket Hideout B3F, "south 2" from (1, 14) ended a tile short; "east 2" onto the arrow (3, 16) walked into the wall instead, the next position check mistook that wall for the one at (7, 20), and the later legs slid the player to the stop tile (10, 13). An open leg followed by a slide is now checked like one followed by a wall hold. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_OverworldRecovery.cpp | 13 ++++++- .../Overworld/PokemonFRLG_OverworldRecovery.h | 3 +- .../PokemonFRLG_OverworldSpin_Tests.cpp | 38 +++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index 20b343f9c1..c9f6dfc447 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -82,6 +82,15 @@ bool is_wall_hold(const RouteStep& next){ return next.action == RouteAction::WALK && next.to_wall && !next.warps; } +// Whether `next` steps onto a spinner. From a tile short of its start it +// misses the arrow, or walks onto another, and ends elsewhere in the maze: +// "south 2" before Rocket Hideout B3F's "east 2" onto the arrow (3, 16) +// ended a tile short, the east leg walked into a wall, and the walk after +// it slid up to (10, 13) (00.31 r1 run 3, console B, 2026-11-10). +bool is_slide(const RouteStep& next){ + return next.action == RouteAction::WALK && next.spin_tiles && !next.warps; +} + // Whether `next`, a hold to a wall, ends on its planned tile from each of // `candidates`: then it finds the player itself. bool hold_finds(const std::vector& maps, const std::vector& candidates, const RouteStep& next){ @@ -432,12 +441,12 @@ class RouteRun{ void check_open_leg(const RouteStep& step, const std::optional& start){ if (maps() == nullptr || m_planning->open_leg_check != OpenLegCheck::REANCHOR || !start || step.action != RouteAction::WALK || step.to_wall || step.warps - || m_next >= m_plan.size() || !is_wall_hold(m_plan[m_next]) + || m_next >= m_plan.size() || !(is_wall_hold(m_plan[m_next]) || is_slide(m_plan[m_next])) ){ return; } const std::vector candidates = short_candidates(*maps(), *start, step); - if (candidates.size() < 2 || hold_finds(*maps(), candidates, m_plan[m_next])){ + if (candidates.size() < 2 || (is_wall_hold(m_plan[m_next]) && hold_finds(*maps(), candidates, m_plan[m_next]))){ return; } const std::optional anchor = plan_reanchor(*maps(), candidates, step, m_planning->costs); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h index 88e18a679b..52cbb9e1d1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h @@ -22,7 +22,8 @@ * (walked_before_warp()), and the way back goes on through the warp; * - an open leg that ended with nothing seen may still have ended up to * OPEN_LEG_SHORTFALL tiles short. When the next step is a hold to a - * wall that doesn't end on its tile from each of those, the player is + * wall that doesn't end on its tile from each of those, or a step onto + * a spinner (which a short start misses), the player is * found at walls the same way and walked back to the leg's end first. * When no holds find them, the leg is taken as walked, as before. * diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp index 0a52517442..433eb39443 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin_Tests.cpp @@ -224,6 +224,40 @@ UnitTestResult test_short_leg_off_hideout_stairs(){ } +// 00.31 r1 run 3 (console B, 2026-11-10), Rocket Hideout B3F: "south 2" +// from (1, 14), at the wall, ended a tile short at (1, 15) with nothing +// seen. "east 2", meant to step onto the arrow (3, 16), walked into the +// wall east of (1, 15); the position check after the next leg took that +// wall for the one east of the stop tile (7, 20) and found the player +// there. From column 1 the hold "east 11" stepped onto the arrow (2, 17), +// which slid them up round (6, 17) and (6, 13) to the stop tile (10, 13); +// the hold west onto the warp slid them back there round (6, 13) (frame: +// the player on (10, 13), the north arrow (10, 14) below). +UnitTestResult test_short_leg_before_hideout_arrows(){ + static const std::vector maps = overworld_maps(); + const MapPosition start{"RocketHideout_B3F", {1, 14}}; + const MapPosition goal{"RocketHideout_B4F", map_point(maps, "RocketHideout_B4F", "warp_0")}; + const auto route = plan_overworld_route(maps, start, RouteGoal{goal, std::nullopt}, default_route_costs(), Direction::WEST); + if (!route){ + return std::string("No route from B3F's west wall to B4F."); + } + for (const int short_by : {1, 2}){ + SimScript script; + script.short_holds = {{1, short_by}}; + OverworldSim sim(maps, start, Direction::WEST, script); + OverworldSimWalker walker(sim); + const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = start, .label = "Sim"}; + const std::string failure = walker.run(*route, planning); + if (!failure.empty() || !(sim.state().position == goal)){ + return std::format( + "With the first leg {} tile(s) short, walked to {}, failure \"{}\":{}", + short_by, to_string(sim.state().position), failure, describe(*route) + ); + } + } + return true; +} + // A lift whose door, the exit mat (1, 2), lets out on the floor picked. std::vector lift_maps(){ const std::string FLOOR = R"({ @@ -339,6 +373,10 @@ const SpinCase SPIN_CASES[] = { .input = {.name = "a short leg off the hideout's stairs", .body = test_short_leg_off_hideout_stairs}, .expectation = {.description = "B4F reached after a short first leg on B3F"}, }, + { + .input = {.name = "a short leg before the hideout's arrows", .body = test_short_leg_before_hideout_arrows}, + .expectation = {.description = "B4F reached after a short leg to the arrow row on B3F"}, + }, { .input = {.name = "lift lets out on the floor picked", .body = test_lift_floor}, .expectation = {.description = "lift lets out on the floor picked"}, From f23905dd024addcd87ad14226f0239329b47bd89 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:11:29 -0800 Subject: [PATCH 08/23] FRLG AutoStory 00.31: B3F's arrow floor as pokeguy's legs, a checked tap a tile Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_OverworldBikeTaps.cpp | 20 +++++- .../Overworld/PokemonFRLG_OverworldBikeTaps.h | 21 ++++++- .../PokemonFRLG_OverworldRecoveryWalk.cpp | 61 +++++++++++++++---- .../Overworld/PokemonFRLG_OverworldRoute.h | 5 ++ .../Overworld/PokemonFRLG_OverworldSim.cpp | 4 +- .../Overworld/PokemonFRLG_OverworldSim.h | 3 + .../PokemonFRLG_OverworldSimTaps.cpp | 24 +++++++- .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 31 +++++++++- .../AutoStory/PokemonFRLG_AutoStoryEvents.h | 5 ++ .../PokemonFRLG_AutoStoryHideout_Tests.cpp | 42 +++++++++++++ .../AutoStory/StoryData/frlg-00.31.plan.json | 32 +++++++++- 11 files changed, 226 insertions(+), 22 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp index fa2871e6d7..18663df9f2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp @@ -6,6 +6,7 @@ #include #include +#include "PokemonFRLG_BikeSpinPresses.h" #include "PokemonFRLG_OverworldBikeTaps.h" namespace PokemonAutomation{ @@ -16,7 +17,11 @@ namespace PokemonFRLG{ StepOutcome count_bike_taps(const RouteStep& step, const BikeTapCalls& calls){ int moved = 0; for (int tap = 1; tap <= step.tiles; tap++){ - const BikeTap result = calls.tap(); + BikeTap result = calls.tap(tap); + for (int retry = 1; retry < calls.tries && !result.moved && !result.interrupt && !result.cleared_late; retry++){ + calls.log(std::format("Taps: tap {} of {} didn't move: tapping again, it may only have turned the player.", tap, step.tiles)); + result = calls.tap(tap); + } if (result.interrupt || result.cleared_late){ calls.log(std::format("Bike: tap {} of {}: interrupted after {} tile(s).", tap, step.tiles, moved)); if (result.interrupt){ @@ -34,6 +39,19 @@ StepOutcome count_bike_taps(const RouteStep& step, const BikeTapCalls& calls){ return StepOutcome{}; } +bool counts_step_taps(const RouteStep& step){ + return step.tapped && step.action == RouteAction::WALK && step.tiles > 0 + && !step.surfing && !step.warps && step.connection_steps.empty(); +} + +Milliseconds step_tap_settle(const RouteStep& step, int tap){ + using namespace MovementMechanics; + if (tap != step.tiles || !step.spin_tiles){ + return 0ms; + } + return SPIN_TILE_TIME * *step.spin_tiles + SPIN_STOP_SETTLE; +} + } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h index c1018ce17f..12a3e8694d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h @@ -32,13 +32,20 @@ struct BikeTap{ // cleared already: a trainer who saw the player, a battle seen late. bool cleared_late = false; }; -// The console side of count_bike_taps(): `tap` taps once and judges it; +// The console side of count_bike_taps(): `tap` taps once, for the leg's +// `tap`th tile (from 1), and judges it; // `clear` clears interrupt i. struct BikeTapCalls{ - std::function tap; + std::function tap; std::function clear; std::function log; + // Taps per tile before one that doesn't move counts as blocked: on + // foot a tap facing another way only turns the player + // (STEP_TAP_TRIES). + int tries = 1; }; +// Taps per tile on foot: the first tap of a leg may only turn. +constexpr int STEP_TAP_TRIES = 2; // How far a sure start may be off before a blocked tap finds the player: // three runs of 00.30 stood 3 tiles off (console B, 2026-11-09). constexpr int BLOCKED_TAP_SLACK = 3; @@ -53,6 +60,16 @@ constexpr int BLOCKED_TAP_SLACK = 3; // and one more, which may have moved before its battle showed. StepOutcome count_bike_taps(const RouteStep& step, const BikeTapCalls& calls); +// Whether `step` is walked on foot a tap at a time (RouteStep::tapped), +// each a tile, by count_bike_taps() with STEP_TAP_TRIES: an open leg or +// one to a wall or onto a spinner, not onto a warp or over a connection. +bool counts_step_taps(const RouteStep& step); + +// How long after a step tap of `step`, the `tap`th (from 1), the screen +// is still: the step, and on the last tap of a leg onto a spinner the +// slide (RouteStep::spin_tiles) and its settle. +Milliseconds step_tap_settle(const RouteStep& step, int tap); + } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index e7fbd0e42a..18b365317f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -76,14 +76,23 @@ double top_band_change(const ImageViewRGB32& before, const ImageViewRGB32& after return ImageMatch::pixel_RMSD(extract_box_reference(before, band), extract_box_reference(after, band)); } -// One tap of a leg counted out on the Bicycle (count_bike_taps()): a -// BIKE_TAP press released to a BIKE_TAP_PERIOD period, then -// BIKE_TAP_SETTLE for the screen to show the step, watching `interrupts` -// throughout. A tap that didn't scroll the screen is watched on for a -// late interrupt, which is cleared. +// A counted tap's press, its release and the wait after it for the +// screen to show the step. +struct TapTiming{ + Milliseconds press; + Milliseconds release; + Milliseconds settle; +}; +// On the Bicycle: a BIKE_TAP press released to a BIKE_TAP_PERIOD period, +// then BIKE_TAP_SETTLE. +constexpr TapTiming BIKE_TAP_TIMING{BIKE_TAP, BIKE_TAP_PERIOD - BIKE_TAP, BIKE_TAP_SETTLE}; + +// One tap of a leg counted out (count_bike_taps()), timed by `timing`, +// watching `interrupts` throughout. A tap that didn't scroll the screen +// is watched on for a late interrupt, which is cleared. BikeTap console_bike_tap( ConsoleHandle& console, ProControllerContext& context, - const RouteStep& step, const OverworldInterrupts& interrupts + const RouteStep& step, const OverworldInterrupts& interrupts, const TapTiming& timing ){ context.wait_for_all_requests(); const VideoSnapshot before = console.video().snapshot(); @@ -96,8 +105,8 @@ BikeTap console_bike_tap( const int ret = run_until( console, context, [&](ProControllerContext& context){ - pbf_press_dpad(context, dpad(step.direction), BIKE_TAP, BIKE_TAP_PERIOD - BIKE_TAP); - pbf_wait(context, BIKE_TAP_SETTLE); + pbf_press_dpad(context, dpad(step.direction), timing.press, timing.release); + pbf_wait(context, timing.settle); context.wait_for_all_requests(); }, callbacks @@ -122,9 +131,32 @@ StepWalk walk_bike_taps( StepWalk out{std::nullopt, current_time(), false, false}; const OverworldInterrupts& watched = step.wild ? interrupts.wild : interrupts.other; BikeTapCalls calls; - calls.tap = [&]{ return console_bike_tap(console, context, step, watched); }; + calls.tap = [&](int){ return console_bike_tap(console, context, step, watched, BIKE_TAP_TIMING); }; + calls.clear = [&](size_t index){ watched[index]->clear(console, context); }; + calls.log = [&](const std::string& message){ console.log(message, COLOR_ORANGE); }; + const StepOutcome outcome = count_bike_taps(step, calls); + out.stopped = outcome.walked; + out.blocked = outcome.blocked; + return out; +} + +// A leg on foot, a step tap at a time (counts_step_taps()): STEP_TAP +// pressed and STEP_TAP_RELEASE let go, past the step's lockout, then the +// slide off a spinner waited out (step_tap_settle()). +StepWalk walk_step_taps( + ConsoleHandle& console, ProControllerContext& context, + const RouteStep& step, const OverworldInterruptSet& interrupts +){ + StepWalk out{std::nullopt, current_time(), false, false}; + const OverworldInterrupts& watched = step.wild ? interrupts.wild : interrupts.other; + BikeTapCalls calls; + calls.tap = [&](int tap){ + const TapTiming timing{STEP_TAP, STEP_TAP_RELEASE, step_tap_settle(step, tap)}; + return console_bike_tap(console, context, step, watched, timing); + }; calls.clear = [&](size_t index){ watched[index]->clear(console, context); }; calls.log = [&](const std::string& message){ console.log(message, COLOR_ORANGE); }; + calls.tries = STEP_TAP_TRIES; const StepOutcome outcome = count_bike_taps(step, calls); out.stopped = outcome.walked; out.blocked = outcome.blocked; @@ -264,9 +296,14 @@ StepOutcome walk_and_watch( clear_open_message(console, context, step.wild ? interrupts.wild : interrupts.other, step); check_overworld(console, context, step); const LegRecorder recorder(console, context, interrupts, step); - const StepWalk walked = counts_bike_taps(step, speed) - ? walk_bike_taps(console, context, step, interrupts) - : walk_step(console, context, step, facing, interrupts, speed); + StepWalk walked; + if (counts_step_taps(step)){ + walked = walk_step_taps(console, context, step, interrupts); + }else if (counts_bike_taps(step, speed)){ + walked = walk_bike_taps(console, context, step, interrupts); + }else{ + walked = walk_step(console, context, step, facing, interrupts, speed); + } if (walked.stopped){ return StepOutcome{.end = StepEnd::STOPPED, .walked = walked.stopped, .blocked = walked.blocked}; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h index 2d5f45f8e4..8841226edd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h @@ -80,6 +80,11 @@ struct RouteStep{ // tiles on, to `end` (spin_slide()). The hold must end on the spinner: // held on, the player walks on after the slide. std::optional spin_tiles; + // WALK on foot: walked a tap at a time, each a tile, and each checked + // to have moved (count_step_taps()), as through the hideout's arrow + // floors, where a hold that ends a tile off slides the player + // elsewhere (console B, 2026-11-10, 00.31 r1). + bool tapped = false; // WALK, SURF: a wild Pokemon can appear on the way: the step crosses // tall grass or water. Elsewhere (indoors, streets) no wild battle can // start, so the walker doesn't watch for one. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp index 14129e9086..938dab9efc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp @@ -880,8 +880,8 @@ StepOutcome OverworldSimWalker::walk_ridden(const RouteStep& step, std::optional clear_late(interrupts(step), OPEN_MESSAGE_WATCH, 1); } check_overworld(step); - if (m_rules.count_bike_taps && counts_bike_taps(step, m_speed)){ - const StepOutcome outcome = walk_bike_taps(step); + if (counts_step_taps(step) || (m_rules.count_bike_taps && counts_bike_taps(step, m_speed))){ + const StepOutcome outcome = counts_step_taps(step) ? walk_step_taps(step) : walk_bike_taps(step); if (outcome.end != StepEnd::DONE){ return outcome; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h index 3b847ecc70..70b4f088e5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h @@ -553,6 +553,9 @@ class OverworldSimWalker{ // count_bike_taps() on the sim. StepOutcome walk_bike_taps(const RouteStep& step); BikeTap bike_tap(const RouteStep& step); + // count_bike_taps() on foot (counts_step_taps()). + StepOutcome walk_step_taps(const RouteStep& step); + BikeTap step_tap(const RouteStep& step, int tap); std::optional late_stop(const RouteStep& step); // stop_tiles(); without SimWalkerRules::whole_leg_in_dark, the dark // screen places the stop at the hold's start. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp index 197d4d7355..65ff730b5c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp @@ -70,7 +70,7 @@ BikeTap OverworldSimWalker::bike_tap(const RouteStep& step){ StepOutcome OverworldSimWalker::walk_bike_taps(const RouteStep& step){ const std::vector& ints = interrupts(step); BikeTapCalls calls; - calls.tap = [&]{ return bike_tap(step); }; + calls.tap = [&](int){ return bike_tap(step); }; calls.clear = [&](size_t index){ clear(ints[index]); }; calls.log = [&](const std::string& message){ m_log.push_back(message); }; m_leg_start = m_sim.state().time; @@ -78,6 +78,28 @@ StepOutcome OverworldSimWalker::walk_bike_taps(const RouteStep& step){ return count_bike_taps(step, calls); } +BikeTap OverworldSimWalker::step_tap(const RouteStep& step, int tap){ + const MapPosition before = m_sim.state().position; + m_sim.tap(step.direction, STEP_TAP, STEP_TAP_RELEASE); + m_sim.watch({}, step_tap_settle(step, tap)); + if (!(m_sim.state().position == before)){ + return BikeTap{.moved = true}; + } + return BikeTap{.moved = false, .interrupt = std::nullopt, .cleared_late = clear_late(interrupts(step), AFTER_LEG_WATCH, MAX_INTERRUPTIONS_PER_LEG) > 0}; +} + +StepOutcome OverworldSimWalker::walk_step_taps(const RouteStep& step){ + const std::vector& ints = interrupts(step); + BikeTapCalls calls; + calls.tap = [&](int tap){ return step_tap(step, tap); }; + calls.clear = [&](size_t index){ clear(ints[index]); }; + calls.log = [&](const std::string& message){ m_log.push_back(message); }; + calls.tries = STEP_TAP_TRIES; + m_leg_start = m_sim.state().time; + m_leg_dark = m_sim.state().dark; + return count_bike_taps(step, calls); +} + // walk_and_watch(), getting on the Bicycle first where // walk_overworld_route_with_recovery() does. StepOutcome OverworldSimWalker::walk(const RouteStep& step, std::optional facing){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index b089da5379..e469c828b9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -16,6 +16,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" #include "PokemonFRLG_AutoStoryAbilities.h" #include "PokemonFRLG_AutoStoryBattleData.h" @@ -166,7 +167,12 @@ Outcome walk_legs(StoryEnv& env, RunState& state, const StoryStep& step){ if (!facing){ facing = face_a_wall(env, start); } - const std::optional> route = fixed_route(story_maps(), start, step.legs); + std::optional> route = fixed_route(story_maps(), start, step.legs); + if (route && step.variant == TAPS_VARIANT){ + for (RouteStep& leg : *route){ + leg.tapped = true; + } + } if (!facing || !route || route->empty()){ return Pokemon::outcome_failed("bad_legs", to_string(start)); } @@ -439,6 +445,24 @@ void add_start_pose_check( add_start_check(checkpoint, start, std::move(reader), std::move(log)); } +namespace{ + +// A leg's step onto a spinner: only its last (`last`), which slides +// `player` on to where the slide ends, facing its way (spin_slide()). +// False mid-leg, or for a slide that loops or leaves through a warp. +bool land_on_spinner(const MapData& map, PlayerState& player, bool last, RouteStep& step){ + const std::optional slide = spin_slide(map, player); + if (!last || !slide){ + return false; + } + player = slide->end; + step.spin_tiles = slide->tiles; + step.facing_after = slide->facing; + return true; +} + +} + std::optional> fixed_route( const std::vector& maps, const MapPosition& start, const std::vector& legs ){ @@ -467,8 +491,11 @@ std::optional> fixed_route( } step.wild |= is_tall_grass(*map, next); player = after_step(*map, player, leg.direction, kind); + if (spin_direction(*map, player.position) && !land_on_spinner(*map, player, c + 1 == leg.tiles, step)){ + return std::nullopt; + } } - step.to_wall = classify_step(*map, player, leg.direction) == StepKind::BLOCKED; + step.to_wall = !step.spin_tiles && classify_step(*map, player, leg.direction) == StepKind::BLOCKED; step.end = MapPosition{map->name, player.position}; route.push_back(step); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h index ee7cb5dced..45a707d4d5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -64,6 +64,11 @@ struct StoryPose{ // has the Running Shoes (00.10 on). inline const std::string RUN_VARIANT = "run"; +// The variant of LEGS walked on foot a tap at a time, each tap checked to +// have moved the player a tile (RouteStep::tapped): the Rocket Hideout's +// arrow floors, where a hold a tile off slides the player elsewhere. +inline const std::string TAPS_VARIANT = "taps"; + // The variant of a STEP into a trainer's line: a tile at a time, at most // TRAINER_LINE_TILES, until the trainer sees the player // (step_until_seen()). The battle after it starts on the trainer's row diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp index e84ba87ea8..5688c4d7e7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp @@ -212,6 +212,44 @@ UnitTestResult test_coded_spinners(){ return true; } +// 00.31's taps through B3F's arrow floor (frlg-00.31.plan.json's +// b3f_arrow_maze, pokeguy's way) on the sim, from the stairs (18, 2) +// to below the stairs to B4F (15, 19): as planned, and with each of the +// turns the taps make dropped in turn (a tap facing another way only +// turns the player, and a dropped one doesn't even turn them). +UnitTestResult test_b3f_maze_taps(){ + using Pokemon::StoryLeg; + const std::vector legs{ + {Direction::WEST, 6}, {Direction::SOUTH, 5}, {Direction::WEST, 7}, {Direction::SOUTH, 2}, {Direction::WEST, 1}, + {Direction::SOUTH, 2}, {Direction::WEST, 2}, {Direction::SOUTH, 3}, {Direction::WEST, 3}, {Direction::SOUTH, 2}, + {Direction::EAST, 2}, {Direction::WEST, 2}, {Direction::SOUTH, 5}, {Direction::EAST, 10}, {Direction::NORTH, 6}, + }; + const std::vector& maps = story_maps(); + const MapPosition start{"RocketHideout_B3F", {18, 2}}; + const MapPosition goal{"RocketHideout_B3F", {15, 19}}; + std::optional> route = fixed_route(maps, start, legs); + if (!route || !(route->back().end == goal)){ + return std::string("The legs don't end below B3F's stairs to B4F."); + } + for (RouteStep& step : *route){ + step.tapped = true; + } + for (int dropped = 0; dropped <= (int)legs.size(); dropped++){ + SimScript script; + if (dropped > 0){ + script.dropped_turn_taps = {dropped}; + } + OverworldSim sim(maps, start, Direction::EAST, script); + OverworldSimWalker walker(sim); + const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = start, .label = "Sim"}; + const std::string failure = walker.run(*route, planning); + if (!failure.empty() || !(sim.state().position == goal)){ + return std::format("With turn tap {} dropped, walked to {}, failure \"{}\".", dropped, to_string(sim.state().position), failure); + } + } + return true; +} + struct AutoStoryHideoutBodyInput{ std::string name; UnitTestResult (*body)(); @@ -251,6 +289,10 @@ const AutoStoryHideoutBodyCase HIDEOUT_BODY_CASES[] = { .input = {.name = "coded spinners", .body = test_coded_spinners}, .expectation = {.description = "B2F's and B3F's arrows come from code, not the map"}, }, + { + .input = {.name = "B3F's arrow floor a tap at a time", .body = test_b3f_maze_taps}, + .expectation = {.description = "below the stairs to B4F, with any one turn dropped"}, + }, }; const LiftCase LIFT_CASES[] = { diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json index 23a3cb24d4..1787f57fab 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json @@ -58,12 +58,26 @@ "legs": [{"direction": "west", "tiles": 2}, {"direction": "north", "tiles": 2}], "why": "west to (21, 4), a tile short of the Grunt's north line (20, 4..5), and up column 21 to the wall, onto the stairs (21, 2), whose warp is a step east" }, + { + "id": "b3f_off_stairs", + "kind": "route", + "target": {"certainty": "tile", "map": "RocketHideout_B3F", "where": {"facing": "east", "kind": "tiles", "tiles": [[18, 2]]}}, + "variant": "run", + "why": "east off the stairs (21, 2) to B3F, onto its stairs (18, 2)" + }, + { + "id": "b3f_arrow_maze", + "kind": "legs", + "variant": "taps", + "legs": [{"direction": "west", "tiles": 6}, {"direction": "south", "tiles": 5}, {"direction": "west", "tiles": 7}, {"direction": "south", "tiles": 2}, {"direction": "west", "tiles": 1}, {"direction": "south", "tiles": 2}, {"direction": "west", "tiles": 2}, {"direction": "south", "tiles": 3}, {"direction": "west", "tiles": 3}, {"direction": "south", "tiles": 2}, {"direction": "east", "tiles": 2}, {"direction": "west", "tiles": 2}, {"direction": "south", "tiles": 5}, {"direction": "east", "tiles": 10}, {"direction": "north", "tiles": 6}], + "why": "pokeguy's way through the arrow floor (video 56:39-56:50), a tap a tile: west along the top corridor and down column 12 to row 7, west to (5, 7), down to (5, 9) between the arrows; west onto (4, 9), which slides to the stop (2, 9); south onto (2, 11), which slides east to the stop (6, 11); west to (4, 11), down column 4 to (4, 14), west to the wall (1, 14), down to (1, 16); east onto (3, 16), which slides east and, turned by (7, 16), south to the stop (7, 20); west to (5, 20), down column 5 to row 25, east to column 15 and up to (15, 19), below the stairs to B4F (15, 18). He detours to the BLACKGLASSES on the way down column 5; we don't." + }, { "id": "hideout_b4f_west", "kind": "route", "target": {"certainty": "tile", "map": "RocketHideout_B4F", "where": {"facing": "west", "kind": "tiles", "tiles": [[5, 3]]}}, "variant": "run", - "why": "east off the stairs to B3F, B3F to B4F (15, 18), round to (5, 3), east of the tile below the Grunt (4, 2)" + "why": "up onto the stairs (15, 18) to B4F (11, 15), round to (5, 3), east of the tile below the Grunt (4, 2)" }, { "id": "key_grunt_line", @@ -90,12 +104,26 @@ "kind": "talk", "why": "pick up the LIFT KEY (pokeguy 57:33)" }, + { + "id": "b3f_from_b4f", + "kind": "route", + "target": {"certainty": "tile", "map": "RocketHideout_B3F", "where": {"facing": "west", "kind": "tiles", "tiles": [[15, 18]]}}, + "variant": "run", + "why": "back to B4F's stairs (11, 15) and up them to B3F's (15, 18)" + }, + { + "id": "b3f_back_to_candy_row", + "kind": "legs", + "variant": "taps", + "legs": [{"direction": "south", "tiles": 2}, {"direction": "west", "tiles": 5}, {"direction": "north", "tiles": 6}], + "why": "pokeguy's way back (video 57:39-57:42), a tap a tile: down to row 20, west to column 10, up it onto the arrow (10, 14), which slides a tile north to the stop (10, 13)" + }, { "id": "beside_b3f_rare_candy", "kind": "route", "target": {"certainty": "tile", "map": "RocketHideout_B3F", "where": {"facing": "north", "kind": "tiles", "tiles": [[12, 13]]}}, "variant": "run", - "why": "back up the stairs to B3F, below the Rare Candy (12, 12) beside the arrow tiles" + "why": "east along row 13 to the wall, below the Rare Candy (12, 12)" }, { "id": "b3f_rare_candy", From 6f3974e7589f1942bc01ce0ff1047e13941e00ef Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:11:48 -0800 Subject: [PATCH 09/23] fixup: no ms literal --- .../PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp index 18663df9f2..4dad679747 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.cpp @@ -47,7 +47,7 @@ bool counts_step_taps(const RouteStep& step){ Milliseconds step_tap_settle(const RouteStep& step, int tap){ using namespace MovementMechanics; if (tap != step.tiles || !step.spin_tiles){ - return 0ms; + return Milliseconds(0); } return SPIN_TILE_TIME * *step.spin_tiles + SPIN_STOP_SETTLE; } From 9cb0488b22da4bccbec117513e49cbf44f843a0c Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:13:20 -0800 Subject: [PATCH 10/23] FRLG AutoStory: LEGS take the taps variant --- .../PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp index efc9dfe566..3f2925510e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp @@ -236,8 +236,9 @@ bool known_game_step(const StoryStep& step){ bool known_variant(const StoryStep& step){ switch (step.kind){ case StoryStepKind::ROUTE: - case StoryStepKind::LEGS: return step.variant.empty() || step.variant == RUN_VARIANT || step.variant == BIKE_VARIANT; + case StoryStepKind::LEGS: + return step.variant.empty() || step.variant == RUN_VARIANT || step.variant == BIKE_VARIANT || step.variant == TAPS_VARIANT; case StoryStepKind::STEP: return step.variant.empty() || step.variant == TRAINER_LINE_VARIANT || step.variant == TRAINER_WAIT_VARIANT; case StoryStepKind::GAME: From 515782a0462d4fc11565f6908e8763338cae1a2a Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:15:05 -0800 Subject: [PATCH 11/23] FRLG AutoStory: three step taps per tile, the run check skips taps legs --- .../PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h | 5 +++-- .../Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h index 12a3e8694d..fb5bb67188 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h @@ -44,8 +44,9 @@ struct BikeTapCalls{ // (STEP_TAP_TRIES). int tries = 1; }; -// Taps per tile on foot: the first tap of a leg may only turn. -constexpr int STEP_TAP_TRIES = 2; +// Taps per tile on foot: the first tap of a leg may only turn, and the +// game may miss a turn tap (MovementMechanics::MAX_TURN_TAPS). +constexpr int STEP_TAP_TRIES = 3; // How far a sure start may be off before a blocked tap finds the player: // three runs of 00.30 stood 3 tiles off (console B, 2026-11-09). constexpr int BLOCKED_TAP_SLACK = 3; 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 d81c8fe481..e28aef7676 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -359,7 +359,8 @@ UnitTestResult test_runs_after_shoes(){ size_t runs = 0; for (const StoryCheckpoint& checkpoint : story_checkpoints()){ for (const StoryStep& step : checkpoint.steps){ - if (step.kind != StoryStepKind::ROUTE && step.kind != StoryStepKind::LEGS){ + // Taps walk a tile a tap at any speed. + if ((step.kind != StoryStepKind::ROUTE && step.kind != StoryStepKind::LEGS) || step.variant == TAPS_VARIANT){ continue; } const MoveSpeed expected = has_shoes ? MoveSpeed::RUN : MoveSpeed::WALK; From ada1353b85a531926c168ece302315ac6a5e093d Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:17:22 -0800 Subject: [PATCH 12/23] FRLG AutoStory 00.31: the golden trace with the taps legs; the B3F taps and short-hold sweep test --- .../PokemonFRLG_AutoStoryHideout_Tests.cpp | 78 ++++++++++++++---- .../ReplayData/frlg-story-sim-trace.json | 80 +++++++++++++++---- 2 files changed, 125 insertions(+), 33 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp index 5688c4d7e7..5a041601d7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include "Common/Cpp/TestRunners/UnitTest.h" @@ -212,24 +213,15 @@ UnitTestResult test_coded_spinners(){ return true; } -// 00.31's taps through B3F's arrow floor (frlg-00.31.plan.json's -// b3f_arrow_maze, pokeguy's way) on the sim, from the stairs (18, 2) -// to below the stairs to B4F (15, 19): as planned, and with each of the -// turns the taps make dropped in turn (a tap facing another way only -// turns the player, and a dropped one doesn't even turn them). -UnitTestResult test_b3f_maze_taps(){ - using Pokemon::StoryLeg; - const std::vector legs{ - {Direction::WEST, 6}, {Direction::SOUTH, 5}, {Direction::WEST, 7}, {Direction::SOUTH, 2}, {Direction::WEST, 1}, - {Direction::SOUTH, 2}, {Direction::WEST, 2}, {Direction::SOUTH, 3}, {Direction::WEST, 3}, {Direction::SOUTH, 2}, - {Direction::EAST, 2}, {Direction::WEST, 2}, {Direction::SOUTH, 5}, {Direction::EAST, 10}, {Direction::NORTH, 6}, - }; +// `legs` from `start` tapped out on the sim (RouteStep::tapped), facing +// `facing`: as planned, and with each of the turns the taps make dropped +// in turn (a tap facing another way only turns the player, and a +// dropped one doesn't even turn them). Empty if each run ends on `goal`. +std::string tap_legs_on_sim(const MapPosition& start, Direction facing, const std::vector& legs, const MapPosition& goal){ const std::vector& maps = story_maps(); - const MapPosition start{"RocketHideout_B3F", {18, 2}}; - const MapPosition goal{"RocketHideout_B3F", {15, 19}}; std::optional> route = fixed_route(maps, start, legs); if (!route || !(route->back().end == goal)){ - return std::string("The legs don't end below B3F's stairs to B4F."); + return "The legs from " + to_string(start) + " don't end on " + to_string(goal) + "."; } for (RouteStep& step : *route){ step.tapped = true; @@ -239,7 +231,7 @@ UnitTestResult test_b3f_maze_taps(){ if (dropped > 0){ script.dropped_turn_taps = {dropped}; } - OverworldSim sim(maps, start, Direction::EAST, script); + OverworldSim sim(maps, start, facing, script); OverworldSimWalker walker(sim); const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = start, .label = "Sim"}; const std::string failure = walker.run(*route, planning); @@ -247,6 +239,60 @@ UnitTestResult test_b3f_maze_taps(){ return std::format("With turn tap {} dropped, walked to {}, failure \"{}\".", dropped, to_string(sim.state().position), failure); } } + return ""; +} + +// The planned route from `start` to `goal` on the sim, with each of its +// holds 1 and 2 tiles short in turn. Empty if each run ends on `goal`. +std::string short_holds_on_sim(const MapPosition& start, Direction facing, const MapPosition& goal){ + const std::vector& maps = story_maps(); + const auto route = plan_overworld_route(maps, start, RouteGoal{goal, std::nullopt}, default_route_costs(), facing); + if (!route){ + return "No route from " + to_string(start) + "."; + } + for (int hold = 1; hold <= (int)route->size(); hold++){ + for (const int short_by : {1, 2}){ + SimScript script; + script.short_holds = {{hold, short_by}}; + OverworldSim sim(maps, start, facing, script); + OverworldSimWalker walker(sim); + const RoutePlanning planning{.maps = &maps, .costs = default_route_costs(), .start = start, .label = "Sim"}; + const std::string failure = walker.run(*route, planning); + if (!failure.empty() || !(sim.state().position == goal)){ + return std::format("Hold {} {} short from {}: walked to {}, failure \"{}\".", hold, short_by, to_string(start), to_string(sim.state().position), failure); + } + } + } + return ""; +} + +// 00.31's taps through B3F's arrow floor (frlg-00.31.plan.json's +// b3f_arrow_maze and b3f_back_to_candy_row, pokeguy's way): down from +// the stairs (18, 2) to below the stairs to B4F (15, 19), and back from +// them (15, 18) to the stop (10, 13). The routes planned after them, +// onto the stairs to B4F and east to below the Rare Candy, have no +// arrow on the way: a short hold there is found again. +UnitTestResult test_b3f_maze_taps(){ + using Pokemon::StoryLeg; + const MapPosition below_stairs{"RocketHideout_B3F", {15, 19}}; + const MapPosition candy_stop{"RocketHideout_B3F", {10, 13}}; + const std::vector failures{ + tap_legs_on_sim({"RocketHideout_B3F", {18, 2}}, Direction::EAST, { + {Direction::WEST, 6}, {Direction::SOUTH, 5}, {Direction::WEST, 7}, {Direction::SOUTH, 2}, {Direction::WEST, 1}, + {Direction::SOUTH, 2}, {Direction::WEST, 2}, {Direction::SOUTH, 3}, {Direction::WEST, 3}, {Direction::SOUTH, 2}, + {Direction::EAST, 2}, {Direction::WEST, 2}, {Direction::SOUTH, 5}, {Direction::EAST, 10}, {Direction::NORTH, 6}, + }, below_stairs), + tap_legs_on_sim({"RocketHideout_B3F", {15, 18}}, Direction::WEST, { + {Direction::SOUTH, 2}, {Direction::WEST, 5}, {Direction::NORTH, 6}, + }, candy_stop), + short_holds_on_sim(below_stairs, Direction::NORTH, {"RocketHideout_B4F", map_point(story_maps(), "RocketHideout_B4F", "warp_0")}), + short_holds_on_sim(candy_stop, Direction::NORTH, {"RocketHideout_B3F", {12, 13}}), + }; + for (const std::string& failure : failures){ + if (!failure.empty()){ + return failure; + } + } return true; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json index db636bfd22..c98f337e39 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json @@ -1277,7 +1277,7 @@ "[Checkpoint] 00.30: done, 24 run, 0 skipped", "[Checkpoint] 00.30: passed on attempt 1 (one-shot)", "begin 00.31", - "[Checkpoint] 00.31: start, 16 events", + "[Checkpoint] 00.31: start, 20 events", "[Event] 00.31/1 from_save: start", "[Event] 00.31/1 from_save: done", "[Event] 00.31/2 celadon_below_game_corner: start", @@ -1304,33 +1304,79 @@ "[Event] 00.31/9 b2f_to_stairs: start", "00.31/b2f_to_stairs: ok at RocketHideout_B2F (21, 2) facing north (tile)", "[Event] 00.31/9 b2f_to_stairs: done", - "[Event] 00.31/10 hideout_b4f_west: start", + "[Event] 00.31/10 b3f_off_stairs: start", + "00.31/b3f_off_stairs: ok at RocketHideout_B3F (18, 2) facing east (tile)", + "[Event] 00.31/10 b3f_off_stairs: done", + "[Event] 00.31/11 b3f_arrow_maze: start", + "00.31/b3f_arrow_maze: ok at RocketHideout_B3F (15, 19) facing north (tile)", + "[Event] 00.31/11 b3f_arrow_maze: done", + "[Event] 00.31/12 hideout_b4f_west: start", "00.31/hideout_b4f_west: ok at RocketHideout_B4F (5, 3) facing west (tile)", - "[Event] 00.31/10 hideout_b4f_west: done", - "[Event] 00.31/11 key_grunt_line: start", + "[Event] 00.31/12 hideout_b4f_west: done", + "[Event] 00.31/13 key_grunt_line: start", "00.31/key_grunt_line: ok at RocketHideout_B4F (4, 3) facing west (tile)", - "[Event] 00.31/11 key_grunt_line: done", - "[Event] 00.31/12 lift_key_grunt: start", + "[Event] 00.31/13 key_grunt_line: done", + "[Event] 00.31/14 lift_key_grunt: start", "00.31/lift_key_grunt: ok at -", - "[Event] 00.31/12 lift_key_grunt: done", - "[Event] 00.31/13 below_lift_key: start", + "[Event] 00.31/14 lift_key_grunt: done", + "[Event] 00.31/15 below_lift_key: start", "00.31/below_lift_key: ok at RocketHideout_B4F (3, 3) facing north (tile)", - "[Event] 00.31/13 below_lift_key: done", - "[Event] 00.31/14 lift_key: start", + "[Event] 00.31/15 below_lift_key: done", + "[Event] 00.31/16 lift_key: start", "00.31/lift_key: ok at -", - "[Event] 00.31/14 lift_key: done", - "[Event] 00.31/15 beside_b3f_rare_candy: start", + "[Event] 00.31/16 lift_key: done", + "[Event] 00.31/17 b3f_from_b4f: start", + "00.31/b3f_from_b4f: ok at RocketHideout_B3F (15, 18) facing west (tile)", + "[Event] 00.31/17 b3f_from_b4f: done", + "[Event] 00.31/18 b3f_back_to_candy_row: start", + "00.31/b3f_back_to_candy_row: ok at RocketHideout_B3F (10, 13) facing north (tile)", + "[Event] 00.31/18 b3f_back_to_candy_row: done", + "[Event] 00.31/19 beside_b3f_rare_candy: start", "00.31/beside_b3f_rare_candy: ok at RocketHideout_B3F (12, 13) facing north (tile)", - "[Event] 00.31/15 beside_b3f_rare_candy: done", - "[Event] 00.31/16 b3f_rare_candy: start", + "[Event] 00.31/19 beside_b3f_rare_candy: done", + "[Event] 00.31/20 b3f_rare_candy: start", "00.31/b3f_rare_candy: ok at -", - "[Event] 00.31/16 b3f_rare_candy: done", + "[Event] 00.31/20 b3f_rare_candy: done", "save at RocketHideout_B3F (12, 13) facing north (tile)", - "[Checkpoint] 00.31: done, 16 run, 0 skipped", + "[Checkpoint] 00.31: done, 20 run, 0 skipped", "[Checkpoint] 00.31: passed on attempt 1 (one-shot)", "[Segment] 00: 35 of 35 checkpoints one-shot", "[Segment] 00: done, 35 checkpoints", "completed", - "00.01: 2 stubbed: intro, options\n00.02: 0 stubbed\n00.03: 1 stubbed: to_the_lab\n00.04: 5 stubbed: squirtle_ball, choose_squirtle, no_nickname, rival_takes_bulbasaur, rival_battle\n00.05: 1 stubbed: parcel_from_clerk\n00.06: 2 stubbed: give_parcel, pokedex_scene\n00.07: 2 stubbed: heal_viridian, old_man_tutorial\n00.08: 1 stubbed: heal_pewter\n00.09: 3 stubbed: camper_liam, challenge_brock, brock\n00.10: 1 stubbed: shoes_from_aide\n00.11: 4 stubbed: heal_pewter, bug_catcher_colton, bug_catcher_greg, bug_catcher_james\n00.12: 1 stubbed: heal_route4\n00.12c: 1 stubbed: magikarp_to_box\n00.13: 6 stubbed: heal_route4, moon_stone_ball, found_moon_stone, rocket_grunt, super_nerd_miguel, helix_fossil\n00.14: 2 stubbed: teach_mega_kick, heal_cerulean\n00.14b: 3 stubbed: buy_potions, grind_to_lv23, heal_cerulean\n00.14c: 4 stubbed: challenge_misty, misty, heal_cerulean, teach_water_pulse\n00.15: 4 stubbed: teach_water_pulse, buy_potions, grind_for_rival, heal_cerulean\n00.15b: 2 stubbed: teach_water_pulse, rival_cerulean\n00.16: 7 stubbed: heal_cerulean, bug_catcher_cale, lass_ali, youngster_timmy, lass_reli, camper_ethan, rocket_grunt\n00.17: 4 stubbed: hiker_franklin, picnicker_kelsey, hiker_nob, lass_haley\n00.18: 7 stubbed: bill_clefairy, help_bill, bill_into_teleporter, cell_separator, bill_comes_out, thank_bill, ss_ticket\n00.19: 1 stubbed: heal_cerulean\n00.20: 3 stubbed: buy_poke_balls, catch_oddish, heal_cerulean\n00.21: 3 stubbed: rocket_grunt, camper_jeff, heal_vermilion\n00.22: 6 stubbed: show_ss_ticket, rival_ss_anne, captain, hm01_cut, ss_anne_sails, heal_vermilion\n00.23: 9 stubbed: teach_cut, teach_dig, cut_gym_tree, sailor_dwayne, engineer_baily, gentleman_tucker, trash_cans, cut_tree_out, heal_vermilion\n00.24: 4 stubbed: surge_winnable, grind_for_surge, heal_vermilion, cut_gym_tree\n00.25: 4 stubbed: challenge_lt_surge, lt_surge, cut_tree_out, heal_vermilion\n00.26: 8 stubbed: chairman, hear_story, bike_voucher, cut_cerulean_tree, talk_bike_clerk, bicycle, buy_repels, heal_cerulean\n00.27: 6 stubbed: cut_cerulean_tree, cut_route9_tree, picnicker_alicia, hiker_jeremy, bug_catcher_conner, heal_route10\n00.28: 9 stubbed: cut_route10_tree, pokemaniac_ashton, pokemaniac_winston, picnicker_martha, hiker_allen, hiker_lenny, picnicker_sofia, hiker_dudley, picnicker_dana\n00.29: 1 stubbed: heal_lavender\n00.30: 7 stubbed: register_bike, buy_ropes_and_super_repels, ride_bike, gamer_rich, catch_pidgey, celadon_nurse, heal_celadon\n00.31: 6 stubbed: talk_poster_guard, rocket_grunt, poster_switch, lift_key_grunt, lift_key, b3f_rare_candy\n" + "00.01: 2 stubbed: intro, options", + "00.02: 0 stubbed", + "00.03: 1 stubbed: to_the_lab", + "00.04: 5 stubbed: squirtle_ball, choose_squirtle, no_nickname, rival_takes_bulbasaur, rival_battle", + "00.05: 1 stubbed: parcel_from_clerk", + "00.06: 2 stubbed: give_parcel, pokedex_scene", + "00.07: 2 stubbed: heal_viridian, old_man_tutorial", + "00.08: 1 stubbed: heal_pewter", + "00.09: 3 stubbed: camper_liam, challenge_brock, brock", + "00.10: 1 stubbed: shoes_from_aide", + "00.11: 4 stubbed: heal_pewter, bug_catcher_colton, bug_catcher_greg, bug_catcher_james", + "00.12: 1 stubbed: heal_route4", + "00.12c: 1 stubbed: magikarp_to_box", + "00.13: 6 stubbed: heal_route4, moon_stone_ball, found_moon_stone, rocket_grunt, super_nerd_miguel, helix_fossil", + "00.14: 2 stubbed: teach_mega_kick, heal_cerulean", + "00.14b: 3 stubbed: buy_potions, grind_to_lv23, heal_cerulean", + "00.14c: 4 stubbed: challenge_misty, misty, heal_cerulean, teach_water_pulse", + "00.15: 4 stubbed: teach_water_pulse, buy_potions, grind_for_rival, heal_cerulean", + "00.15b: 2 stubbed: teach_water_pulse, rival_cerulean", + "00.16: 7 stubbed: heal_cerulean, bug_catcher_cale, lass_ali, youngster_timmy, lass_reli, camper_ethan, rocket_grunt", + "00.17: 4 stubbed: hiker_franklin, picnicker_kelsey, hiker_nob, lass_haley", + "00.18: 7 stubbed: bill_clefairy, help_bill, bill_into_teleporter, cell_separator, bill_comes_out, thank_bill, ss_ticket", + "00.19: 1 stubbed: heal_cerulean", + "00.20: 3 stubbed: buy_poke_balls, catch_oddish, heal_cerulean", + "00.21: 3 stubbed: rocket_grunt, camper_jeff, heal_vermilion", + "00.22: 6 stubbed: show_ss_ticket, rival_ss_anne, captain, hm01_cut, ss_anne_sails, heal_vermilion", + "00.23: 9 stubbed: teach_cut, teach_dig, cut_gym_tree, sailor_dwayne, engineer_baily, gentleman_tucker, trash_cans, cut_tree_out, heal_vermilion", + "00.24: 4 stubbed: surge_winnable, grind_for_surge, heal_vermilion, cut_gym_tree", + "00.25: 4 stubbed: challenge_lt_surge, lt_surge, cut_tree_out, heal_vermilion", + "00.26: 8 stubbed: chairman, hear_story, bike_voucher, cut_cerulean_tree, talk_bike_clerk, bicycle, buy_repels, heal_cerulean", + "00.27: 6 stubbed: cut_cerulean_tree, cut_route9_tree, picnicker_alicia, hiker_jeremy, bug_catcher_conner, heal_route10", + "00.28: 9 stubbed: cut_route10_tree, pokemaniac_ashton, pokemaniac_winston, picnicker_martha, hiker_allen, hiker_lenny, picnicker_sofia, hiker_dudley, picnicker_dana", + "00.29: 1 stubbed: heal_lavender", + "00.30: 7 stubbed: register_bike, buy_ropes_and_super_repels, ride_bike, gamer_rich, catch_pidgey, celadon_nurse, heal_celadon", + "00.31: 6 stubbed: talk_poster_guard, rocket_grunt, poster_switch, lift_key_grunt, lift_key, b3f_rare_candy" ] } From fcde135d2940ed42e684d3dcfacf010e48f6732c Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:18:47 -0800 Subject: [PATCH 13/23] FRLG AutoStory 00.31: golden trace from the old one, only 00.31 changed; CRLF include --- .../PokemonFRLG_AutoStoryHideout_Tests.cpp | 2 +- .../ReplayData/frlg-story-sim-trace.json | 36 +------------------ 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp index 5a041601d7..5c046ef92e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include "Common/Cpp/TestRunners/UnitTest.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json index c98f337e39..e3cc1c3a99 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json @@ -1343,40 +1343,6 @@ "[Segment] 00: 35 of 35 checkpoints one-shot", "[Segment] 00: done, 35 checkpoints", "completed", - "00.01: 2 stubbed: intro, options", - "00.02: 0 stubbed", - "00.03: 1 stubbed: to_the_lab", - "00.04: 5 stubbed: squirtle_ball, choose_squirtle, no_nickname, rival_takes_bulbasaur, rival_battle", - "00.05: 1 stubbed: parcel_from_clerk", - "00.06: 2 stubbed: give_parcel, pokedex_scene", - "00.07: 2 stubbed: heal_viridian, old_man_tutorial", - "00.08: 1 stubbed: heal_pewter", - "00.09: 3 stubbed: camper_liam, challenge_brock, brock", - "00.10: 1 stubbed: shoes_from_aide", - "00.11: 4 stubbed: heal_pewter, bug_catcher_colton, bug_catcher_greg, bug_catcher_james", - "00.12: 1 stubbed: heal_route4", - "00.12c: 1 stubbed: magikarp_to_box", - "00.13: 6 stubbed: heal_route4, moon_stone_ball, found_moon_stone, rocket_grunt, super_nerd_miguel, helix_fossil", - "00.14: 2 stubbed: teach_mega_kick, heal_cerulean", - "00.14b: 3 stubbed: buy_potions, grind_to_lv23, heal_cerulean", - "00.14c: 4 stubbed: challenge_misty, misty, heal_cerulean, teach_water_pulse", - "00.15: 4 stubbed: teach_water_pulse, buy_potions, grind_for_rival, heal_cerulean", - "00.15b: 2 stubbed: teach_water_pulse, rival_cerulean", - "00.16: 7 stubbed: heal_cerulean, bug_catcher_cale, lass_ali, youngster_timmy, lass_reli, camper_ethan, rocket_grunt", - "00.17: 4 stubbed: hiker_franklin, picnicker_kelsey, hiker_nob, lass_haley", - "00.18: 7 stubbed: bill_clefairy, help_bill, bill_into_teleporter, cell_separator, bill_comes_out, thank_bill, ss_ticket", - "00.19: 1 stubbed: heal_cerulean", - "00.20: 3 stubbed: buy_poke_balls, catch_oddish, heal_cerulean", - "00.21: 3 stubbed: rocket_grunt, camper_jeff, heal_vermilion", - "00.22: 6 stubbed: show_ss_ticket, rival_ss_anne, captain, hm01_cut, ss_anne_sails, heal_vermilion", - "00.23: 9 stubbed: teach_cut, teach_dig, cut_gym_tree, sailor_dwayne, engineer_baily, gentleman_tucker, trash_cans, cut_tree_out, heal_vermilion", - "00.24: 4 stubbed: surge_winnable, grind_for_surge, heal_vermilion, cut_gym_tree", - "00.25: 4 stubbed: challenge_lt_surge, lt_surge, cut_tree_out, heal_vermilion", - "00.26: 8 stubbed: chairman, hear_story, bike_voucher, cut_cerulean_tree, talk_bike_clerk, bicycle, buy_repels, heal_cerulean", - "00.27: 6 stubbed: cut_cerulean_tree, cut_route9_tree, picnicker_alicia, hiker_jeremy, bug_catcher_conner, heal_route10", - "00.28: 9 stubbed: cut_route10_tree, pokemaniac_ashton, pokemaniac_winston, picnicker_martha, hiker_allen, hiker_lenny, picnicker_sofia, hiker_dudley, picnicker_dana", - "00.29: 1 stubbed: heal_lavender", - "00.30: 7 stubbed: register_bike, buy_ropes_and_super_repels, ride_bike, gamer_rich, catch_pidgey, celadon_nurse, heal_celadon", - "00.31: 6 stubbed: talk_poster_guard, rocket_grunt, poster_switch, lift_key_grunt, lift_key, b3f_rare_candy" + "00.01: 2 stubbed: intro, options\n00.02: 0 stubbed\n00.03: 1 stubbed: to_the_lab\n00.04: 5 stubbed: squirtle_ball, choose_squirtle, no_nickname, rival_takes_bulbasaur, rival_battle\n00.05: 1 stubbed: parcel_from_clerk\n00.06: 2 stubbed: give_parcel, pokedex_scene\n00.07: 2 stubbed: heal_viridian, old_man_tutorial\n00.08: 1 stubbed: heal_pewter\n00.09: 3 stubbed: camper_liam, challenge_brock, brock\n00.10: 1 stubbed: shoes_from_aide\n00.11: 4 stubbed: heal_pewter, bug_catcher_colton, bug_catcher_greg, bug_catcher_james\n00.12: 1 stubbed: heal_route4\n00.12c: 1 stubbed: magikarp_to_box\n00.13: 6 stubbed: heal_route4, moon_stone_ball, found_moon_stone, rocket_grunt, super_nerd_miguel, helix_fossil\n00.14: 2 stubbed: teach_mega_kick, heal_cerulean\n00.14b: 3 stubbed: buy_potions, grind_to_lv23, heal_cerulean\n00.14c: 4 stubbed: challenge_misty, misty, heal_cerulean, teach_water_pulse\n00.15: 4 stubbed: teach_water_pulse, buy_potions, grind_for_rival, heal_cerulean\n00.15b: 2 stubbed: teach_water_pulse, rival_cerulean\n00.16: 7 stubbed: heal_cerulean, bug_catcher_cale, lass_ali, youngster_timmy, lass_reli, camper_ethan, rocket_grunt\n00.17: 4 stubbed: hiker_franklin, picnicker_kelsey, hiker_nob, lass_haley\n00.18: 7 stubbed: bill_clefairy, help_bill, bill_into_teleporter, cell_separator, bill_comes_out, thank_bill, ss_ticket\n00.19: 1 stubbed: heal_cerulean\n00.20: 3 stubbed: buy_poke_balls, catch_oddish, heal_cerulean\n00.21: 3 stubbed: rocket_grunt, camper_jeff, heal_vermilion\n00.22: 6 stubbed: show_ss_ticket, rival_ss_anne, captain, hm01_cut, ss_anne_sails, heal_vermilion\n00.23: 9 stubbed: teach_cut, teach_dig, cut_gym_tree, sailor_dwayne, engineer_baily, gentleman_tucker, trash_cans, cut_tree_out, heal_vermilion\n00.24: 4 stubbed: surge_winnable, grind_for_surge, heal_vermilion, cut_gym_tree\n00.25: 4 stubbed: challenge_lt_surge, lt_surge, cut_tree_out, heal_vermilion\n00.26: 8 stubbed: chairman, hear_story, bike_voucher, cut_cerulean_tree, talk_bike_clerk, bicycle, buy_repels, heal_cerulean\n00.27: 6 stubbed: cut_cerulean_tree, cut_route9_tree, picnicker_alicia, hiker_jeremy, bug_catcher_conner, heal_route10\n00.28: 9 stubbed: cut_route10_tree, pokemaniac_ashton, pokemaniac_winston, picnicker_martha, hiker_allen, hiker_lenny, picnicker_sofia, hiker_dudley, picnicker_dana\n00.29: 1 stubbed: heal_lavender\n00.30: 7 stubbed: register_bike, buy_ropes_and_super_repels, ride_bike, gamer_rich, catch_pidgey, celadon_nurse, heal_celadon\n00.31: 6 stubbed: talk_poster_guard, rocket_grunt, poster_switch, lift_key_grunt, lift_key, b3f_rare_candy\n" ] } From ab60d971008cf39cadd15bda8c130b478e331268 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:20:32 -0800 Subject: [PATCH 14/23] FRLG AutoStory: fixed_route in its own file, AutoStoryLegs.cpp, keeping AutoStoryEvents.cpp under 1000 lines --- .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 58 -------------- .../AutoStory/PokemonFRLG_AutoStoryLegs.cpp | 76 +++++++++++++++++++ SerialPrograms/cmake/SourceFiles.cmake | 1 + 3 files changed, 77 insertions(+), 58 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index e469c828b9..344aaaeccb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -16,7 +16,6 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" -#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" #include "PokemonFRLG_AutoStoryAbilities.h" #include "PokemonFRLG_AutoStoryBattleData.h" @@ -445,63 +444,6 @@ void add_start_pose_check( add_start_check(checkpoint, start, std::move(reader), std::move(log)); } -namespace{ - -// A leg's step onto a spinner: only its last (`last`), which slides -// `player` on to where the slide ends, facing its way (spin_slide()). -// False mid-leg, or for a slide that loops or leaves through a warp. -bool land_on_spinner(const MapData& map, PlayerState& player, bool last, RouteStep& step){ - const std::optional slide = spin_slide(map, player); - if (!last || !slide){ - return false; - } - player = slide->end; - step.spin_tiles = slide->tiles; - step.facing_after = slide->facing; - return true; -} - -} - -std::optional> fixed_route( - const std::vector& maps, const MapPosition& start, const std::vector& legs -){ - const MapData* map = nullptr; - for (const MapData& candidate : maps){ - if (candidate.name == start.map){ - map = &candidate; - } - } - if (map == nullptr || !in_bounds(*map, start.point)){ - return std::nullopt; - } - std::vector route; - PlayerState player{start.point, elevation_at(*map, start.point), false}; - for (const StoryLeg& leg : legs){ - RouteStep step; - step.direction = leg.direction; - step.tiles = leg.tiles; - step.facing_after = leg.direction; - step.walk_only = !map->allow_running; - for (int c = 0; c < leg.tiles; c++){ - const StepKind kind = classify_step(*map, player, leg.direction); - const TilePos next = player.position.next(leg.direction); - if (kind != StepKind::WALK || !in_bounds(*map, next) || warps_on_step(*map, next)){ - return std::nullopt; - } - step.wild |= is_tall_grass(*map, next); - player = after_step(*map, player, leg.direction, kind); - if (spin_direction(*map, player.position) && !land_on_spinner(*map, player, c + 1 == leg.tiles, step)){ - return std::nullopt; - } - } - step.to_wall = !step.spin_tiles && classify_step(*map, player, leg.direction) == StepKind::BLOCKED; - step.end = MapPosition{map->name, player.position}; - route.push_back(step); - } - return route; -} - Pokemon::Pose paced_pose(const Pokemon::Pose& patch, const StoryStep& step){ std::optional pace; if (const std::optional grind = parse_grind_step(step)){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp new file mode 100644 index 0000000000..8423c21844 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp @@ -0,0 +1,76 @@ +/* AutoStory Legs + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h" +#include "PokemonFRLG_AutoStoryEvents.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// A leg's step onto a spinner: only its last (`last`), which slides +// `player` on to where the slide ends, facing its way (spin_slide()). +// False mid-leg, or for a slide that loops or leaves through a warp. +bool land_on_spinner(const MapData& map, PlayerState& player, bool last, RouteStep& step){ + const std::optional slide = spin_slide(map, player); + if (!last || !slide){ + return false; + } + player = slide->end; + step.spin_tiles = slide->tiles; + step.facing_after = slide->facing; + return true; +} + +} // namespace + +std::optional> fixed_route( + const std::vector& maps, const MapPosition& start, const std::vector& legs +){ + const MapData* map = nullptr; + for (const MapData& candidate : maps){ + if (candidate.name == start.map){ + map = &candidate; + } + } + if (map == nullptr || !in_bounds(*map, start.point)){ + return std::nullopt; + } + std::vector route; + PlayerState player{start.point, elevation_at(*map, start.point), false}; + for (const StoryLeg& leg : legs){ + RouteStep step; + step.direction = leg.direction; + step.tiles = leg.tiles; + step.facing_after = leg.direction; + step.walk_only = !map->allow_running; + for (int c = 0; c < leg.tiles; c++){ + const StepKind kind = classify_step(*map, player, leg.direction); + const TilePos next = player.position.next(leg.direction); + if (kind != StepKind::WALK || !in_bounds(*map, next) || warps_on_step(*map, next)){ + return std::nullopt; + } + step.wild |= is_tall_grass(*map, next); + player = after_step(*map, player, leg.direction, kind); + if (spin_direction(*map, player.position) && !land_on_spinner(*map, player, c + 1 == leg.tiles, step)){ + return std::nullopt; + } + } + step.to_wall = !step.spin_tiles && classify_step(*map, player, leg.direction) == StepKind::BLOCKED; + step.end = MapPosition{map->name, player.position}; + route.push_back(step); + } + return route; +} + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 25b636266e..3d71d4e3a3 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1944,6 +1944,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryDamage.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldSteps.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFoeTracker.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFoeTracker.h From 421a651ca41630b425be8382506ab1829ee57cf3 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:22:38 -0800 Subject: [PATCH 15/23] FRLG AutoStory: TAPS_VARIANT and fixed_route() in AutoStoryLegs.h, off AutoStoryEvents.h's symbol count --- .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStoryEvents.h | 12 ------ .../PokemonFRLG_AutoStoryHideout_Tests.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStoryLegs.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStoryLegs.h | 39 +++++++++++++++++++ .../AutoStory/PokemonFRLG_AutoStoryRowSim.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 + SerialPrograms/cmake/SourceFiles.cmake | 1 + 8 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 344aaaeccb..1563e3e99c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -23,6 +23,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryHideout.h" +#include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryScreenEvents.h" #include "PokemonFRLG_AutoStorySummary.h" #include "PokemonFRLG_AutoStoryTable.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h index 45a707d4d5..74631b27cf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -64,11 +64,6 @@ struct StoryPose{ // has the Running Shoes (00.10 on). inline const std::string RUN_VARIANT = "run"; -// The variant of LEGS walked on foot a tap at a time, each tap checked to -// have moved the player a tile (RouteStep::tapped): the Rocket Hideout's -// arrow floors, where a hold a tile off slides the player elsewhere. -inline const std::string TAPS_VARIANT = "taps"; - // The variant of a STEP into a trainer's line: a tile at a time, at most // TRAINER_LINE_TILES, until the trainer sees the player // (step_until_seen()). The battle after it starts on the trainer's row @@ -217,13 +212,6 @@ void add_start_pose_check( Pokemon::Checkpoint& checkpoint, const std::optional& start, SavePoseReader read, StoryLog log ); -// `legs` from `start` as route steps for the walker, each checked against -// the map: nothing if a step is blocked or leaves the map. A leg ends "to -// wall" if the next step its way is blocked. -std::optional> fixed_route( - const std::vector& maps, const MapPosition& start, const std::vector& legs -); - // Where a GRIND or capture `step` that paces (pace = ...) leaves the // player who started it on `patch`: the patch's tile or the one its pace // leads to, as the last battle came, facing unknown. `patch` for any diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp index 5c046ef92e..eb424124d6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp @@ -16,6 +16,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryHideout.h" #include "PokemonFRLG_AutoStoryHideoutLift.h" +#include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryTableSteps.h" #include "PokemonFRLG_AutoStoryFieldSteps.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp index 8423c21844..420268e05a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp @@ -6,6 +6,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h" +#include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryEvents.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h new file mode 100644 index 0000000000..d19c8fd42f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h @@ -0,0 +1,39 @@ +/* AutoStory Legs + * + * From: https://github.com/PokemonAutomation/ + * + * LEGS steps: a fixed list of legs, as the walker's route steps. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryLegs_H +#define PokemonAutomation_PokemonFRLG_AutoStoryLegs_H + +#include +#include +#include +#include "Pokemon/AutoStory/Types/Pokemon_StoryStep.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +// The variant of LEGS walked on foot a tap at a time, each tap checked to +// have moved the player a tile (RouteStep::tapped): the Rocket Hideout's +// arrow floors, where a hold a tile off slides the player elsewhere. +inline const std::string TAPS_VARIANT = "taps"; + +// `legs` from `start` as route steps for the walker, each checked against +// the map: nothing if a step is blocked or leaves the map. A leg ends "to +// wall" if the next step its way is blocked. +std::optional> fixed_route( + const std::vector& maps, const MapPosition& start, const std::vector& legs +); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp index 91ce25068e..a3fbdc9155 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp @@ -13,6 +13,7 @@ #include #include "Common/Cpp/Exceptions.h" #include "Pokemon/AutoStory/Pokemon_TilePose.h" +#include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryBattleDecisions.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" 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 e28aef7676..bd8b7080f0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -22,6 +22,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" +#include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryCapture.h" #include "PokemonFRLG_AutoStoryGrind.h" diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 3d71d4e3a3..38199837a9 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1945,6 +1945,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldSteps.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFoeTracker.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFoeTracker.h From 5ba4c269350cffb2dc0c940ec8d18e0b902bbd13 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:23:36 -0800 Subject: [PATCH 16/23] FRLG AutoStory: JsonParser includes AutoStoryLegs.h; AutoStory_Tests under 1000 lines --- .../PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp | 1 + .../Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp index 3f2925510e..a7e08d42ca 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp @@ -22,6 +22,7 @@ #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRooms.h" +#include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h" #include "LegacyJsonFormat.h" 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 bd8b7080f0..48a3e724dc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -360,7 +360,6 @@ UnitTestResult test_runs_after_shoes(){ size_t runs = 0; for (const StoryCheckpoint& checkpoint : story_checkpoints()){ for (const StoryStep& step : checkpoint.steps){ - // Taps walk a tile a tap at any speed. if ((step.kind != StoryStepKind::ROUTE && step.kind != StoryStepKind::LEGS) || step.variant == TAPS_VARIANT){ continue; } From 62e1cedfbfdc4bb7e09c0a978555f4cc5dfd8e30 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:24:20 -0800 Subject: [PATCH 17/23] FRLG AutoStory: close JsonParser's AutoStoryLegs.h include --- .../PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp index a7e08d42ca..f0a4649081 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/JsonParser.cpp @@ -22,7 +22,7 @@ #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRooms.h" -#include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h +#include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLegs.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h" #include "VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h" #include "LegacyJsonFormat.h" From bd86cf734726917f2d1060bed7e8886c5730f787 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 01:25:17 -0800 Subject: [PATCH 18/23] FRLG AutoStory: Lavender tests include AutoStoryLegs.h --- .../Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp index 8c3bb9795f..b90d21a91b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryLavender_Tests.cpp @@ -29,6 +29,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryFaultSweep_Tests.h" #include "PokemonFRLG_AutoStoryResources.h" From 55ff73bf56be3a9e4bc1ebed141cf040e4ff55e8 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 02:49:56 -0800 Subject: [PATCH 19/23] FRLG AutoStory 00.31: a talk fails unless A opens a message Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryActions.cpp | 15 +++++++++++++++ .../AutoStory/PokemonFRLG_AutoStoryActions.h | 2 ++ .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 5 ++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp index 94a86456c2..391a1817ed 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp @@ -555,6 +555,21 @@ void answer_yes_no(ConsoleHandle& console, ProControllerContext& context, bool y ); } +// A talk to a person or an item ball opens a message; an A that opens +// none faced nothing (00.31 b3f_rare_candy, console B, 2026-11-10: one A, +// "done", on the wrong floor). The message is left open for the next step. +bool talk_opens_message(ConsoleHandle& console, ProControllerContext& context){ + WhiteDialogWatcher opened(COLOR_RED); + const int shown = run_until( + console, context, + [](ProControllerContext& context){ + pbf_press_button(context, BUTTON_A, 160ms, 2000ms); + }, + {opened} + ); + return shown >= 0; +} + std::optional talk_and_count_pages(ConsoleHandle& console, ProControllerContext& context){ WhiteDialogWatcher opened(COLOR_RED); const int shown = run_until( diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h index 07e37e35c9..bdf5be0d80 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h @@ -117,6 +117,8 @@ void answer_yes_no(ConsoleHandle& console, ProControllerContext& context, bool y // has, one or two, then on to the overworld. Language-free: one A after // the first page has printed either closes the message or shows its // second page. Nothing if no message showed. +// Presses A; true once a message box is up. +bool talk_opens_message(ConsoleHandle& console, ProControllerContext& context); std::optional talk_and_count_pages(ConsoleHandle& console, ProControllerContext& context); // From the overworld: one step `direction`, onto a trigger or into a door. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 1563e3e99c..52de5db764 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -17,6 +17,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" +#include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryAbilities.h" #include "PokemonFRLG_AutoStoryBattleData.h" #include "PokemonFRLG_AutoStoryCapture.h" @@ -719,7 +720,9 @@ ConsoleAction console_action_of(StoryActionId id){ return take_step; case StoryActionId::TALK: return [](StoryEnv& env, RunState&, const StoryStep&){ - pbf_press_button(env.context, BUTTON_A, 160ms, 800ms); + if (!talk_opens_message(env.console, env.context)){ + return Pokemon::outcome_failed("no_message", "talk: A opened no message; nothing to talk to or pick up here."); + } return Pokemon::outcome_ok(); }; case StoryActionId::ANSWER: From 3f53ca1e9b986eb567babbd23699128d11051dc3 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 02:50:27 -0800 Subject: [PATCH 20/23] FRLG AutoStory 00.31: keep the talk check beside its step Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryActions.cpp | 15 --------------- .../AutoStory/PokemonFRLG_AutoStoryActions.h | 2 -- .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 19 ++++++++++++++++++- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp index 391a1817ed..94a86456c2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp @@ -555,21 +555,6 @@ void answer_yes_no(ConsoleHandle& console, ProControllerContext& context, bool y ); } -// A talk to a person or an item ball opens a message; an A that opens -// none faced nothing (00.31 b3f_rare_candy, console B, 2026-11-10: one A, -// "done", on the wrong floor). The message is left open for the next step. -bool talk_opens_message(ConsoleHandle& console, ProControllerContext& context){ - WhiteDialogWatcher opened(COLOR_RED); - const int shown = run_until( - console, context, - [](ProControllerContext& context){ - pbf_press_button(context, BUTTON_A, 160ms, 2000ms); - }, - {opened} - ); - return shown >= 0; -} - std::optional talk_and_count_pages(ConsoleHandle& console, ProControllerContext& context){ WhiteDialogWatcher opened(COLOR_RED); const int shown = run_until( diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h index bdf5be0d80..07e37e35c9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h @@ -117,8 +117,6 @@ void answer_yes_no(ConsoleHandle& console, ProControllerContext& context, bool y // has, one or two, then on to the overworld. Language-free: one A after // the first page has printed either closes the message or shows its // second page. Nothing if no message showed. -// Presses A; true once a message box is up. -bool talk_opens_message(ConsoleHandle& console, ProControllerContext& context); std::optional talk_and_count_pages(ConsoleHandle& console, ProControllerContext& context); // From the overworld: one step `direction`, onto a trigger or into a door. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 52de5db764..be8410780d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -9,15 +9,16 @@ #include #include "Common/Cpp/Exceptions.h" #include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "Pokemon/Navigation/Pokemon_RouteLog.h" +#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" -#include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryAbilities.h" #include "PokemonFRLG_AutoStoryBattleData.h" #include "PokemonFRLG_AutoStoryCapture.h" @@ -495,6 +496,22 @@ std::optional wall_beside(const MapData& map, const TilePos& tile){ namespace{ +// A talk to a person or an item ball opens a message; an A that opens +// none faced nothing (00.31 b3f_rare_candy, console B, 2026-11-10: one A, +// "done", on the wrong floor). The message is left open for the next step. +bool talk_opens_message(ConsoleHandle& console, ProControllerContext& context){ + WhiteDialogWatcher opened(COLOR_RED); + const int shown = run_until( + console, context, + [](ProControllerContext& context){ + pbf_press_button(context, BUTTON_A, 160ms, 2000ms); + }, + {opened} + ); + return shown >= 0; +} + + bool walked(StoryEnv& env, RunState& state, const StoryStep& step){ const Outcome outcome = walk_route(env, state, step); if (outcome.succeeded() && outcome.pose){ From 5fb00548c8aad9dfdc07ec18a2ee56bc38f0883c Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 03:41:33 -0800 Subject: [PATCH 21/23] FRLG AutoStory 00.31: tap B4F's open floor after the LIFT KEY From the Grunt's line to below the LIFT KEY and on to B4F's stairs (11, 15) are now taps legs, one checked tap per tile; below_lift_key keeps a turn-only route to face the key and b3f_from_b4f only climbs the stairs. The sweep checks run them with each turn dropped and the stairs with any hold short. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_AutoStoryHideout_Tests.cpp | 29 ++++++++++++++-- .../ReplayData/frlg-story-sim-trace.json | 34 +++++++++++-------- .../AutoStory/StoryData/frlg-00.31.plan.json | 18 ++++++++-- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp index eb424124d6..6e678803fa 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryHideout_Tests.cpp @@ -218,8 +218,10 @@ UnitTestResult test_coded_spinners(){ // `facing`: as planned, and with each of the turns the taps make dropped // in turn (a tap facing another way only turns the player, and a // dropped one doesn't even turn them). Empty if each run ends on `goal`. -std::string tap_legs_on_sim(const MapPosition& start, Direction facing, const std::vector& legs, const MapPosition& goal){ - const std::vector& maps = story_maps(); +std::string tap_legs_on_sim( + const MapPosition& start, Direction facing, const std::vector& legs, const MapPosition& goal, + const std::vector& maps = story_maps() +){ std::optional> route = fixed_route(maps, start, legs); if (!route || !(route->back().end == goal)){ return "The legs from " + to_string(start) + " don't end on " + to_string(goal) + "."; @@ -272,11 +274,25 @@ std::string short_holds_on_sim(const MapPosition& start, Direction facing, const // the stairs (18, 2) to below the stairs to B4F (15, 19), and back from // them (15, 18) to the stop (10, 13). The routes planned after them, // onto the stairs to B4F and east to below the Rare Candy, have no -// arrow on the way: a short hold there is found again. +// arrow on the way: a short hold there is found again. B4F after the +// LIFT KEY, a tap a tile from the Grunt's line to below the key and on +// to the stairs (11, 15) with any one turn dropped, and the stairs up. UnitTestResult test_b3f_maze_taps(){ using Pokemon::StoryLeg; const MapPosition below_stairs{"RocketHideout_B3F", {15, 19}}; const MapPosition candy_stop{"RocketHideout_B3F", {10, 13}}; + const MapPosition b4f_below_key{"RocketHideout_B4F", {3, 3}}; + const MapPosition b4f_stairs{"RocketHideout_B4F", {11, 15}}; + // The Lift Key Grunt (4, 2) is beaten by then: (4, 3), in his line, is + // open floor. + std::vector key_grunt_beaten = story_maps(); + for (MapData& map : key_grunt_beaten){ + for (MapObject& object : map.objects){ + if (map.name == "RocketHideout_B4F" && object.x == 4 && object.y == 2){ + object.trainer.reset(); + } + } + } const std::vector failures{ tap_legs_on_sim({"RocketHideout_B3F", {18, 2}}, Direction::EAST, { {Direction::WEST, 6}, {Direction::SOUTH, 5}, {Direction::WEST, 7}, {Direction::SOUTH, 2}, {Direction::WEST, 1}, @@ -288,6 +304,13 @@ UnitTestResult test_b3f_maze_taps(){ }, candy_stop), short_holds_on_sim(below_stairs, Direction::NORTH, {"RocketHideout_B4F", map_point(story_maps(), "RocketHideout_B4F", "warp_0")}), short_holds_on_sim(candy_stop, Direction::NORTH, {"RocketHideout_B3F", {12, 13}}), + tap_legs_on_sim({"RocketHideout_B4F", {4, 3}}, Direction::WEST, { + {Direction::WEST, 1}, + }, b4f_below_key), + tap_legs_on_sim(b4f_below_key, Direction::NORTH, { + {Direction::EAST, 3}, {Direction::SOUTH, 4}, {Direction::EAST, 5}, {Direction::SOUTH, 8}, + }, b4f_stairs, key_grunt_beaten), + short_holds_on_sim(b4f_stairs, Direction::SOUTH, {"RocketHideout_B3F", {15, 18}}), }; for (const std::string& failure : failures){ if (!failure.empty()){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json index e3cc1c3a99..77e203aee2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData/frlg-story-sim-trace.json @@ -1277,7 +1277,7 @@ "[Checkpoint] 00.30: done, 24 run, 0 skipped", "[Checkpoint] 00.30: passed on attempt 1 (one-shot)", "begin 00.31", - "[Checkpoint] 00.31: start, 20 events", + "[Checkpoint] 00.31: start, 22 events", "[Event] 00.31/1 from_save: start", "[Event] 00.31/1 from_save: done", "[Event] 00.31/2 celadon_below_game_corner: start", @@ -1319,26 +1319,32 @@ "[Event] 00.31/14 lift_key_grunt: start", "00.31/lift_key_grunt: ok at -", "[Event] 00.31/14 lift_key_grunt: done", - "[Event] 00.31/15 below_lift_key: start", + "[Event] 00.31/15 beside_lift_key: start", + "00.31/beside_lift_key: ok at RocketHideout_B4F (3, 3) facing west (tile)", + "[Event] 00.31/15 beside_lift_key: done", + "[Event] 00.31/16 below_lift_key: start", "00.31/below_lift_key: ok at RocketHideout_B4F (3, 3) facing north (tile)", - "[Event] 00.31/15 below_lift_key: done", - "[Event] 00.31/16 lift_key: start", + "[Event] 00.31/16 below_lift_key: done", + "[Event] 00.31/17 lift_key: start", "00.31/lift_key: ok at -", - "[Event] 00.31/16 lift_key: done", - "[Event] 00.31/17 b3f_from_b4f: start", + "[Event] 00.31/17 lift_key: done", + "[Event] 00.31/18 b4f_to_stairs: start", + "00.31/b4f_to_stairs: ok at RocketHideout_B4F (11, 15) facing south (tile)", + "[Event] 00.31/18 b4f_to_stairs: done", + "[Event] 00.31/19 b3f_from_b4f: start", "00.31/b3f_from_b4f: ok at RocketHideout_B3F (15, 18) facing west (tile)", - "[Event] 00.31/17 b3f_from_b4f: done", - "[Event] 00.31/18 b3f_back_to_candy_row: start", + "[Event] 00.31/19 b3f_from_b4f: done", + "[Event] 00.31/20 b3f_back_to_candy_row: start", "00.31/b3f_back_to_candy_row: ok at RocketHideout_B3F (10, 13) facing north (tile)", - "[Event] 00.31/18 b3f_back_to_candy_row: done", - "[Event] 00.31/19 beside_b3f_rare_candy: start", + "[Event] 00.31/20 b3f_back_to_candy_row: done", + "[Event] 00.31/21 beside_b3f_rare_candy: start", "00.31/beside_b3f_rare_candy: ok at RocketHideout_B3F (12, 13) facing north (tile)", - "[Event] 00.31/19 beside_b3f_rare_candy: done", - "[Event] 00.31/20 b3f_rare_candy: start", + "[Event] 00.31/21 beside_b3f_rare_candy: done", + "[Event] 00.31/22 b3f_rare_candy: start", "00.31/b3f_rare_candy: ok at -", - "[Event] 00.31/20 b3f_rare_candy: done", + "[Event] 00.31/22 b3f_rare_candy: done", "save at RocketHideout_B3F (12, 13) facing north (tile)", - "[Checkpoint] 00.31: done, 20 run, 0 skipped", + "[Checkpoint] 00.31: done, 22 run, 0 skipped", "[Checkpoint] 00.31: passed on attempt 1 (one-shot)", "[Segment] 00: 35 of 35 checkpoints one-shot", "[Segment] 00: done, 35 checkpoints", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json index 1787f57fab..af8f3bbbe4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.31.plan.json @@ -92,24 +92,38 @@ "declared_after": {"certainty": "tile", "map": "RocketHideout_B4F", "where": {"facing": "west", "kind": "tiles", "tiles": [[4, 3]]}}, "why": "Rocket Grunt (TRAINER_TEAM_ROCKET_GRUNT_18): Koffing, Zubat Lv21; he drops the LIFT KEY" }, + { + "id": "beside_lift_key", + "kind": "legs", + "variant": "taps", + "legs": [{"direction": "west", "tiles": 1}], + "why": "a tap west from the Grunt's line (4, 3) to below the LIFT KEY (3, 3)" + }, { "id": "below_lift_key", "kind": "route", "target": {"certainty": "tile", "map": "RocketHideout_B4F", "where": {"facing": "north", "kind": "tiles", "tiles": [[3, 3]]}}, "variant": "run", - "why": "a tile west, below the LIFT KEY (3, 2)" + "why": "turn to face the LIFT KEY (3, 2): no tile to walk" }, { "id": "lift_key", "kind": "talk", "why": "pick up the LIFT KEY (pokeguy 57:33)" }, + { + "id": "b4f_to_stairs", + "kind": "legs", + "variant": "taps", + "legs": [{"direction": "east", "tiles": 3}, {"direction": "south", "tiles": 4}, {"direction": "east", "tiles": 5}, {"direction": "south", "tiles": 8}], + "why": "a tap a tile from below the LIFT KEY (3, 3): east to the wall (6, 3), down to (6, 7), east to (11, 7) and down onto the stairs (11, 15)" + }, { "id": "b3f_from_b4f", "kind": "route", "target": {"certainty": "tile", "map": "RocketHideout_B3F", "where": {"facing": "west", "kind": "tiles", "tiles": [[15, 18]]}}, "variant": "run", - "why": "back to B4F's stairs (11, 15) and up them to B3F's (15, 18)" + "why": "east up B4F's stairs (11, 15) to B3F's (15, 18)" }, { "id": "b3f_back_to_candy_row", From d9190da1c346a382d5c87202c137f11a34c7c89f Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 04:13:34 -0800 Subject: [PATCH 22/23] FRLG overworld: confirm a warp's destination after its fade A black that clears with the old scene back is no warp: wait_out_warp() now compares the screen after the fade with one taken before the hold (warp_left_scene()) and fails 'warp to X not confirmed'. Sim fault black_without_warp and rule confirm_warp_destination, with WarpFade cases. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_OverworldRecoveryWalk.cpp | 6 +- .../Overworld/PokemonFRLG_OverworldSim.cpp | 18 ++++ .../Overworld/PokemonFRLG_OverworldSim.h | 11 +++ .../Overworld/PokemonFRLG_OverworldWalk.cpp | 97 ++++++++++++++++++- .../Overworld/PokemonFRLG_OverworldWalk.h | 22 ++++- .../PokemonFRLG_OverworldWarpFade_Tests.cpp | 22 ++++- .../AutoStory/PokemonFRLG_AutoStoryRooms.cpp | 7 +- 7 files changed, 170 insertions(+), 13 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index 18b365317f..6d969a2147 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -200,6 +200,7 @@ StepWalk walk_step( } context.wait_for_all_requests(); out.dark = on_dark_cave(console); + const VideoSnapshot before = console.video().snapshot(); out.hold_start = current_time(); BlackScreenOverWatcher arrival(COLOR_RED); Pokemon::WatchAlong fade(arrival); @@ -212,7 +213,7 @@ StepWalk walk_step( return out; } if (step.warps){ - wait_out_warp(console, context, step, fade); + wait_out_warp(console, context, step, fade, before); static_assert(AFTER_WARP_BATTLE_WATCH >= AFTER_WARP); if (run_from_battle_after_warp(console, context)){ console.log("Route: a wild battle, not the warp to " + step.end.map + "; the player is on " + to_string(step) + " before the warp.", COLOR_ORANGE); @@ -349,6 +350,7 @@ void hold_to_warp( callbacks.emplace_back(*watchers.back()); } context.wait_for_all_requests(); + const VideoSnapshot before = console.video().snapshot(); const int ret = run_until( console, context, [&](ProControllerContext& context){ @@ -358,7 +360,7 @@ void hold_to_warp( callbacks ); if (ret == 0){ - wait_out_warp(console, context, step); + wait_out_warp(console, context, step, before); check_warp_was_no_battle(console, context, step); return; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp index 938dab9efc..56734b1174 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp @@ -358,6 +358,13 @@ bool OverworldSim::trainer_sees(Milliseconds pressed){ // game stopped them there: a warp, a trainer, a wild battle. bool OverworldSim::after_step(const Step& step, Milliseconds pressed){ const SimTiming& timing = m_script.timing; + if (step.warped && m_script.black_without_warp.contains(++m_warp_steps)){ + m_frozen = true; + schedule(pressed + timing.tile, SimScreen::FADE, false); + schedule(pressed + timing.tile + timing.fade, SimScreen::OVERWORLD, true); + note("black without a warp; the player stays at " + to_string(m_state.position) + "."); + return true; + } m_map = step.map; m_player = step.player; m_state.steps++; @@ -797,6 +804,17 @@ bool OverworldSimWalker::fade_over_since(Milliseconds from) const{ // the battle screen stands in for the wipe. The fade is watched for from // `watched_from`: a fade over by then is missed. bool OverworldSimWalker::after_warp(const RouteStep& step, int warps_before, Milliseconds watched_from){ + // A fade seen with no warp: the console's screen check + // (warp_left_scene()) finds the scene from before the hold. + const bool black_only = m_sim.state().warps == warps_before + && (m_sim.state().screen == SimScreen::FADE || fade_over_since(watched_from)); + if (black_only){ + if (m_rules.confirm_warp_destination){ + fail("walk_overworld_route(): the warp to " + step.end.map + " not confirmed: the screen after the fade shows the scene from before the hold."); + } + m_sim.watch({}, AFTER_WARP); + return true; + } if (m_sim.state().warps == warps_before){ if (!m_sim.watch({SimWatcher::BATTLE_SCREEN}, WARP_TIMEOUT)){ fail("walk_overworld_route(): no fade in and out after walking onto the warp to " + step.end.map + "."); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h index 70b4f088e5..0c29a98946 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h @@ -141,6 +141,10 @@ struct SimScript{ // (SimWalkerRules::confirm_turn) after 00.28 run 2 (console B, // 2026-11-09), where a one-tile leg only turned the player. std::set dropped_turn_taps; + // Fault injection: steps onto a warp, by number from 1, that show the + // fade's black and clear with the player where they were, not warped + // (console B, 2026-11-10 01:44, 00.31 run 4, "east 1 (warp)" on B4F). + std::set black_without_warp; // The player rides the Bicycle: a tap facing another way takes a step // too, a hold through a turn loses no tile // (MovementMechanics::BIKE_TAP_ONLY_TURNS), and no step tap is @@ -387,6 +391,8 @@ class OverworldSim{ int m_encounter_rate_buff = 0; // The turn taps so far, for SimScript::dropped_turn_taps. int m_turn_taps = 0; + // Steps onto a warp so far (SimScript::black_without_warp). + int m_warp_steps = 0; // The last tap, until a hold. std::optional m_last_tap; // When the last Bicycle tap started, and how many came too soon. @@ -465,6 +471,11 @@ struct SimWalkerRules{ // 2026-11-09 01:41, 00.27, the warp to CeruleanCity: the watch started // about 1.3 s into the hold). bool watch_fade_along_hold = true; + // A warp's fade is taken as the warp only once the screen after it + // shows the player off the map they held from (warp_left_scene()). + // Without it a black that cleared with the player where they were was + // taken as the warp (console B, 2026-11-10 01:44, 00.31 run 4). + bool confirm_warp_destination = true; // A turn tap is checked by the facing on screen, and tapped again // while the player faces another way (OverworldWalkSteps::turn_to()). // Without it a dropped tap left a one-tile leg turning the player diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp index 104d07542f..8de83e0b7a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -7,7 +7,9 @@ #include #include #include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" +#include #include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/ImageTools/ImageDiff.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "CommonTools/Async/InferenceRoutines.h" #include "CommonTools/VisualDetectors/BlackScreenDetector.h" @@ -293,9 +295,66 @@ std::vector warp_hold_watchers(const RouteStep& step, Poke return {&fade}; } +namespace{ + +// How close (pixel RMSD) the overlap of two screens is for the same scene. +constexpr double SAME_SCENE_RMSD = 25; +// The GBA screen's tiles across and down. +constexpr int SCREEN_TILES_X = 15; +constexpr int SCREEN_TILES_Y = 10; +// From the fade's end until the new map is in full light. +constexpr Milliseconds WARP_FADE_IN(300); + +// The RMSD of `before` and `after` where they overlap, with the scene +// scrolled `dx`, `dy` pixels: `after` at (x, y) shows `before` at +// (x + dx, y + dy). +double scrolled_rmsd(const ImageViewRGB32& before, const ImageViewRGB32& after, int dx, int dy){ + const size_t width = before.width() - (size_t)std::abs(dx); + const size_t height = before.height() - (size_t)std::abs(dy); + const ImageViewRGB32 old_part = before.sub_image(dx > 0 ? dx : 0, dy > 0 ? dy : 0, width, height); + const ImageViewRGB32 new_part = after.sub_image(dx < 0 ? -dx : 0, dy < 0 ? -dy : 0, width, height); + return ImageMatch::pixel_RMSD(old_part, new_part); +} + +} // namespace + +bool warp_left_scene( + const ImageViewRGB32& before, const ImageViewRGB32& after, + const ImageFloatBox& game, Direction direction, int max_tiles +){ + const ImageViewRGB32 old_box = extract_box_reference(before, game); + const ImageViewRGB32 new_box = extract_box_reference(after, game); + if (old_box.width() != new_box.width() || old_box.height() != new_box.height()){ + return true; + } + if (dark_cave_screen(before) || dark_cave_screen(after)){ + return true; + } + const int tile_x = (int)old_box.width() / SCREEN_TILES_X; + const int tile_y = (int)old_box.height() / SCREEN_TILES_Y; + // Keep at least 5 tiles of overlap to compare. + const int most = std::min(max_tiles, (direction == Direction::NORTH || direction == Direction::SOUTH ? SCREEN_TILES_Y : SCREEN_TILES_X) - 5); + for (int tiles = 0; tiles <= most; tiles++){ + int dx = 0; + int dy = 0; + switch (direction){ + case Direction::NORTH: dy = -tiles * tile_y; break; + case Direction::SOUTH: dy = tiles * tile_y; break; + case Direction::WEST: dx = -tiles * tile_x; break; + case Direction::EAST: dx = tiles * tile_x; break; + } + if (scrolled_rmsd(old_box, new_box, dx, dy) < SAME_SCENE_RMSD){ + return false; + } + } + return true; +} + +namespace{ + // One watcher for the whole fade: a ladder's black is short enough to be // over before a second watcher, started once the fade is seen, looks. -void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, Pokemon::WatchAlong& fade){ +void wait_out_fade(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, Pokemon::WatchAlong& fade){ if (fade.fired()){ console.log("Route: the fade to " + step.end.map + " was over before the hold ended."); return; @@ -310,10 +369,38 @@ void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const } } -void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ +} // namespace + +// A black screen that clears with the player where they were is no warp +// (console B, 2026-11-10 01:44, 00.31 run 4: "east 1 (warp)" was taken as +// walked while the player stayed on B4F). +void wait_out_warp( + ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, + Pokemon::WatchAlong& fade, const VideoSnapshot& before +){ + wait_out_fade(console, context, step, fade); + if (!before){ + return; + } + pbf_wait(context, WARP_FADE_IN); + context.wait_for_all_requests(); + const VideoSnapshot after = console.video().snapshot(); + if (!after){ + return; + } + if (!warp_left_scene(*before.frame, *after.frame, GameSettings::instance().GAME_BOX, step.direction, step.tiles + step.warp_slack + 2)){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + "walk_overworld_route(): the warp to " + step.end.map + " not confirmed: the screen after the fade shows the scene from before the hold.", + console + ); + } +} + +void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, const VideoSnapshot& before){ BlackScreenOverWatcher arrival(COLOR_RED); Pokemon::WatchAlong fade(arrival); - wait_out_warp(console, context, step, fade); + wait_out_warp(console, context, step, fade, before); } // Fails unless the overworld is up. Under the START menu or a message the @@ -606,6 +693,8 @@ void walk_step_leg( ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, const OverworldInterruptSet& interrupts, MoveSpeed speed ){ + context.wait_for_all_requests(); + const VideoSnapshot before = console.video().snapshot(); BlackScreenOverWatcher arrival(COLOR_RED); Pokemon::WatchAlong fade(arrival); Pokemon::walk_leg( @@ -619,7 +708,7 @@ void walk_step_leg( if (!step.warps){ return; } - wait_out_warp(console, context, step, fade); + wait_out_warp(console, context, step, fade, before); static_assert(AFTER_WARP_BATTLE_WATCH >= AFTER_WARP); check_warp_was_no_battle(console, context, step); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h index 5666f54367..a07ff14ac6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h @@ -23,7 +23,9 @@ #include #include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "Pokemon/AutoStory/Pokemon_ScreenEvents.h" #include "Pokemon/Navigation/Pokemon_LegWalker.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" @@ -176,10 +178,24 @@ std::vector warp_hold_watchers(const RouteStep& step, Poke // After a hold onto `step`'s warp: waits out its fade, unless `fade`, a // BlackScreenOverWatcher watched along the hold, saw it over already; -// else waits on with that watcher, which may have seen the black. -void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, Pokemon::WatchAlong& fade); +// else waits on with that watcher, which may have seen the black. Then +// fails unless the screen after the fade differs from `before`, taken +// before the hold (warp_left_scene()). +void wait_out_warp( + ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, + Pokemon::WatchAlong& fade, const VideoSnapshot& before +); // The same, watching only from now: for a caller that saw the black itself. -void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step); +void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, const VideoSnapshot& before); + +// Whether `after` no longer shows the scene `before` showed, scrolled 0 to +// `max_tiles` tiles on toward `direction` inside the game box `game`: +// black then clear with the old scene back is no warp. A screen too dark to +// compare (a dark cave) counts as left. +bool warp_left_scene( + const ImageViewRGB32& before, const ImageViewRGB32& after, + const ImageFloatBox& game, Direction direction, int max_tiles +); // Before `step`: fails unless the overworld is up. void check_overworld(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpFade_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpFade_Tests.cpp index de344c2dc1..dbaa49462c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpFade_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWarpFade_Tests.cpp @@ -8,6 +8,7 @@ */ #include +#include #include #include #include "Common/Cpp/Exceptions.h" @@ -31,11 +32,15 @@ struct WarpFadeInput{ Milliseconds fade{0}; // SimWalkerRules::watch_fade_along_hold. bool watch_along_hold = true; + // SimScript::black_without_warp and SimWalkerRules::confirm_warp_destination. + std::set black_without_warp = {}; + bool confirm_destination = true; }; struct WarpFadeExpectation{ // The failure the walk stops on; empty: the route is walked. std::string failure; + int warps = 1; }; struct WarpFadeCase{ @@ -73,15 +78,17 @@ class Test_OverworldWarpFade : public UnitTest{ out.end = OUTSIDE; SimScript script; script.timing.fade = m_case.input.fade; + script.black_without_warp = m_case.input.black_without_warp; SimWalkerRules rules; rules.watch_fade_along_hold = m_case.input.watch_along_hold; + rules.confirm_warp_destination = m_case.input.confirm_destination; OverworldSim sim(maps(), MART, Direction::SOUTH, script); OverworldSimWalker walker(sim, rules); const RoutePlanning planning{.maps = &maps(), .costs = default_route_costs(), .start = MART, .label = "Sim"}; const std::string failure = walker.run({out}, planning); const std::string& expected = m_case.expectation.failure; const bool as_expected = expected.empty() ? failure.empty() : failure.find(expected) != std::string::npos; - if (as_expected && sim.state().warps == 1){ + if (as_expected && sim.state().warps == m_case.expectation.warps){ return true; } std::string log; @@ -89,8 +96,8 @@ class Test_OverworldWarpFade : public UnitTest{ log += "\n " + line; } return std::format( - "Expected failure \"{}\" after 1 warp; got \"{}\" after {}:{}", - expected, failure, sim.state().warps, log + "Expected failure \"{}\" after {} warp(s); got \"{}\" after {}:{}", + expected, m_case.expectation.warps, failure, sim.state().warps, log ); } @@ -114,6 +121,15 @@ const WarpFadeCase WARP_FADE_CASES[] = { .input = {.name = "a fade still on when the hold ends, watched from its end", .fade = 1000ms, .watch_along_hold = false}, .expectation = {.failure = ""}, }, + { + .input = {.name = "black without a warp, destination confirmed", .fade = 1000ms, .black_without_warp = {1}}, + .expectation = {.failure = "the warp to ViridianCity not confirmed", .warps = 0}, + }, + { + // 00.31 run 4 (console B, 2026-11-10 01:44): taken as walked. + .input = {.name = "black without a warp, any black taken as the warp", .fade = 1000ms, .black_without_warp = {1}, .confirm_destination = false}, + .expectation = {.failure = "", .warps = 0}, + }, }; void add_tests_OverworldWarpFade(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRooms.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRooms.cpp index e6dbf9cb22..290f50c27d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRooms.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRooms.cpp @@ -71,7 +71,12 @@ void walk_room_legs( facing = leg.direction; continue; } + VideoSnapshot before; for (int tile = 0; tile < leg.tiles; tile++){ + if (leg.warps && tile + 1 == leg.tiles){ + context.wait_for_all_requests(); + before = console.video().snapshot(); + } step_once(console, context, leg.direction, facing); facing = leg.direction; } @@ -80,7 +85,7 @@ void walk_room_legs( step.direction = leg.direction; step.tiles = 1; step.warps = true; - OverworldWalkSteps::wait_out_warp(console, context, step); + OverworldWalkSteps::wait_out_warp(console, context, step, before); } } } From 17c8115f28c4c36c957deb3965b586d2a473aa45 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 04:14:28 -0800 Subject: [PATCH 23/23] FRLG overworld: keep warp confirmation within code health limits Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG_OverworldRecoveryWalk.cpp | 5 +-- .../Overworld/PokemonFRLG_OverworldSim.cpp | 27 +------------ .../Overworld/PokemonFRLG_OverworldSim.h | 7 +++- .../PokemonFRLG_OverworldSimTaps.cpp | 38 +++++++++++++++++++ .../Overworld/PokemonFRLG_OverworldWalk.cpp | 8 ++-- .../Overworld/PokemonFRLG_OverworldWalk.h | 9 ----- 6 files changed, 52 insertions(+), 42 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp index 6d969a2147..d2d935c811 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp @@ -189,9 +189,8 @@ StepWalk walk_step( StepWalk out{std::nullopt, current_time(), false, false}; switch (step.action){ case RouteAction::WALK:{ - // Turning first, with a tap, makes the hold start from a standstill - // facing the right way: holding through a turn lost a tile on the - // console, while holds from a standstill were exact over 15 tiles. + // Turning first, with a tap, starts the hold from a standstill facing + // the right way: exact over 15 tiles, where a turn lost one. if (turns_first(step, speed, facing)){ turn_to(console, context, step.direction); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp index 56734b1174..cd3c1f38d4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp @@ -358,11 +358,7 @@ bool OverworldSim::trainer_sees(Milliseconds pressed){ // game stopped them there: a warp, a trainer, a wild battle. bool OverworldSim::after_step(const Step& step, Milliseconds pressed){ const SimTiming& timing = m_script.timing; - if (step.warped && m_script.black_without_warp.contains(++m_warp_steps)){ - m_frozen = true; - schedule(pressed + timing.tile, SimScreen::FADE, false); - schedule(pressed + timing.tile + timing.fade, SimScreen::OVERWORLD, true); - note("black without a warp; the player stays at " + to_string(m_state.position) + "."); + if (step.warped && black_without_warp(pressed)){ return true; } m_map = step.map; @@ -787,32 +783,13 @@ std::optional OverworldSimWalker::hold_watching(const RouteStep& step, } // Whether a warp's fade showed and was over between `from` and now. -bool OverworldSimWalker::fade_over_since(Milliseconds from) const{ - const SimState& state = m_sim.state(); - if (state.screen == SimScreen::FADE){ - return false; - } - return std::any_of( - state.shown.begin(), state.shown.end(), - [&](const SimShown& shown){ return shown.screen == SimScreen::FADE && shown.at >= from; } - ); -} - // wait_out_warp(), then run_from_battle_after_warp(): false if the fade // was a wild battle's, run from. wait_out_warp()'s watcher takes a wild // battle's wipe for the fade (run 7; console B, 2026-11-03, Mt. Moon 1F): // the battle screen stands in for the wipe. The fade is watched for from // `watched_from`: a fade over by then is missed. bool OverworldSimWalker::after_warp(const RouteStep& step, int warps_before, Milliseconds watched_from){ - // A fade seen with no warp: the console's screen check - // (warp_left_scene()) finds the scene from before the hold. - const bool black_only = m_sim.state().warps == warps_before - && (m_sim.state().screen == SimScreen::FADE || fade_over_since(watched_from)); - if (black_only){ - if (m_rules.confirm_warp_destination){ - fail("walk_overworld_route(): the warp to " + step.end.map + " not confirmed: the screen after the fade shows the scene from before the hold."); - } - m_sim.watch({}, AFTER_WARP); + if (black_without_warp(step, warps_before, watched_from)){ return true; } if (m_sim.state().warps == warps_before){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h index 0c29a98946..2eb49aedbe 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h @@ -391,8 +391,10 @@ class OverworldSim{ int m_encounter_rate_buff = 0; // The turn taps so far, for SimScript::dropped_turn_taps. int m_turn_taps = 0; - // Steps onto a warp so far (SimScript::black_without_warp). + // Steps onto a warp so far, and the fault on one + // (SimScript::black_without_warp): its black without the warp. int m_warp_steps = 0; + bool black_without_warp(Milliseconds pressed); // The last tap, until a hold. std::optional m_last_tap; // When the last Bicycle tap started, and how many came too soon. @@ -579,6 +581,9 @@ class OverworldSimWalker{ std::optional walk_step(const RouteStep& step, std::optional facing); bool after_warp(const RouteStep& step, int warps_before, Milliseconds watched_from); bool fade_over_since(Milliseconds from) const; + // after_warp() on a fade seen with no warp: fails, or with + // SimWalkerRules::confirm_warp_destination off, takes it as the warp. + bool black_without_warp(const RouteStep& step, int warps_before, Milliseconds watched_from); [[noreturn]] void fail_off_route(const RouteStep& step); std::optional hold_watching(const RouteStep& step, Milliseconds hold, const std::vector& interrupts); size_t clear_late(const std::vector& interrupts, Milliseconds watch, size_t max); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp index 65ff730b5c..578d0fb1e9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimTaps.cpp @@ -140,6 +140,44 @@ void sim_step_once(OverworldSim& sim, Direction direction){ } +bool OverworldSimWalker::fade_over_since(Milliseconds from) const{ + const SimState& state = m_sim.state(); + if (state.screen == SimScreen::FADE){ + return false; + } + return std::any_of( + state.shown.begin(), state.shown.end(), + [&](const SimShown& shown){ return shown.screen == SimScreen::FADE && shown.at >= from; } + ); +} + + +// A fade seen with no warp: the console's screen check +// (warp_left_scene()) finds the scene from before the hold. +bool OverworldSimWalker::black_without_warp(const RouteStep& step, int warps_before, Milliseconds watched_from){ + const bool black_only = m_sim.state().warps == warps_before + && (m_sim.state().screen == SimScreen::FADE || fade_over_since(watched_from)); + if (!black_only){ + return false; + } + if (m_rules.confirm_warp_destination){ + fail("walk_overworld_route(): the warp to " + step.end.map + " not confirmed: the screen after the fade shows the scene from before the hold."); + } + m_sim.watch({}, OverworldWalkSteps::AFTER_WARP); + return true; +} + +bool OverworldSim::black_without_warp(Milliseconds pressed){ + if (!m_script.black_without_warp.contains(++m_warp_steps)){ + return false; + } + m_frozen = true; + schedule(pressed + m_script.timing.tile, SimScreen::FADE, false); + schedule(pressed + m_script.timing.tile + m_script.timing.fade, SimScreen::OVERWORLD, true); + note("black without a warp; the player stays at " + to_string(m_state.position) + "."); + return true; +} + } // namespace PokemonFRLG } // namespace NintendoSwitch } // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp index 8de83e0b7a..54987045d8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -316,8 +316,10 @@ double scrolled_rmsd(const ImageViewRGB32& before, const ImageViewRGB32& after, return ImageMatch::pixel_RMSD(old_part, new_part); } -} // namespace - +// Whether `after` no longer shows the scene `before` showed, scrolled 0 to +// `max_tiles` tiles on toward `direction` inside the game box `game`: black +// then clear with the old scene back is no warp. A screen too dark to +// compare (a dark cave) counts as left. bool warp_left_scene( const ImageViewRGB32& before, const ImageViewRGB32& after, const ImageFloatBox& game, Direction direction, int max_tiles @@ -350,8 +352,6 @@ bool warp_left_scene( return true; } -namespace{ - // One watcher for the whole fade: a ladder's black is short enough to be // over before a second watcher, started once the fade is seen, looks. void wait_out_fade(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, Pokemon::WatchAlong& fade){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h index a07ff14ac6..8ec2f7cacf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h @@ -188,15 +188,6 @@ void wait_out_warp( // The same, watching only from now: for a caller that saw the black itself. void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step, const VideoSnapshot& before); -// Whether `after` no longer shows the scene `before` showed, scrolled 0 to -// `max_tiles` tiles on toward `direction` inside the game box `game`: -// black then clear with the old scene back is no warp. A screen too dark to -// compare (a dark cave) counts as left. -bool warp_left_scene( - const ImageViewRGB32& before, const ImageViewRGB32& after, - const ImageFloatBox& game, Direction direction, int max_tiles -); - // Before `step`: fails unless the overworld is up. void check_overworld(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step);