From 303ed1b93081469f1dc0d85cfce0b4b9d0e55aaa Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 11:35:15 -0800 Subject: [PATCH 1/8] PokemonBDSP AutoStory: sim tests, Jubilife to the Center open legs and kids Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp index 394a8bc0b1..3e43cd0157 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -374,6 +374,9 @@ class SimulatedRouteIO : public RouteIO{ const TilePos& at() const{ return m_at; } + size_t tiles_walked() const{ + return m_walked; + } virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override{ count_call(); @@ -427,6 +430,7 @@ class SimulatedRouteIO : public RouteIO{ m_at = *next; moved++; } + m_walked += moved; return moved; } @@ -436,6 +440,7 @@ class SimulatedRouteIO : public RouteIO{ std::vector m_obstacles; std::vector& m_notes; size_t m_calls = 0; + size_t m_walked = 0; }; StoryWorld jubilife_world(){ @@ -480,6 +485,82 @@ UnitTestResult test_blocked_from_several_tiles(Logger&){ return true; } +size_t tiles_of(const std::vector& legs){ + size_t tiles = 0; + for (const PlannedLeg& leg : legs){ + tiles += leg.leg.tiles; + } + return tiles; +} + +// The fewest tiles from `from` to `goal` on Jubilife, open legs exact. +size_t jubilife_shortest(const StoryWorld& world, TilePos from, TilePos goal){ + const auto plan = plan_robust_route(world, from, goal, waypoint_plan_costs()); + return plan ? tiles_of(*plan) : 0; +} + +// lab-B 2026-11-11 11:16 (00.05 to_the_center from (48, 62)): "north 20 +// (open)" ended about 4 tiles short, by the kids at (52, 46) and (54, 46), +// and the replan went "west 33 (to wall)", "east 42 (to wall)". No open +// leg may run longer than one leg can (max_open_tiles), so a long stretch +// meets a wall on the way, and the plan stays near the shortest way. +UnitTestResult test_jubilife_center_open_legs(Logger& logger){ + const StoryWorld world = jubilife_world(); + const TilePos from{48, 62}; + const TilePos goal{52, 41}; + const RobustPlanCosts costs = town_plan_costs(); + const auto plan = plan_robust_route(world, from, goal, costs); + if (!plan){ + return "no plan from (48, 62)."; + } + std::string legs; + for (const PlannedLeg& leg : *plan){ + legs += " " + to_string(leg.leg); + } + logger.log("Jubilife to the Center:" + legs); + for (const PlannedLeg& leg : *plan){ + if (!leg.leg.ends_at_wall && leg.leg.tiles > (size_t)costs.max_open_tiles){ + return std::format("an open leg of {} tiles, over {}:{}", leg.leg.tiles, costs.max_open_tiles, legs); + } + } + const size_t least = jubilife_shortest(world, from, goal); + if (tiles_of(*plan) * 10 > least * 13){ + return std::format("walks {} tiles where {} would do:{}", tiles_of(*plan), least, legs); + } + return true; +} + +// The same walk on the console: the kids at (52, 46) and (54, 46) stop a +// walk north up their columns. The walker replans from where it stopped +// and reaches the Center without a long way round. +UnitTestResult test_jubilife_center_kids(Logger&){ + const StoryWorld world = jubilife_world(); + const TilePos from{48, 62}; + const TilePos goal{52, 41}; + std::vector notes; + SimulatedRouteIO io(world, from, {{52, 46}, {54, 46}}, notes); + RouteTrainers trainers{.sights = {}, .fight = [](const std::string&){}}; + try{ + walk_route(io, world, {from}, trainers, { + .goal = [goal](const TilePos& pos){ return pos == goal; }, + .label = "T", + .avoid = {}, + .costs = town_plan_costs(), + .speed = MoveSpeed::WALK, + }); + }catch (const RouteFailed& e){ + return "failed: " + e.message; + } + if (io.at() != goal){ + return "ended at " + Pokemon::to_string(io.at()) + ", not at (52, 41)."; + } + const size_t least = jubilife_shortest(world, from, goal); + if (io.tiles_walked() * 10 > least * 13 + 40){ + return std::format("walked {} tiles where {} would do.", io.tiles_walked(), least); + } + return true; +} + struct PlannedRouteInput{ std::string name; @@ -532,6 +613,14 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .input = {"blocked from several possible tiles routes around", test_blocked_from_several_tiles}, .expectation = {}, }, + { + .input = {"Jubilife to the Center: open legs no longer than one leg", test_jubilife_center_open_legs}, + .expectation = {}, + }, + { + .input = {"Jubilife to the Center past the kids", test_jubilife_center_kids}, + .expectation = {}, + }, }; void add_tests_AutoStory_PlannedRoute(UnitTestDatabase& database){ From 18304df226cc66f28a3fc8ecc7347c21a9e8c391 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 11:45:29 -0800 Subject: [PATCH 2/8] PokemonBDSP AutoStory: town plans keep straight open runs to one leg Open legs run together in one direction were tapped as one walk: "north 20 (open)" to Jubilife's Center ended about 4 tiles short on lab-B (2026-11-11). Town costs now cap a straight run of open legs at max_open_tiles, so a long stretch meets a wall on the way. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Data/PokemonBDSP_AutoStory_PlanCosts.cpp | 5 ++- .../Data/PokemonBDSP_AutoStory_RobustRoute.h | 4 +++ .../PokemonBDSP_AutoStory_RoutePlanner.cpp | 13 +++++-- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 34 +++++++++++++++---- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp index fed0c55f4c..cf4ca1d40b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp @@ -33,9 +33,12 @@ RobustPlanCosts town_plan_costs(){ // Open legs go on the D-pad now, a whole tile a tap, so they land exactly // at any length ("south 5" went 6 in r134a on stick holds). A wall at a // leg's end is still worth a little: r64 went 38 tiles round the town - // to end each leg on one, for 12 straight. + // to end each leg on one, for 12 straight. But only one leg's worth in a + // straight line: "north 20 (open)", two legs run together, ended about + // 4 tiles short in Jubilife (lab-B 2026-11-11). RobustPlanCosts costs; costs.exact_open_tiles = costs.max_open_tiles; + costs.max_open_run = costs.max_open_tiles; costs.per_open_tile = 1; costs.leg_not_at_wall = 4; return costs; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h index a54bdc1610..4808512c66 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h @@ -49,6 +49,10 @@ struct RobustPlanCosts : TilePlanCosts{ // so a short step after a wall beats a long open leg. int per_open_tile = 0; int max_open_tiles = 12; // longest open leg to consider + // Longest straight run of open legs one after another, 0 for no limit. + // Taps of one run lose count past about 12: on lab-B (2026-11-11) + // "north 20 (open)" through Jubilife ended about 4 tiles short. + int max_open_run = 0; size_t max_spread = 5; // most tiles the player may be on after a leg // Most sets of possible tiles to search before giving up. The search is // over sets, not tiles, so it grows far faster than the map: all of diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp index a89679cf16..39f23c1534 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp @@ -374,6 +374,7 @@ class RobustSearch{ Spread parent; PlannedLeg leg; bool done = false; + size_t open_run = 0; // tiles of the straight open run ending here }; using Entry = std::pair; struct EntryGreater{ @@ -402,18 +403,26 @@ class RobustSearch{ if (expansion.next.size() > m_costs.max_spread || expansion.next == spread){ return; } + size_t open_run = expansion.leg.ends_at_wall ? 0 : expansion.leg.tiles; if (spread != m_start){ - const TileLeg& prev = m_nodes.at(spread).leg.leg; + const Node& from = m_nodes.at(spread); + const TileLeg& prev = from.leg.leg; if (expansion.leg.direction == prev.direction && !prev.ends_at_wall){ expansion.cost -= m_costs.per_leg; + if (!expansion.leg.ends_at_wall){ + open_run += from.open_run; + } } } + if (m_costs.max_open_run > 0 && open_run > (size_t)m_costs.max_open_run){ + return; + } const long long total = cost + expansion.cost; auto iter = m_nodes.find(expansion.next); if (iter != m_nodes.end() && iter->second.cost <= total){ return; } - m_nodes[expansion.next] = Node{total, spread, PlannedLeg{expansion.leg, expansion.next}}; + m_nodes[expansion.next] = Node{total, spread, PlannedLeg{expansion.leg, expansion.next}, false, open_run}; m_queue.emplace(total, std::move(expansion.next)); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp index 3e43cd0157..1897dd26cd 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -385,11 +385,22 @@ class SimulatedRouteIO : public RouteIO{ return {.stop = WalkStop::BLOCKED, .walked = ROUTE_START_DELAY + 800ms + per_tile * moved + per_tile / 2, .wild_battles = 0, .moved_chunks = moved}; } + // Taps of more than `safe` tiles in one walk move `lost` tiles fewer, + // and the count does not see it (lab-B 2026-11-11 11:16: "north 20 + // (open)" ended about 4 tiles short). + void lose_on_long_taps(size_t safe, size_t lost){ + m_safe_taps = safe; + m_lost_taps = lost; + } + virtual WalkResult walk_taps(Direction direction, size_t tiles, const std::string&) override{ count_call(); - const size_t moved = move(direction, tiles); - return {.stop = moved < tiles ? WalkStop::BLOCKED : WalkStop::LIMIT, .walked = 250ms * tiles, - .wild_battles = 0, .moved_chunks = moved}; + const size_t lost = tiles > m_safe_taps ? std::min(m_lost_taps, tiles) : 0; + const size_t moved = move(direction, tiles - lost); + if (moved < tiles - lost){ + return {.stop = WalkStop::BLOCKED, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = moved}; + } + return {.stop = WalkStop::LIMIT, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = tiles}; } virtual void press(const RouteInput& input) override{ count_call(); @@ -441,6 +452,8 @@ class SimulatedRouteIO : public RouteIO{ std::vector& m_notes; size_t m_calls = 0; size_t m_walked = 0; + size_t m_safe_taps = SIZE_MAX; + size_t m_lost_taps = 0; }; StoryWorld jubilife_world(){ @@ -530,15 +543,18 @@ UnitTestResult test_jubilife_center_open_legs(Logger& logger){ return true; } -// The same walk on the console: the kids at (52, 46) and (54, 46) stop a -// walk north up their columns. The walker replans from where it stopped -// and reaches the Center without a long way round. +// The same walk on the console: "north 20 (open)" ended on row 46, about +// 4 tiles short, unseen, and the kids stand at (52, 46) and (54, 46). +// Taps longer than one open leg (max_open_tiles) lose 4 tiles here. The +// walker must still reach the Center without a long way round (the +// console replanned "west 33 (to wall)", "east 42 (to wall)"). UnitTestResult test_jubilife_center_kids(Logger&){ const StoryWorld world = jubilife_world(); const TilePos from{48, 62}; const TilePos goal{52, 41}; std::vector notes; SimulatedRouteIO io(world, from, {{52, 46}, {54, 46}}, notes); + io.lose_on_long_taps((size_t)town_plan_costs().max_open_tiles, 4); RouteTrainers trainers{.sights = {}, .fight = [](const std::string&){}}; try{ walk_route(io, world, {from}, trainers, { @@ -556,7 +572,11 @@ UnitTestResult test_jubilife_center_kids(Logger&){ } const size_t least = jubilife_shortest(world, from, goal); if (io.tiles_walked() * 10 > least * 13 + 40){ - return std::format("walked {} tiles where {} would do.", io.tiles_walked(), least); + std::string text; + for (const std::string& note : notes){ + text += "\n " + note; + } + return std::format("walked {} tiles where {} would do:{}", io.tiles_walked(), least, text); } return true; } From 48758b7e54a4b85b98200db9c762950f34f778c9 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 12:06:39 -0800 Subject: [PATCH 3/8] PokemonBDSP AutoStory: fault sweep, open legs coming up short Every story ROUTE step whose start the table knows is walked on the simulated console from each start tile, once as planned and once with every open leg of n tiles stopping min(4, n / 4) tiles early, unseen (lab-B 2026-11-11: "north 20 (open)" ended about 4 short). The sim no longer counts arrive()'s banner pauses as walker calls. Red: 31 of 62 routes end off their target with the fault (33 on #374). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 146 +++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp index 1897dd26cd..e8dd73bd91 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -22,6 +22,13 @@ #include "Data/PokemonBDSP_AutoStory_StoryTrainers.h" #include "Data/PokemonBDSP_AutoStory_TrainerSight.h" #include "Data/PokemonBDSP_AutoStory_WalkRules.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "Pokemon/AutoStory/Pokemon_TilePose.h" +#include "Pokemon/AutoStory/Types/Pokemon_GridPose.h" +#include "PokemonBDSP_AutoStory_StoryExecutor.h" +#include "PokemonBDSP_AutoStory_StoryPlaces.h" +#include "PokemonBDSP_AutoStory_StoryTable.h" +#include "Utils/PokemonBDSP_AutoStory_StoryLanguage.h" #include "Utils/PokemonBDSP_AutoStory_PlannedRoute.h" #include "Utils/PokemonBDSP_AutoStory_RouteIO.h" #include "Utils/PokemonBDSP_AutoStory_RouteTiming.h" @@ -37,6 +44,10 @@ namespace{ using namespace std::chrono_literals; using Pokemon::Direction; +using Pokemon::GridPose; +using Pokemon::Pose; +using Pokemon::StoryStep; +using Pokemon::StoryStepKind; using Pokemon::TilePos; @@ -392,10 +403,17 @@ class SimulatedRouteIO : public RouteIO{ m_safe_taps = safe; m_lost_taps = lost; } + // Fault class "open leg comes up short": an open leg of n tiles stops + // up to min(4, n / 4) tiles early, unseen (lab-B 2026-11-11: "north 20 + // (open)" ended about 4 short). Each open leg loses min(`lost`, that). + void stop_open_legs_short(size_t lost){ + m_short_open = lost; + } virtual WalkResult walk_taps(Direction direction, size_t tiles, const std::string&) override{ count_call(); - const size_t lost = tiles > m_safe_taps ? std::min(m_lost_taps, tiles) : 0; + const size_t long_lost = tiles > m_safe_taps ? std::min(m_lost_taps, tiles) : 0; + const size_t lost = std::max(long_lost, std::min({m_short_open, (size_t)4, tiles / 4})); const size_t moved = move(direction, tiles - lost); if (moved < tiles - lost){ return {.stop = WalkStop::BLOCKED, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = moved}; @@ -403,7 +421,11 @@ class SimulatedRouteIO : public RouteIO{ return {.stop = WalkStop::LIMIT, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = tiles}; } virtual void press(const RouteInput& input) override{ - count_call(); + // arrive() pauses for up to 3 s for a location banner the sim never + // shows: those pauses are not a walker that loops. + if (input.kind != RouteInputKind::PAUSE){ + count_call(); + } // A tap under 100 ms only turns (route_turn_tap()). if (input.kind == RouteInputKind::DPAD && input.hold >= 100ms){ move(input.direction, input.count); @@ -454,6 +476,7 @@ class SimulatedRouteIO : public RouteIO{ size_t m_walked = 0; size_t m_safe_taps = SIZE_MAX; size_t m_lost_taps = 0; + size_t m_short_open = 0; }; StoryWorld jubilife_world(){ @@ -581,6 +604,121 @@ UnitTestResult test_jubilife_center_kids(Logger&){ return true; } +// One ROUTE step of the story table, from where the steps before it end. +struct StoryRoute{ + std::string name; + Pose from; + Pose goal; + std::string costs; +}; + +// Every ROUTE step whose start the table knows: a row's start, a ROUTE's +// target or a step's pose_after. Steps after any other step start +// unknown and are left out. +void add_story_route(const std::string& row, const StoryStep& step, std::optional& at, std::vector& routes){ + if (step.kind == StoryStepKind::ROUTE){ + const Pose goal = Pokemon::pose_of(Pokemon::story_arg(step.args, "target")); + if (at){ + routes.push_back({std::format("{} {}", row, step.name), *at, goal, step.action}); + } + at = goal; + }else{ + at.reset(); + } + if (step.pose_after){ + at = Pokemon::pose_of(*step.pose_after); + } +} +std::vector story_routes(){ + std::vector routes; + for (const StoryCheckpoint& row : story_checkpoints()){ + std::optional at; + if (row.start){ + at = Pokemon::pose_of(*row.start); + } + for (const StoryStep& step : row.steps){ + add_story_route(row.id, step, at, routes); + } + } + return routes; +} + +// Walks `route` from each of its start tiles on the simulated console, +// every open leg `lost` tiles short (capped per leg). Returns the tiles +// walked from each start, or why it failed. +std::string sweep_story_route(const StoryRoute& route, size_t lost, std::vector& walked){ + const StoryWorld* world = story_plan_world(route.from.map, route.goal.map); + const std::optional costs = story_route_costs(route.costs); + if (world == nullptr || !costs){ + return route.name + ": no world or costs."; + } + std::vector targets; + for (const TilePos& pos : Pokemon::tiles_of(route.goal)){ + targets.push_back(story_to_world(*world, route.goal.map, pos)); + } + std::vector start; + for (const TilePos& pos : Pokemon::tiles_of(route.from)){ + start.push_back(story_to_world(*world, route.from.map, pos)); + } + for (const TilePos& from : start){ + std::vector notes; + SimulatedRouteIO io(*world, from, {}, notes); + io.stop_open_legs_short(lost); + RouteTrainers trainers{.sights = story_trainers(*world), .fight = [](const std::string&){}}; + try{ + walk_route(io, *world, start, trainers, { + .goal = [&](const TilePos& pos){ return std::find(targets.begin(), targets.end(), pos) != targets.end(); }, + .label = route.name, + .avoid = {}, + .costs = *costs, + .speed = MoveSpeed::WALK, + }); + }catch (const RouteFailed& e){ + std::string last; + for (size_t i = notes.size() > 4 ? notes.size() - 4 : 0; i < notes.size(); i++){ + last += "\n " + notes[i]; + } + return std::format("{} from {}, open legs {} short: {}{}", route.name, Pokemon::to_string(from), lost, e.message, last); + } + if (std::find(targets.begin(), targets.end(), io.at()) == targets.end()){ + return std::format("{} from {}, open legs {} short: ended at {}.", route.name, Pokemon::to_string(from), lost, Pokemon::to_string(io.at())); + } + walked.push_back(io.tiles_walked()); + } + return ""; +} + +// Fault sweep: every story route, walked with every open leg coming up +// short by 4 tiles (at most a quarter of the leg), still ends on its +// target. The log line per route gives the most tiles walked from any of +// its start tiles, without the fault and with it. +UnitTestResult test_story_routes_open_legs_short(Logger& logger){ + std::string failures; + const std::vector routes = story_routes(); + for (const StoryRoute& route : routes){ + std::string line = route.name + ":"; + for (size_t lost : {(size_t)0, (size_t)4}){ + std::vector walked; + const std::string error = sweep_story_route(route, lost, walked); + if (!error.empty()){ + failures += "\n " + error; + line += " FAIL"; + continue; + } + size_t most = 0; + for (size_t tiles : walked){ + most = std::max(most, tiles); + } + line += " " + std::to_string(most); + } + logger.log("[open legs short: 0, 4] " + line); + } + if (!failures.empty()){ + return std::format("{} routes swept:{}", routes.size(), failures); + } + return true; +} + struct PlannedRouteInput{ std::string name; @@ -641,6 +779,10 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .input = {"Jubilife to the Center past the kids", test_jubilife_center_kids}, .expectation = {}, }, + { + .input = {"fault sweep: every story route with open legs coming up short", test_story_routes_open_legs_short}, + .expectation = {}, + }, }; void add_tests_AutoStory_PlannedRoute(UnitTestDatabase& database){ From 954ae877bac09b6fd4fdebcfcb27d00386126485 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 12:52:37 -0800 Subject: [PATCH 4/8] BDSP AutoStory: golden test for every story route's planned legs Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_PlanGolden.h | 301 ++++++++++++++++++ ...onBDSP_AutoStory_StorySimulation_Tests.cpp | 49 +++ SerialPrograms/cmake/SourceFiles.cmake | 1 + 3 files changed, 351 insertions(+) create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h new file mode 100644 index 0000000000..447c356777 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -0,0 +1,301 @@ +/* BDSP AutoStory Plan Golden + * + * From: https://github.com/PokemonAutomation/ + * + * The legs the planner plans for every ROUTE of the story simulation + * (PokemonBDSP_AutoStory_StorySimulation_Tests.cpp, "plans match the + * golden"): per route a header " costs= from + * to ", then one line per leg with the tiles it may end on. + * One string per line: MSVC caps a single literal at 16 KB. + * Regenerate from the test's failure log; see test_golden_plans(). + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_PlanGolden_H +#define PokemonAutomation_PokemonBDSP_AutoStory_PlanGolden_H + +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + +// The stored plan lines, in the order the simulation plans them. +inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { + "00.01 below_the_flute costs=default from PlayerHouse2F (4, 6) to PlayerHouse2F (7, 5)", + "00.01 north 1 (to wall) -> PlayerHouse2F (4, 5)", + "00.01 east 3 (open) -> PlayerHouse2F (7, 5)", + "00.01 onto_the_flute_tile costs=default from PlayerHouse2F (7, 5) to PlayerHouse2F (8, 4)", + "00.01 north 1 (to wall) -> PlayerHouse2F (7, 4)", + "00.01 east 1 (to wall) -> PlayerHouse2F (8, 4)", + "00.01 above_the_door costs=default from PlayerHouse1F (10, 3) (10, 4) to PlayerHouse1F (6, 9)", + "00.01 south 7 (to wall) -> PlayerHouse1F (10, 10)", + "00.01 north 1 (open) -> PlayerHouse1F (10, 9)", + "00.01 west 4 (open) -> PlayerHouse1F (6, 9)", + "00.01 short_of_barrys_door costs=default from TwinleafTown (20, 22) to TwinleafTown (10, 12)", + "00.01 west 7 (open) -> Twinleaf Town (13, 22)", + "00.01 north 10 (to wall) -> Twinleaf Town (13, 12)", + "00.01 west 3 (open) -> Twinleaf Town (10, 12)", + "00.01 back_onto_barrys_doorstep costs=default from TwinleafTown (9, 13) to TwinleafTown (9, 12)", + "00.01 north 1 (open) -> Twinleaf Town (9, 12)", + "00.01 below_barrys_stairs costs=default from RivalHouse1F (6, 9) to RivalHouse1F (2, 3)", + "00.01 west 4 (to wall) -> RivalHouse1F (2, 9)", + "00.01 north 6 (to wall) -> RivalHouse1F (2, 3)", + "00.01 above_barrys_stairs costs=default from RivalHouse2F (3, 5) to RivalHouse2F (3, 4)", + "00.01 north 1 (to wall) -> RivalHouse2F (3, 4)", + "00.01 above_barrys_door costs=default from RivalHouse1F (2, 3) to RivalHouse1F (6, 9)", + "00.01 south 6 (open) -> RivalHouse1F (2, 9)", + "00.01 east 4 (open) -> RivalHouse1F (6, 9)", + "00.01 below_barrys_warning costs=default from TwinleafTown (9, 12) to Route201 (15, 19)", + "00.01 east 6 (open) -> Twinleaf Town (15, 12)", + "00.01 north 24 (to wall) -> Route 201 (15, 13)", + "00.01 south 6 (open) -> Route 201 (15, 19)", + "00.01 away_from_barry costs=default from Route201 (15, 18) to Route201 (12, 17)", + "00.01 north 1 (open) -> Route 201 (15, 17)", + "00.01 west 3 (open) -> Route 201 (12, 17)", + "00.01 below_the_lake_entrance costs=default from Route201 (12, 17) to VerityLakefront (17, 14)", + "00.01 north 1 (open) -> Route 201 (12, 16)", + "00.01 west 26 (to wall) -> Verity Lakefront (18, 23)", + "00.01 north 9 (to wall) -> Verity Lakefront (18, 14)", + "00.01 west 1 (open) -> Verity Lakefront (17, 14)", + "00.02 to_the_lake_entrance costs=default from VerityLakefront (17, 14) to VerityLakefront (17, 13)", + "00.02 north 1 (open) -> Verity Lakefront (17, 13)", + "00.03 short_of_rowan costs=default from VerityLakefront (17, 14) (17, 15) to Route201 (4, 14)", + "00.03 south 7 (to wall) -> Verity Lakefront (17, 21)", + "00.03 east 19 (open) -> Route 201 (4, 14)", + "00.03 by_the_counter costs=default from PlayerHouse1F (5, 8) (6, 8) to PlayerHouse1F (4, 8)", + "00.03 west 2 (to wall) -> PlayerHouse1F (4, 8)", + "00.03 above_the_door_again costs=default from PlayerHouse1F (4, 8) to PlayerHouse1F (6, 9)", + "00.03 east 2 (open) -> PlayerHouse1F (6, 8)", + "00.03 south 1 (open) -> PlayerHouse1F (6, 9)", + "00.03 short_of_dawn costs=default from TwinleafTown (20, 22) to Route201 (63, 5)", + "00.03 west 3 (open) -> Twinleaf Town (17, 22)", + "00.03 north 34 (to wall) -> Route 201 (17, 13)", + "00.03 east 40 (to wall) -> Route 201 (57, 13)", + "00.03 west 7 (open) -> Route 201 (50, 13)", + "00.03 north 10 (to wall) -> Route 201 (50, 3)", + "00.03 east 13 (to wall) -> Route 201 (63, 3)", + "00.03 south 2 (open) -> Route 201 (63, 5)", + "00.04 onto_the_path costs=town from SandgemTown (26, 11) (27, 11) (28, 11) (26, 12) (27, 12) (28, 12) to SandgemTown (29, 12)", + "00.04 east 3 (to wall) -> Sandgem Town (29, 11) Sandgem Town (29, 12)", + "00.04 north 1 (to wall) -> Sandgem Town (29, 11)", + "00.04 south 1 (open) -> Sandgem Town (29, 12)", + "00.04 home costs=default from Route201 (57, 5) (58, 5) (59, 5) (60, 5) (61, 5) (62, 5) (63, 5) to TwinleafTown (20, 22) (20, 23) (20, 24) (20, 25) (20, 26)", + "00.04 west 21 (to wall) -> Route 201 (42, 5)", + "00.04 south 4 (open) -> Route 201 (42, 9)", + "00.04 west 28 (to wall) -> Route 201 (14, 9)", + "00.04 south 42 (to wall) -> Twinleaf Town (14, 26)", + "00.04 east 6 (open) -> Twinleaf Town (20, 26)", + "00.04 beside_mom costs=default from PlayerHouse1F (6, 9) to PlayerHouse1F (6, 7)", + "00.04 north 2 (open) -> PlayerHouse1F (6, 7)", + "00.04 around_mom costs=default from PlayerHouse1F (6, 7) to PlayerHouse1F (5, 9)", + "00.04 south 2 (open) -> PlayerHouse1F (6, 9)", + "00.04 west 1 (to wall) -> PlayerHouse1F (5, 9)", + "00.04 short_of_the_catch_tutorial costs=default from TwinleafTown (19, 22) to Route202 (22, 27)", + "00.04 west 2 (open) -> Twinleaf Town (17, 22)", + "00.04 north 34 (to wall) -> Route 201 (17, 13)", + "00.04 east 40 (to wall) -> Route 201 (57, 13)", + "00.04 west 7 (open) -> Route 201 (50, 13)", + "00.04 north 7 (open) -> Route 201 (50, 6)", + "00.04 east 43 (to wall) -> Sandgem Town (29, 13)", + "00.04 west 5 (open) -> Sandgem Town (24, 13)", + "00.04 north 21 (to wall) -> Route 202 (25, 24)", + "00.04 west 3 (to wall) -> Route 202 (22, 24)", + "00.04 south 3 (open) -> Route 202 (22, 27)", + "00.04b to_catch_grass costs=default from Route202 (15, 25) (16, 25) (17, 25) (18, 25) (19, 25) (20, 25) (21, 25) (15, 26) (16, 26) (17, 26) (18, 26) (19, 26) (20, 26) (21, 26) (15, 27) (16, 27) (17, 27) (18, 27) (19, 27) (20, 27) (21, 27) (21, 28) (21, 29) to Route202 (18, 25) (19, 25) (20, 25) (18, 26) (19, 26) (20, 26) (18, 27) (19, 27) (20, 27)", + "00.04b east 15 (to wall) -> Route 202 (23, 25) Route 202 (30, 26) Route 202 (30, 27) Route 202 (30, 28) Route 202 (30, 29)", + "00.04b north 5 (to wall) -> Route 202 (23, 24) Route 202 (30, 24)", + "00.04b west 8 (to wall) -> Route 202 (22, 24)", + "00.04b south 1 (open) -> Route 202 (22, 25)", + "00.04b west 2 (open) -> Route 202 (20, 25)", + "00.04b into_sandgem costs=robust from Route202 (18, 25) (19, 25) (20, 25) (18, 26) (19, 26) (20, 26) (18, 27) (19, 27) (20, 27) to SandgemTown (29, 5)", + "00.04b south 2 (to wall) -> Route 202 (18, 27) Route 202 (19, 27) Route 202 (20, 27)", + "00.04b east 12 (to wall) -> Route 202 (30, 27)", + "00.04b south 10 (to wall) -> Sandgem Town (29, 5)", + "00.04b below_center_door costs=town from SandgemTown (29, 5) to SandgemTown (17, 11)", + "00.04b west 5 (open) -> Sandgem Town (24, 5)", + "00.04b south 6 (open) -> Sandgem Town (24, 11)", + "00.04b west 7 (open) -> Sandgem Town (17, 11)", + "00.04d north_to_jubilife costs=default from Route202 (30, 24) to Route202 (11, 0) (12, 0) (13, 0) (14, 0) (15, 0) (16, 0) (17, 0) (18, 0) (11, 1) (12, 1) (13, 1) (14, 1) (15, 1) (16, 1) (17, 1) (18, 1) (11, 2) (12, 2) (13, 2) (14, 2) (15, 2) (16, 2) (17, 2) (18, 2) (11, 3) (12, 3) (13, 3) (14, 3) (15, 3) (16, 3) (17, 3) (18, 3)", + "00.04d south 2 (open) -> Route 202 (30, 26)", + "00.04d west 27 (to wall) -> Route 202 (3, 26)", + "00.04d north 12 (to wall) -> Route 202 (3, 14)", + "00.04d east 14 (to wall) -> Route 202 (17, 14)", + "00.04d south 8 (to wall) -> Route 202 (17, 22)", + "00.04d east 13 (to wall) -> Route 202 (30, 22)", + "00.04d north 18 (to wall) -> Route 202 (30, 4)", + "00.04d south 1 (open) -> Route 202 (30, 5)", + "00.04d west 12 (open) -> Route 202 (18, 5)", + "00.04d north 2 (open) -> Route 202 (18, 3)", + "00.05 to_the_center costs=town from JubilifeCity (48, 62) to JubilifeCity (52, 41)", + "00.05 west 1 (open) -> Jubilife City (47, 62)", + "00.05 north 5 (open) -> Jubilife City (47, 57)", + "00.05 east 3 (open) -> Jubilife City (50, 57)", + "00.05 north 16 (to wall) -> Jubilife City (50, 41)", + "00.05 east 2 (open) -> Jubilife City (52, 41)", + "00.05 to_the_school costs=town from JubilifeCity (52, 41) to JubilifeCity (40, 41)", + "00.05 west 12 (open) -> Jubilife City (40, 41)", + "00.05b below_the_presidents_trigger costs=town from JubilifeCity (40, 41) to JubilifeCity (46, 41)", + "00.05b east 6 (open) -> Jubilife City (46, 41)", + "00.05b past_the_president costs=default from JubilifeCity (46, 40) to JubilifeCity (48, 40)", + "00.05b east 2 (open) -> Jubilife City (48, 40)", + "00.05b below_the_mart_clown costs=town from JubilifeCity (48, 40) to JubilifeCity (55, 34)", + "00.05b north 6 (open) -> Jubilife City (48, 34)", + "00.05b east 7 (open) -> Jubilife City (55, 34)", + "00.05b below_the_tv_clown costs=town from JubilifeCity (55, 34) to JubilifeCity (36, 17)", + "00.05b west 23 (to wall) -> Jubilife City (32, 34)", + "00.05b north 10 (open) -> Jubilife City (32, 24)", + "00.05b east 4 (open) -> Jubilife City (36, 24)", + "00.05b north 7 (open) -> Jubilife City (36, 17)", + "00.05b below_the_company_clown costs=town from JubilifeCity (36, 17) to JubilifeCity (15, 19)", + "00.05b south 4 (open) -> Jubilife City (36, 21)", + "00.05b west 9 (open) -> Jubilife City (27, 21)", + "00.05b south 4 (to wall) -> Jubilife City (27, 25)", + "00.05b west 12 (open) -> Jubilife City (15, 25)", + "00.05b north 6 (open) -> Jubilife City (15, 19)", + "00.05c below_the_president costs=town from JubilifeCity (15, 19) to JubilifeCity (46, 36)", + "00.05c south 8 (to wall) -> Jubilife City (15, 27)", + "00.05c east 11 (to wall) -> Jubilife City (26, 27)", + "00.05c north 3 (open) -> Jubilife City (26, 24)", + "00.05c east 11 (open) -> Jubilife City (37, 24)", + "00.05c south 1 (to wall) -> Jubilife City (37, 25)", + "00.05c east 7 (open) -> Jubilife City (44, 25)", + "00.05c south 11 (open) -> Jubilife City (44, 36)", + "00.05c east 2 (open) -> Jubilife City (46, 36)", + "00.05c to_the_route_203_street costs=town from JubilifeCity (46, 36) to JubilifeCity (58, 22)", + "00.05c east 1 (open) -> Jubilife City (47, 36)", + "00.05c north 9 (open) -> Jubilife City (47, 27)", + "00.05c east 9 (to wall) -> Jubilife City (56, 27)", + "00.05c north 5 (open) -> Jubilife City (56, 22)", + "00.05c east 2 (open) -> Jubilife City (58, 22)", + "01.01 west_of_barrys_trigger costs=town from JubilifeCity (58, 22) to Route203 (4, 18)", + "01.01 east 9 (open) -> Route 203 (4, 18)", + "01.02 south_to_the_cliff costs=default from Route203 (5, 17) (5, 18) (5, 19) (5, 20) to Route203 (5, 20)", + "01.02 south 3 (to wall) -> Route 203 (5, 20)", + "01.02 by_the_gate costs=default from Route203 (5, 20) to Route203 (55, 9)", + "01.02 north 2 (open) -> Route 203 (5, 18)", + "01.02 east 50 (to wall) -> Route 203 (55, 18)", + "01.02 north 9 (open) -> Route 203 (55, 9)", + "01.02 west_of_the_hikers_trigger costs=default from OreburghGate (4, 22) (5, 22) to OreburghGate (6, 22)", + "01.02 south 1 (to wall) -> OreburghGate (4, 23) OreburghGate (5, 23)", + "01.02 east 2 (to wall) -> OreburghGate (6, 23)", + "01.02 north 1 (open) -> OreburghGate (6, 22)", + "01.02 past_curtis costs=default from OreburghGate (7, 22) to OreburghGate (20, 22)", + "01.02 east 13 (open) -> OreburghGate (20, 22)", + "01.02 by_the_east_mouth costs=default from OreburghGate (20, 22) to OreburghGate (27, 22)", + "01.02 east 7 (open) -> OreburghGate (27, 22)", + "01.02 west_of_the_welcome costs=default from OreburghCity (2, 13) (3, 13) to OreburghCity (9, 13)", + "01.02 north 3 (to wall) -> Oreburgh City (2, 10) Oreburgh City (3, 10)", + "01.02 east 4 (to wall) -> Oreburgh City (6, 10)", + "01.02 south 3 (open) -> Oreburgh City (6, 13)", + "01.02 east 3 (open) -> Oreburgh City (9, 13)", + "01.03 below_the_centers_door costs=town from OreburghCity (43, 21) (44, 21) (45, 21) (43, 22) (44, 22) (45, 22) to OreburghCity (47, 21)", + "01.03 east 5 (to wall) -> Oreburgh City (48, 21) Oreburgh City (48, 22)", + "01.03 north 1 (to wall) -> Oreburgh City (48, 21)", + "01.03 west 1 (open) -> Oreburgh City (47, 21)", + "01.03 above_the_mine costs=town from OreburghCity (47, 21) to OreburghCity (46, 58)", + "01.03 west 3 (open) -> Oreburgh City (44, 21)", + "01.03 south 20 (to wall) -> Oreburgh City (44, 41)", + "01.03 east 1 (open) -> Oreburgh City (45, 41)", + "01.03 south 14 (to wall) -> Oreburgh City (45, 55)", + "01.03 east 1 (open) -> Oreburgh City (46, 55)", + "01.03 south 3 (open) -> Oreburgh City (46, 58)", + "01.03 below_roark costs=default from OreburghMine (15, 9) to OreburghMine (18, 29)", + "01.03 east 2 (to wall) -> OreburghMine (17, 9)", + "01.03 south 2 (to wall) -> OreburghMine (17, 11)", + "01.03 west 2 (to wall) -> OreburghMine (15, 11)", + "01.03 south 6 (to wall) -> OreburghMine (15, 17)", + "01.03 east 14 (to wall) -> OreburghMine (29, 17)", + "01.03 south 10 (to wall) -> OreburghMine (29, 27)", + "01.03 west 3 (to wall) -> OreburghMine (26, 27)", + "01.03 south 2 (to wall) -> OreburghMine (26, 29)", + "01.03 west 8 (open) -> OreburghMine (18, 29)", + "01.03 below_the_coal_rooms_warp costs=default from OreburghMine (18, 29) to OreburghMine (15, 2)", + "01.03 east 9 (to wall) -> OreburghMine (27, 29)", + "01.03 north 5 (to wall) -> OreburghMine (27, 24)", + "01.03 east 2 (to wall) -> OreburghMine (29, 24)", + "01.03 north 8 (to wall) -> OreburghMine (29, 16)", + "01.03 west 16 (to wall) -> OreburghMine (13, 16)", + "01.03 east 2 (open) -> OreburghMine (15, 16)", + "01.03 north 5 (to wall) -> OreburghMine (15, 11)", + "01.03 east 2 (to wall) -> OreburghMine (17, 11)", + "01.03 north 2 (to wall) -> OreburghMine (17, 9)", + "01.03 west 4 (to wall) -> OreburghMine (13, 9)", + "01.03 north 7 (to wall) -> OreburghMine (13, 2)", + "01.03 east 2 (open) -> OreburghMine (15, 2)", + "01.03 below_the_centers_door_again costs=town from OreburghCity (45, 57) to OreburghCity (47, 21)", + "01.03 west 2 (to wall) -> Oreburgh City (43, 57)", + "01.03 north 16 (to wall) -> Oreburgh City (43, 41)", + "01.03 east 1 (open) -> Oreburgh City (44, 41)", + "01.03 north 21 (to wall) -> Oreburgh City (44, 20)", + "01.03 south 1 (open) -> Oreburgh City (44, 21)", + "01.03 east 3 (open) -> Oreburgh City (47, 21)", + "01.05 east_of_barrys_trigger costs=town from OreburghCity (26, 21) (26, 22) to OreburghCity (7, 13)", + "01.05 west 17 (to wall) -> Oreburgh City (9, 21) Oreburgh City (9, 22)", + "01.05 north 5 (to wall) -> Oreburgh City (9, 17)", + "01.05 east 2 (open) -> Oreburgh City (11, 17)", + "01.05 north 4 (open) -> Oreburgh City (11, 13)", + "01.05 west 4 (open) -> Oreburgh City (7, 13)", + "01.05 by_the_gate costs=default from OreburghCity (5, 13) to OreburghCity (2, 13)", + "01.05 west 3 (open) -> Oreburgh City (2, 13)", + "01.05 through_the_gate costs=default from OreburghGate (27, 22) (26, 22) to OreburghGate (4, 22)", + "01.05 south 1 (open) -> OreburghGate (26, 23) OreburghGate (27, 23)", + "01.05 west 19 (to wall) -> OreburghGate (8, 23)", + "01.05 north 1 (to wall) -> OreburghGate (8, 22)", + "01.05 west 4 (open) -> OreburghGate (4, 22)", + "01.06 below_rowans_trigger costs=town from Route203 (55, 9) to JubilifeCity (47, 8)", + "01.06 south 10 (to wall) -> Route 203 (55, 19)", + "01.06 west 17 (to wall) -> Route 203 (38, 19)", + "01.06 north 1 (open) -> Route 203 (38, 18)", + "01.06 west 12 (open) -> Route 203 (26, 18)", + "01.06 south 1 (open) -> Route 203 (26, 19)", + "01.06 west 4 (open) -> Route 203 (22, 19)", + "01.06 north 4 (open) -> Route 203 (22, 15)", + "01.06 west 17 (to wall) -> Route 203 (5, 15)", + "01.06 south 5 (to wall) -> Route 203 (5, 20)", + "01.06 west 9 (open) -> Jubilife City (59, 24)", + "01.06 south 2 (to wall) -> Jubilife City (59, 26)", + "01.06 west 18 (to wall) -> Jubilife City (41, 26)", + "01.06 north 18 (to wall) -> Jubilife City (41, 8)", + "01.06 east 6 (to wall) -> Jubilife City (47, 8)", + "01.08 west_to_the_wall costs=default from JubilifeCity (46, 5) (47, 5) to JubilifeCity (44, 5)", + "01.08 west 3 (to wall) -> Jubilife City (44, 5)", + "01.08 below_the_ravaged_path costs=town from JubilifeCity (44, 5) to Route204South (11, 2)", + "01.08 east 2 (open) -> Jubilife City (46, 5)", + "01.08 north 19 (to wall) -> Route 204 (14, 18)", + "01.08 west 2 (open) -> Route 204 (12, 18)", + "01.08 north 16 (to wall) -> Route 204 (12, 2)", + "01.08 west 1 (to wall) -> Route 204 (11, 2)", + "01.09 west_of_the_rock costs=default from RavagedPath (19, 50) to RavagedPath (21, 43)", + "01.09 north 7 (open) -> RavagedPath (19, 43)", + "01.09 east 2 (open) -> RavagedPath (21, 43)", + "01.09 above_the_way_out costs=default from RavagedPath (21, 43) to RavagedPath (28, 44)", + "01.09 east 8 (to wall) -> RavagedPath (29, 43)", + "01.09 south 1 (to wall) -> RavagedPath (29, 44)", + "01.09 west 1 (open) -> RavagedPath (28, 44)", + "01.10 line_1 costs=line from Route204North (20, 26) to Route204North (20, 27)", + "01.10 south 1 (open) -> Route 204 (20, 27)", + "01.10 line_2 costs=line from Route204North (20, 27) to Route204North (11, 27)", + "01.10 west 9 (open) -> Route 204 (11, 27)", + "01.10 line_3 costs=line from Route204North (11, 27) to Route204North (11, 22)", + "01.10 north 5 (open) -> Route 204 (11, 22)", + "01.10 line_4 costs=line from Route204North (11, 22) to Route204North (19, 22)", + "01.10 east 8 (open) -> Route 204 (19, 22)", + "01.10 line_5 costs=line from Route204North (19, 22) to Route204North (19, 12)", + "01.10 north 10 (open) -> Route 204 (19, 12)", + "01.10 line_6 costs=line from Route204North (19, 12) to Route204North (11, 12)", + "01.10 west 8 (open) -> Route 204 (11, 12)", + "01.10 line_7 costs=line from Route204North (11, 12) to Route204North (11, 5)", + "01.10 north 7 (open) -> Route 204 (11, 5)", + "01.10 into_floaroma costs=line from Route204North (11, 5) to FloaromaTown (11, 29)", + "01.10 north 8 (open) -> Floaroma Town (11, 29)", + "01.11 west_along_the_field costs=default from FloaromaTown (11, 29) to FloaromaTown (3, 29)", + "01.11 west 8 (open) -> Floaroma Town (3, 29)", + "01.11 below_the_old_man costs=default from FloaromaTown (4, 26) to FloaromaTown (3, 26)", + "01.11 west 1 (open) -> Floaroma Town (3, 26)", +}; + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp index 0f2ab27ec9..414022092c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp @@ -27,6 +27,7 @@ #include "Pokemon/AutoStory/Types/Pokemon_GridPose.h" #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "Data/PokemonBDSP_AutoStory_RobustRoute.h" +#include "PokemonBDSP_AutoStory_PlanGolden.h" #include "Data/PokemonBDSP_AutoStory_WalkRules.h" #include "Utils/PokemonBDSP_AutoStory_Location.h" #include "Data/PokemonBDSP_AutoStory_PlanCosts.h" @@ -78,6 +79,7 @@ struct Walked{ std::optional at; std::string error; std::string plan; + std::vector golden = {}; }; // The tiles a plan walks. @@ -132,6 +134,15 @@ Walked plan_route(const Pose& from, const StoryStep& step){ for (const PlannedLeg& leg : *plan){ walked.plan += " " + to_string(leg.leg); } + walked.golden.push_back(std::format("{} costs={} from{} to{}", step.name, step.action.empty() ? "default" : step.action, + describe(from.map, Pokemon::tiles_of(from)), describe(goal.map, Pokemon::tiles_of(goal)))); + for (const PlannedLeg& leg : *plan){ + std::string line = std::format(" {} ->", to_string(leg.leg)); + for (const TilePos& pos : leg.after){ + line += std::format(" {}", describe(*world, pos)); + } + walked.golden.push_back(line); + } const std::string detour = detour_error(*world, start, at_goal, *plan); if (!detour.empty()){ return {std::nullopt, step.name + ": " + detour, walked.plan}; @@ -222,6 +233,8 @@ class FakeGame : public Pokemon::StoryStepExecutor{ std::vector& trace; std::map failures; std::vector plans; + // Every ROUTE's legs, one header line per route, for the golden test. + std::vector golden; explicit FakeGame(std::vector& trace) : trace(trace) @@ -280,6 +293,9 @@ class FakeGame : public Pokemon::StoryStepExecutor{ if (!walked.plan.empty()){ plans.push_back(walked.plan); } + for (const std::string& line : walked.golden){ + golden.push_back(std::format("{} {}", m_row, line)); + } return walked.at ? Pokemon::outcome_ok(*walked.at) : Pokemon::outcome_ok(Pose{}); } @@ -370,6 +386,35 @@ UnitTestResult test_whole_table(Logger& logger){ return true; } +// The legs planned for every ROUTE of the whole story, against the stored +// copy in PokemonBDSP_AutoStory_PlanGolden.h. A change that should not +// alter any plan must leave this byte-identical. To regenerate after an +// intended plan change: run this suite, and replace the lines of +// BDSP_PLAN_GOLDEN with the lines the failure logs after "GOLDEN|". +UnitTestResult test_golden_plans(Logger& logger){ + Simulation sim; + const Pokemon::SegmentReport report = sim.run({}, Language::English); + if (!report.completed){ + return "expected the whole story through:" + joined(sim.lines); + } + const std::vector& actual = sim.game.golden; + const size_t stored = sizeof(BDSP_PLAN_GOLDEN) / sizeof(BDSP_PLAN_GOLDEN[0]); + size_t first_diff = 0; + while (first_diff < actual.size() && first_diff < stored && actual[first_diff] == BDSP_PLAN_GOLDEN[first_diff]){ + first_diff++; + } + if (first_diff == actual.size() && first_diff == stored){ + return true; + } + for (const std::string& line : actual){ + logger.log(std::format("GOLDEN|{}", line)); + } + return std::format("plans differ from the golden at line {} ({} lines now, {} stored): now \"{}\", stored \"{}\".", + first_diff + 1, actual.size(), stored, + first_diff < actual.size() ? std::string_view(actual[first_diff]) : std::string_view(), + first_diff < stored ? BDSP_PLAN_GOLDEN[first_diff] : std::string_view()); +} + UnitTestResult test_start_and_end(Logger&){ Simulation sim; Pokemon::SegmentReport report = sim.run({.from = "00.04b", .to = "00.04d"}); @@ -592,6 +637,10 @@ const AutoStoryStorySimulationCase AUTO_STORY_STORY_SIMULATION_CASES[] = { .input = {"no hand-written legs but the listed ones", test_no_hand_written_legs}, .expectation = {}, }, + { + .input = {"plans match the golden", test_golden_plans}, + .expectation = {}, + }, }; void add_tests_AutoStory_StorySimulation(UnitTestDatabase& database){ diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index acf34b6d01..74160b3be6 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1743,6 +1743,7 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Maps_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Maps_Tests.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp + Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.h From 6d76f886483c32f023c787d073688a463fe65aaf Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 13:30:23 -0800 Subject: [PATCH 5/8] PokemonBDSP AutoStory: fault sweep models timed holds overshooting Console measurement (lab-B 2026-11-11, Jubilife): D-pad taps are tile-exact (5, 10, 15 and 20 taps, each moved a tile) and stick runs timed for 10 tiles overshot by about 3, three of three; none came up short. The sim's open legs are taps and so exact; a timed stick hold now goes 0..ceil(0.35 n) tiles further until a wall stops it. The walker taps every open leg, so no story route sees the fault. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp index e8dd73bd91..b541a8e482 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -403,17 +403,18 @@ class SimulatedRouteIO : public RouteIO{ m_safe_taps = safe; m_lost_taps = lost; } - // Fault class "open leg comes up short": an open leg of n tiles stops - // up to min(4, n / 4) tiles early, unseen (lab-B 2026-11-11: "north 20 - // (open)" ended about 4 short). Each open leg loses min(`lost`, that). - void stop_open_legs_short(size_t lost){ - m_short_open = lost; + // Fault class "a timed hold overshoots": a stick hold timed for n + // tiles goes 0..ceil(0.35 n) tiles further, unseen, until a wall stops + // it (lab-B 2026-11-11, Jubilife: runs timed for 10 tiles went about 13, + // three of three). D-pad taps are tile-exact (5 to 20 taps, every one + // moved) and walks to a wall end at the wall, so neither has a fault. + void overshoot_timed_holds(bool overshoot){ + m_overshoot = overshoot; } virtual WalkResult walk_taps(Direction direction, size_t tiles, const std::string&) override{ count_call(); - const size_t long_lost = tiles > m_safe_taps ? std::min(m_lost_taps, tiles) : 0; - const size_t lost = std::max(long_lost, std::min({m_short_open, (size_t)4, tiles / 4})); + const size_t lost = tiles > m_safe_taps ? std::min(m_lost_taps, tiles) : 0; const size_t moved = move(direction, tiles - lost); if (moved < tiles - lost){ return {.stop = WalkStop::BLOCKED, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = moved}; @@ -430,6 +431,15 @@ class SimulatedRouteIO : public RouteIO{ if (input.kind == RouteInputKind::DPAD && input.hold >= 100ms){ move(input.direction, input.count); } + // A stick hold is timed: route_open_hold() is half a tile under n. + if (input.kind == RouteInputKind::STICK){ + const Milliseconds per_tile = route_ms_per_tile(input.direction, MoveSpeed::WALK); + const size_t tiles = (size_t)((input.hold + per_tile / 2) / per_tile); + const size_t over = m_overshoot ? (tiles * 35 + 99) / 100 : 0; + for (size_t press = 0; press < input.count; press++){ + move(input.direction, tiles + over); + } + } } virtual bool dialog_within(Milliseconds, Color) override{ count_call(); @@ -476,7 +486,7 @@ class SimulatedRouteIO : public RouteIO{ size_t m_walked = 0; size_t m_safe_taps = SIZE_MAX; size_t m_lost_taps = 0; - size_t m_short_open = 0; + bool m_overshoot = false; }; StoryWorld jubilife_world(){ @@ -644,9 +654,9 @@ std::vector story_routes(){ } // Walks `route` from each of its start tiles on the simulated console, -// every open leg `lost` tiles short (capped per leg). Returns the tiles -// walked from each start, or why it failed. -std::string sweep_story_route(const StoryRoute& route, size_t lost, std::vector& walked){ +// every timed hold overshooting if `overshoot`. Returns the tiles walked +// from each start, or why it failed. +std::string sweep_story_route(const StoryRoute& route, bool overshoot, std::vector& walked){ const StoryWorld* world = story_plan_world(route.from.map, route.goal.map); const std::optional costs = story_route_costs(route.costs); if (world == nullptr || !costs){ @@ -663,7 +673,7 @@ std::string sweep_story_route(const StoryRoute& route, size_t lost, std::vector< for (const TilePos& from : start){ std::vector notes; SimulatedRouteIO io(*world, from, {}, notes); - io.stop_open_legs_short(lost); + io.overshoot_timed_holds(overshoot); RouteTrainers trainers{.sights = story_trainers(*world), .fight = [](const std::string&){}}; try{ walk_route(io, *world, start, trainers, { @@ -678,28 +688,28 @@ std::string sweep_story_route(const StoryRoute& route, size_t lost, std::vector< for (size_t i = notes.size() > 4 ? notes.size() - 4 : 0; i < notes.size(); i++){ last += "\n " + notes[i]; } - return std::format("{} from {}, open legs {} short: {}{}", route.name, Pokemon::to_string(from), lost, e.message, last); + return std::format("{} from {}{}: {}{}", route.name, Pokemon::to_string(from), overshoot ? ", holds overshooting" : "", e.message, last); } if (std::find(targets.begin(), targets.end(), io.at()) == targets.end()){ - return std::format("{} from {}, open legs {} short: ended at {}.", route.name, Pokemon::to_string(from), lost, Pokemon::to_string(io.at())); + return std::format("{} from {}{}: ended at {}.", route.name, Pokemon::to_string(from), overshoot ? ", holds overshooting" : "", Pokemon::to_string(io.at())); } walked.push_back(io.tiles_walked()); } return ""; } -// Fault sweep: every story route, walked with every open leg coming up -// short by 4 tiles (at most a quarter of the leg), still ends on its -// target. The log line per route gives the most tiles walked from any of -// its start tiles, without the fault and with it. -UnitTestResult test_story_routes_open_legs_short(Logger& logger){ +// Fault sweep: every story route, walked with every timed hold +// overshooting, still ends on its target. The log line per route gives the +// most tiles walked from any of its start tiles, without the fault and with +// it. +UnitTestResult test_story_routes_holds_overshoot(Logger& logger){ std::string failures; const std::vector routes = story_routes(); for (const StoryRoute& route : routes){ std::string line = route.name + ":"; - for (size_t lost : {(size_t)0, (size_t)4}){ + for (bool overshoot : {false, true}){ std::vector walked; - const std::string error = sweep_story_route(route, lost, walked); + const std::string error = sweep_story_route(route, overshoot, walked); if (!error.empty()){ failures += "\n " + error; line += " FAIL"; @@ -711,7 +721,7 @@ UnitTestResult test_story_routes_open_legs_short(Logger& logger){ } line += " " + std::to_string(most); } - logger.log("[open legs short: 0, 4] " + line); + logger.log("[timed holds overshoot: no, yes] " + line); } if (!failures.empty()){ return std::format("{} routes swept:{}", routes.size(), failures); @@ -780,7 +790,7 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .expectation = {}, }, { - .input = {"fault sweep: every story route with open legs coming up short", test_story_routes_open_legs_short}, + .input = {"fault sweep: every story route with timed holds overshooting", test_story_routes_holds_overshoot}, .expectation = {}, }, }; From 0113ca2158b40524c72c0013ff4022bf0579eba8 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 13:46:58 -0800 Subject: [PATCH 6/8] PokemonBDSP AutoStory: drop the 12-tile cap on straight open runs The cap answered "north 20 (open)" ending 4 tiles short on lab-B. The console measurement since (2026-11-11, Jubilife) shows D-pad taps are tile-exact; that walk was a timed hold, which overshoots. This walker taps every open leg, and the story-route fault sweep passes 62 of 62 with and without the cap, which only made routes longer (00.05b company clown 27 -> 35, 00.05c president 48 -> 54, 01.06 102 -> 124). This reverts commit 18304df226cc66f28a3fc8ecc7347c21a9e8c391. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Data/PokemonBDSP_AutoStory_PlanCosts.cpp | 5 +-- .../Data/PokemonBDSP_AutoStory_RobustRoute.h | 4 --- .../PokemonBDSP_AutoStory_RoutePlanner.cpp | 13 ++----- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 34 ++++--------------- 4 files changed, 10 insertions(+), 46 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp index cf4ca1d40b..fed0c55f4c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.cpp @@ -33,12 +33,9 @@ RobustPlanCosts town_plan_costs(){ // Open legs go on the D-pad now, a whole tile a tap, so they land exactly // at any length ("south 5" went 6 in r134a on stick holds). A wall at a // leg's end is still worth a little: r64 went 38 tiles round the town - // to end each leg on one, for 12 straight. But only one leg's worth in a - // straight line: "north 20 (open)", two legs run together, ended about - // 4 tiles short in Jubilife (lab-B 2026-11-11). + // to end each leg on one, for 12 straight. RobustPlanCosts costs; costs.exact_open_tiles = costs.max_open_tiles; - costs.max_open_run = costs.max_open_tiles; costs.per_open_tile = 1; costs.leg_not_at_wall = 4; return costs; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h index 4808512c66..a54bdc1610 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RobustRoute.h @@ -49,10 +49,6 @@ struct RobustPlanCosts : TilePlanCosts{ // so a short step after a wall beats a long open leg. int per_open_tile = 0; int max_open_tiles = 12; // longest open leg to consider - // Longest straight run of open legs one after another, 0 for no limit. - // Taps of one run lose count past about 12: on lab-B (2026-11-11) - // "north 20 (open)" through Jubilife ended about 4 tiles short. - int max_open_run = 0; size_t max_spread = 5; // most tiles the player may be on after a leg // Most sets of possible tiles to search before giving up. The search is // over sets, not tiles, so it grows far faster than the map: all of diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp index 39f23c1534..a89679cf16 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RoutePlanner.cpp @@ -374,7 +374,6 @@ class RobustSearch{ Spread parent; PlannedLeg leg; bool done = false; - size_t open_run = 0; // tiles of the straight open run ending here }; using Entry = std::pair; struct EntryGreater{ @@ -403,26 +402,18 @@ class RobustSearch{ if (expansion.next.size() > m_costs.max_spread || expansion.next == spread){ return; } - size_t open_run = expansion.leg.ends_at_wall ? 0 : expansion.leg.tiles; if (spread != m_start){ - const Node& from = m_nodes.at(spread); - const TileLeg& prev = from.leg.leg; + const TileLeg& prev = m_nodes.at(spread).leg.leg; if (expansion.leg.direction == prev.direction && !prev.ends_at_wall){ expansion.cost -= m_costs.per_leg; - if (!expansion.leg.ends_at_wall){ - open_run += from.open_run; - } } } - if (m_costs.max_open_run > 0 && open_run > (size_t)m_costs.max_open_run){ - return; - } const long long total = cost + expansion.cost; auto iter = m_nodes.find(expansion.next); if (iter != m_nodes.end() && iter->second.cost <= total){ return; } - m_nodes[expansion.next] = Node{total, spread, PlannedLeg{expansion.leg, expansion.next}, false, open_run}; + m_nodes[expansion.next] = Node{total, spread, PlannedLeg{expansion.leg, expansion.next}}; m_queue.emplace(total, std::move(expansion.next)); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp index b541a8e482..f382f0724e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -396,13 +396,6 @@ class SimulatedRouteIO : public RouteIO{ return {.stop = WalkStop::BLOCKED, .walked = ROUTE_START_DELAY + 800ms + per_tile * moved + per_tile / 2, .wild_battles = 0, .moved_chunks = moved}; } - // Taps of more than `safe` tiles in one walk move `lost` tiles fewer, - // and the count does not see it (lab-B 2026-11-11 11:16: "north 20 - // (open)" ended about 4 tiles short). - void lose_on_long_taps(size_t safe, size_t lost){ - m_safe_taps = safe; - m_lost_taps = lost; - } // Fault class "a timed hold overshoots": a stick hold timed for n // tiles goes 0..ceil(0.35 n) tiles further, unseen, until a wall stops // it (lab-B 2026-11-11, Jubilife: runs timed for 10 tiles went about 13, @@ -411,15 +404,11 @@ class SimulatedRouteIO : public RouteIO{ void overshoot_timed_holds(bool overshoot){ m_overshoot = overshoot; } - virtual WalkResult walk_taps(Direction direction, size_t tiles, const std::string&) override{ count_call(); - const size_t lost = tiles > m_safe_taps ? std::min(m_lost_taps, tiles) : 0; - const size_t moved = move(direction, tiles - lost); - if (moved < tiles - lost){ - return {.stop = WalkStop::BLOCKED, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = moved}; - } - return {.stop = WalkStop::LIMIT, .walked = 250ms * tiles, .wild_battles = 0, .moved_chunks = tiles}; + const size_t moved = move(direction, tiles); + return {.stop = moved < tiles ? WalkStop::BLOCKED : WalkStop::LIMIT, .walked = 250ms * tiles, + .wild_battles = 0, .moved_chunks = moved}; } virtual void press(const RouteInput& input) override{ // arrive() pauses for up to 3 s for a location banner the sim never @@ -484,8 +473,6 @@ class SimulatedRouteIO : public RouteIO{ std::vector& m_notes; size_t m_calls = 0; size_t m_walked = 0; - size_t m_safe_taps = SIZE_MAX; - size_t m_lost_taps = 0; bool m_overshoot = false; }; @@ -576,18 +563,15 @@ UnitTestResult test_jubilife_center_open_legs(Logger& logger){ return true; } -// The same walk on the console: "north 20 (open)" ended on row 46, about -// 4 tiles short, unseen, and the kids stand at (52, 46) and (54, 46). -// Taps longer than one open leg (max_open_tiles) lose 4 tiles here. The -// walker must still reach the Center without a long way round (the -// console replanned "west 33 (to wall)", "east 42 (to wall)"). +// The same walk on the console: the kids at (52, 46) and (54, 46) stop a +// walk north up their columns. The walker replans from where it stopped +// and reaches the Center without a long way round. UnitTestResult test_jubilife_center_kids(Logger&){ const StoryWorld world = jubilife_world(); const TilePos from{48, 62}; const TilePos goal{52, 41}; std::vector notes; SimulatedRouteIO io(world, from, {{52, 46}, {54, 46}}, notes); - io.lose_on_long_taps((size_t)town_plan_costs().max_open_tiles, 4); RouteTrainers trainers{.sights = {}, .fight = [](const std::string&){}}; try{ walk_route(io, world, {from}, trainers, { @@ -605,11 +589,7 @@ UnitTestResult test_jubilife_center_kids(Logger&){ } const size_t least = jubilife_shortest(world, from, goal); if (io.tiles_walked() * 10 > least * 13 + 40){ - std::string text; - for (const std::string& note : notes){ - text += "\n " + note; - } - return std::format("walked {} tiles where {} would do:{}", io.tiles_walked(), least, text); + return std::format("walked {} tiles where {} would do.", io.tiles_walked(), least); } return true; } From 1e8f2561efdccf1f15d22afd9fafffed71d6eb95 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 13:47:36 -0800 Subject: [PATCH 7/8] PokemonBDSP AutoStory: sim test, Jubilife to the Center with held runs overshooting lab-B 2026-11-11 13:38: "north 20 (open)" walked as a held run overshot and the walk ended far from the Center. The simulated console now times a hold to a limit and, with the fault on, goes up to ceil(0.35 n) tiles past it until a wall stops it. From (48, 62) the walk with every timed hold overshooting must still end on (52, 41); this walker taps open legs, so it does. It replaces the open-leg cap test. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp index f382f0724e..61d1d2ba92 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -391,8 +391,17 @@ class SimulatedRouteIO : public RouteIO{ virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override{ count_call(); - const size_t moved = move(walk.direction, SIZE_MAX); const Milliseconds per_tile = route_ms_per_tile(walk.direction, MoveSpeed::WALK); + if (m_overshoot && walk.limit > ROUTE_START_DELAY){ + // A hold timed for n tiles (ROUTE_START_DELAY, then half a + // tile under n) goes on past them until a wall stops it. + const size_t tiles = (size_t)((walk.limit - ROUTE_START_DELAY + per_tile / 2) / per_tile); + const size_t want = tiles + (tiles * 35 + 99) / 100; + const size_t moved = move(walk.direction, want); + return {.stop = moved < want ? WalkStop::BLOCKED : WalkStop::LIMIT, .walked = walk.limit, + .wild_battles = 0, .moved_chunks = moved}; + } + const size_t moved = move(walk.direction, SIZE_MAX); return {.stop = WalkStop::BLOCKED, .walked = ROUTE_START_DELAY + 800ms + per_tile * moved + per_tile / 2, .wild_battles = 0, .moved_chunks = moved}; } @@ -532,33 +541,33 @@ size_t jubilife_shortest(const StoryWorld& world, TilePos from, TilePos goal){ return plan ? tiles_of(*plan) : 0; } -// lab-B 2026-11-11 11:16 (00.05 to_the_center from (48, 62)): "north 20 -// (open)" ended about 4 tiles short, by the kids at (52, 46) and (54, 46), -// and the replan went "west 33 (to wall)", "east 42 (to wall)". No open -// leg may run longer than one leg can (max_open_tiles), so a long stretch -// meets a wall on the way, and the plan stays near the shortest way. -UnitTestResult test_jubilife_center_open_legs(Logger& logger){ +// lab-B 2026-11-11 13:38 (00.05 to_the_center from (48, 62)): "north 20 +// (open)" walked as a held run (3175 ms) overshot, the west leg after it +// stopped 9 tiles in, the walker put walls at (54, 41..43) and "arrived" +// at (52, 41) nowhere near the Center. Timed holds overshoot by up to +// ceil(0.35 n) tiles (three runs of 10 went about 13); taps are exact. +// With every timed hold overshooting the walk still ends on the tile. +UnitTestResult test_jubilife_center_held_overshoot(Logger&){ const StoryWorld world = jubilife_world(); const TilePos from{48, 62}; const TilePos goal{52, 41}; - const RobustPlanCosts costs = town_plan_costs(); - const auto plan = plan_robust_route(world, from, goal, costs); - if (!plan){ - return "no plan from (48, 62)."; - } - std::string legs; - for (const PlannedLeg& leg : *plan){ - legs += " " + to_string(leg.leg); - } - logger.log("Jubilife to the Center:" + legs); - for (const PlannedLeg& leg : *plan){ - if (!leg.leg.ends_at_wall && leg.leg.tiles > (size_t)costs.max_open_tiles){ - return std::format("an open leg of {} tiles, over {}:{}", leg.leg.tiles, costs.max_open_tiles, legs); - } + std::vector notes; + SimulatedRouteIO io(world, from, {}, notes); + io.overshoot_timed_holds(true); + RouteTrainers trainers{.sights = {}, .fight = [](const std::string&){}}; + try{ + walk_route(io, world, {from}, trainers, { + .goal = [goal](const TilePos& pos){ return pos == goal; }, + .label = "T", + .avoid = {}, + .costs = town_plan_costs(), + .speed = MoveSpeed::WALK, + }); + }catch (const RouteFailed& e){ + return "failed: " + e.message; } - const size_t least = jubilife_shortest(world, from, goal); - if (tiles_of(*plan) * 10 > least * 13){ - return std::format("walks {} tiles where {} would do:{}", tiles_of(*plan), least, legs); + if (io.at() != goal){ + return "ended at " + Pokemon::to_string(io.at()) + ", not at (52, 41)."; } return true; } @@ -762,7 +771,7 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .expectation = {}, }, { - .input = {"Jubilife to the Center: open legs no longer than one leg", test_jubilife_center_open_legs}, + .input = {"Jubilife to the Center with timed holds overshooting", test_jubilife_center_held_overshoot}, .expectation = {}, }, { From f7727c22c1d99c86861797ccc58b64a189e9368f Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 11 Nov 2026 13:51:08 -0800 Subject: [PATCH 8/8] BDSP AutoStory: golden plans without the open-run cap Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_PlanGolden.h | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index 447c356777..e63fe2d69b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -129,10 +129,8 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "00.04d north 2 (open) -> Route 202 (18, 3)", "00.05 to_the_center costs=town from JubilifeCity (48, 62) to JubilifeCity (52, 41)", "00.05 west 1 (open) -> Jubilife City (47, 62)", - "00.05 north 5 (open) -> Jubilife City (47, 57)", - "00.05 east 3 (open) -> Jubilife City (50, 57)", - "00.05 north 16 (to wall) -> Jubilife City (50, 41)", - "00.05 east 2 (open) -> Jubilife City (52, 41)", + "00.05 north 21 (open) -> Jubilife City (47, 41)", + "00.05 east 5 (open) -> Jubilife City (52, 41)", "00.05 to_the_school costs=town from JubilifeCity (52, 41) to JubilifeCity (40, 41)", "00.05 west 12 (open) -> Jubilife City (40, 41)", "00.05b below_the_presidents_trigger costs=town from JubilifeCity (40, 41) to JubilifeCity (46, 41)", @@ -149,25 +147,17 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "00.05b north 7 (open) -> Jubilife City (36, 17)", "00.05b below_the_company_clown costs=town from JubilifeCity (36, 17) to JubilifeCity (15, 19)", "00.05b south 4 (open) -> Jubilife City (36, 21)", - "00.05b west 9 (open) -> Jubilife City (27, 21)", - "00.05b south 4 (to wall) -> Jubilife City (27, 25)", - "00.05b west 12 (open) -> Jubilife City (15, 25)", - "00.05b north 6 (open) -> Jubilife City (15, 19)", + "00.05b west 21 (open) -> Jubilife City (15, 21)", + "00.05b north 2 (open) -> Jubilife City (15, 19)", "00.05c below_the_president costs=town from JubilifeCity (15, 19) to JubilifeCity (46, 36)", - "00.05c south 8 (to wall) -> Jubilife City (15, 27)", - "00.05c east 11 (to wall) -> Jubilife City (26, 27)", - "00.05c north 3 (open) -> Jubilife City (26, 24)", - "00.05c east 11 (open) -> Jubilife City (37, 24)", - "00.05c south 1 (to wall) -> Jubilife City (37, 25)", - "00.05c east 7 (open) -> Jubilife City (44, 25)", - "00.05c south 11 (open) -> Jubilife City (44, 36)", + "00.05c south 5 (open) -> Jubilife City (15, 24)", + "00.05c east 29 (open) -> Jubilife City (44, 24)", + "00.05c south 12 (open) -> Jubilife City (44, 36)", "00.05c east 2 (open) -> Jubilife City (46, 36)", "00.05c to_the_route_203_street costs=town from JubilifeCity (46, 36) to JubilifeCity (58, 22)", "00.05c east 1 (open) -> Jubilife City (47, 36)", - "00.05c north 9 (open) -> Jubilife City (47, 27)", - "00.05c east 9 (to wall) -> Jubilife City (56, 27)", - "00.05c north 5 (open) -> Jubilife City (56, 22)", - "00.05c east 2 (open) -> Jubilife City (58, 22)", + "00.05c north 14 (open) -> Jubilife City (47, 22)", + "00.05c east 11 (open) -> Jubilife City (58, 22)", "01.01 west_of_barrys_trigger costs=town from JubilifeCity (58, 22) to Route203 (4, 18)", "01.01 east 9 (open) -> Route 203 (4, 18)", "01.02 south_to_the_cliff costs=default from Route203 (5, 17) (5, 18) (5, 19) (5, 20) to Route203 (5, 20)", @@ -196,10 +186,8 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "01.03 above_the_mine costs=town from OreburghCity (47, 21) to OreburghCity (46, 58)", "01.03 west 3 (open) -> Oreburgh City (44, 21)", "01.03 south 20 (to wall) -> Oreburgh City (44, 41)", - "01.03 east 1 (open) -> Oreburgh City (45, 41)", - "01.03 south 14 (to wall) -> Oreburgh City (45, 55)", - "01.03 east 1 (open) -> Oreburgh City (46, 55)", - "01.03 south 3 (open) -> Oreburgh City (46, 58)", + "01.03 east 2 (open) -> Oreburgh City (46, 41)", + "01.03 south 17 (open) -> Oreburgh City (46, 58)", "01.03 below_roark costs=default from OreburghMine (15, 9) to OreburghMine (18, 29)", "01.03 east 2 (to wall) -> OreburghMine (17, 9)", "01.03 south 2 (to wall) -> OreburghMine (17, 11)", @@ -247,17 +235,9 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "01.06 south 10 (to wall) -> Route 203 (55, 19)", "01.06 west 17 (to wall) -> Route 203 (38, 19)", "01.06 north 1 (open) -> Route 203 (38, 18)", - "01.06 west 12 (open) -> Route 203 (26, 18)", - "01.06 south 1 (open) -> Route 203 (26, 19)", - "01.06 west 4 (open) -> Route 203 (22, 19)", - "01.06 north 4 (open) -> Route 203 (22, 15)", - "01.06 west 17 (to wall) -> Route 203 (5, 15)", - "01.06 south 5 (to wall) -> Route 203 (5, 20)", - "01.06 west 9 (open) -> Jubilife City (59, 24)", - "01.06 south 2 (to wall) -> Jubilife City (59, 26)", - "01.06 west 18 (to wall) -> Jubilife City (41, 26)", - "01.06 north 18 (to wall) -> Jubilife City (41, 8)", - "01.06 east 6 (to wall) -> Jubilife City (47, 8)", + "01.06 west 57 (open) -> Jubilife City (44, 22)", + "01.06 north 14 (to wall) -> Jubilife City (44, 8)", + "01.06 east 3 (to wall) -> Jubilife City (47, 8)", "01.08 west_to_the_wall costs=default from JubilifeCity (46, 5) (47, 5) to JubilifeCity (44, 5)", "01.08 west 3 (to wall) -> Jubilife City (44, 5)", "01.08 below_the_ravaged_path costs=town from JubilifeCity (44, 5) to Route204South (11, 2)",