From f185de0cd63590f4dea23dc7fdf2c32e84a19124 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 8 Nov 2026 16:19:41 -0800 Subject: [PATCH 1/4] BDSP AutoStory: no route ends beside a warp walking toward it 01.05's open walk west to (2, 13), beside the Oreburgh Gate's mouth, slid onto the warp (lab-B 2026-11-08, four runs). A table test plans every ROUTE step as the walker does and fails on an open leg that may end on the tile before a door it walks toward. It flagged 01.05's old by_the_gate and four more: 00.03 above_the_door_again (now counted legs from the west), 01.02 by_the_east_mouth and 01.05 through_the_gate (two tiles short of the Gate's mouths, the taps go the rest), and 01.03 above_the_mine (two rows above the warp row, the door run goes on). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_StoryTable.cpp | 11 ++- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 81 +++++++++++++++++++ 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable.cpp index a6e5a30c63..2f7cb7123d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable.cpp @@ -124,6 +124,8 @@ StoryStep make(StoryStepKind kind, std::string name, std::string why){ step.why = std::move(why); return step; } +// A route toward a door or a warp stops two tiles short, not beside it: an +// open walk there can slide onto it (01.05, lab-B 2026-11-08). StoryStep route(std::string name, Pose target, std::string why, std::string costs = ""){ StoryStep step = make(StoryStepKind::ROUTE, std::move(name), std::move(why)); step.target = std::move(target); @@ -337,7 +339,8 @@ std::vector lake_and_pokedex(){ // Line up on the table's corner west first: a plan from either tile // ran east into Mom at (7, 8), who talks (r29). route("by_the_counter", at(HOME, 4, 8, WEST), "west against the table's corner (3, 8)"), - route("above_the_door_again", at(HOME, 6, 9, SOUTH), "to above the door"), + anchored(legs("above_the_door_again", {{.direction = EAST, .tiles = 1}, {.direction = SOUTH, .tiles = 1}, {.direction = EAST, .tiles = 1}}, + "east, south past the wall (4, 9), and east to above the door: not south toward it"), at(HOME, 6, 9, EAST)), step_into("out_of_the_house_again", SOUTH, "onto the door's tile (6, 10), and out", at(TWINLEAF, "house_doorstep", SOUTH)), // Through the grass now, with a starter: wild battles are run from. route("short_of_dawn", at(ROUTE_201, 63, 5, EAST), "Twinleaf, then east along Route 201 to its east edge"), @@ -637,7 +640,7 @@ StoryCheckpoint oreburgh_to_route_203(){ // for a banner already gone (lab-B, 2026-11-08 15:31, 15:39, 15:47, // 15:54; frames in Screenshots/AutoStory/banner/). step_into("into_oreburgh_gate", WEST, "the Gate's mouth (1, 13)", arrival(GATE, {27, 22}, WEST)), - route("through_the_gate", at(GATE, 4, 22, WEST), "west along row 22 to the warp tile by the west mouth (3, 22)"), + route("through_the_gate", at(GATE, 5, 22, WEST), "west along row 22 to two tiles short of the west mouth's warp (3, 22)"), // Route 203's banner or a failure here: the old walk west "until the // banner" went on into the pond's pocket (r75). 01.06 heads south. tap_into("out_of_oreburgh_gate", WEST, "the west mouth (3, 22)", out_of_oreburgh_gate()), @@ -674,7 +677,7 @@ StoryCheckpoint route_203_to_oreburgh(){ // can come up a moment after them; the scene's B closes it. scene("the_hiker", at(GATE, 7, 22, EAST), "HM Rock Smash, then the Hidden Moves card"), route("past_curtis", at(GATE, 20, 22, EAST), "east along row 22 past Camper Curtis's column (17), fighting him"), - route("by_the_east_mouth", at(GATE, 27, 22, EAST), "east past Picnicker Diana's column (24), fighting her"), + route("by_the_east_mouth", at(GATE, 26, 22, EAST), "east past Picnicker Diana's column (24), fighting her, to two short of the mouth"), tap_into("into_oreburgh", EAST, "the Gate's east mouth (28, 22)", arrival(OREBURGH, map_point(OREBURGH, "gate_mouth").next(EAST), EAST)), route("west_of_the_welcome", at(OREBURGH, 9, 13, EAST), "east along row 13"), @@ -766,7 +769,7 @@ StoryCheckpoint oreburgh_center_heal(){ StoryCheckpoint oreburgh_mine_to_roark(){ const Pose below_roark = next_to(MINE, "roark", SOUTH, NORTH); return row("01.03", "Oreburgh Mine to Roark", out_of_oreburgh_center(), { - route("above_the_mine", at(OREBURGH, 46, 58, SOUTH), "down the door's column to above the mine's warp tiles", "town"), + route("above_the_mine", at(OREBURGH, 46, 57, SOUTH), "down the door's column to two above the mine's warp tiles (44..48, 59)", "town"), step_into("into_the_mine", SOUTH, "the warp tile (46, 59)", at(MINE_HALL, 12, 1, SOUTH)), step_into("into_the_coal_room", SOUTH, "down the entrance hall through the cave mouth", at(MINE, 15, 2, SOUTH)), anchored(to_walls("south_to_the_rock", {{.direction = SOUTH, .tiles = 8}}, "south against the corridor rock (15, 11)"), diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp index c16b365d7f..a6797a9190 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -19,7 +19,10 @@ #include "Data/PokemonBDSP_AutoStory_PlanCosts.h" #include "Data/PokemonBDSP_AutoStory_RoutePlanner.h" #include "Data/PokemonBDSP_AutoStory_StoryMaps.h" +#include "Data/PokemonBDSP_AutoStory_WallRecovery.h" #include "Actions/PokemonBDSP_AutoStory_Events.h" +#include "PokemonBDSP_AutoStory_StoryExecutor.h" +#include "PokemonBDSP_AutoStory_StoryPlaces.h" #include "PokemonBDSP_AutoStory_StoryTable.h" #include "PokemonBDSP_AutoStory_StoryTable_Tests.h" @@ -218,6 +221,80 @@ UnitTestResult test_route204_north_line(Logger& logger){ return true; } +// The legs a ROUTE step from `from` plans, as walk_route() plans them (the +// step's costs, then the default ones), on `world`; nothing if none. +std::optional> route_step_plan(const StoryWorld& world, const Pokemon::Pose& from, const Pokemon::StoryStep& step){ + std::vector start; + for (const TilePos& pos : Pokemon::tiles_of(from)){ + start.push_back(story_to_world(world, from.map, pos)); + } + std::vector targets; + for (const TilePos& pos : Pokemon::tiles_of(*step.target)){ + targets.push_back(story_to_world(world, step.target->map, pos)); + } + const auto goal = [&](const TilePos& pos){ return std::find(targets.begin(), targets.end(), pos) != targets.end(); }; + std::optional> legs = plan_recovered_route(world, start, goal, *story_route_costs(step.variant)); + return legs ? legs : plan_recovered_route(world, start, goal, RobustPlanCosts()); +} + +// Why `planned` may slide into a door or a warp, or "": an open leg (not to +// a wall) that may end on the tile before one, walking toward it. A part of +// a tile too far takes the warp (lab-B 2026-11-08 15:31 to 15:54: 01.05's +// open walk west to (2, 13), beside the Oreburgh Gate's mouth, slid into +// the Gate, and the tap after it waited for a banner already gone). The +// maps draw every warp as a door tile, cave mouths too. +std::string slides_into_door(const StoryWorld& world, const PlannedLeg& planned){ + if (planned.leg.ends_at_wall){ + return ""; + } + for (const TilePos& pos : planned.after){ + const TilePos ahead = pos.next(planned.leg.direction); + if (world.tile(ahead) == Pokemon::TileKind::DOOR){ + return std::format("the open leg {} may end on {}, the tile before the door {}", + to_string(planned.leg), describe(world, pos), describe(world, ahead)); + } + } + return ""; +} + +// No ROUTE step of the table plans an open leg that ends before a door it +// walks toward: a door is gone through by a step that runs or taps into it +// from where the route ends on a wall or off its line. Where a row's steps +// leave the player is followed from its start through each step's target +// or pose_after; a route from an unknown place is not checked. +UnitTestResult test_story_routes_stop_short_of_doors(Logger& logger){ + std::vector found; + size_t checked = 0; + for (const StoryCheckpoint& row : story_checkpoints()){ + std::optional at = row.start; + for (const Pokemon::StoryStep& step : row.steps){ + const bool known = at && !Pokemon::tiles_of(*at).empty(); + const StoryWorld* world = step.kind == StoryStepKind::ROUTE && known + ? story_plan_world(at->map, step.target->map) : nullptr; + if (step.kind == StoryStepKind::ROUTE && world == nullptr){ + logger.log(std::format("{} {}: not checked, from {}.", row.id, step.name, at ? Pokemon::to_string(*at) : "nowhere known")); + } + const std::optional> legs = world ? route_step_plan(*world, *at, step) : std::nullopt; + checked += legs ? 1 : 0; + for (const PlannedLeg& planned : legs ? *legs : std::vector{}){ + const std::string why = slides_into_door(*world, planned); + if (!why.empty()){ + found.push_back(std::format("{} {}: {}.", row.id, step.name, why)); + } + } + at = step.kind == StoryStepKind::ROUTE ? step.target + : step.pose_after ? step.pose_after + : step.kind == StoryStepKind::LEGS || step.kind == StoryStepKind::STEP ? std::nullopt : at; + } + } + logger.log(std::format("{} routes planned.", checked)); + std::string out; + for (const std::string& line : found){ + out += "\n " + line; + } + return found.empty() ? UnitTestResult(true) : UnitTestResult("Open legs that end before a door they walk toward:" + out); +} + struct AutoStoryStoryTableInput{ std::string name; @@ -270,6 +347,10 @@ const AutoStoryStoryTableCase AUTO_STORY_STORY_TABLE_CASES[] = { .input = {"Route 204 North: the line into Floaroma", test_route204_north_line}, .expectation = {}, }, + { + .input = {"Story table: no open leg ends before a door it walks toward (lab-B, 2026-11-08)", test_story_routes_stop_short_of_doors}, + .expectation = {}, + }, }; void add_tests_AutoStory_StoryTable(UnitTestDatabase& database){ From c19b41111f15c10b226c975899677715c5cf88f1 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 8 Nov 2026 16:34:51 -0800 Subject: [PATCH 2/4] BDSP AutoStory: the story sim's old steps in their own file Moved unchanged out of StorySim_Tests.cpp, which is at the 1000-line limit: r75's and r81's old cave exits and the old mine steps. The next commit adds 01.05's old tap into the Oreburgh Gate beside them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_OldStorySteps.cpp | 80 +++++++++++++++++++ .../PokemonBDSP_AutoStory_OldStorySteps.h | 50 ++++++++++++ .../PokemonBDSP_AutoStory_StorySim_Tests.cpp | 63 +-------------- SerialPrograms/cmake/SourceFiles.cmake | 2 + 4 files changed, 133 insertions(+), 62 deletions(-) create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp new file mode 100644 index 0000000000..1d7c4db01e --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp @@ -0,0 +1,80 @@ +/* BDSP AutoStory - Old story steps + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Pokemon/AutoStory/Pokemon_TilePose.h" +#include "PokemonBDSP_AutoStory_OldStorySteps.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + +using Pokemon::Direction; +using Pokemon::Pose; +using Pokemon::StoryStep; +using Pokemon::StoryStepKind; +using Pokemon::TilePos; + + +StoryStep r75_old_gate_exit(){ + StoryStep step; + step.kind = StoryStepKind::LEGS; + step.name = "out_of_oreburgh_gate"; + step.legs = {{.direction = Direction::WEST, .tiles = 8}}; + step.variant = "to_map"; + step.pose_after = Pokemon::tile_pose("Route203", {TilePos{55, 9}}, Direction::WEST); + return step; +} +Pose r75_pond_pocket(){ + std::vector tiles; + for (int y = 6; y <= 13; y++){ + for (int x = 49; x <= 54; x++){ + tiles.push_back({x, y}); + } + } + return Pokemon::tile_pose("Route203", tiles); +} + +StoryStep r81_old_cave_exit(){ + StoryStep step; + step.kind = StoryStepKind::LEGS; + step.name = "out_of_the_ravaged_path"; + step.legs = {{.direction = Direction::SOUTH, .tiles = 4}}; + step.variant = "to_wall"; + step.pose_after = Pokemon::tile_pose("Route204North", {TilePos{20, 26}}, Direction::SOUTH); + return step; +} +Pose r81_below_the_mouth(){ + return Pokemon::tile_pose("Route204North", {TilePos{20, 27}, TilePos{20, 28}, TilePos{20, 29}, TilePos{20, 30}}); +} + +StoryStep old_mine_hall_19(std::string name, Direction direction){ + StoryStep step; + step.kind = StoryStepKind::LEGS; + step.name = std::move(name); + step.legs = {{.direction = direction, .tiles = 19}}; + return step; +} + +StoryStep old_coal_room_crate_cut(){ + StoryStep step; + step.kind = StoryStepKind::LEGS; + step.name = "to_roarks_corner"; + step.legs = { + {.direction = Direction::EAST, .tiles = 1}, {.direction = Direction::SOUTH, .tiles = 2}, + {.direction = Direction::WEST, .tiles = 1}, {.direction = Direction::SOUTH, .tiles = 5}, + {.direction = Direction::EAST, .tiles = 14}, {.direction = Direction::SOUTH, .tiles = 10}, + {.direction = Direction::SOUTH, .tiles = 2}, {.direction = Direction::WEST, .tiles = 11}, + }; + return step; +} + + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h new file mode 100644 index 0000000000..a9dabdf0bb --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h @@ -0,0 +1,50 @@ +/* BDSP AutoStory - Old story steps + * + * From: https://github.com/PokemonAutomation/ + * + * Steps the story table had that went wrong on the console, as they were: + * the story simulation's regression tests run them in place of the + * table's step of the same name and check they still go wrong there. + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_OldStorySteps_H +#define PokemonAutomation_PokemonBDSP_AutoStory_OldStorySteps_H + +#include +#include "Pokemon/AutoStory/Pokemon_StorySteps.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +// r75: out of the Oreburgh Gate as a run west until Route 203's banner +// (the old event west_until_transition()). The banner reads a few tiles +// in: the run ends west of the Gate's warp tile (55, 9), in the pocket by +// the pond (Route 203's x 49 to 54, rows 6 to 13). +Pokemon::StoryStep r75_old_gate_exit(); +// Where r75's run west ended: the pocket by Route 203's pond. +Pokemon::Pose r75_pond_pocket(); + +// r81: out of the Ravaged Path as a timed walk south (the old event's +// 4 s walk_dir()), its fade missed: on past cave_exit (20, 26) to the +// cliff, column 20 down to row 30. +Pokemon::StoryStep r81_old_cave_exit(); +// Where r81's walk south ended: below the Ravaged Path's mouth. +Pokemon::Pose r81_below_the_mouth(); + +// Oreburgh Mine B1F: tapping 19 tiles leaves the player 1 tile short of the warp door. +Pokemon::StoryStep old_mine_hall_19(std::string name, Pokemon::Direction direction); + +// Oreburgh Mine: stepping south at col 29 without bypassing the crate +// hits the wooden crate at (29, 28) on the south leg, a tile down. +Pokemon::StoryStep old_coal_room_crate_cut(); + + + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp index 85f4792206..753d084692 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp @@ -41,6 +41,7 @@ #include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_CoordEvents.h" #include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Maps.h" #include "PokemonBDSP_AutoStory_GridSim.h" +#include "PokemonBDSP_AutoStory_OldStorySteps.h" #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h" #include "PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h" #include "PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h" @@ -740,44 +741,6 @@ UnitTestResult run_exit_test(Logger& logger, const std::string& row_id, const St return true; } -// r75: out of the Oreburgh Gate as a run west until Route 203's banner -// (the old event west_until_transition()). The banner reads a few tiles -// in: the run ends west of the Gate's warp tile (55, 9), in the pocket by -// the pond (Route 203's x 49 to 54, rows 6 to 13). -StoryStep r75_old_gate_exit(){ - StoryStep step; - step.kind = StoryStepKind::LEGS; - step.name = "out_of_oreburgh_gate"; - step.legs = {{.direction = Direction::WEST, .tiles = 8}}; - step.variant = "to_map"; - step.pose_after = Pokemon::tile_pose("Route203", {TilePos{55, 9}}, Direction::WEST); - return step; -} -Pose r75_pond_pocket(){ - std::vector tiles; - for (int y = 6; y <= 13; y++){ - for (int x = 49; x <= 54; x++){ - tiles.push_back({x, y}); - } - } - return Pokemon::tile_pose("Route203", tiles); -} -// r81: out of the Ravaged Path as a timed walk south (the old event's -// 4 s walk_dir()), its fade missed: on past cave_exit (20, 26) to the -// cliff, column 20 down to row 30. -StoryStep r81_old_cave_exit(){ - StoryStep step; - step.kind = StoryStepKind::LEGS; - step.name = "out_of_the_ravaged_path"; - step.legs = {{.direction = Direction::SOUTH, .tiles = 4}}; - step.variant = "to_wall"; - step.pose_after = Pokemon::tile_pose("Route204North", {TilePos{20, 26}}, Direction::SOUTH); - return step; -} -Pose r81_below_the_mouth(){ - return Pokemon::tile_pose("Route204North", {TilePos{20, 27}, TilePos{20, 28}, TilePos{20, 29}, TilePos{20, 30}}); -} - UnitTestResult test_coord_events(Logger&){ for (const auto& [map, json] : bdsp_map_json()){ const StoryWorld* world = story_plan_world(map, map); @@ -860,30 +823,6 @@ UnitTestResult test_exit_ravaged_path(Logger& logger){ return run_exit_test(logger, "01.09", r81_old_cave_exit(), SimMisses{.fade = 0, .banner = std::nullopt}, r81_below_the_mouth()); } -// Oreburgh Mine B1F: tapping 19 tiles leaves the player 1 tile short of the warp door. -StoryStep old_mine_hall_19(std::string name, Direction direction){ - StoryStep step; - step.kind = StoryStepKind::LEGS; - step.name = std::move(name); - step.legs = {{.direction = direction, .tiles = 19}}; - return step; -} - -// Oreburgh Mine: stepping south at col 29 without bypassing the crate -// hits the wooden crate at (29, 28) on the south leg, a tile down. -StoryStep old_coal_room_crate_cut(){ - StoryStep step; - step.kind = StoryStepKind::LEGS; - step.name = "to_roarks_corner"; - step.legs = { - {.direction = Direction::EAST, .tiles = 1}, {.direction = Direction::SOUTH, .tiles = 2}, - {.direction = Direction::WEST, .tiles = 1}, {.direction = Direction::SOUTH, .tiles = 5}, - {.direction = Direction::EAST, .tiles = 14}, {.direction = Direction::SOUTH, .tiles = 10}, - {.direction = Direction::SOUTH, .tiles = 2}, {.direction = Direction::WEST, .tiles = 11}, - }; - return step; -} - UnitTestResult test_story_sim_step_failure(Logger& logger, const std::string& row, const StoryStep& old_step, const std::string& expected_failed_step, const std::string& expected_error){ SimExecutor executor(logger); const std::vector rows = table_with(row, old_step); diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 437d83cce7..c6a21120c8 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1707,6 +1707,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryPlaces.cpp Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryPlaces.h + Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp + Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp From 26b4ed4aeefe533d34f06823da161c60b1292bf7 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 8 Nov 2026 16:35:01 -0800 Subject: [PATCH 3/4] BDSP AutoStory: a dim cave floor is not a tap step's fade On lab-B (2026-11-08 15:31 to 15:54) 01.05's walk slid into the Oreburgh Gate, and its tap step read the Gate's floor (about 46) as the fade and waited 8 s for a banner already gone. A look after a tap is the fade only when black (< 25) or a drop to dark from the look before the tap (tap_faded()). A banner before the first tap means the walk before took us through: the step ends with no tap. A tap step taps at most two past the door its map has ahead, so one begun through the warp with its banner gone fails a few tiles in, not across the Gate. Tests: tap_faded() on the Gate's floor and real fades; the story sim's 01.05 tap step begun through the Gate's mouth, banner up and gone (red before: 24 taps across the Gate); GridSim's part-tile offset taking the warp on the old open walk west. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_StoryStepIO.cpp | 42 ++++++++++++---- .../PokemonBDSP_AutoStory_StoryStepIO.h | 9 +++- .../PokemonBDSP_AutoStory_StoryWalkSteps.cpp | 48 ++++++++++++++++--- .../PokemonBDSP_AutoStory_StoryWalkSteps.h | 2 +- .../PokemonBDSP_AutoStory_Walk_Tests.cpp | 33 +++++++++++++ .../PokemonBDSP_AutoStory_GridSim_Tests.cpp | 28 +++++++++++ .../PokemonBDSP_AutoStory_OldStorySteps.cpp | 10 ++++ .../PokemonBDSP_AutoStory_OldStorySteps.h | 4 ++ .../PokemonBDSP_AutoStory_StorySim_Tests.cpp | 48 +++++++++++++++++-- 9 files changed, 202 insertions(+), 22 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp index 299796c325..c0d9661af7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp @@ -213,8 +213,11 @@ enum class TapLook{ BANNER, }; -// Looks for the location banner `banner` (and, if `dark_too`, the fade) -// for up to `wait`. +// The mean of r, g and b over the screen, 0 to 255; 255 with no frame. +double brightness_of(const VideoSnapshot& screen){ + return screen ? image_average(*screen.frame).sum() / 3 : 255; +} + void keep_banner_frame(const ImageViewRGB32& frame, const std::string& folder, const std::string& banner){ Filesystem::create_directories(Filesystem::Path(folder)); frame.save(folder + now_to_filestring() + "-" + normalize_location_name(banner) + ".png"); @@ -228,10 +231,12 @@ void log_new_banner_read(VideoStream& stream, const std::string& read, std::stri last_read = read; } +// Looks for the location banner `banner` for up to `wait`, and with +// `before` (the brightness before the tap) for the fade (tap_faded()). // Logs each distinct banner read and how the wait ended: the Oreburgh Gate's // entry missed its banner twice (lab-B, 2026-11-08 15:31 and 15:39) though // a hand probe saw it 1.5 s after the fade, and nothing said why. -TapLook look_after_tap(VideoStream& stream, ProControllerContext& context, const std::string& banner, Milliseconds wait, bool dark_too){ +TapLook look_after_tap(VideoStream& stream, ProControllerContext& context, const std::string& banner, Milliseconds wait, std::optional before){ const WallClock start = current_time(); const WallClock deadline = start + wait; std::string last_read; @@ -243,7 +248,7 @@ TapLook look_after_tap(VideoStream& stream, ProControllerContext& context, const while (true){ context.wait_for_all_requests(); const VideoSnapshot screen = stream.video().snapshot(); - if (!dark_too && screen && current_time() >= next_frame){ + if (!before && screen && current_time() >= next_frame){ keep_banner_frame(*screen.frame, folder, banner); next_frame += 500ms; } @@ -252,9 +257,9 @@ TapLook look_after_tap(VideoStream& stream, ProControllerContext& context, const if (screen && location_banner_matches(read, banner)){ return TapLook::BANNER; } - const double brightness = screen ? image_average(*screen.frame).sum() / 3 : 255; + const double brightness = brightness_of(screen); darkest = std::min(darkest, brightness); - if (dark_too && brightness < FADE_DARKNESS){ + if (before && tap_faded(*before, brightness)){ return TapLook::DARK; } if (current_time() >= deadline){ @@ -269,6 +274,16 @@ TapLook look_after_tap(VideoStream& stream, ProControllerContext& context, const } // namespace +// Black as the Gym's door fades (< 25), or a drop to dark: a look under +// FADE_DARKNESS is not a fade by itself, since a cave's floor is that dim +// (the Oreburgh Gate's about 46, lab-B 2026-11-08), but a fade into a cave +// from a lit street goes from about 120 to 45..64. +constexpr double TAP_FADE_BLACK = 25; +constexpr double TAP_FADE_DROP = 0.7; +bool tap_faded(double before, double after){ + return after < TAP_FADE_BLACK || (after < FADE_DARKNESS && after < before * TAP_FADE_DROP); +} + ConsoleStoryStepIO::ConsoleStoryStepIO(VideoStream& stream, ProControllerContext& context) : m_stream(stream) , m_context(context) @@ -305,15 +320,23 @@ bool ConsoleStoryStepIO::run_into_door(Direction direction, bool run, Millisecon // A held walk can carry on past a fade that goes unseen: out of the Gym it // walked on south (r219g), and through the Oreburgh Gate's west mouth on // west into a pocket by Route 203's pond (r75). Taps during the fade are -// eaten. +// eaten. The banner before the first tap means we are through already: +// the walk before slid onto the warp (lab-B 2026-11-08 15:31). std::optional ConsoleStoryStepIO::tap_to_banner(Direction direction, const std::string& map, size_t max_taps){ const std::string& banner = story_banner_name(map); + m_context.wait_for_all_requests(); + VideoSnapshot screen = m_stream.video().snapshot(); + if (screen && location_banner_matches(read_location_banner(*screen.frame), banner)){ + m_stream.log("[Banner] \"" + banner + "\" shows before the first tap: through already."); + return 0; + } for (size_t tap = 1; tap <= max_taps; tap++){ + const double before = brightness_of(screen); pbf_press_dpad(m_context, dpad_toward(direction), 160ms, 0ms); - TapLook look = look_after_tap(m_stream, m_context, banner, 1500ms, true); + TapLook look = look_after_tap(m_stream, m_context, banner, 1500ms, before); const bool faded = look == TapLook::DARK; if (faded){ - look = look_after_tap(m_stream, m_context, banner, 8000ms, false); + look = look_after_tap(m_stream, m_context, banner, 8000ms, std::nullopt); } if (look == TapLook::BANNER){ m_context.wait_for(1000ms); @@ -322,6 +345,7 @@ std::optional ConsoleStoryStepIO::tap_to_banner(Direction direction, con if (faded){ break; } + screen = m_stream.video().snapshot(); } return std::nullopt; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.h index 52470d8fcd..a48007ee2f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.h @@ -51,7 +51,8 @@ class StoryStepIO{ // D-pad taps `direction` one at a time, each looked at, toward a door // or cave mouth, until the fade (then no more taps) and the location // banner of `map` (a JSON map's name), for at most `max_taps`. Returns - // the taps it took, or nothing if no banner showed. + // the taps it took (0 if the banner shows before the first: through + // already), or nothing if no banner showed. virtual std::optional tap_to_banner(Pokemon::Direction direction, const std::string& map, size_t max_taps) = 0; // Presses through any text until the overworld is quiet; with `fade`, a // fade must come first (a map change). Fails otherwise. @@ -59,6 +60,12 @@ class StoryStepIO{ }; +// Whether a look after a tap toward a door or a cave mouth shows its fade, +// from its brightness `after` and that of the look before the tap, +// `before` (the mean of r, g and b, 0 to 255). +bool tap_faded(double before, double after); + + // The console. class ConsoleStoryStepIO : public StoryStepIO{ public: diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp index 514efc1725..8a0d50e0b9 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp @@ -158,16 +158,52 @@ Outcome StoryWalkSteps::leg_to_map(const StoryStep& step){ return arrived ? Pokemon::outcome_ok() : Pokemon::outcome_failed("no_banner", map); } +namespace{ +// Taps toward a door with no table door ahead of it. +constexpr size_t TAPS_TO_BANNER = 30; +// How many taps `direction` a tap step from `from` takes at most: the +// tiles to the door its map has ahead of every tile of `from`, and two +// more; TAPS_TO_BANNER where the map has none. A step through already, +// its banner gone, then stops a few tiles on (lab-B 2026-11-08: 01.05's +// walk slid into the Oreburgh Gate, whose row 22 runs 24 tiles on). +size_t taps_to_banner(const Pose& from, Direction direction){ + size_t most = 0; + try{ + const Pokemon::MapData& map = story_map(from.map); + for (const TilePos& pos : Pokemon::tiles_of(from)){ + const size_t tiles = Pokemon::tiles_to_door(map, pos, direction); + TilePos door = pos; + for (size_t i = 0; i < tiles; i++){ + door = door.next(direction); + } + if (tiles == 0 || map.tiles.at(door) != Pokemon::TileKind::DOOR){ + return TAPS_TO_BANNER; + } + most = std::max(most, tiles); + } + }catch (...){ + return TAPS_TO_BANNER; + } + return most == 0 ? TAPS_TO_BANNER : most + 2; +} +} // namespace + // A STEP "to_banner": D-pad taps toward a door or cave mouth until the fade // and pose_after's map's location banner. No banner fails the step right -// there. -Outcome StoryWalkSteps::tap_to_banner(const StoryStep& step){ +// there; a banner before any tap means the walk before took us through. +Outcome StoryWalkSteps::tap_to_banner(const Pose& from, const StoryStep& step){ const std::string map = step.pose_after ? step.pose_after->map : ""; - const std::optional taps = m_io.tap_to_banner(step.direction, map, 30); + const size_t limit = taps_to_banner(from, step.direction); + const std::optional taps = m_io.tap_to_banner(step.direction, map, limit); if (!taps){ - return Pokemon::outcome_failed("no_banner", map); + return Pokemon::outcome_failed("no_banner", std::format("{} in {} taps {}: through already, its banner gone?", + map, limit, direction_name(step.direction))); + } + if (*taps == 0){ + log(std::format("[{}] {}: {}'s banner before any tap: through already.", m_row, step.name, map)); + }else{ + log(std::format("[{}] {}: {}'s banner after {} taps {}.", m_row, step.name, map, *taps, direction_name(step.direction))); } - log(std::format("[{}] {}: {}'s banner after {} taps {}.", m_row, step.name, map, *taps, direction_name(step.direction))); return Pokemon::outcome_ok(); } @@ -340,7 +376,7 @@ Outcome StoryWalkSteps::legs(RunState& state, const StoryStep& step){ Outcome StoryWalkSteps::step(RunState& state, const StoryStep& step){ if (step.variant == "to_banner"){ turn(step.direction); - return tap_to_banner(step); + return tap_to_banner(state.pose, step); } if (step.variant == "tap"){ // No separate turn tap first: at 1 tile from the door, a turn tap diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.h index a25435dd55..a7c4aad024 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.h @@ -75,7 +75,7 @@ class StoryWalkSteps{ Pokemon::Outcome counted_wall(const Pokemon::Pose& from, const Pokemon::StoryStep& step); Pokemon::Outcome leg_to_dialogue(const Pokemon::StoryStep& step); Pokemon::Outcome leg_to_map(const Pokemon::StoryStep& step); - Pokemon::Outcome tap_to_banner(const Pokemon::StoryStep& step); + Pokemon::Outcome tap_to_banner(const Pokemon::Pose& from, const Pokemon::StoryStep& step); void turn(Pokemon::Direction direction); void log(const std::string& text); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp index 252f0ef541..4bacc207a3 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp @@ -15,6 +15,7 @@ #include "Utils/PokemonBDSP_AutoStory_Location.h" #include "Utils/PokemonBDSP_AutoStory_RouteWalk.h" #include "Actions/PokemonBDSP_AutoStory_Talks.h" +#include "PokemonBDSP_AutoStory_StoryStepIO.h" #include "PokemonBDSP_AutoStory_Walk_Tests.h" namespace PokemonAutomation{ @@ -120,6 +121,34 @@ UnitTestResult test_door_fade(Logger&){ return true; } +// A tap step's fade is a real one: black, or a drop to dark from the look +// before the tap. The Oreburgh Gate's floor, about 46 before and after a +// tap inside it, is no fade: read as one, the tap into the Gate from +// Oreburgh, already through, waited 8 s for a banner gone (lab-B, +// 2026-11-08 15:31 to 15:54). +UnitTestResult test_tap_fade(Logger&){ + struct Case{ + std::string name; + double before; + double after; + bool faded; + }; + const std::vector cases{ + {.name = "inside the Gate, its floor", .before = 46, .after = 46, .faded = false}, + {.name = "inside the Gate, a darker patch", .before = 52, .after = 44, .faded = false}, + {.name = "on a street", .before = 120, .after = 112, .faded = false}, + {.name = "the street into the Gate's mouth, to black", .before = 120, .after = 8, .faded = true}, + {.name = "the street into a cave, a dim fade (45 to 64 measured)", .before = 120, .after = 60, .faded = true}, + {.name = "out of the Gate, from its floor to black", .before = 46, .after = 12, .faded = true}, + }; + for (const Case& item : cases){ + if (tap_faded(item.before, item.after) != item.faded){ + return item.name + (item.faded ? ": no fade read." : ": read as a fade."); + } + } + return true; +} + UnitTestResult test_location_banner(Logger&){ struct Case{ @@ -285,6 +314,10 @@ const AutoStoryWalkCase AUTO_STORY_WALK_CASES[] = { .input = {"out of a door needs its fade", test_door_fade}, .expectation = {}, }, + { + .input = {"a tap into a door fades to black or drops to dark, not a dim floor (lab-B, 2026-11-08)", test_tap_fade}, + .expectation = {}, + }, { .input = {"location banner match", test_location_banner}, .expectation = {}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.cpp index 190f7409da..11ccb344d4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.cpp @@ -562,6 +562,30 @@ UnitTestResult test_roarks_room_from_a_row_off(Logger& logger){ return true; } +// lab-B 2026-11-08 15:31 to 15:54: 01.05's open walk west 3 from (5, 13), +// where Barry's push leaves us, to (2, 13) beside the Oreburgh Gate's mouth +// (1, 13) went on into the Gate. D-pad taps move whole tiles but keep a +// part-tile offset: 0.375 of a tile west of (5, 13), the three taps take +// the warp; on the tile, they stop beside it. +UnitTestResult test_gate_walk_part_tile_off(Logger&){ + const StoryWorld& world = *story_plan_world("OreburghCity", "OreburghCity"); + for (const bool off : {false, true}){ + GridSim sim({.world = &world}, story_to_world(world, "OreburghCity", {5, 13}), Direction::WEST, true); + if (off){ + sim.tap(Direction::WEST, 60ms, true); + } + SimStop stop = SimStop::DONE; + for (int tap = 0; tap < 3 && stop == SimStop::DONE; tap++){ + stop = sim.tap(Direction::WEST, 160ms, false).stop; + } + if ((stop == SimStop::WARP) != off){ + return std::format("{} (5, 13): three taps west ended {} at {}.", off ? "0.375 west of" : "on", + sim_stop_name(stop), to_string(sim.player().pos)); + } + } + return true; +} + UnitTestResult test_wandering_npc_mechanics(Logger& logger){ StoryWorld world = make_world({ "#######", @@ -909,6 +933,10 @@ const AutoStoryGridSimCase AUTO_STORY_GRID_SIM_CASES[] = { .input = {"01.03, Oreburgh Mine B1F entrance hall corridor runs to and back", test_oreburgh_mine_hall_corridor}, .expectation = {}, }, + { + .input = {"01.05, a part of a tile off, the old open walk west takes the Gate's warp (lab-B, 2026-11-08)", test_gate_walk_part_tile_off}, + .expectation = {}, + }, }; void add_tests_AutoStory_GridSim(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp index 1d7c4db01e..657513f382 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.cpp @@ -73,6 +73,16 @@ StoryStep old_coal_room_crate_cut(){ return step; } +StoryStep old_tap_into_the_gate(){ + StoryStep step; + step.kind = StoryStepKind::STEP; + step.name = "into_oreburgh_gate"; + step.direction = Direction::WEST; + step.variant = "to_banner"; + step.pose_after = Pokemon::tile_pose("OreburghGate", {TilePos{27, 22}, TilePos{26, 22}}, Direction::WEST); + return step; +} + } // namespace PokemonBDSP diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h index a9dabdf0bb..580eb84f32 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_OldStorySteps.h @@ -41,6 +41,10 @@ Pokemon::StoryStep old_mine_hall_19(std::string name, Pokemon::Direction directi // hits the wooden crate at (29, 28) on the south leg, a tile down. Pokemon::StoryStep old_coal_room_crate_cut(); +// 01.05's old tap into the Oreburgh Gate, west to its banner, after an +// open walk to the tile beside its mouth (1, 13) that slid onto the warp: +// the tap step began inside the Gate (lab-B 2026-11-08 15:31 to 15:54). +Pokemon::StoryStep old_tap_into_the_gate(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp index 753d084692..5f6a1a86b7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim_Tests.cpp @@ -71,13 +71,18 @@ using Pokemon::TilePos; // (run_until_map()) of the run goes unseen, though the player did go // through. The console missed both (r75, r81). The `dark`th door run reads // dark SIM_FALSE_DARK in, short of the door, as lab-B's did on 2026-11-08. -// The counts and flags below are the run's: how many fades and banners it -// looked for, whether a miss happened since the executor last looked, and -// whether a missed fade is still unseen. +// The `through`th tap step (tap_to_banner(), from 0) starts on its far side, +// its banner gone unless `through_banner`: the walk before it slid onto the +// warp (lab-B 2026-11-08). The counts and flags below are the run's: how +// many fades and banners it looked for, whether a miss happened since the +// executor last looked, and whether a missed fade is still unseen. struct SimMisses{ std::optional fade; std::optional banner; std::optional dark = {}; + std::optional through = {}; + bool through_banner = false; + size_t tap_steps = 0; size_t fades = 0; size_t banners = 0; size_t doors = 0; @@ -227,10 +232,17 @@ bool SimStoryStepIO::run_until_map(Direction direction, Milliseconds limit, cons } // D-pad taps, each looked at, until the fade and then the banner (the -// console's ConsoleStoryStepIO::tap_to_banner()). Each look stands still, -// so a banner on the far side reads at once. A fade seen ends the taps, +// console's ConsoleStoryStepIO::tap_to_banner()): none if the banner shows +// before the first. Each look stands still, so a banner on the far side +// reads at once. A fade seen ends the taps, // banner or not; with the fade missed the next look still sees the banner. std::optional SimStoryStepIO::tap_to_banner(Direction direction, const std::string& map, size_t max_taps){ + if (m_misses.through == m_misses.tap_steps++){ + m_misses.missed = true; + if (m_far_side() && m_misses.through_banner){ + return 0; + } + } bool crossed = false; for (size_t tap = 1; tap <= max_taps; tap++){ const SimMove move = m_sim.tap(direction, 160ms, false); @@ -823,6 +835,26 @@ UnitTestResult test_exit_ravaged_path(Logger& logger){ return run_exit_test(logger, "01.09", r81_old_cave_exit(), SimMisses{.fade = 0, .banner = std::nullopt}, r81_below_the_mouth()); } +// lab-B 2026-11-08 15:31 to 15:54: 01.05's walk to the tile beside the +// Oreburgh Gate's mouth slid onto the warp, and the tap step after it began +// inside the Gate. With its banner up, the step ends there with no tap and +// no fade (the clean run's fade into the Gate is not seen); with it gone, +// it fails a few taps on, not across the Gate. +UnitTestResult test_tap_through_already(Logger& logger, bool banner){ + const std::vector rows = table_with("01.05", old_tap_into_the_gate()); + SimExecutor clean(logger); + run_rows_on(clean, logger, {.from = "01.05", .to = "01.05"}, rows); + SimExecutor through(logger, {.fade = {}, .banner = {}, .through = 1, .through_banner = banner}); + run_rows_on(through, logger, {.from = "01.05", .to = "01.05"}, rows); + const SimRun& run = through.result(); + const std::optional at = run.world ? story_to_local(*run.world, "OreburghGate", run.end) : std::nullopt; + const bool passed = banner + ? run.error.empty() && through.misses().fades + 1 == clean.misses().fades + : run.failed_step == "01.05 into_oreburgh_gate" && at && at->y == 22 && at->x >= 21; + return passed ? UnitTestResult(true) : UnitTestResult(std::format("failed in '{}' on {} after {} fades (clean {}): {}", + run.failed_step, end_of(run), through.misses().fades, clean.misses().fades, run.error.empty() ? "no failure" : run.error)); +} + UnitTestResult test_story_sim_step_failure(Logger& logger, const std::string& row, const StoryStep& old_step, const std::string& expected_failed_step, const std::string& expected_error){ SimExecutor executor(logger); const std::vector rows = table_with(row, old_step); @@ -894,6 +926,12 @@ const AutoStoryStorySimCase AUTO_STORY_STORY_SIM_CASES[] = { }}, .expectation = {}}, {.input = {"r75, out of the Oreburgh Gate", test_exit_gate}, .expectation = {}}, {.input = {"r81, out of the Ravaged Path", test_exit_ravaged_path}, .expectation = {}}, + {.input = {"01.05, a tap step begun through the Gate's mouth, its banner up (lab-B, 2026-11-08)", [](Logger& logger){ + return test_tap_through_already(logger, true); + }}, .expectation = {}}, + {.input = {"01.05, a tap step begun through the Gate's mouth, its banner gone (lab-B, 2026-11-08)", [](Logger& logger){ + return test_tap_through_already(logger, false); + }}, .expectation = {}}, { .input = {"01.03, a dark frame 1.8 s down the mine's entrance hall is not its mouth (lab-B, 2026-11-08)", [](Logger& logger){ SimExecutor executor(logger, {.fade = {}, .banner = {}, .dark = 1}); From a6641e723c01f99d16fd54165e3e8c4c7b55839a Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 8 Nov 2026 16:43:51 -0800 Subject: [PATCH 4/4] BDSP AutoStory: mark the tap step's fade and through-already checks as stopgaps Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp index c0d9661af7..43df0cf73f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryStepIO.cpp @@ -278,6 +278,9 @@ TapLook look_after_tap(VideoStream& stream, ProControllerContext& context, const // FADE_DARKNESS is not a fade by itself, since a cave's floor is that dim // (the Oreburgh Gate's about 46, lab-B 2026-11-08), but a fade into a cave // from a lit street goes from about 120 to 45..64. +// TODO(#268 slice 3): stopgap. A uniform-screen fade watcher (the shared +// Black/WhiteScreen stddev test, as in upstream #1717) should replace this +// brightness drop; remove it once that watcher passes the Gate frames. constexpr double TAP_FADE_BLACK = 25; constexpr double TAP_FADE_DROP = 0.7; bool tap_faded(double before, double after){ @@ -322,6 +325,9 @@ bool ConsoleStoryStepIO::run_into_door(Direction direction, bool run, Millisecon // west into a pocket by Route 203's pond (r75). Taps during the fade are // eaten. The banner before the first tap means we are through already: // the walk before slid onto the warp (lab-B 2026-11-08 15:31). +// TODO(#268 slice 2): stopgap. The "through already" check sees only a +// banner still on screen; once walkers report the fade or banner they saw +// (WalkResult::warp), read that instead and remove this check. std::optional ConsoleStoryStepIO::tap_to_banner(Direction direction, const std::string& map, size_t max_taps){ const std::string& banner = story_banner_name(map); m_context.wait_for_all_requests();