From 2b98f7315a966d895e4aaf7d86432bf78128f559 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 11:06:21 -0800 Subject: [PATCH 01/47] BDSP AutoStory: a sim test for the Mart clown staying out of column 56's reach (red) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...PokemonBDSP_AutoStory_WanderWait_Tests.cpp | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp index f22d1d1731..3410d21852 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp @@ -83,9 +83,12 @@ std::vector clown_starts(const TilePos& player){ } // The wait from `start` with the clown starting on `clown`, his walk -// seeded by `seed`. -WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const TilePos& clown, uint64_t seed, const WanderWaitPlan& plan){ - const SimWanderer wanderer{.name = "clown_mart", .box = jubilife_mart_clown_box(), .pos = clown, .seed = seed}; +// seeded by `seed`; with `stays`, he never steps. +WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const TilePos& clown, uint64_t seed, const WanderWaitPlan& plan, bool stays = false){ + SimWanderer wanderer{.name = "clown_mart", .box = jubilife_mart_clown_box(), .pos = clown, .seed = seed}; + if (stays){ + wanderer.step_interval = Milliseconds(0); + } GridSim sim({.world = &world, .wanderers = {wanderer}}, start, Direction::NORTH, false); SimWanderWait body(sim); const WanderWaitResult result = wait_beside_wanderer(body, start, plan); @@ -122,6 +125,28 @@ UnitTestResult test_mart_clown_reached_from_column_56(Logger& logger){ return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait missed the clown:{}", out)); } +// On lab-B (2026-11-12 11:00) the clown stayed out of reach of column 56 +// for the whole wait, on his box's west column. From either start, the +// wait talks to him on whichever tile of his box he stays. +UnitTestResult test_mart_clown_reached_when_he_stays(Logger& logger){ + const StoryWorld world = clown_world(); + std::string out; + size_t runs = 0; + for (const auto& [row, start] : {std::pair{"00.05b", {56, 36}}, {"00.05c", {56, 31}}}){ + const WanderWaitPlan plan = wander_wait_plan(story_step(row, "mart_clown")); + for (const TilePos& clown : clown_starts(start)){ + runs++; + const WanderWaitResult result = run_wait(world, start, clown, 1, plan, true); + if (result.end != WanderWaitEnd::TALKED || result.at != plan.exit){ + out += std::format("\n {} with the clown staying on {}: ended {} on {}.", row, + Pokemon::to_string(clown), (int)result.end, Pokemon::to_string(result.at)); + } + } + } + logger.log(std::format("{} waits run.", runs)); + return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait missed the clown:{}", out)); +} + // How many of the clown's starts and seeds one stand tile alone talks // to him from, facing west, within the plan's asks. size_t talks_from(const StoryWorld& world, const TilePos& stand, const WanderWaitPlan& table_plan){ @@ -192,6 +217,8 @@ class Test_AutoStoryWanderWait : public UnitTest{ const WanderWaitCase WANDER_WAIT_CASES[] = { {.input = {"Wander wait: the Mart clown is reached from column 56 wherever he starts (00.05b, 00.05c)", test_mart_clown_reached_from_column_56}, .expectation = {}}, + {.input = {"Wander wait: the Mart clown is reached on whichever tile he stays (lab-B 2026-11-12, column 54)", + test_mart_clown_reached_when_he_stays}, .expectation = {}}, {.input = {"Wander wait: the Mart clown's first stand tile is where the simulation meets him most", test_mart_clown_first_stand}, .expectation = {}}, }; From 8df2cc36fa7d49313b290a4284c550970880f6c8 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 11:15:18 -0800 Subject: [PATCH 02/47] BDSP AutoStory: wait for the Mart clown at both ends of his box, a tile and two asks at a time On lab-B (2026-11-12 11:03) 00.05b's mart_clown asked twelve times from (56, 32) with the clown diagonal on (55, 33), and he can stay on column 54, out of reach of column 56. wait_for_wanderer now takes a far_stand (his box's west column, 54, facing east) and walks between the ends along the row above or below the box; it asks twice a tile and steps on a tile at a time (D-pad taps), so it reaches his row. If he stays in the way after the talk, the way out steps into the box and goes round him. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_Events_Jubilife.cpp | 22 ++-- .../PokemonBDSP_AutoStory_WanderWait.cpp | 112 ++++++++++++++---- .../PokemonBDSP_AutoStory_WanderWait.h | 46 +++++-- .../PokemonBDSP_AutoStory_StoryData.cpp | 13 +- .../PokemonBDSP_AutoStory_SimWanderWait.cpp | 17 ++- ...PokemonBDSP_AutoStory_WanderWait_Tests.cpp | 58 ++++++++- .../AutoStory/StoryData/bdsp-00.05b.plan.json | 28 ++++- .../AutoStory/StoryData/bdsp-00.05c.plan.json | 28 ++++- 8 files changed, 265 insertions(+), 59 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp index 858b79e2ee..17c8f04acc 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp @@ -172,7 +172,7 @@ class ConsoleWanderWait : public WanderWaitBody{ const WalkResult result = walk_tiles_dpad(m_stream, m_context, run_from_wild_battle, route_stick(direction), 1, label); const std::optional moved = wander_row_step(result, 1); if (!moved){ - fail_step(m_stream, std::format("{}: {} instead of a step along the column.", label, walk_stop_name(result.stop))); + fail_step(m_stream, std::format("{}: {} instead of a one-tile step.", label, walk_stop_name(result.stop))); } return *moved != 0; } @@ -199,16 +199,21 @@ class ConsoleWanderWait : public WanderWaitBody{ bool m_again; }; // The talk to a wanderer by waiting for him on the step's "stand" tiles, -// from the tile the step before left us on (in their column). It ends on -// its declared tile, against a wall the declared way and one at the -// column's back (away from his box): both taps must not move. +// then on its "far_stand" tiles (his box's other end), in turn, from the +// tile the step before left us on. It ends on its declared tile, against +// a wall the declared way and one at the stand column's back (away from +// his box): both taps must not move. Pokemon::Outcome wait_for_wanderer(StoryExecutor& executor, Pokemon::RunState& state, const Pokemon::StoryStep& step){ VideoStream& stream = executor.stream(); const Pokemon::GridPose& stand = Pokemon::story_arg(step.args, "stand"); + const Pokemon::GridPose& far_stand = Pokemon::story_arg(step.args, "far_stand"); const std::vector start = Pokemon::tiles_of(state.pose); if (!step.pose_after || start.size() != 1 || stand.tiles.empty() || !stand.facing){ fail_step(stream, step.name + ": needs one start tile, stand tiles and their facing, and a declared end."); } + if (!far_stand.tiles.empty() && !far_stand.facing){ + fail_step(stream, step.name + ": its far stand tiles need a facing."); + } const Pokemon::Pose exit = Pokemon::pose_of(*step.pose_after); const std::vector exit_tiles = Pokemon::tiles_of(exit); const std::optional exit_wall = Pokemon::facing_of(exit); @@ -217,7 +222,10 @@ Pokemon::Outcome wait_for_wanderer(StoryExecutor& executor, Pokemon::RunState& s } // The column's back: the way away from his box. const Direction back = Pokemon::ALL_DIRECTIONS[((size_t)*stand.facing + 2) % 4]; - const WanderWaitPlan plan{.stands = stand.tiles, .facing = *stand.facing, .exit = exit_tiles[0], .exit_walls = {*exit_wall, back}}; + WanderWaitPlan plan{.sides = {{.stands = stand.tiles, .facing = *stand.facing}}, .exit = exit_tiles[0], .exit_walls = {*exit_wall, back}}; + if (!far_stand.tiles.empty()){ + plan.sides.push_back({.stands = far_stand.tiles, .facing = *far_stand.facing}); + } ConsoleWanderWait body(stream, executor.context(), step.name, Pokemon::story_arg(step.args, "again")); const WanderWaitResult result = wait_beside_wanderer(body, start[0], plan); switch (result.end){ @@ -227,9 +235,9 @@ Pokemon::Outcome wait_for_wanderer(StoryExecutor& executor, Pokemon::RunState& s case WanderWaitEnd::NO_TALK: fail_step(stream, std::format("{}: no talk from any stand tile; on {}.", step.name, Pokemon::to_string(result.at))); case WanderWaitEnd::STUCK: - fail_step(stream, std::format("{}: a step along the column stayed blocked at {}.", step.name, Pokemon::to_string(result.at))); + fail_step(stream, std::format("{}: a step on the way stayed blocked at {}.", step.name, Pokemon::to_string(result.at))); case WanderWaitEnd::LOST: - fail_step(stream, std::format("{}: a step from {} moved to {}: not on the column.", step.name, Pokemon::to_string(exit_tiles[0]), Pokemon::to_string(result.at))); + fail_step(stream, std::format("{}: a step from {} moved to {}: not on the exit.", step.name, Pokemon::to_string(exit_tiles[0]), Pokemon::to_string(result.at))); } fail_step(stream, step.name + ": unknown wait end."); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp index bd05488eeb..256a5ecee7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp @@ -4,6 +4,9 @@ * */ +#include +#include +#include #include "PokemonBDSP_AutoStory_WanderWait.h" namespace PokemonAutomation{ @@ -16,17 +19,19 @@ using Pokemon::TilePos; namespace{ -// Walks the column from `at` to `to`, a tile a step. A blocked step asks -// that way while `talked` is false, and ends the walk if the talk counts. -// False if a step stayed blocked for the plan's asks, or `to` is off the -// column. -bool walk_column(WanderWaitBody& body, TilePos& at, TilePos to, const WanderWaitPlan& plan, bool* talked){ - if (at.x != to.x){ +// Walks a straight line from `at` to `to`, a tile a step. A blocked step +// asks that way while `talked` is false, and ends the walk if the talk +// counts. False if a step stayed blocked for `tries` steps, or `to` is +// not on a line from `at`. +bool walk_line(WanderWaitBody& body, TilePos& at, TilePos to, const WanderWaitPlan& plan, size_t tries, bool* talked){ + if (at.x != to.x && at.y != to.y){ return false; } while (at != to){ - const Direction direction = to.y < at.y ? Direction::NORTH : Direction::SOUTH; - size_t tries = 0; + const Direction direction = at.x != to.x + ? (to.x < at.x ? Direction::WEST : Direction::EAST) + : (to.y < at.y ? Direction::NORTH : Direction::SOUTH); + size_t blocked = 0; while (!body.step(direction)){ if (talked != nullptr && !*talked){ body.face(direction); @@ -35,7 +40,7 @@ bool walk_column(WanderWaitBody& body, TilePos& at, TilePos to, const WanderWait return true; } } - if (++tries >= plan.asks){ + if (++blocked >= tries){ return false; } body.wait(plan.blocked_wait); @@ -45,9 +50,44 @@ bool walk_column(WanderWaitBody& body, TilePos& at, TilePos to, const WanderWait return true; } -// Asks from where the player stands, facing the plan's way. -bool ask_from_stand(WanderWaitBody& body, const WanderWaitPlan& plan){ - body.face(plan.facing); +// The row to cross between columns from `at` to `to`: the one above the +// stands or the one below, whichever walk is shorter. +int crossing_row(const WanderWaitPlan& plan, const TilePos& at, const TilePos& to){ + std::optional top; + std::optional bottom; + for (const WanderWaitSide& side : plan.sides){ + for (const TilePos& stand : side.stands){ + top = top ? std::min(*top, stand.y) : stand.y; + bottom = bottom ? std::max(*bottom, stand.y) : stand.y; + } + } + const int above = top.value_or(at.y) - 1; + const int below = bottom.value_or(at.y) + 1; + const int up = std::abs(at.y - above) + std::abs(to.y - above); + const int down = std::abs(at.y - below) + std::abs(to.y - below); + return up <= down ? above : below; +} + +// Walks from `at` to `to`: down the column, or between columns along a +// crossing row. Asks a blocked step in a column as walk_line() does. +bool walk_to(WanderWaitBody& body, TilePos& at, TilePos to, const WanderWaitPlan& plan, size_t tries, bool* talked){ + if (at.x == to.x){ + return walk_line(body, at, to, plan, tries, talked); + } + const int row = crossing_row(plan, at, to); + if (!walk_line(body, at, {at.x, row}, plan, tries, talked)){ + return false; + } + if (talked != nullptr && *talked){ + return true; + } + return walk_line(body, at, {to.x, row}, plan, tries, nullptr) + && walk_line(body, at, to, plan, tries, talked); +} + +// Asks from where the player stands, facing `facing`. +bool ask_from_stand(WanderWaitBody& body, const WanderWaitPlan& plan, Direction facing){ + body.face(facing); for (size_t ask = 0; ask < plan.asks; ask++){ if (body.ask()){ return true; @@ -57,6 +97,30 @@ bool ask_from_stand(WanderWaitBody& body, const WanderWaitPlan& plan){ return false; } +// The way into the box from the side whose column `at` is on. +std::optional inward_from(const WanderWaitPlan& plan, const TilePos& at){ + for (const WanderWaitSide& side : plan.sides){ + if (!side.stands.empty() && side.stands[0].x == at.x){ + return side.facing; + } + } + return std::nullopt; +} + +// Walks from where the talk counted to the exit. If he stays in the way +// on the column, steps into the box beside him and goes round. +bool walk_out(WanderWaitBody& body, TilePos& at, const WanderWaitPlan& plan){ + if (walk_to(body, at, plan.exit, plan, plan.exit_tries, nullptr)){ + return true; + } + const std::optional inward = inward_from(plan, at); + if (!inward || at.x != plan.exit.x || !body.step(*inward)){ + return walk_to(body, at, plan.exit, plan, plan.blocked_tries, nullptr); + } + at = at.next(*inward); + return walk_to(body, at, plan.exit, plan, plan.blocked_tries, nullptr); +} + } // namespace @@ -64,23 +128,25 @@ WanderWaitResult wait_beside_wanderer(WanderWaitBody& body, TilePos at, const Wa bool talked = false; TilePos talked_at = at; for (size_t round = 0; round < plan.rounds && !talked; round++){ - for (const TilePos& stand : plan.stands){ - if (!walk_column(body, at, stand, plan, &talked)){ - return {.end = WanderWaitEnd::STUCK, .at = at, .talked = at}; - } - if (!talked){ - talked = ask_from_stand(body, plan); - } - if (talked){ - talked_at = at; - break; + for (size_t s = 0; s < plan.sides.size() && !talked; s++){ + const WanderWaitSide& side = plan.sides[s]; + for (size_t pass = 0; pass < plan.passes && !talked; pass++){ + for (size_t i = 0; i < side.stands.size() && !talked; i++){ + if (!walk_to(body, at, side.stands[i], plan, plan.blocked_tries, &talked)){ + return {.end = WanderWaitEnd::STUCK, .at = at, .talked = at}; + } + if (!talked){ + talked = ask_from_stand(body, plan, side.facing); + } + talked_at = at; + } } } } if (!talked){ return {.end = WanderWaitEnd::NO_TALK, .at = at, .talked = at}; } - if (!walk_column(body, at, plan.exit, plan, nullptr)){ + if (!walk_out(body, at, plan)){ return {.end = WanderWaitEnd::STUCK, .at = at, .talked = talked_at}; } for (Direction wall : plan.exit_walls){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h index 5cd7813aa1..149cb0fc19 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h @@ -3,9 +3,13 @@ * From: https://github.com/PokemonAutomation/ * * A talk to someone who wanders, by waiting for him rather than chasing - * him: stand on a tile beside his box, face it, and ask each time he may - * have come level, then try the next tile. The Mart clown (00.05b, - * 00.05c) is waited for on column 56, east of his box. + * him: stand on an end column of his box, inside it, face in, and ask + * each time he may have come level, then try the next tile. Our tile is + * one he can no longer step on, so he comes level more often. A box wider + * than two columns has a far column he can stay on out of reach: the wait + * then takes turns between the two ends. The Mart clown (00.05b, 00.05c) + * wanders columns 54 to 56: he is waited for on 56 facing west, then on + * 54 facing east. * */ @@ -22,23 +26,39 @@ namespace NintendoSwitch{ namespace PokemonBDSP{ -// Where and how long to wait. The stands and the exit are on one column. -struct WanderWaitPlan{ - // The tiles to wait on, in order; the list is walked `rounds` times. +// One end of his box to wait at: tiles on one column, in order, a tile +// apart (the list is walked again from its start: end it a tile from its +// first), and the way to face from them, into the box. +struct WanderWaitSide{ std::vector stands; - // The way to face from a stand: toward his box. Pokemon::Direction facing = Pokemon::Direction::WEST; +}; + +// Where and how long to wait. Between columns the wait walks round the +// stands' rows: along the row above them or the one below, whichever is +// shorter. Those rows must be open. +struct WanderWaitPlan{ + // The ends to wait at, in turn; the list is walked `rounds` times. + std::vector sides; // Where the wait ends after the talk. A step from it toward each of // `exit_walls` must not move: the walls there prove the tile. Pokemon::TilePos exit; std::vector exit_walls; - // Asks from each stand before the next one. - size_t asks = 12; + // Asks from each stand before the next one: few, so the wait steps on + // to his row instead of pressing A at nobody (lab-B 2026-11-12 11:03: + // twelve asks from (56, 32) while he stood on (55, 33)). + size_t asks = 2; + // Times a side's stands are walked before the next side. + size_t passes = 3; // The pause after an ask that found nobody. Milliseconds between_asks = Milliseconds(500); // The wait for someone in the column to step out of it: a wanderer // tries a step every 2 s or so, and may stay. Milliseconds blocked_wait = Milliseconds(2000); + // Blocked steps on the way before giving up, and on the way out + // before walking round him. + size_t blocked_tries = 12; + size_t exit_tries = 3; size_t rounds = 2; }; @@ -59,8 +79,8 @@ class WanderWaitBody{ enum class WanderWaitEnd{ TALKED, // the talk counted; the player is on the plan's exit NO_TALK, // every ask of every round found nobody to talk to - STUCK, // a step along the column stayed blocked - LOST, // an exit wall was not there: off the column + STUCK, // a step on the way stayed blocked + LOST, // an exit wall was not there: not on the exit }; // How a wait ended, and where. struct WanderWaitResult{ @@ -69,8 +89,8 @@ struct WanderWaitResult{ Pokemon::TilePos talked; // where the talk counted, for TALKED }; -// Waits beside the wanderer from `at`, on the plan's column. A step along -// the column that something stops is someone in the column: the wait asks +// Waits for the wanderer from `at`, at the plan's sides in turn. A step +// in his box that something stops is him in the column: the wait asks // that way too, then waits and steps again. WanderWaitResult wait_beside_wanderer(WanderWaitBody& body, Pokemon::TilePos at, const WanderWaitPlan& plan); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp index cb22e7d4c3..63023c1ec7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp @@ -71,12 +71,17 @@ void add_wanderer_talks(std::vector& actions){ // Walks the row below his home, asking north. actions.push_back({.kind = Pokemon::StoryStepKind::TALK, .name = "talk_to_wanderer", .args = {again}, .console_only = false, .certainty = certainty}); - // Waits for him on a column beside his box (WanderWaitPlan); ends - // against a wall the declared way and one at the column's back. + // Waits for him at an end column of his box, then at the other end + // (WanderWaitPlan); ends against a wall the declared way and one at + // the stand column's back. const Pokemon::StoryArgSpec stand = required( - "stand", Pokemon::StoryArgType::GRID_POSE, "the tiles to wait on, in order, on the start's column; facing his box" + "stand", Pokemon::StoryArgType::GRID_POSE, "the tiles to wait on first, in order, on one column; facing into his box" ); - actions.push_back({.kind = Pokemon::StoryStepKind::TALK, .name = "wait_for_wanderer", .args = {stand, again}, + const Pokemon::StoryArgSpec far_stand = optional( + "far_stand", Pokemon::StoryArgType::GRID_POSE, Pokemon::GridPose{}, + "the tiles to wait on next, on his box's other end column; facing into it" + ); + actions.push_back({.kind = Pokemon::StoryStepKind::TALK, .name = "wait_for_wanderer", .args = {stand, far_stand, again}, .console_only = false, .certainty = certainty}); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimWanderWait.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimWanderWait.cpp index 45c0a6156c..e1e8e8332b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimWanderWait.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimWanderWait.cpp @@ -55,9 +55,14 @@ void SimWanderWait::wait(Milliseconds time){ WanderWaitPlan wander_wait_plan(const Pokemon::StoryStep& step){ const Pokemon::GridPose& stand = Pokemon::story_arg(step.args, "stand"); const Pokemon::Pose exit = Pokemon::pose_of(*step.pose_after); + const Pokemon::GridPose& far_stand = Pokemon::story_arg(step.args, "far_stand"); const Direction back = Pokemon::ALL_DIRECTIONS[((size_t)*stand.facing + 2) % 4]; - return WanderWaitPlan{.stands = stand.tiles, .facing = *stand.facing, + WanderWaitPlan plan{.sides = {{.stands = stand.tiles, .facing = *stand.facing}}, .exit = Pokemon::tiles_of(exit).at(0), .exit_walls = {*Pokemon::facing_of(exit), back}}; + if (!far_stand.tiles.empty()){ + plan.sides.push_back({.stands = far_stand.tiles, .facing = *far_stand.facing}); + } + return plan; } @@ -65,8 +70,10 @@ namespace{ // The plan's tiles on `world`. WanderWaitPlan on_world(WanderWaitPlan plan, const StoryWorld& world, const std::string& map){ - for (TilePos& stand : plan.stands){ - stand = story_to_world(world, map, stand); + for (WanderWaitSide& side : plan.sides){ + for (TilePos& stand : side.stands){ + stand = story_to_world(world, map, stand); + } } plan.exit = story_to_world(world, map, plan.exit); return plan; @@ -100,9 +107,9 @@ Pokemon::Outcome sim_wait_for_wanderer(GridSim& sim, const StoryWorld& world, co case WanderWaitEnd::NO_TALK: return Pokemon::outcome_failed("operation_failed", std::format("{}: no talk from any stand tile; on {}.", step.name, at)); case WanderWaitEnd::STUCK: - return Pokemon::outcome_failed("operation_failed", std::format("{}: a step along the column stayed blocked at {}.", step.name, at)); + return Pokemon::outcome_failed("operation_failed", std::format("{}: a step on the way stayed blocked at {}.", step.name, at)); case WanderWaitEnd::LOST: - return Pokemon::outcome_failed("operation_failed", std::format("{}: a step from the exit moved to {}: not on the column.", step.name, at)); + return Pokemon::outcome_failed("operation_failed", std::format("{}: a step from the exit moved to {}: not on the exit.", step.name, at)); } return Pokemon::outcome_failed("operation_failed", step.name + ": unknown wait end."); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp index 3410d21852..1eb8f239fd 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp @@ -3,12 +3,14 @@ * From: https://github.com/PokemonAutomation/ * * The Mart clown wanders (54..56, 32..34) round (55, 33). 00.05b and - * 00.05c wait for him on column 56 facing west (wait_for_wanderer): these - * run that wait on the simulation with him starting on each tile of his - * box, and pick the tile to wait on first. + * 00.05c wait for him in his box's end columns, 56 facing west, then 54 + * facing east (wait_for_wanderer): these run that wait on the simulation + * with him starting, or staying, on each tile of his box, and pick the + * tile to wait on first. He never steps onto the player's tile. * */ +#include #include #include #include @@ -147,11 +149,55 @@ UnitTestResult test_mart_clown_reached_when_he_stays(Logger& logger){ return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait missed the clown:{}", out)); } +// The simulation's wait, counting its asks. +class CountingWanderWait : public SimWanderWait{ +public: + using SimWanderWait::SimWanderWait; + virtual bool ask() override{ + asks++; + return SimWanderWait::ask(); + } + size_t asks = 0; +}; + +// On lab-B (2026-11-12 11:03) 00.05b ended "no talk from any stand tile; +// on (56, 32)" with the clown diagonal, on (55, 33): A faced nobody, a +// dozen times. With him staying there and the wait on (56, 32), it steps +// to his row and talks within a few asks. +UnitTestResult test_mart_clown_diagonal_reached(Logger& logger){ + const StoryWorld world = clown_world(); + std::string out; + for (const std::string row : {"00.05b", "00.05c"}){ + const WanderWaitPlan table_plan = wander_wait_plan(story_step(row, "mart_clown")); + WanderWaitPlan plan = table_plan; + // Its east side's walk, from (56, 32) on. + std::vector& stands = plan.sides.at(0).stands; + const auto at = std::find(stands.begin(), stands.end(), TilePos{56, 32}); + if (at == stands.end()){ + return row + ": no stand on (56, 32)."; + } + std::rotate(stands.begin(), at, stands.end()); + SimWanderer clown{.name = "clown_mart", .box = jubilife_mart_clown_box(), .pos = {55, 33}, .seed = 1}; + clown.step_interval = Milliseconds(0); + GridSim sim({.world = &world, .wanderers = {clown}}, {56, 32}, Direction::WEST, false); + CountingWanderWait body(sim); + const WanderWaitResult result = wait_beside_wanderer(body, {56, 32}, plan); + logger.log(std::format("{}: ended {} after {} asks, talked on {}.", row, (int)result.end, body.asks, Pokemon::to_string(result.talked))); + if (result.end != WanderWaitEnd::TALKED || result.talked != TilePos{56, 33} || body.asks > 3){ + out += std::format("\n {}: ended {} on {} after {} asks, talked on {}.", row, (int)result.end, + Pokemon::to_string(result.at), body.asks, Pokemon::to_string(result.talked)); + } + } + return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait stayed off his row:{}", out)); +} + // How many of the clown's starts and seeds one stand tile alone talks // to him from, facing west, within the plan's asks. size_t talks_from(const StoryWorld& world, const TilePos& stand, const WanderWaitPlan& table_plan){ WanderWaitPlan plan = table_plan; - plan.stands = {stand}; + plan.sides = {{.stands = {stand}, .facing = Direction::WEST}}; + plan.asks = 12; + plan.passes = 1; plan.rounds = 1; size_t talks = 0; for (const TilePos& clown : clown_starts(stand)){ @@ -178,7 +224,7 @@ UnitTestResult test_mart_clown_first_stand(Logger& logger){ } } for (const std::string row : {"00.05b", "00.05c"}){ - const TilePos first = wander_wait_plan(story_step(row, "mart_clown")).stands.at(0); + const TilePos first = wander_wait_plan(story_step(row, "mart_clown")).sides.at(0).stands.at(0); if (first != TilePos{56, best_y}){ return std::format("{} waits first on {}; the simulation talks most from (56, {}).", row, Pokemon::to_string(first), best_y); } @@ -219,6 +265,8 @@ const WanderWaitCase WANDER_WAIT_CASES[] = { test_mart_clown_reached_from_column_56}, .expectation = {}}, {.input = {"Wander wait: the Mart clown is reached on whichever tile he stays (lab-B 2026-11-12, column 54)", test_mart_clown_reached_when_he_stays}, .expectation = {}}, + {.input = {"Wander wait: the Mart clown diagonal to (56, 32) is reached on his row within 3 asks (lab-B 2026-11-12 11:03)", + test_mart_clown_diagonal_reached}, .expectation = {}}, {.input = {"Wander wait: the Mart clown's first stand tile is where the simulation meets him most", test_mart_clown_first_stand}, .expectation = {}}, }; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json index 4daa0c242e..639468efa1 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json @@ -83,6 +83,28 @@ { "action": "wait_for_wanderer", "args": { + "far_stand": { + "facing": "east", + "map": "JubilifeCity", + "tiles": [ + [ + 54, + 32 + ], + [ + 54, + 33 + ], + [ + 54, + 34 + ], + [ + 54, + 33 + ] + ] + }, "stand": { "facing": "west", "map": "JubilifeCity", @@ -95,6 +117,10 @@ 56, 34 ], + [ + 56, + 33 + ], [ 56, 32 @@ -114,7 +140,7 @@ }, "id": "mart_clown", "kind": "talk", - "why": "the clown by the Mart (wanders 54..56, 32..34): wait on column 56 facing west until he comes level, A about every 2 s; 'Do Pokemon grow by defeating others?' Yes; Coupon 1. Ends north against the wall at (56, 30)" + "why": "the clown by the Mart (wanders 54..56, 32..34): wait in his box's east column facing west, then its west column facing east, a D-pad tap a tile along it and two A presses a tile; 'Do Pokemon grow by defeating others?' Yes; Coupon 1. Ends north against the wall at (56, 30)" }, { "action": "town", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index 3ae7db38bf..dd4623fb30 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -144,6 +144,28 @@ "action": "wait_for_wanderer", "args": { "again": true, + "far_stand": { + "facing": "east", + "map": "JubilifeCity", + "tiles": [ + [ + 54, + 32 + ], + [ + 54, + 33 + ], + [ + 54, + 34 + ], + [ + 54, + 33 + ] + ] + }, "stand": { "facing": "west", "map": "JubilifeCity", @@ -156,6 +178,10 @@ 56, 34 ], + [ + 56, + 33 + ], [ 56, 32 @@ -175,7 +201,7 @@ }, "id": "mart_clown", "kind": "talk", - "why": "his coupon again, or his talk if he gave it: wait on column 56 facing west, as in 00.05b" + "why": "his coupon again, or his talk if he gave it: wait in his box's end columns, as in 00.05b" }, { "action": "town", From 1de59e0e4540bf78f60b7d5e11f7a67d9955cbbd Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 11:16:17 -0800 Subject: [PATCH 03/47] BDSP AutoStory wander wait: a side's walk in its own function; the clown's moves as an enum in the tests Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_WanderWait.cpp | 33 ++++++++++++------- ...PokemonBDSP_AutoStory_WanderWait_Tests.cpp | 18 ++++++---- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp index 256a5ecee7..ae6021adc8 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp @@ -121,6 +121,25 @@ bool walk_out(WanderWaitBody& body, TilePos& at, const WanderWaitPlan& plan){ return walk_to(body, at, plan.exit, plan, plan.blocked_tries, nullptr); } +// Walks `side`'s stands the plan's passes, asking from each, until the +// talk counts (`talked`, on `at`). False if a step stayed blocked. +bool wait_at_side(WanderWaitBody& body, TilePos& at, const WanderWaitPlan& plan, const WanderWaitSide& side, bool& talked){ + for (size_t pass = 0; pass < plan.passes; pass++){ + for (const TilePos& stand : side.stands){ + if (!walk_to(body, at, stand, plan, plan.blocked_tries, &talked)){ + return false; + } + if (!talked){ + talked = ask_from_stand(body, plan, side.facing); + } + if (talked){ + return true; + } + } + } + return true; +} + } // namespace @@ -129,18 +148,10 @@ WanderWaitResult wait_beside_wanderer(WanderWaitBody& body, TilePos at, const Wa TilePos talked_at = at; for (size_t round = 0; round < plan.rounds && !talked; round++){ for (size_t s = 0; s < plan.sides.size() && !talked; s++){ - const WanderWaitSide& side = plan.sides[s]; - for (size_t pass = 0; pass < plan.passes && !talked; pass++){ - for (size_t i = 0; i < side.stands.size() && !talked; i++){ - if (!walk_to(body, at, side.stands[i], plan, plan.blocked_tries, &talked)){ - return {.end = WanderWaitEnd::STUCK, .at = at, .talked = at}; - } - if (!talked){ - talked = ask_from_stand(body, plan, side.facing); - } - talked_at = at; - } + if (!wait_at_side(body, at, plan, plan.sides[s], talked)){ + return {.end = WanderWaitEnd::STUCK, .at = at, .talked = at}; } + talked_at = at; } } if (!talked){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp index 1eb8f239fd..f95e034edf 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp @@ -84,11 +84,17 @@ std::vector clown_starts(const TilePos& player){ return starts; } +// Whether the clown walks his box or stays where he starts. +enum class ClownMoves{ + WANDERS, + STAYS, +}; + // The wait from `start` with the clown starting on `clown`, his walk -// seeded by `seed`; with `stays`, he never steps. -WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const TilePos& clown, uint64_t seed, const WanderWaitPlan& plan, bool stays = false){ +// seeded by `seed`. +WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const TilePos& clown, uint64_t seed, const WanderWaitPlan& plan, ClownMoves moves){ SimWanderer wanderer{.name = "clown_mart", .box = jubilife_mart_clown_box(), .pos = clown, .seed = seed}; - if (stays){ + if (moves == ClownMoves::STAYS){ wanderer.step_interval = Milliseconds(0); } GridSim sim({.world = &world, .wanderers = {wanderer}}, start, Direction::NORTH, false); @@ -115,7 +121,7 @@ UnitTestResult test_mart_clown_reached_from_column_56(Logger& logger){ for (const TilePos& clown : clown_starts(start)){ for (uint64_t seed = 1; seed <= SEEDS; seed++){ runs++; - const WanderWaitResult result = run_wait(world, start, clown, seed, plan); + const WanderWaitResult result = run_wait(world, start, clown, seed, plan, ClownMoves::WANDERS); if (result.end != WanderWaitEnd::TALKED || result.at != plan.exit){ out += std::format("\n {} with the clown on {}, seed {}: ended {} on {}.", row, Pokemon::to_string(clown), seed, (int)result.end, Pokemon::to_string(result.at)); @@ -138,7 +144,7 @@ UnitTestResult test_mart_clown_reached_when_he_stays(Logger& logger){ const WanderWaitPlan plan = wander_wait_plan(story_step(row, "mart_clown")); for (const TilePos& clown : clown_starts(start)){ runs++; - const WanderWaitResult result = run_wait(world, start, clown, 1, plan, true); + const WanderWaitResult result = run_wait(world, start, clown, 1, plan, ClownMoves::STAYS); if (result.end != WanderWaitEnd::TALKED || result.at != plan.exit){ out += std::format("\n {} with the clown staying on {}: ended {} on {}.", row, Pokemon::to_string(clown), (int)result.end, Pokemon::to_string(result.at)); @@ -202,7 +208,7 @@ size_t talks_from(const StoryWorld& world, const TilePos& stand, const WanderWai size_t talks = 0; for (const TilePos& clown : clown_starts(stand)){ for (uint64_t seed = 1; seed <= SEEDS; seed++){ - talks += run_wait(world, stand, clown, seed, plan).end == WanderWaitEnd::TALKED ? 1 : 0; + talks += run_wait(world, stand, clown, seed, plan, ClownMoves::WANDERS).end == WanderWaitEnd::TALKED ? 1 : 0; } } return talks; From 8f5e29e94daea577d48088318c5ff32180dbad83 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 12:11:25 -0800 Subject: [PATCH 04/47] BDSP AutoStory: a sim test for the Poketch Company's clown walking off the swept row (red) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonBDSP_AutoStory_Events.h | 3 + .../PokemonBDSP_AutoStory_Events_Jubilife.cpp | 4 ++ ...PokemonBDSP_AutoStory_WanderWait_Tests.cpp | 71 ++++++++++++++++--- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h index 64d5acd2fa..897df7a853 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h @@ -77,6 +77,9 @@ bool asks_someone_else(const Pokemon::MapData& map, Pokemon::TilePos stand, Poke // data/games/bdsp/maps/jubilife_city.json (decomp range 1). The story map // leaves him out of its wanderers (the decomp hides him behind a flag). Pokemon::TileBox jubilife_mart_clown_box(); +// The row the Poketch Company's clown wanders, round (15, 18), as the +// Mart clown's box. +Pokemon::TileBox jubilife_company_clown_box(); // The tiles 00.05c may start on: against the Poketch Company's sign // (00.05b's end), and on the street east (its own end, 01.01's start). std::pair jubilife_start_tiles(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp index 17c8f04acc..2e7d0947a7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp @@ -305,6 +305,10 @@ Pokemon::TileBox jubilife_mart_clown_box(){ return {.x0 = 54, .y0 = 32, .x1 = 56, .y1 = 34}; } +Pokemon::TileBox jubilife_company_clown_box(){ + return {.x0 = 14, .y0 = 18, .x1 = 16, .y1 = 18}; +} + std::pair jubilife_start_tiles(){ return {{14, 19}, {58, 22}}; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp index f95e034edf..513fa0a67e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp @@ -41,14 +41,18 @@ using Pokemon::TilePos; namespace{ -// Jubilife alone, with the Mart clown wandering his box instead of -// standing on (55, 33). One map at (0, 0): world tiles are its own. +// Jubilife alone, with the Mart clown and the Poketch Company's clown +// wandering their boxes instead of standing on their spawns. One map at +// (0, 0): world tiles are its own. StoryWorld clown_world(){ Pokemon::MapData map = story_map("JubilifeCity"); for (Pokemon::MapObject& object : map.objects){ if (object.name == "clown_mart"){ object.wander = jubilife_mart_clown_box(); } + if (object.name == "clown_poketch_company"){ + object.wander = jubilife_company_clown_box(); + } } StoryWorld world; world.add("JubilifeCity", map, {0, 0}); @@ -70,10 +74,9 @@ const Pokemon::StoryStep& story_step(const std::string& row, const std::string& throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No step {} in row {}.", name, row)); } -// Where the clown may start: each tile of his box but `player`'s. -std::vector clown_starts(const TilePos& player){ +// Where a clown wandering `box` may start: each tile of it but `player`'s. +std::vector clown_starts(const TilePos& player, const TileBox& box = jubilife_mart_clown_box()){ std::vector starts; - const TileBox box = jubilife_mart_clown_box(); for (int y = box.y0; y <= box.y1; y++){ for (int x = box.x0; x <= box.x1; x++){ if (TilePos{x, y} != player){ @@ -90,10 +93,25 @@ enum class ClownMoves{ STAYS, }; -// The wait from `start` with the clown starting on `clown`, his walk -// seeded by `seed`. -WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const TilePos& clown, uint64_t seed, const WanderWaitPlan& plan, ClownMoves moves){ - SimWanderer wanderer{.name = "clown_mart", .box = jubilife_mart_clown_box(), .pos = clown, .seed = seed}; +// Which clown a wait is for. +struct Clown{ + std::string name; + TileBox box; +}; +Clown mart_clown(){ + return {"clown_mart", jubilife_mart_clown_box()}; +} +Clown company_clown(){ + return {"clown_poketch_company", jubilife_company_clown_box()}; +} + +// The wait from `start` with `who` starting on `clown`, his walk seeded +// by `seed`. +WanderWaitResult run_clown_wait( + const StoryWorld& world, const Clown& who, const TilePos& start, const TilePos& clown, uint64_t seed, + const WanderWaitPlan& plan, ClownMoves moves +){ + SimWanderer wanderer{.name = who.name, .box = who.box, .pos = clown, .seed = seed}; if (moves == ClownMoves::STAYS){ wanderer.step_interval = Milliseconds(0); } @@ -106,9 +124,42 @@ WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const T } return result; } +// The wait for the Mart clown. +WanderWaitResult run_wait(const StoryWorld& world, const TilePos& start, const TilePos& clown, uint64_t seed, const WanderWaitPlan& plan, ClownMoves moves){ + return run_clown_wait(world, mart_clown(), start, clown, seed, plan, moves); +} constexpr uint64_t SEEDS = 8; +// On lab-B (2026-11-12 11:47) 00.05b's company_clown swept row 19 below +// the Poketch Company's clown, asking north, while he walked off it: "no +// coupon question from any tile below his range". 00.05b and 00.05c now +// wait for him in his row (14..16, 18): from where their routes leave us, +// (15, 19), the wait talks to him wherever he starts or stays, and ends +// against the company's sign on (14, 19). +UnitTestResult test_company_clown_reached_in_his_row(Logger& logger){ + const StoryWorld world = clown_world(); + const TilePos start{15, 19}; + std::string out; + size_t runs = 0; + for (const std::string row : {"00.05b", "00.05c"}){ + const WanderWaitPlan plan = wander_wait_plan(story_step(row, "company_clown")); + for (const TilePos& clown : clown_starts(start, jubilife_company_clown_box())){ + for (uint64_t seed = 0; seed <= SEEDS; seed++){ + runs++; + const ClownMoves moves = seed == 0 ? ClownMoves::STAYS : ClownMoves::WANDERS; + const WanderWaitResult result = run_clown_wait(world, company_clown(), start, clown, seed, plan, moves); + if (result.end != WanderWaitEnd::TALKED || result.at != plan.exit){ + out += std::format("\n {} with the clown on {}, seed {}: ended {} on {}.", row, + Pokemon::to_string(clown), seed, (int)result.end, Pokemon::to_string(result.at)); + } + } + } + } + logger.log(std::format("{} waits run.", runs)); + return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait missed the company's clown:{}", out)); +} + // 00.05b comes up column 56 from the wall (56, 36), 00.05c down it from // (56, 31): from each, the wait talks to the clown wherever in his box he // starts, over seeds 1 to 8, and ends on (56, 31). @@ -273,6 +324,8 @@ const WanderWaitCase WANDER_WAIT_CASES[] = { test_mart_clown_reached_when_he_stays}, .expectation = {}}, {.input = {"Wander wait: the Mart clown diagonal to (56, 32) is reached on his row within 3 asks (lab-B 2026-11-12 11:03)", test_mart_clown_diagonal_reached}, .expectation = {}}, + {.input = {"Wander wait: the Poketch Company's clown is reached in his row, wandering or not (lab-B 2026-11-12 11:47)", + test_company_clown_reached_in_his_row}, .expectation = {}}, {.input = {"Wander wait: the Mart clown's first stand tile is where the simulation meets him most", test_mart_clown_first_stand}, .expectation = {}}, }; From d1036d9defde8bf76601a6b740e59bd3cab1147a Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 12:12:41 -0800 Subject: [PATCH 05/47] BDSP AutoStory: 00.05b and 00.05c wait for the Poketch Company's clown in his row On lab-B (2026-11-12 11:47) 00.05b's company_clown swept row 19 below him, asking north, while he walked off: no coupon question from any tile. His zone is the one row (14..16, 18): the step is now a wait_for_wanderer on its west end (14, 18) facing east, then its east end (16, 18) facing west, so he has to come next to us on our row. It ends against the company's sign on (14, 19) facing west, as the save tile was before. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/StoryData/bdsp-00.05b.plan.json | 30 ++++++++++++++++--- .../AutoStory/StoryData/bdsp-00.05c.plan.json | 30 +++++++++++++++---- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json index 639468efa1..989ed18b9c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json @@ -202,20 +202,42 @@ "why": "west along the long road, north beside the sign" }, { - "action": "talk_to_wanderer", + "action": "wait_for_wanderer", + "args": { + "far_stand": { + "facing": "west", + "map": "JubilifeCity", + "tiles": [ + [ + 16, + 18 + ] + ] + }, + "stand": { + "facing": "east", + "map": "JubilifeCity", + "tiles": [ + [ + 14, + 18 + ] + ] + } + }, "declared_after": { - "facing": "north", + "facing": "west", "map": "JubilifeCity", "tiles": [ [ - 15, + 14, 19 ] ] }, "id": "company_clown", "kind": "talk", - "why": "the clown by the Poketch Company: 'Do moves have types?' Yes; Coupon 2" + "why": "the clown by the Poketch Company (wanders 14..16, 18): wait in his row, on (14, 18) facing east, then (16, 18) facing west; 'Do moves have types?' Yes; Coupon 2. Ends west against the company's sign (13, 19)" }, { "action": "line", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index dd4623fb30..a2875e0cde 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -49,23 +49,43 @@ "why": "below the Poketch Company's clown" }, { - "action": "talk_to_wanderer", + "action": "wait_for_wanderer", "args": { - "again": true + "again": true, + "far_stand": { + "facing": "west", + "map": "JubilifeCity", + "tiles": [ + [ + 16, + 18 + ] + ] + }, + "stand": { + "facing": "east", + "map": "JubilifeCity", + "tiles": [ + [ + 14, + 18 + ] + ] + } }, "declared_after": { - "facing": "north", + "facing": "west", "map": "JubilifeCity", "tiles": [ [ - 15, + 14, 19 ] ] }, "id": "company_clown", "kind": "talk", - "why": "his coupon again, or his talk if he gave it (00.05b's, lab-B 2026-11-11: a coupon went missing)" + "why": "his coupon again, or his talk if he gave it (00.05b's, lab-B 2026-11-11: a coupon went missing): wait in his row as in 00.05b; ends west against the company's sign" }, { "action": "town", From 41c9d2e5ff7d43d5051981bf93583780630b2950 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 12:17:36 -0800 Subject: [PATCH 06/47] BDSP AutoStory 00.05c: the later routes keep off the Wonder Station's plaza too; the president stands on (46, 35) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/StoryData/bdsp-00.05c.plan.json | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index a2875e0cde..c03761c8e7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -90,6 +90,20 @@ { "action": "town", "args": { + "avoid": [ + [ + 40, + 20, + 52, + 25 + ], + [ + 40, + 26, + 43, + 27 + ] + ], "fight_wild": false, "greeter": [ [ @@ -136,6 +150,20 @@ { "action": "town", "args": { + "avoid": [ + [ + 40, + 20, + 52, + 25 + ], + [ + 40, + 26, + 43, + 27 + ] + ], "fight_wild": false, "greeter": [ [ @@ -226,6 +254,20 @@ { "action": "town", "args": { + "avoid": [ + [ + 40, + 20, + 52, + 25 + ], + [ + 40, + 26, + 43, + 27 + ] + ], "fight_wild": false, "greeter": [ [ @@ -253,7 +295,7 @@ { "id": "president", "kind": "talk", - "why": "the Poketch Company's president at (46, 36)" + "why": "the Poketch Company's president at (46, 35), level with (45, 35)" }, { "declared_after": { @@ -279,6 +321,20 @@ { "action": "line", "args": { + "avoid": [ + [ + 40, + 20, + 52, + 25 + ], + [ + 40, + 26, + 43, + 27 + ] + ], "fight_wild": false, "target": { "facing": "east", From e97d0035999b3efcb36cf6e9c7d20ff139a45202 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 12:18:18 -0800 Subject: [PATCH 07/47] BDSP AutoStory: route goldens for 00.05b/00.05c ending against the company's sign and keeping off the plaza Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_bench.golden.txt | 8 ++--- .../AutoStory/Data/route_plans.golden.txt | 35 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index 4f20ad59b1..e2318fda67 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -38,12 +38,12 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05b below_the_mart_clown | 5450 | 5450 | 5450 | 1 | 0 | 0 | 3.30! | 1.00 | 1.00 | 1650 ms (stand-in) | PASS 00.05b below_the_tv_clown | 27350 | 27350 | 27350 | 1 | 0 | 0 | 6.29! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS -00.05b beside_the_company_sign | 1450 | 1450 | 1450 | 1 | 0 | 0 | 4.14! | 1.00 | 1.00 | 350 ms (stand-in) | PASS +00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS 00.05c below_the_company_clown | 900 | 900 | 900 | 0 | 0 | 0 | 2.57! | 1.00 | 1.00 | 350 ms (stand-in) | PASS -00.05c below_the_tv_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 5.00! | 3250 ms (stand-in) | PASS -00.05c below_the_mart_clown | 20350 | 20350 | 20350 | 1 | 0 | 0 | 4.68! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS +00.05c below_the_tv_clown | 22700 | 22700 | 22700 | 0 | 0 | 0 | 6.78! | 1.00 | 5.00! | 3350 ms (stand-in) | PASS +00.05c below_the_mart_clown | 18550 | 18550 | 18550 | 3 | 0 | 0 | 4.26! | 1.00 | 23.00! | 4350 ms (stand-in) | PASS 00.05c beside_the_president | 12200 | 12200 | 12200 | 0 | 0 | 0 | 6.26! | 1.00 | 1.00 | 1950 ms (stand-in) | PASS -00.05c to_the_route_203_street | 21000 | 21000 | 21000 | 0 | 0 | 0 | 6.00! | 1.00 | 1.00 | 3500 ms (stand-in) | PASS +00.05c to_the_route_203_street | 14250 | 14250 | 14250 | 1 | 0 | 0 | 4.07! | 1.00 | 1.00 | 3500 ms (stand-in) | PASS 01.01 west_of_barrys_trigger | 7300 | 7300 | 7300 | 0 | 0 | 0 | 6.35! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 01.02 by_the_gate | 24815 | 26050 | 13700 | 2 | 9 | 0 | 3.60! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 5e5f4df555..84496c1e17 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -243,11 +243,10 @@ anchor); 0 from one start tile. totals: 3 legs, 2 turns, 3 open, 0 localization == 00.05b beside_the_company_sign (costs: line) - from: JubilifeCity (15, 19) facing north (tile) + from: JubilifeCity (14, 19) facing west (tile) target: JubilifeCity (14, 19) facing west (tile) - start candidates: Jubilife City (15, 19) - 1. west 1 (to wall) -> Jubilife City (14, 19) - totals: 1 legs, 0 turns, 0 open, 0 localization + start candidates: Jubilife City (14, 19) + totals: 0 legs, 0 turns, 0 open, 0 localization == 00.05c below_the_company_clown (costs: town) from: JubilifeCity (14, 19) facing west (tile) @@ -257,11 +256,11 @@ anchor); 0 from one start tile. totals: 1 legs, 0 turns, 1 open, 0 localization == 00.05c below_the_tv_clown (costs: town) - from: JubilifeCity (15, 19) facing north (tile) + from: JubilifeCity (14, 19) facing west (tile) target: JubilifeCity (36, 17) facing north (tile) - start candidates: Jubilife City (15, 19) - 1. south 2 (open) -> Jubilife City (15, 21) - 2. east 21 (open) -> Jubilife City (36, 21) + start candidates: Jubilife City (14, 19) + 1. south 2 (open) -> Jubilife City (14, 21) + 2. east 22 (open) -> Jubilife City (36, 21) 3. north 4 (open) -> Jubilife City (36, 17) totals: 3 legs, 2 turns, 3 open, 0 localization @@ -269,10 +268,14 @@ anchor); 0 from one start tile. from: JubilifeCity (36, 17) facing north (tile) target: JubilifeCity (56, 31) facing south (tile) start candidates: Jubilife City (36, 17) - 1. east 8 (open) -> Jubilife City (44, 17) - 2. south 14 (open) -> Jubilife City (44, 31) - 3. east 12 (to wall) -> Jubilife City (56, 31) - totals: 3 legs, 2 turns, 2 open, 0 localization + 1. west 1 (open) -> Jubilife City (35, 17) + 2. south 10 (to wall) -> Jubilife City (35, 27) + 3. east 1 (to wall) -> Jubilife City (36, 27) + 4. south 5 (open) -> Jubilife City (36, 32) + 5. east 7 (open) -> Jubilife City (43, 32) + 6. north 1 (open) -> Jubilife City (43, 31) + 7. east 13 (to wall) -> Jubilife City (56, 31) + totals: 7 legs, 6 turns, 4 open, 0 localization == 00.05c beside_the_president (costs: town) from: JubilifeCity (56, 31) facing north (tile) @@ -286,9 +289,11 @@ anchor); 0 from one start tile. from: JubilifeCity (45, 35) facing east (tile) target: JubilifeCity (58, 22) facing east (tile) start candidates: Jubilife City (45, 35) - 1. north 13 (open) -> Jubilife City (45, 22) - 2. east 13 (open) -> Jubilife City (58, 22) - totals: 2 legs, 1 turns, 2 open, 0 localization + 1. north 9 (open) -> Jubilife City (45, 26) + 2. east 14 (to wall) -> Jubilife City (59, 26) + 3. west 1 (open) -> Jubilife City (58, 26) + 4. north 4 (open) -> Jubilife City (58, 22) + totals: 4 legs, 3 turns, 3 open, 0 localization == 01.01 west_of_barrys_trigger (costs: town) from: JubilifeCity (58, 22) facing east (tile) From d4d1588f88c8f79060e1d4c7dc8736c9c4bee346 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:15:28 -0800 Subject: [PATCH 08/47] BDSP AutoStory: read the coupons in the Bag; sim cases for held coupons, a missing one at 00.05b's end and the company clown idling two tiles away (red) read_coupons sets a flag for each coupon in the Key Items; check_coupons fails when one is missing. The wander wait walks a shared row straight, asking a blocked step. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonBDSP_AutoStory_Bag.cpp | 13 ++++ .../Actions/PokemonBDSP_AutoStory_Bag.h | 10 +++ .../PokemonBDSP_AutoStory_BagItemReader.cpp | 9 ++- .../PokemonBDSP_AutoStory_BagItemReader.h | 5 ++ .../Actions/PokemonBDSP_AutoStory_Events.h | 11 +++ .../PokemonBDSP_AutoStory_Events_Jubilife.cpp | 70 +++++++++++++++++++ .../PokemonBDSP_AutoStory_WanderWait.cpp | 7 +- .../PokemonBDSP_AutoStory_WanderWait.h | 11 +-- ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 24 +++++++ .../PokemonBDSP_AutoStory_StorySim.cpp | 20 ++++++ .../PokemonBDSP_AutoStory_StorySim.h | 3 + ...onBDSP_AutoStory_StorySimulation_Tests.cpp | 2 +- ...PokemonBDSP_AutoStory_WanderWait_Tests.cpp | 28 ++++++++ 13 files changed, 204 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp index 47a82d84be..35ad278940 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp @@ -381,6 +381,19 @@ bool bag_has_item(VideoStream& stream, ProControllerContext& context, const std: return found; } +std::vector bag_has_items( + VideoStream& stream, ProControllerContext& context, const std::vector& names, int target_pocket +){ + std::vector found; + open_menu(stream, context, MenuCursorPosition::BAG, 5); + pbf_wait(context, 1000ms); + for (const std::string& name : names){ + found.push_back(find_bag_item_in_open_bag(stream, context, name, target_pocket)); + } + bag_back_to_overworld(stream, context, "Bag: Did not return to the overworld after looking for the Key Items."); + return found; +} + void use_potion_first_pokemon(VideoStream& stream, ProControllerContext& context, double heal_below){ OverlayBoxScope hp_overlay(stream.overlay(), COLOR_GREEN, {0.137, 0.160, 0.202, 0.016}, ""); bool healed = false; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.h index 8d36bcb927..f38caf2785 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.h @@ -13,6 +13,7 @@ #include #include +#include #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/Tools/VideoStream.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" @@ -52,6 +53,15 @@ bool bag_has_item( int target_pocket ); +// Open the Bag from the overworld once, look for each of `names` in the +// pocket, and close it again. Whether each is there, in `names`' order. +std::vector bag_has_items( + VideoStream& stream, + ProControllerContext& context, + const std::vector& names, + int target_pocket +); + // Read the lead's HP bar in the Bag and, if it is below `heal_below` (a // fraction of full), use Potions until it is full. heal_below = 1 always // heals; 0.5 only checks and heals when the lead is under half, and is diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.cpp index c2fbea43f9..11bc87234f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.cpp @@ -24,7 +24,8 @@ constexpr std::string_view STORY_ITEM_OCR = R"JSON({ "eng": { "potion": ["Potion"], "antidote": ["Antidote"], "paralyze-heal": ["Paralyze Heal"], "awakening": ["Awakening"], "poke-ball": ["Poké Ball", "Poke Ball"], "repel": ["Repel"], - "super-repel": ["Super Repel"], "max-repel": ["Max Repel"], "escape-rope": ["Escape Rope"] + "super-repel": ["Super Repel"], "max-repel": ["Max Repel"], "escape-rope": ["Escape Rope"], + "coupon-1": ["Coupon 1"], "coupon-2": ["Coupon 2"], "coupon-3": ["Coupon 3"] }, "fra": { "potion": ["Potion"], "antidote": ["Antidote"], "paralyze-heal": ["Anti-Para"], @@ -109,6 +110,12 @@ std::string read_bag_item_slug(Logger& logger, Language language, const ImageVie return StoryItemMatcher::instance().read(logger, language, image); } +bool bag_item_named(Language language, std::string_view slug){ + const JsonValue json = parse_json(std::string(STORY_ITEM_OCR)); + const JsonObject* names = json.to_object_throw().get_object(language_data(language).code); + return names != nullptr && names->get_value(std::string(slug)) != nullptr; +} + } // namespace PokemonBDSP } // namespace NintendoSwitch diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.h index 5f378de015..f4e7779ffe 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagItemReader.h @@ -11,6 +11,7 @@ #define PokemonAutomation_PokemonBDSP_AutoStory_BagItemReader_H #include +#include #include "Common/Cpp/Logging/AbstractLogger.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/Language.h" @@ -24,6 +25,10 @@ namespace PokemonBDSP{ // "" when it is none of them. std::string read_bag_item_slug(Logger& logger, Language language, const ImageViewRGB32& image); +// Whether the reader has a name for the item `slug` in `language` (the +// coupons have their English names only). +bool bag_item_named(Language language, std::string_view slug); + } // namespace PokemonBDSP } // namespace NintendoSwitch diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h index 897df7a853..1efd79316a 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include #include "Pokemon/Navigation/Pokemon_MapData.h" #include "PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h" @@ -77,6 +79,15 @@ bool asks_someone_else(const Pokemon::MapData& map, Pokemon::TilePos stand, Poke // data/games/bdsp/maps/jubilife_city.json (decomp range 1). The story map // leaves him out of its wanderers (the decomp hides him behind a flag). Pokemon::TileBox jubilife_mart_clown_box(); +// A Jubilife clown's coupon (00.05b, 00.05c): his talk step, the Key +// Item's Bag slug, and the run flag read_coupons sets when it is held. +struct ClownCoupon{ + std::string_view step; + std::string_view slug; + std::string_view flag; +}; +// The three clowns' coupons: the Mart's 1, the company's 2, the TV's 3. +std::span jubilife_clown_coupons(); // The row the Poketch Company's clown wanders, round (15, 18), as the // Mart clown's box. Pokemon::TileBox jubilife_company_clown_box(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp index 2e7d0947a7..7a5b0cd9d4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp @@ -9,6 +9,9 @@ #include #include +#include +#include +#include #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -28,6 +31,9 @@ #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkDpad.h" #include "PokemonBDSP_AutoStory_Talks.h" #include "PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walks.h" +#include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_StoryLanguage.h" +#include "PokemonBDSP_AutoStory_Bag.h" +#include "PokemonBDSP_AutoStory_BagItemReader.h" #include "PokemonBDSP_AutoStory_WildBattle.h" #include "PokemonBDSP_AutoStory_Events.h" #include "PokemonBDSP_AutoStory_WanderWait.h" @@ -254,6 +260,59 @@ void check_poketch(VideoStream& stream, ProControllerContext& context){ stream.log("[Talk] The Poketch is on the screen."); } +// The Bag's Key Items pocket. +constexpr int KEY_ITEMS_POCKET = 8; + +// The coupons in the Key Items pocket, when the reader has their names in +// the game's language: whether each clown's is held, in +// jubilife_clown_coupons()' order. +std::optional> held_coupons(VideoStream& stream, ProControllerContext& context){ + std::vector slugs; + for (const ClownCoupon& coupon : jubilife_clown_coupons()){ + if (!bag_item_named(story_language(), coupon.slug)){ + stream.log(std::format("[Coupons] No name for {} in the game's language: not read.", coupon.slug), COLOR_ORANGE); + return std::nullopt; + } + slugs.emplace_back(coupon.slug); + } + return bag_has_items(stream, context, slugs, KEY_ITEMS_POCKET); +} + +// 00.05c's look in the Bag: a flag for each coupon held, so the talk to +// a clown whose coupon is there is skipped (its step's skip_if). Unread, +// every clown is talked to. +Pokemon::Outcome read_coupons(StoryExecutor& executor, Pokemon::RunState& state, const Pokemon::StoryStep&){ + VideoStream& stream = executor.stream(); + const std::optional> held = held_coupons(stream, executor.context()); + if (!held){ + return Pokemon::outcome_ok(); + } + const std::span coupons = jubilife_clown_coupons(); + for (size_t i = 0; i < coupons.size(); i++){ + stream.log(std::format("[Coupons] {}: {}.", coupons[i].slug, (*held)[i] ? "held" : "missing")); + if ((*held)[i]){ + state.flags.emplace(coupons[i].flag); + } + } + return Pokemon::outcome_ok(); +} + +// 00.05b's end: all three coupons in the Bag, or the row fails here +// rather than saving a run the president will give no Poketch. +void check_coupons(VideoStream& stream, ProControllerContext& context){ + const std::optional> held = held_coupons(stream, context); + if (!held){ + return; + } + const std::span coupons = jubilife_clown_coupons(); + for (size_t i = 0; i < coupons.size(); i++){ + if (!(*held)[i]){ + fail_step(stream, std::format("No {} in the Key Items: {} gave none.", coupons[i].slug, coupons[i].step)); + } + } + stream.log("[Coupons] All three coupons are in the Key Items."); +} + // 00.05c starts against the Poketch Company's sign (14, 19) facing west // (00.05b's end) or on the street east, (58, 22) facing east (its own end // and 01.01's start, when a run gave no Poketch). A step west tells them @@ -305,6 +364,15 @@ Pokemon::TileBox jubilife_mart_clown_box(){ return {.x0 = 54, .y0 = 32, .x1 = 56, .y1 = 34}; } +std::span jubilife_clown_coupons(){ + static constexpr ClownCoupon COUPONS[] = { + {.step = "mart_clown", .slug = "coupon-1", .flag = "has_coupon_1"}, + {.step = "company_clown", .slug = "coupon-2", .flag = "has_coupon_2"}, + {.step = "tv_clown", .slug = "coupon-3", .flag = "has_coupon_3"}, + }; + return COUPONS; +} + Pokemon::TileBox jubilife_company_clown_box(){ return {.x0 = 14, .y0 = 18, .x1 = 16, .y1 = 18}; } @@ -317,6 +385,8 @@ void add_jubilife_events(StoryEvents& events){ events.emplace("talk_to_wanderer", talk_to_wanderer); events.emplace("wait_for_wanderer", wait_for_wanderer); events.emplace("check_poketch", console_event(check_poketch)); + events.emplace("read_coupons", read_coupons); + events.emplace("check_coupons", console_event(check_coupons)); events.emplace("jubilife_start_probe", jubilife_start_probe); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp index ae6021adc8..d9f4f29c57 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.cpp @@ -68,10 +68,11 @@ int crossing_row(const WanderWaitPlan& plan, const TilePos& at, const TilePos& t return up <= down ? above : below; } -// Walks from `at` to `to`: down the column, or between columns along a -// crossing row. Asks a blocked step in a column as walk_line() does. +// Walks from `at` to `to`: along the row or the column they share, or +// between columns along a crossing row. Asks a blocked step in the row or +// column as walk_line() does: in his zone, it is him. bool walk_to(WanderWaitBody& body, TilePos& at, TilePos to, const WanderWaitPlan& plan, size_t tries, bool* talked){ - if (at.x == to.x){ + if (at.x == to.x || at.y == to.y){ return walk_line(body, at, to, plan, tries, talked); } const int row = crossing_row(plan, at, to); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h index 149cb0fc19..437a9ab50d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WanderWait.h @@ -7,9 +7,11 @@ * each time he may have come level, then try the next tile. Our tile is * one he can no longer step on, so he comes level more often. A box wider * than two columns has a far column he can stay on out of reach: the wait - * then takes turns between the two ends. The Mart clown (00.05b, 00.05c) - * wanders columns 54 to 56: he is waited for on 56 facing west, then on - * 54 facing east. + * then takes turns between the two ends, and a side may hold tiles a step + * in from its end, toward him. The Mart clown (00.05b, 00.05c) wanders + * columns 54 to 56: he is waited for on 56 facing west, then on 54 facing + * east. The Poketch Company's clown wanders the row (14..16, 18): from + * 14 and 15 facing east, then 16 and 15 facing west. * */ @@ -34,7 +36,8 @@ struct WanderWaitSide{ Pokemon::Direction facing = Pokemon::Direction::WEST; }; -// Where and how long to wait. Between columns the wait walks round the +// Where and how long to wait. Between stands on one row or column the +// wait walks straight; between columns otherwise it walks round the // stands' rows: along the row above them or the one below, whichever is // shorter. Those rows must be open. struct WanderWaitPlan{ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp index e835a17caa..d7aa868885 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp @@ -451,6 +451,28 @@ UnitTestResult no_poketch_fails_00_05c(Logger& logger){ UnitTestResult missing_coupon_collected_in_00_05c(Logger& logger){ return passes(poketch_run(logger, false)); } +// 00.05c on lab-B 2026-11-12 12:48: the save held all three coupons, and +// the re-talk to the Poketch Company's clown failed the row ("no talk from +// any stand tile") while he stayed out of reach. The Bag's coupons skip +// the talks to clowns who gave theirs. +UnitTestResult held_coupons_skip_00_05c_clowns(Logger& logger){ + SimWorldKnobs knobs; + knobs.out_of_reach = {"company_clown", "mart_clown"}; + return passes(run_case(logger, "00.05c", "00.05c", {.fade = {}, .banner = {}}, std::move(knobs))); +} +// 00.05b with the Poketch Company's clown answered by the sign's text +// (lab-B 2026-11-11): two coupons. The row fails at its coupon check +// instead of saving them. +UnitTestResult missing_coupon_fails_00_05b(Logger& logger){ + SimWorldKnobs knobs; + knobs.coupons_at_start = {}; + knobs.talks_without_coupon = {"company_clown"}; + const std::string stopped = run_case(logger, "00.05b", "00.05b", {.fade = {}, .banner = {}}, std::move(knobs)); + if (stopped.find("00.05b all_three_coupons") == std::string::npos){ + return UnitTestResult("expected a stop at 00.05b's coupon check; got " + (stopped.empty() ? std::string("a pass") : stopped)); + } + return true; +} // 01.01 from a save with no Poketch: Jubilife's east-exit guard would // ask about the Poketch campaign and turn us back (lab-B 2026-11-11, the // walk took him for a trainer); the row stops at its first step instead. @@ -740,6 +762,8 @@ const FailureCase AUTO_STORY_FAILURE_CASES[] = { }}, .expectation = {}}, {.input = {"00.05c a coupon missing (the sign read for the Poketch Company clown): no Poketch, 00.05c fails (lab-B 2026-11-11)", no_poketch_fails_00_05c}, .expectation = {}}, {.input = {"00.05c a coupon missing from 00.05b: its clown talks collect it, the president gives the Poketch", missing_coupon_collected_in_00_05c}, .expectation = {}}, + {.input = {"00.05c all three coupons held: no clown is talked to, so one out of reach does not fail the row (lab-B 2026-11-12 12:48)", held_coupons_skip_00_05c_clowns}, .expectation = {}}, + {.input = {"00.05b a coupon missing at its end: the row fails at its coupon check, before the save", missing_coupon_fails_00_05b}, .expectation = {}}, {.input = {"01.01 with no Poketch: the east-exit guard's gate stops the row at its check, not a trainer fight (lab-B 2026-11-11)", gate_guard_stops_01_01}, .expectation = {}}, {.input = {"00.04 to the ledge column with a wild battle on each pass through Route 201's grass (lab-B 2026-11-09 16:14)", [](Logger& logger){ return passes(ledge_walk_in_grass(logger, {})); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp index 8df64c2a21..d4d4e035c2 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp @@ -13,6 +13,7 @@ #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "Pokemon/AutoStory/Types/Pokemon_GridPose.h" +#include "PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h" #include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Maps.h" #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h" #include "PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryPlaces.h" @@ -700,6 +701,9 @@ StoryBoundActions SimExecutor::sim_actions(){ if (!sync(state.pose)){ return stubbed(step, state); } + if (m_knobs.out_of_reach.contains(step.name)){ + return Pokemon::outcome_failed("operation_failed", step.name + ": no talk from any stand tile."); + } return sim_wait_for_wanderer(m_sim, m_sim.world(), state.pose, step); }; return StoryBoundActions{ @@ -723,6 +727,22 @@ StoryBoundActions SimExecutor::sim_actions(){ if (name == "wait_for_wanderer"){ return wait_for_wanderer; } + if (name == "read_coupons"){ + return [this](const StoryStep&, RunState& state){ + for (const ClownCoupon& coupon : jubilife_clown_coupons()){ + if (m_coupons.contains(std::string(coupon.step))){ + state.flags.emplace(coupon.flag); + } + } + return Pokemon::outcome_ok(); + }; + } + if (name == "check_coupons"){ + return [this](const StoryStep& step, RunState&){ + return m_coupons.size() == jubilife_clown_coupons().size() ? Pokemon::outcome_ok() + : Pokemon::outcome_failed("operation_failed", std::format("{}: {} of the coupons in the Key Items.", step.name, m_coupons.size())); + }; + } return stubbed; }, }; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h index 4eecb78cfe..f61e5a625b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h @@ -209,6 +209,9 @@ struct SimWorldKnobs{ // president's talk gives it with all three coupons only. std::set coupons_at_start = {"mart_clown", "tv_clown", "company_clown"}; std::set talks_without_coupon = {}; + // The wanderer waits, by step name, that never meet him (lab-B + // 2026-11-12 12:48: the company's clown stayed out of reach). + std::set out_of_reach = {}; bool poketch_at_start = true; }; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp index 6c917376ed..a8d4a1bf36 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp @@ -546,7 +546,7 @@ UnitTestResult test_gives_up_after_attempts(Logger&){ // Events that leave the player where they were: the look at the Poketch, // and 00.05c's start probe, whose step west the Poketch Company's sign // stops on 00.05b's end, (14, 19). -const std::set EVENTS_IN_PLACE{"check_poketch", "jubilife_start_probe"}; +const std::set EVENTS_IN_PLACE{"check_poketch", "jubilife_start_probe", "read_coupons", "check_coupons"}; // Each row that has a start pose starts where the row before it leaves // the player, by the same planning and walking the fake run does. diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp index 513fa0a67e..be362ff919 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp @@ -248,6 +248,32 @@ UnitTestResult test_mart_clown_diagonal_reached(Logger& logger){ return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait stayed off his row:{}", out)); } +// On lab-B (2026-11-12 12:48) 00.05c's wait for the Poketch Company's +// clown ended on (16, 18) with him idling on our row out of reach. From +// either end of his row alone, the wait steps toward him a tile at a time +// inside his row and talks to him idling at the other end. +UnitTestResult test_company_clown_idling_two_tiles_away(Logger& logger){ + const StoryWorld world = clown_world(); + std::string out; + for (const std::string row : {"00.05b", "00.05c"}){ + const WanderWaitPlan table_plan = wander_wait_plan(story_step(row, "company_clown")); + for (const WanderWaitSide& side : table_plan.sides){ + WanderWaitPlan plan = table_plan; + plan.sides = {side}; + plan.rounds = 1; + const TilePos end = side.stands.at(0); + const TilePos clown{end.x == 14 ? 16 : 14, end.y}; + const TilePos start = end.next(Direction::SOUTH); + const WanderWaitResult result = run_clown_wait(world, company_clown(), start, clown, 1, plan, ClownMoves::STAYS); + logger.log(std::format("{} from {}: ended {} on {}.", row, Pokemon::to_string(end), (int)result.end, Pokemon::to_string(result.at))); + if (result.end == WanderWaitEnd::NO_TALK){ + out += std::format("\n {}: from {} with him on {}, no talk.", row, Pokemon::to_string(end), Pokemon::to_string(clown)); + } + } + } + return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait stayed at the end:{}", out)); +} + // How many of the clown's starts and seeds one stand tile alone talks // to him from, facing west, within the plan's asks. size_t talks_from(const StoryWorld& world, const TilePos& stand, const WanderWaitPlan& table_plan){ @@ -326,6 +352,8 @@ const WanderWaitCase WANDER_WAIT_CASES[] = { test_mart_clown_diagonal_reached}, .expectation = {}}, {.input = {"Wander wait: the Poketch Company's clown is reached in his row, wandering or not (lab-B 2026-11-12 11:47)", test_company_clown_reached_in_his_row}, .expectation = {}}, + {.input = {"Wander wait: the Poketch Company's clown idling at his row's other end is reached (lab-B 2026-11-12 12:48)", + test_company_clown_idling_two_tiles_away}, .expectation = {}}, {.input = {"Wander wait: the Mart clown's first stand tile is where the simulation meets him most", test_mart_clown_first_stand}, .expectation = {}}, }; From c5d00b371d70ddb0b8b059522ad55dc37217ace3 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:16:21 -0800 Subject: [PATCH 09/47] BDSP AutoStory 00.05b/00.05c: coupons from the Bag; the company clown's wait steps toward him 00.05c reads the Key Items after its start probe and skips the talk to each clown whose coupon is there (lab-B 2026-11-12 12:48: the re-talk to the Poketch Company's clown, who had given his, failed the row). Its walk to him now ends against the company's sign, where the talk ends, so a skipped talk leaves the pose right. 00.05b ends with the same check and fails before its save when a coupon is missing. The company clown's wait also stands a tile in from each end of his row, toward him. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/StoryData/bdsp-00.05b.plan.json | 16 +++++++++- .../AutoStory/StoryData/bdsp-00.05c.plan.json | 29 +++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json index 989ed18b9c..369fbf125f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05b.plan.json @@ -211,6 +211,10 @@ [ 16, 18 + ], + [ + 15, + 18 ] ] }, @@ -221,6 +225,10 @@ [ 14, 18 + ], + [ + 15, + 18 ] ] } @@ -237,7 +245,7 @@ }, "id": "company_clown", "kind": "talk", - "why": "the clown by the Poketch Company (wanders 14..16, 18): wait in his row, on (14, 18) facing east, then (16, 18) facing west; 'Do moves have types?' Yes; Coupon 2. Ends west against the company's sign (13, 19)" + "why": "the clown by the Poketch Company (wanders 14..16, 18): wait in his row, from (14, 18) and (15, 18) facing east, then (16, 18) and (15, 18) facing west, a tile toward him at a time; 'Do moves have types?' Yes; Coupon 2. Ends west against the company's sign (13, 19)" }, { "action": "line", @@ -267,6 +275,12 @@ "id": "beside_the_company_sign", "kind": "route", "why": "west 1 against the Poketch Company's signboard (13, 19): the bump pins the tile the save is made on (console 2026-11-11: a save believed at (15, 19) was in the Poketch lobby)" + }, + { + "action": "check_coupons", + "id": "all_three_coupons", + "kind": "game_action", + "why": "Key Items hold Coupons 1, 2 and 3, or the row fails before its save: the president gives the Poketch for all three only" } ], "id": "00.05b", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index c03761c8e7..8ba9eb9c1b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -7,6 +7,12 @@ "kind": "game_action", "why": "a step west: the Poketch Company's sign (14, 19) blocks it (00.05b's end); on the street (58, 22) it goes (a rerun from 01.01's start when no Poketch came)" }, + { + "action": "read_coupons", + "id": "coupons_held", + "kind": "game_action", + "why": "which coupons the Key Items hold: the talk to a clown whose coupon is there is skipped (lab-B 2026-11-12 12:48: the re-talk to a clown who had given his failed the row)" + }, { "action": "town", "args": { @@ -34,11 +40,11 @@ ] ], "target": { - "facing": "north", + "facing": "west", "map": "JubilifeCity", "tiles": [ [ - 15, + 14, 19 ] ] @@ -46,7 +52,7 @@ }, "id": "below_the_company_clown", "kind": "route", - "why": "below the Poketch Company's clown" + "why": "against the Poketch Company's sign below his row, where the talk ends (and stays when his coupon is held)" }, { "action": "wait_for_wanderer", @@ -59,6 +65,10 @@ [ 16, 18 + ], + [ + 15, + 18 ] ] }, @@ -69,6 +79,10 @@ [ 14, 18 + ], + [ + 15, + 18 ] ] } @@ -85,6 +99,9 @@ }, "id": "company_clown", "kind": "talk", + "skip_if": [ + "has_coupon_2" + ], "why": "his coupon again, or his talk if he gave it (00.05b's, lab-B 2026-11-11: a coupon went missing): wait in his row as in 00.05b; ends west against the company's sign" }, { @@ -145,6 +162,9 @@ }, "id": "tv_clown", "kind": "talk", + "skip_if": [ + "has_coupon_3" + ], "why": "his coupon again, or his talk if he gave it" }, { @@ -249,6 +269,9 @@ }, "id": "mart_clown", "kind": "talk", + "skip_if": [ + "has_coupon_1" + ], "why": "his coupon again, or his talk if he gave it: wait in his box's end columns, as in 00.05b" }, { From cd66983da58d4a15d581e25fdb020437785294c5 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:19:50 -0800 Subject: [PATCH 10/47] BDSP AutoStory: 00.05c's known certainty gap moves to step 13 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp index bf9bd564d3..ad143aaede 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp @@ -163,7 +163,7 @@ const std::set KNOWN_CERTAINTY_GAPS{ "00.05b step 1 below_the_presidents_trigger: needs tile, has set", "00.05b step 10 below_the_company_clown: needs tile, has set", "00.05b step 4 past_the_president: needs tile, has set", - "00.05c step 12 to_the_route_203_street: needs tile, has set", + "00.05c step 13 to_the_route_203_street: needs tile, has set", "01.01 step 2 west_of_barrys_trigger: needs tile, has set", "01.02 step 1 south_to_the_cliff: needs tile, has set", "01.02 step 10 west_of_the_welcome: needs tile, has set", From be3dde3c9991c89fc900ea17b0650bc6d6454598 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:20:21 -0800 Subject: [PATCH 11/47] BDSP AutoStory: route goldens for 00.05c's walk to the company's sign Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Programs/AutoStory/Data/route_bench.golden.txt | 2 +- .../Programs/AutoStory/Data/route_plans.golden.txt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index e2318fda67..f07fae1adf 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -39,7 +39,7 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05b below_the_tv_clown | 27350 | 27350 | 27350 | 1 | 0 | 0 | 6.29! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS 00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS -00.05c below_the_company_clown | 900 | 900 | 900 | 0 | 0 | 0 | 2.57! | 1.00 | 1.00 | 350 ms (stand-in) | PASS +00.05c below_the_company_clown | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS 00.05c below_the_tv_clown | 22700 | 22700 | 22700 | 0 | 0 | 0 | 6.78! | 1.00 | 5.00! | 3350 ms (stand-in) | PASS 00.05c below_the_mart_clown | 18550 | 18550 | 18550 | 3 | 0 | 0 | 4.26! | 1.00 | 23.00! | 4350 ms (stand-in) | PASS 00.05c beside_the_president | 12200 | 12200 | 12200 | 0 | 0 | 0 | 6.26! | 1.00 | 1.00 | 1950 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 84496c1e17..1ffbe50453 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -250,10 +250,9 @@ anchor); 0 from one start tile. == 00.05c below_the_company_clown (costs: town) from: JubilifeCity (14, 19) facing west (tile) - target: JubilifeCity (15, 19) facing north (tile) + target: JubilifeCity (14, 19) facing west (tile) start candidates: Jubilife City (14, 19) - 1. east 1 (open) -> Jubilife City (15, 19) - totals: 1 legs, 0 turns, 1 open, 0 localization + totals: 0 legs, 0 turns, 0 open, 0 localization == 00.05c below_the_tv_clown (costs: town) from: JubilifeCity (14, 19) facing west (tile) From 983174e8305b028926147a0913e8941a64b84842 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:20:54 -0800 Subject: [PATCH 12/47] BDSP AutoStory sim: the BDSP events in their own functions Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_StorySim.cpp | 84 +++++++++++-------- .../PokemonBDSP_AutoStory_StorySim.h | 6 ++ 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp index d4d4e035c2..663863fd5f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp @@ -696,16 +696,6 @@ StoryBoundActions SimExecutor::sim_actions(){ const auto stubbed = [this](const StoryStep&, RunState&){ return stub(); }; - // Played from where the step before left us, on its map. - const auto wait_for_wanderer = [this, stubbed](const StoryStep& step, RunState& state){ - if (!sync(state.pose)){ - return stubbed(step, state); - } - if (m_knobs.out_of_reach.contains(step.name)){ - return Pokemon::outcome_failed("operation_failed", step.name + ": no talk from any stand tile."); - } - return sim_wait_for_wanderer(m_sim, m_sim.world(), state.pose, step); - }; return StoryBoundActions{ .new_game = stubbed, .options = stubbed, @@ -718,36 +708,58 @@ StoryBoundActions SimExecutor::sim_actions(){ return heal(state, step); }, .save = stubbed, - .event = [this, stubbed, wait_for_wanderer](const std::string& name) -> Pokemon::StoryActionFunction{ - if (name == "check_poketch"){ - return [this](const StoryStep& step, RunState&){ - return m_poketch ? Pokemon::outcome_ok() : Pokemon::outcome_failed("no_poketch", step.name + ": no Poketch on the screen."); - }; - } - if (name == "wait_for_wanderer"){ - return wait_for_wanderer; - } - if (name == "read_coupons"){ - return [this](const StoryStep&, RunState& state){ - for (const ClownCoupon& coupon : jubilife_clown_coupons()){ - if (m_coupons.contains(std::string(coupon.step))){ - state.flags.emplace(coupon.flag); - } - } - return Pokemon::outcome_ok(); - }; - } - if (name == "check_coupons"){ - return [this](const StoryStep& step, RunState&){ - return m_coupons.size() == jubilife_clown_coupons().size() ? Pokemon::outcome_ok() - : Pokemon::outcome_failed("operation_failed", std::format("{}: {} of the coupons in the Key Items.", step.name, m_coupons.size())); - }; - } - return stubbed; + .event = [this](const std::string& name){ + return sim_event(name); }, }; } +Pokemon::StoryActionFunction SimExecutor::sim_event(const std::string& name){ + if (name == "check_poketch"){ + return [this](const StoryStep& step, RunState&){ + return m_poketch ? Pokemon::outcome_ok() : Pokemon::outcome_failed("no_poketch", step.name + ": no Poketch on the screen."); + }; + } + if (name == "wait_for_wanderer"){ + return [this](const StoryStep& step, RunState& state){ + return wait_for_wanderer(step, state); + }; + } + if (name == "read_coupons"){ + return [this](const StoryStep&, RunState& state){ + return read_coupons(state); + }; + } + if (name == "check_coupons"){ + return [this](const StoryStep& step, RunState&){ + return m_coupons.size() == jubilife_clown_coupons().size() ? Pokemon::outcome_ok() + : Pokemon::outcome_failed("operation_failed", std::format("{}: {} of the coupons in the Key Items.", step.name, m_coupons.size())); + }; + } + return [this](const StoryStep&, RunState&){ + return stub(); + }; +} + +Outcome SimExecutor::wait_for_wanderer(const StoryStep& step, RunState& state){ + if (!sync(state.pose)){ + return stub(); + } + if (m_knobs.out_of_reach.contains(step.name)){ + return Pokemon::outcome_failed("operation_failed", step.name + ": no talk from any stand tile."); + } + return sim_wait_for_wanderer(m_sim, m_sim.world(), state.pose, step); +} + +Outcome SimExecutor::read_coupons(RunState& state){ + for (const ClownCoupon& coupon : jubilife_clown_coupons()){ + if (m_coupons.contains(std::string(coupon.step))){ + state.flags.emplace(coupon.flag); + } + } + return Pokemon::outcome_ok(); +} + // The look at a battle's opening that shows its battle: past the three // looks of a door's fade (StoryInterrupts::max_looks), 1.8 s at BDSP's. constexpr size_t OPENING_LOOKS = 6; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h index f61e5a625b..c2499d7551 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h @@ -523,6 +523,12 @@ class SimExecutor : public Pokemon::TableExecutor{ // A clown's coupon or the president's Poketch, after step `step` passed. void count_coupons(const std::string& step); StoryBoundActions sim_actions(); + // The BDSP event `name` on the simulation: the ones it plays, or a stub. + Pokemon::StoryActionFunction sim_event(const std::string& name); + // A wander wait, played from where the step before left us, on its map. + Pokemon::Outcome wait_for_wanderer(const Pokemon::StoryStep& step, Pokemon::RunState& state); + // 00.05c's look in the Bag: a flag for each coupon held. + Pokemon::Outcome read_coupons(Pokemon::RunState& state); // The screen between steps: the dialog that popped up, if one did; a // battle's opening, its battle on the OPENING_LOOKS-th look. `fresh` // starts a new look. From 16f3205b81bc11dc7f276aaa016c5347ac7ed743 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:27:00 -0800 Subject: [PATCH 13/47] BDSP AutoStory 00.05c: no clown re-talks; 00.05b's coupon check is the only one 00.05b now ends with all three coupons checked in the Bag, so 00.05c's re-talks (insurance for a coupon lost on 2026-11-11) go, as on lab 4587cd75c: it walks from its start to the president. The plaza and greeter tests that walked 00.05c to the company's clown walk it to the president instead. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonBDSP_AutoStory_Events.h | 5 +- .../PokemonBDSP_AutoStory_Events_Jubilife.cpp | 26 +- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 19 +- ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 29 +- .../PokemonBDSP_AutoStory_StorySim.cpp | 17 -- .../PokemonBDSP_AutoStory_StorySim.h | 5 - ...onBDSP_AutoStory_StorySimulation_Tests.cpp | 2 +- ...emonBDSP_AutoStory_WallBattleSim_Tests.cpp | 19 +- ...PokemonBDSP_AutoStory_WanderWait_Tests.cpp | 32 +-- .../AutoStory/StoryData/bdsp-00.05c.plan.json | 269 +----------------- 10 files changed, 47 insertions(+), 376 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h index 1efd79316a..1330a6dec0 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h @@ -79,12 +79,11 @@ bool asks_someone_else(const Pokemon::MapData& map, Pokemon::TilePos stand, Poke // data/games/bdsp/maps/jubilife_city.json (decomp range 1). The story map // leaves him out of its wanderers (the decomp hides him behind a flag). Pokemon::TileBox jubilife_mart_clown_box(); -// A Jubilife clown's coupon (00.05b, 00.05c): his talk step, the Key -// Item's Bag slug, and the run flag read_coupons sets when it is held. +// A Jubilife clown's coupon (00.05b): his talk step and the Key Item's +// Bag slug. struct ClownCoupon{ std::string_view step; std::string_view slug; - std::string_view flag; }; // The three clowns' coupons: the Mart's 1, the company's 2, the TV's 3. std::span jubilife_clown_coupons(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp index 7a5b0cd9d4..6a9273d39e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp @@ -278,25 +278,6 @@ std::optional> held_coupons(VideoStream& stream, ProController return bag_has_items(stream, context, slugs, KEY_ITEMS_POCKET); } -// 00.05c's look in the Bag: a flag for each coupon held, so the talk to -// a clown whose coupon is there is skipped (its step's skip_if). Unread, -// every clown is talked to. -Pokemon::Outcome read_coupons(StoryExecutor& executor, Pokemon::RunState& state, const Pokemon::StoryStep&){ - VideoStream& stream = executor.stream(); - const std::optional> held = held_coupons(stream, executor.context()); - if (!held){ - return Pokemon::outcome_ok(); - } - const std::span coupons = jubilife_clown_coupons(); - for (size_t i = 0; i < coupons.size(); i++){ - stream.log(std::format("[Coupons] {}: {}.", coupons[i].slug, (*held)[i] ? "held" : "missing")); - if ((*held)[i]){ - state.flags.emplace(coupons[i].flag); - } - } - return Pokemon::outcome_ok(); -} - // 00.05b's end: all three coupons in the Bag, or the row fails here // rather than saving a run the president will give no Poketch. void check_coupons(VideoStream& stream, ProControllerContext& context){ @@ -366,9 +347,9 @@ Pokemon::TileBox jubilife_mart_clown_box(){ std::span jubilife_clown_coupons(){ static constexpr ClownCoupon COUPONS[] = { - {.step = "mart_clown", .slug = "coupon-1", .flag = "has_coupon_1"}, - {.step = "company_clown", .slug = "coupon-2", .flag = "has_coupon_2"}, - {.step = "tv_clown", .slug = "coupon-3", .flag = "has_coupon_3"}, + {.step = "mart_clown", .slug = "coupon-1"}, + {.step = "company_clown", .slug = "coupon-2"}, + {.step = "tv_clown", .slug = "coupon-3"}, }; return COUPONS; } @@ -385,7 +366,6 @@ void add_jubilife_events(StoryEvents& events){ events.emplace("talk_to_wanderer", talk_to_wanderer); events.emplace("wait_for_wanderer", wait_for_wanderer); events.emplace("check_poketch", console_event(check_poketch)); - events.emplace("read_coupons", read_coupons); events.emplace("check_coupons", console_event(check_coupons)); events.emplace("jubilife_start_probe", jubilife_start_probe); } 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 a3d0425fa2..8eee48cc0c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -463,7 +463,7 @@ std::string company_clown_plaza_tiles(Logger& logger, TableRoute route, int x){ } const StoryWorld& world = *route.world; for (const PlannedLeg& planned : *plan.legs){ - logger.log(std::format("00.05c below_the_company_clown from ({}, 22): {}", x, to_string(planned))); + logger.log(std::format("00.05c beside_the_president from ({}, 22): {}", x, to_string(planned))); } const auto plaza = [&](const TilePos& pos){ const std::optional local = story_to_local(world, "JubilifeCity", pos); @@ -475,7 +475,8 @@ std::string company_clown_plaza_tiles(Logger& logger, TableRoute route, int x){ return most == 0 ? "" : std::format("the leg {} walks {} tile(s) of the plaza.", leg, most); } -// 00.05c's walk to the Poketch Company's clown from the street +// 00.05c's first walk (to the president since its clown re-talks went; +// to the Poketch Company's clown before) from the street // (57..58, 22), where the checkpoint starts on a rerun from 01.01's start, // keeps off the plaza (WONDER_STATION_PLAZA). BDSP put the Global Wonder Station // there, a round wall with people round it that pret's Diamond map lacks: @@ -484,7 +485,7 @@ std::string company_clown_plaza_tiles(Logger& logger, TableRoute route, int x){ // (45, 24) until the step failed. UnitTestResult test_company_clown_from_the_street_keeps_off_the_plaza(Logger& logger){ for (const TableRoute& route : table_routes()){ - if (route.row != "00.05c" || route.step->name != "below_the_company_clown" || route.world == nullptr){ + if (route.row != "00.05c" || route.step->name != "beside_the_president" || route.world == nullptr){ continue; } std::string out; @@ -492,9 +493,9 @@ UnitTestResult test_company_clown_from_the_street_keeps_off_the_plaza(Logger& lo const std::string found = company_clown_plaza_tiles(logger, route, x); out += found.empty() ? "" : "\n " + found; } - return out.empty() ? UnitTestResult(true) : UnitTestResult("00.05c below_the_company_clown:" + out); + return out.empty() ? UnitTestResult(true) : UnitTestResult("00.05c beside_the_president:" + out); } - return "00.05c below_the_company_clown: not in the table, or from nowhere known."; + return "00.05c beside_the_president: not in the table, or from nowhere known."; } // 00.05c's replan on lab-B (2026-11-12 02:52): the walk west on row 24 @@ -503,7 +504,7 @@ UnitTestResult test_company_clown_from_the_street_keeps_off_the_plaza(Logger& lo // plan at all, with the route costs or the default ones. UnitTestResult test_company_clown_after_the_woman_on_row_24(Logger& logger){ for (TableRoute route : table_routes()){ - if (route.row != "00.05c" || route.step->name != "below_the_company_clown" || route.world == nullptr){ + if (route.row != "00.05c" || route.step->name != "beside_the_president" || route.world == nullptr){ continue; } StoryWorld world = *route.world; @@ -513,14 +514,14 @@ UnitTestResult test_company_clown_after_the_woman_on_row_24(Logger& logger){ route.from = Pokemon::tile_pose("JubilifeCity", {{35, 24}, {36, 24}}, Direction::WEST); const RouteStepPlan plan = plan_table_route(route); if (!plan.legs){ - return "00.05c below_the_company_clown: no plan from (35, 24), (36, 24)."; + return "00.05c beside_the_president: no plan from (35, 24), (36, 24)."; } for (const PlannedLeg& planned : *plan.legs){ - logger.log("00.05c below_the_company_clown from (35, 24), (36, 24): " + to_string(planned)); + logger.log("00.05c beside_the_president from (35, 24), (36, 24): " + to_string(planned)); } return UnitTestResult(true); } - return "00.05c below_the_company_clown: not in the table, or from nowhere known."; + return "00.05c beside_the_president: not in the table, or from nowhere known."; } // 01.08's walk below the Ravaged Path keeps off the row Route 204 South's diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp index d7aa868885..51c375a12b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp @@ -429,37 +429,18 @@ UnitTestResult sandgem_entry_two_columns_west(Logger& logger){ // 00.05c on lab-B 2026-11-11: 00.05b's Poketch Company clown was // "answered" by the sign's text, so the save held two coupons; the // president gave no Poketch and 00.05c went on to the street as passed. -// `misread` re-runs that read in 00.05c's own talk too. "" when the run -// stopped at 00.05c's Poketch check, as it must when a coupon is still -// missing. -std::string poketch_run(Logger& logger, bool misread){ +// 00.05c talks to no clown (00.05b checks its coupons before its save): +// from such a save it stops at its Poketch check. +UnitTestResult no_poketch_fails_00_05c(Logger& logger){ SimWorldKnobs knobs; knobs.coupons_at_start = {"mart_clown", "tv_clown"}; knobs.poketch_at_start = false; - if (misread){ - knobs.talks_without_coupon = {"company_clown"}; - } - return run_case(logger, "00.05c", "00.05c", {.fade = {}, .banner = {}}, std::move(knobs)); -} -UnitTestResult no_poketch_fails_00_05c(Logger& logger){ - const std::string stopped = poketch_run(logger, true); + const std::string stopped = run_case(logger, "00.05c", "00.05c", {.fade = {}, .banner = {}}, std::move(knobs)); if (stopped.find("00.05c poketch") == std::string::npos){ return UnitTestResult("expected a stop at 00.05c's Poketch check; got " + (stopped.empty() ? std::string("a pass") : stopped)); } return true; } -UnitTestResult missing_coupon_collected_in_00_05c(Logger& logger){ - return passes(poketch_run(logger, false)); -} -// 00.05c on lab-B 2026-11-12 12:48: the save held all three coupons, and -// the re-talk to the Poketch Company's clown failed the row ("no talk from -// any stand tile") while he stayed out of reach. The Bag's coupons skip -// the talks to clowns who gave theirs. -UnitTestResult held_coupons_skip_00_05c_clowns(Logger& logger){ - SimWorldKnobs knobs; - knobs.out_of_reach = {"company_clown", "mart_clown"}; - return passes(run_case(logger, "00.05c", "00.05c", {.fade = {}, .banner = {}}, std::move(knobs))); -} // 00.05b with the Poketch Company's clown answered by the sign's text // (lab-B 2026-11-11): two coupons. The row fails at its coupon check // instead of saving them. @@ -761,8 +742,6 @@ const FailureCase AUTO_STORY_FAILURE_CASES[] = { : UnitTestResult("the program went on from a tile the player is not on: " + stopped); }}, .expectation = {}}, {.input = {"00.05c a coupon missing (the sign read for the Poketch Company clown): no Poketch, 00.05c fails (lab-B 2026-11-11)", no_poketch_fails_00_05c}, .expectation = {}}, - {.input = {"00.05c a coupon missing from 00.05b: its clown talks collect it, the president gives the Poketch", missing_coupon_collected_in_00_05c}, .expectation = {}}, - {.input = {"00.05c all three coupons held: no clown is talked to, so one out of reach does not fail the row (lab-B 2026-11-12 12:48)", held_coupons_skip_00_05c_clowns}, .expectation = {}}, {.input = {"00.05b a coupon missing at its end: the row fails at its coupon check, before the save", missing_coupon_fails_00_05b}, .expectation = {}}, {.input = {"01.01 with no Poketch: the east-exit guard's gate stops the row at its check, not a trainer fight (lab-B 2026-11-11)", gate_guard_stops_01_01}, .expectation = {}}, {.input = {"00.04 to the ledge column with a wild battle on each pass through Route 201's grass (lab-B 2026-11-09 16:14)", [](Logger& logger){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp index 663863fd5f..79054a7545 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp @@ -725,11 +725,6 @@ Pokemon::StoryActionFunction SimExecutor::sim_event(const std::string& name){ return wait_for_wanderer(step, state); }; } - if (name == "read_coupons"){ - return [this](const StoryStep&, RunState& state){ - return read_coupons(state); - }; - } if (name == "check_coupons"){ return [this](const StoryStep& step, RunState&){ return m_coupons.size() == jubilife_clown_coupons().size() ? Pokemon::outcome_ok() @@ -745,21 +740,9 @@ Outcome SimExecutor::wait_for_wanderer(const StoryStep& step, RunState& state){ if (!sync(state.pose)){ return stub(); } - if (m_knobs.out_of_reach.contains(step.name)){ - return Pokemon::outcome_failed("operation_failed", step.name + ": no talk from any stand tile."); - } return sim_wait_for_wanderer(m_sim, m_sim.world(), state.pose, step); } -Outcome SimExecutor::read_coupons(RunState& state){ - for (const ClownCoupon& coupon : jubilife_clown_coupons()){ - if (m_coupons.contains(std::string(coupon.step))){ - state.flags.emplace(coupon.flag); - } - } - return Pokemon::outcome_ok(); -} - // The look at a battle's opening that shows its battle: past the three // looks of a door's fade (StoryInterrupts::max_looks), 1.8 s at BDSP's. constexpr size_t OPENING_LOOKS = 6; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h index c2499d7551..cdc1af068b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h @@ -209,9 +209,6 @@ struct SimWorldKnobs{ // president's talk gives it with all three coupons only. std::set coupons_at_start = {"mart_clown", "tv_clown", "company_clown"}; std::set talks_without_coupon = {}; - // The wanderer waits, by step name, that never meet him (lab-B - // 2026-11-12 12:48: the company's clown stayed out of reach). - std::set out_of_reach = {}; bool poketch_at_start = true; }; @@ -527,8 +524,6 @@ class SimExecutor : public Pokemon::TableExecutor{ Pokemon::StoryActionFunction sim_event(const std::string& name); // A wander wait, played from where the step before left us, on its map. Pokemon::Outcome wait_for_wanderer(const Pokemon::StoryStep& step, Pokemon::RunState& state); - // 00.05c's look in the Bag: a flag for each coupon held. - Pokemon::Outcome read_coupons(Pokemon::RunState& state); // The screen between steps: the dialog that popped up, if one did; a // battle's opening, its battle on the OPENING_LOOKS-th look. `fresh` // starts a new look. diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp index a8d4a1bf36..faad663667 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp @@ -546,7 +546,7 @@ UnitTestResult test_gives_up_after_attempts(Logger&){ // Events that leave the player where they were: the look at the Poketch, // and 00.05c's start probe, whose step west the Poketch Company's sign // stops on 00.05b's end, (14, 19). -const std::set EVENTS_IN_PLACE{"check_poketch", "jubilife_start_probe", "read_coupons", "check_coupons"}; +const std::set EVENTS_IN_PLACE{"check_poketch", "jubilife_start_probe", "check_coupons"}; // Each row that has a start pose starts where the row before it leaves // the player, by the same planning and walking the fake run does. diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp index bd24befebd..5cbe3e2ce7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp @@ -344,7 +344,8 @@ const SceneRunCase SCENE_RUN_SIM_CASES[] = { // The Wonder Station's greeter in Jubilife's plaza walks up and talks // whenever we come near, then walks off: on lab-B (2026-11-12 03:57, 00.05c -// below_the_company_clown) she stopped one walk three times, at about +// below_the_company_clown; 00.05c's first walk is now beside_the_president) +// she stopped one walk three times, at about // (44, 28), (43, 30) and (39, 32), and the third failed it as "dialogue the // map does not explain". Here a step onto the step's greeter ground starts // her dialogue, and so does the next one after each talk, `talks` in all. @@ -365,16 +366,16 @@ std::string walk_past_the_greeter(Logger& logger, size_t most_talks){ const StoryStep* step = nullptr; for (const StoryCheckpoint& row : story_checkpoints()){ for (const StoryStep& s : row.steps){ - step = row.id == "00.05c" && s.name == "below_the_company_clown" ? &s : step; + step = row.id == "00.05c" && s.name == "beside_the_president" ? &s : step; } } const StoryWorld* world = story_plan_world("JubilifeCity", "JubilifeCity"); if (step == nullptr || world == nullptr){ - return "00.05c below_the_company_clown: not in the table, or no JubilifeCity world."; + return "00.05c beside_the_president: not in the table, or no JubilifeCity world."; } const std::vector greeter = story_route_tiles(*world, *step, "greeter"); const TilePos start = story_to_world(*world, "JubilifeCity", {57, 22}); - const TilePos target = story_to_world(*world, "JubilifeCity", {15, 19}); + const TilePos target = story_to_world(*world, "JubilifeCity", {45, 35}); GridSim sim({.world = world, .trainers = {}, .triggers = {}}, start, Direction::WEST, true); size_t talks = 0; const auto arm = [&](){ @@ -394,7 +395,7 @@ std::string walk_past_the_greeter(Logger& logger, size_t most_talks){ std::vector believed; try{ believed = walk_route(sim_io, *world, {start}, trainers, {.goal = [&](const TilePos& pos){ return pos == target; }, - .label = "below the company clown", .avoid = story_route_tiles(*world, *step, "avoid"), .costs = *story_route_costs("town"), + .label = "beside the president", .avoid = story_route_tiles(*world, *step, "avoid"), .costs = *story_route_costs("town"), .speed = MoveSpeed::RUN, .scene_next = false, .goal_is_trigger = false, .greeter = greeter}); }catch (const GridSimFailure& e){ return std::format("failed after {} talk(s): {}", talks, e.message); @@ -583,15 +584,15 @@ std::string walk_open_leg_talks(Logger& logger, const OpenLegTalkInput& input){ const StoryStep* step = nullptr; for (const StoryCheckpoint& row : story_checkpoints()){ for (const StoryStep& s : row.steps){ - step = row.id == "00.05c" && s.name == "below_the_company_clown" ? &s : step; + step = row.id == "00.05c" && s.name == "beside_the_president" ? &s : step; } } const StoryWorld* world = story_plan_world("JubilifeCity", "JubilifeCity"); if (step == nullptr || world == nullptr){ - return "00.05c below_the_company_clown: not in the table, or no JubilifeCity world."; + return "00.05c beside_the_president: not in the table, or no JubilifeCity world."; } const TilePos start = story_to_world(*world, "JubilifeCity", {46, 27}); - const TilePos target = story_to_world(*world, "JubilifeCity", {15, 19}); + const TilePos target = story_to_world(*world, "JubilifeCity", {45, 35}); GridSim sim({.world = world, .trainers = {}, .triggers = {}}, start, Direction::SOUTH, true); size_t talks = 0; const auto arm = [&](){ @@ -614,7 +615,7 @@ std::string walk_open_leg_talks(Logger& logger, const OpenLegTalkInput& input){ std::string error; try{ believed = walk_route(io, *world, {start}, trainers, {.goal = [&](const TilePos& pos){ return pos == target; }, - .label = "below the company clown", .avoid = story_route_tiles(*world, *step, "avoid"), .costs = *story_route_costs("town"), + .label = "beside the president", .avoid = story_route_tiles(*world, *step, "avoid"), .costs = *story_route_costs("town"), .speed = MoveSpeed::RUN, .scene_next = false, .goal_is_trigger = false, .greeter = story_route_tiles(*world, *step, "greeter")}); }catch (const GridSimFailure& e){ error = std::format("failed after {} talk(s): {}", talks, e.message); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp index be362ff919..7ec43356f2 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WanderWait_Tests.cpp @@ -2,8 +2,8 @@ * * From: https://github.com/PokemonAutomation/ * - * The Mart clown wanders (54..56, 32..34) round (55, 33). 00.05b and - * 00.05c wait for him in his box's end columns, 56 facing west, then 54 + * The Mart clown wanders (54..56, 32..34) round (55, 33). 00.05b waits + * for him in his box's end columns, 56 facing west, then 54 * facing east (wait_for_wanderer): these run that wait on the simulation * with him starting, or staying, on each tile of his box, and pick the * tile to wait on first. He never steps onto the player's tile. @@ -133,8 +133,8 @@ constexpr uint64_t SEEDS = 8; // On lab-B (2026-11-12 11:47) 00.05b's company_clown swept row 19 below // the Poketch Company's clown, asking north, while he walked off it: "no -// coupon question from any tile below his range". 00.05b and 00.05c now -// wait for him in his row (14..16, 18): from where their routes leave us, +// coupon question from any tile below his range". 00.05b now waits for +// him in his row (14..16, 18): from where their routes leave us, // (15, 19), the wait talks to him wherever he starts or stays, and ends // against the company's sign on (14, 19). UnitTestResult test_company_clown_reached_in_his_row(Logger& logger){ @@ -142,7 +142,7 @@ UnitTestResult test_company_clown_reached_in_his_row(Logger& logger){ const TilePos start{15, 19}; std::string out; size_t runs = 0; - for (const std::string row : {"00.05b", "00.05c"}){ + for (const std::string row : {"00.05b"}){ const WanderWaitPlan plan = wander_wait_plan(story_step(row, "company_clown")); for (const TilePos& clown : clown_starts(start, jubilife_company_clown_box())){ for (uint64_t seed = 0; seed <= SEEDS; seed++){ @@ -160,14 +160,14 @@ UnitTestResult test_company_clown_reached_in_his_row(Logger& logger){ return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait missed the company's clown:{}", out)); } -// 00.05b comes up column 56 from the wall (56, 36), 00.05c down it from -// (56, 31): from each, the wait talks to the clown wherever in his box he -// starts, over seeds 1 to 8, and ends on (56, 31). +// 00.05b comes up column 56 from the wall (56, 36): the wait talks to the +// clown wherever in his box he starts, over seeds 1 to 8, and ends on +// (56, 31). UnitTestResult test_mart_clown_reached_from_column_56(Logger& logger){ const StoryWorld world = clown_world(); std::string out; size_t runs = 0; - for (const auto& [row, start] : {std::pair{"00.05b", {56, 36}}, {"00.05c", {56, 31}}}){ + for (const auto& [row, start] : {std::pair{"00.05b", {56, 36}}}){ const WanderWaitPlan plan = wander_wait_plan(story_step(row, "mart_clown")); for (const TilePos& clown : clown_starts(start)){ for (uint64_t seed = 1; seed <= SEEDS; seed++){ @@ -191,7 +191,7 @@ UnitTestResult test_mart_clown_reached_when_he_stays(Logger& logger){ const StoryWorld world = clown_world(); std::string out; size_t runs = 0; - for (const auto& [row, start] : {std::pair{"00.05b", {56, 36}}, {"00.05c", {56, 31}}}){ + for (const auto& [row, start] : {std::pair{"00.05b", {56, 36}}}){ const WanderWaitPlan plan = wander_wait_plan(story_step(row, "mart_clown")); for (const TilePos& clown : clown_starts(start)){ runs++; @@ -224,7 +224,7 @@ class CountingWanderWait : public SimWanderWait{ UnitTestResult test_mart_clown_diagonal_reached(Logger& logger){ const StoryWorld world = clown_world(); std::string out; - for (const std::string row : {"00.05b", "00.05c"}){ + for (const std::string row : {"00.05b"}){ const WanderWaitPlan table_plan = wander_wait_plan(story_step(row, "mart_clown")); WanderWaitPlan plan = table_plan; // Its east side's walk, from (56, 32) on. @@ -248,14 +248,14 @@ UnitTestResult test_mart_clown_diagonal_reached(Logger& logger){ return out.empty() ? UnitTestResult(true) : UnitTestResult(std::format("The wait stayed off his row:{}", out)); } -// On lab-B (2026-11-12 12:48) 00.05c's wait for the Poketch Company's -// clown ended on (16, 18) with him idling on our row out of reach. From +// On lab-B (2026-11-12 12:48) 00.05c's wait (since dropped) for the +// Poketch Company's clown ended on (16, 18) with him idling on our row out of reach. From // either end of his row alone, the wait steps toward him a tile at a time // inside his row and talks to him idling at the other end. UnitTestResult test_company_clown_idling_two_tiles_away(Logger& logger){ const StoryWorld world = clown_world(); std::string out; - for (const std::string row : {"00.05b", "00.05c"}){ + for (const std::string row : {"00.05b"}){ const WanderWaitPlan table_plan = wander_wait_plan(story_step(row, "company_clown")); for (const WanderWaitSide& side : table_plan.sides){ WanderWaitPlan plan = table_plan; @@ -306,7 +306,7 @@ UnitTestResult test_mart_clown_first_stand(Logger& logger){ best_y = y; } } - for (const std::string row : {"00.05b", "00.05c"}){ + for (const std::string row : {"00.05b"}){ const TilePos first = wander_wait_plan(story_step(row, "mart_clown")).sides.at(0).stands.at(0); if (first != TilePos{56, best_y}){ return std::format("{} waits first on {}; the simulation talks most from (56, {}).", row, Pokemon::to_string(first), best_y); @@ -344,7 +344,7 @@ class Test_AutoStoryWanderWait : public UnitTest{ }; const WanderWaitCase WANDER_WAIT_CASES[] = { - {.input = {"Wander wait: the Mart clown is reached from column 56 wherever he starts (00.05b, 00.05c)", + {.input = {"Wander wait: the Mart clown is reached from column 56 wherever he starts (00.05b)", test_mart_clown_reached_from_column_56}, .expectation = {}}, {.input = {"Wander wait: the Mart clown is reached on whichever tile he stays (lab-B 2026-11-12, column 54)", test_mart_clown_reached_when_he_stays}, .expectation = {}}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index 8ba9eb9c1b..86c0873d86 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -7,273 +7,6 @@ "kind": "game_action", "why": "a step west: the Poketch Company's sign (14, 19) blocks it (00.05b's end); on the street (58, 22) it goes (a rerun from 01.01's start when no Poketch came)" }, - { - "action": "read_coupons", - "id": "coupons_held", - "kind": "game_action", - "why": "which coupons the Key Items hold: the talk to a clown whose coupon is there is skipped (lab-B 2026-11-12 12:48: the re-talk to a clown who had given his failed the row)" - }, - { - "action": "town", - "args": { - "avoid": [ - [ - 40, - 20, - 52, - 25 - ], - [ - 40, - 26, - 43, - 27 - ] - ], - "fight_wild": false, - "greeter": [ - [ - 30, - 22, - 48, - 34 - ] - ], - "target": { - "facing": "west", - "map": "JubilifeCity", - "tiles": [ - [ - 14, - 19 - ] - ] - } - }, - "id": "below_the_company_clown", - "kind": "route", - "why": "against the Poketch Company's sign below his row, where the talk ends (and stays when his coupon is held)" - }, - { - "action": "wait_for_wanderer", - "args": { - "again": true, - "far_stand": { - "facing": "west", - "map": "JubilifeCity", - "tiles": [ - [ - 16, - 18 - ], - [ - 15, - 18 - ] - ] - }, - "stand": { - "facing": "east", - "map": "JubilifeCity", - "tiles": [ - [ - 14, - 18 - ], - [ - 15, - 18 - ] - ] - } - }, - "declared_after": { - "facing": "west", - "map": "JubilifeCity", - "tiles": [ - [ - 14, - 19 - ] - ] - }, - "id": "company_clown", - "kind": "talk", - "skip_if": [ - "has_coupon_2" - ], - "why": "his coupon again, or his talk if he gave it (00.05b's, lab-B 2026-11-11: a coupon went missing): wait in his row as in 00.05b; ends west against the company's sign" - }, - { - "action": "town", - "args": { - "avoid": [ - [ - 40, - 20, - 52, - 25 - ], - [ - 40, - 26, - 43, - 27 - ] - ], - "fight_wild": false, - "greeter": [ - [ - 30, - 22, - 48, - 34 - ] - ], - "target": { - "facing": "north", - "map": "JubilifeCity", - "tiles": [ - [ - 36, - 17 - ] - ] - } - }, - "id": "below_the_tv_clown", - "kind": "route", - "why": "east to the TV station" - }, - { - "action": "talk_to_wanderer", - "args": { - "again": true - }, - "declared_after": { - "facing": "north", - "map": "JubilifeCity", - "tiles": [ - [ - 36, - 17 - ] - ] - }, - "id": "tv_clown", - "kind": "talk", - "skip_if": [ - "has_coupon_3" - ], - "why": "his coupon again, or his talk if he gave it" - }, - { - "action": "town", - "args": { - "avoid": [ - [ - 40, - 20, - 52, - 25 - ], - [ - 40, - 26, - 43, - 27 - ] - ], - "fight_wild": false, - "greeter": [ - [ - 30, - 22, - 48, - 34 - ] - ], - "target": { - "facing": "south", - "map": "JubilifeCity", - "tiles": [ - [ - 56, - 31 - ] - ] - } - }, - "id": "below_the_mart_clown", - "kind": "route", - "why": "east along row 31, above the Mart clown's box, to the wall (57, 31)" - }, - { - "action": "wait_for_wanderer", - "args": { - "again": true, - "far_stand": { - "facing": "east", - "map": "JubilifeCity", - "tiles": [ - [ - 54, - 32 - ], - [ - 54, - 33 - ], - [ - 54, - 34 - ], - [ - 54, - 33 - ] - ] - }, - "stand": { - "facing": "west", - "map": "JubilifeCity", - "tiles": [ - [ - 56, - 33 - ], - [ - 56, - 34 - ], - [ - 56, - 33 - ], - [ - 56, - 32 - ] - ] - } - }, - "declared_after": { - "facing": "north", - "map": "JubilifeCity", - "tiles": [ - [ - 56, - 31 - ] - ] - }, - "id": "mart_clown", - "kind": "talk", - "skip_if": [ - "has_coupon_1" - ], - "why": "his coupon again, or his talk if he gave it: wait in his box's end columns, as in 00.05b" - }, { "action": "town", "args": { @@ -313,7 +46,7 @@ }, "id": "beside_the_president", "kind": "route", - "why": "from the wall north of column 56 round the boy below the Mart to the Poketch president" + "why": "from the Poketch Company's sign (00.05b's end; 00.05b checks all three coupons are in the Bag) or the street east, round the plaza to the Poketch president" }, { "id": "president", From 2e51ebbf12e11a89e802bea330f0697bf1e9cdc5 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:31:46 -0800 Subject: [PATCH 14/47] BDSP AutoStory: the open-leg greeter test keeps its walk to the company's clown; 00.05c's certainty gap is step 6 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp | 2 +- .../Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp index ad143aaede..09b5dbea02 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp @@ -163,7 +163,7 @@ const std::set KNOWN_CERTAINTY_GAPS{ "00.05b step 1 below_the_presidents_trigger: needs tile, has set", "00.05b step 10 below_the_company_clown: needs tile, has set", "00.05b step 4 past_the_president: needs tile, has set", - "00.05c step 13 to_the_route_203_street: needs tile, has set", + "00.05c step 6 to_the_route_203_street: needs tile, has set", "01.01 step 2 west_of_barrys_trigger: needs tile, has set", "01.02 step 1 south_to_the_cliff: needs tile, has set", "01.02 step 10 west_of_the_welcome: needs tile, has set", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp index 5cbe3e2ce7..8be9a8c5b8 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp @@ -592,7 +592,9 @@ std::string walk_open_leg_talks(Logger& logger, const OpenLegTalkInput& input){ return "00.05c beside_the_president: not in the table, or no JubilifeCity world."; } const TilePos start = story_to_world(*world, "JubilifeCity", {46, 27}); - const TilePos target = story_to_world(*world, "JubilifeCity", {45, 35}); + // The walk south then west to the Poketch Company's clown it was on + // lab-B, on 00.05c's plaza ground (the president's walk has the same). + const TilePos target = story_to_world(*world, "JubilifeCity", {15, 19}); GridSim sim({.world = world, .trainers = {}, .triggers = {}}, start, Direction::SOUTH, true); size_t talks = 0; const auto arm = [&](){ From c532aec1d4f30a3efabd4bc2b62e3d59d3203e85 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:32:18 -0800 Subject: [PATCH 15/47] BDSP AutoStory: route goldens for 00.05c's walk from its start to the president Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_bench.golden.txt | 5 +-- .../AutoStory/Data/route_plans.golden.txt | 39 ++++--------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index f07fae1adf..dd6bc300d8 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -39,10 +39,7 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05b below_the_tv_clown | 27350 | 27350 | 27350 | 1 | 0 | 0 | 6.29! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS 00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS -00.05c below_the_company_clown | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS -00.05c below_the_tv_clown | 22700 | 22700 | 22700 | 0 | 0 | 0 | 6.78! | 1.00 | 5.00! | 3350 ms (stand-in) | PASS -00.05c below_the_mart_clown | 18550 | 18550 | 18550 | 3 | 0 | 0 | 4.26! | 1.00 | 23.00! | 4350 ms (stand-in) | PASS -00.05c beside_the_president | 12200 | 12200 | 12200 | 0 | 0 | 0 | 6.26! | 1.00 | 1.00 | 1950 ms (stand-in) | PASS +00.05c beside_the_president | 31200 | 31200 | 31200 | 1 | 0 | 0 | 5.43! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS 00.05c to_the_route_203_street | 14250 | 14250 | 14250 | 1 | 0 | 0 | 4.07! | 1.00 | 1.00 | 3500 ms (stand-in) | PASS 01.01 west_of_barrys_trigger | 7300 | 7300 | 7300 | 0 | 0 | 0 | 6.35! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 1ffbe50453..4ae827cec5 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -248,41 +248,16 @@ anchor); 0 from one start tile. start candidates: Jubilife City (14, 19) totals: 0 legs, 0 turns, 0 open, 0 localization -== 00.05c below_the_company_clown (costs: town) - from: JubilifeCity (14, 19) facing west (tile) - target: JubilifeCity (14, 19) facing west (tile) - start candidates: Jubilife City (14, 19) - totals: 0 legs, 0 turns, 0 open, 0 localization - -== 00.05c below_the_tv_clown (costs: town) +== 00.05c beside_the_president (costs: town) from: JubilifeCity (14, 19) facing west (tile) - target: JubilifeCity (36, 17) facing north (tile) + target: JubilifeCity (45, 35) facing east (tile) start candidates: Jubilife City (14, 19) 1. south 2 (open) -> Jubilife City (14, 21) - 2. east 22 (open) -> Jubilife City (36, 21) - 3. north 4 (open) -> Jubilife City (36, 17) - totals: 3 legs, 2 turns, 3 open, 0 localization - -== 00.05c below_the_mart_clown (costs: town) - from: JubilifeCity (36, 17) facing north (tile) - target: JubilifeCity (56, 31) facing south (tile) - start candidates: Jubilife City (36, 17) - 1. west 1 (open) -> Jubilife City (35, 17) - 2. south 10 (to wall) -> Jubilife City (35, 27) - 3. east 1 (to wall) -> Jubilife City (36, 27) - 4. south 5 (open) -> Jubilife City (36, 32) - 5. east 7 (open) -> Jubilife City (43, 32) - 6. north 1 (open) -> Jubilife City (43, 31) - 7. east 13 (to wall) -> Jubilife City (56, 31) - totals: 7 legs, 6 turns, 4 open, 0 localization - -== 00.05c beside_the_president (costs: town) - from: JubilifeCity (56, 31) facing north (tile) - target: JubilifeCity (45, 35) facing east (tile) - start candidates: Jubilife City (56, 31) - 1. west 11 (open) -> Jubilife City (45, 31) - 2. south 4 (open) -> Jubilife City (45, 35) - totals: 2 legs, 1 turns, 2 open, 0 localization + 2. east 19 (open) -> Jubilife City (33, 21) + 3. south 15 (to wall) -> Jubilife City (33, 36) + 4. north 1 (open) -> Jubilife City (33, 35) + 5. east 12 (open) -> Jubilife City (45, 35) + totals: 5 legs, 4 turns, 4 open, 0 localization == 00.05c to_the_route_203_street (costs: line) from: JubilifeCity (45, 35) facing east (tile) From f6dee1cdfbce0ea86bf2234e1ffd9bd451465cc8 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:36:04 -0800 Subject: [PATCH 16/47] BDSP AutoStory: the open-leg greeter test's note in its header comment Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp index 8be9a8c5b8..09296f0c60 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp @@ -580,6 +580,8 @@ class UncountedTalkIO : public RouteIO{ }; // Where the walk from (46, 27) past the greeter's talks went wrong, or "". +// It walks to the Poketch Company's clown, as on lab-B, on the plaza +// ground of 00.05c's walk to the president (the old walk's, unchanged). std::string walk_open_leg_talks(Logger& logger, const OpenLegTalkInput& input){ const StoryStep* step = nullptr; for (const StoryCheckpoint& row : story_checkpoints()){ @@ -592,8 +594,6 @@ std::string walk_open_leg_talks(Logger& logger, const OpenLegTalkInput& input){ return "00.05c beside_the_president: not in the table, or no JubilifeCity world."; } const TilePos start = story_to_world(*world, "JubilifeCity", {46, 27}); - // The walk south then west to the Poketch Company's clown it was on - // lab-B, on 00.05c's plaza ground (the president's walk has the same). const TilePos target = story_to_world(*world, "JubilifeCity", {15, 19}); GridSim sim({.world = world, .trainers = {}, .triggers = {}}, start, Direction::SOUTH, true); size_t talks = 0; From 4435ed5fdf539b6d375af3e2d799daa955ff1eaa Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:45:06 -0800 Subject: [PATCH 17/47] BDSP AutoStory: 00.05c ends below the east-exit sign (59, 21) on taps each ended by a wall The walk up the main road ends on row 27 west of the Mart's hedges; a measured LEGS step then taps south onto row 28's wall, east to the hedges, north 1, east along row 26 to its wall and north up column 59 to the sign. Every tile the road's walk may end on (a row or a few columns off) ends on (59, 21) facing north, west of the guard's trigger column 60. 01.01 starts there. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonBDSP_AutoStory_Events.h | 2 +- .../PokemonBDSP_AutoStory_Events_Jubilife.cpp | 4 +- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 10 +- ...PokemonBDSP_AutoStory_FaultSweep_Tests.cpp | 2 +- ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 18 +++ .../AutoStory/StoryData/bdsp-00.05c.plan.json | 129 +++++++++++++++++- .../AutoStory/StoryData/bdsp-01.01.plan.json | 6 +- 7 files changed, 154 insertions(+), 17 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h index 1330a6dec0..5ed92a1f06 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events.h @@ -91,7 +91,7 @@ std::span jubilife_clown_coupons(); // Mart clown's box. Pokemon::TileBox jubilife_company_clown_box(); // The tiles 00.05c may start on: against the Poketch Company's sign -// (00.05b's end), and on the street east (its own end, 01.01's start). +// (00.05b's end), and below the east-exit sign (its own end, 01.01's start). std::pair jubilife_start_tiles(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp index 6a9273d39e..68d15a9618 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Events_Jubilife.cpp @@ -295,7 +295,7 @@ void check_coupons(VideoStream& stream, ProControllerContext& context){ } // 00.05c starts against the Poketch Company's sign (14, 19) facing west -// (00.05b's end) or on the street east, (58, 22) facing east (its own end +// (00.05b's end) or below the east-exit sign, (59, 21) facing north (its own end // and 01.01's start, when a run gave no Poketch). A step west tells them // apart: the sign blocks it, the street does not. Pokemon::Outcome jubilife_start_probe(StoryExecutor& executor, Pokemon::RunState&, const Pokemon::StoryStep&){ @@ -359,7 +359,7 @@ Pokemon::TileBox jubilife_company_clown_box(){ } std::pair jubilife_start_tiles(){ - return {{14, 19}, {58, 22}}; + return {{14, 19}, {59, 21}}; } void add_jubilife_events(StoryEvents& events){ 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 8eee48cc0c..03a620d963 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -456,14 +456,14 @@ constexpr Pokemon::TileBox WONDER_STATION_PLAZA[] = { }; std::string company_clown_plaza_tiles(Logger& logger, TableRoute route, int x){ - route.from = Pokemon::tile_pose("JubilifeCity", {{x, 22}}, Direction::WEST); + route.from = Pokemon::tile_pose("JubilifeCity", {{x, 21}}, Direction::WEST); const RouteStepPlan plan = plan_table_route(route); if (!plan.legs){ - return std::format("no plan from ({}, 22).", x); + return std::format("no plan from ({}, 21).", x); } const StoryWorld& world = *route.world; for (const PlannedLeg& planned : *plan.legs){ - logger.log(std::format("00.05c beside_the_president from ({}, 22): {}", x, to_string(planned))); + logger.log(std::format("00.05c beside_the_president from ({}, 21): {}", x, to_string(planned))); } const auto plaza = [&](const TilePos& pos){ const std::optional local = story_to_local(world, "JubilifeCity", pos); @@ -477,7 +477,7 @@ std::string company_clown_plaza_tiles(Logger& logger, TableRoute route, int x){ // 00.05c's first walk (to the president since its clown re-talks went; // to the Poketch Company's clown before) from the street -// (57..58, 22), where the checkpoint starts on a rerun from 01.01's start, +// (57..58, 21), where the checkpoint starts on a rerun from 01.01's start, // keeps off the plaza (WONDER_STATION_PLAZA). BDSP put the Global Wonder Station // there, a round wall with people round it that pret's Diamond map lacks: // on lab-B (2026-11-12 01:22 and 01:55) the walk west from (57, 22) was @@ -801,7 +801,7 @@ const AutoStoryStoryTableCase AUTO_STORY_STORY_TABLE_CASES[] = { .expectation = {}, }, { - .input = {"00.05c: from the street (57..58, 22), the walk keeps off the Wonder Station's plaza (lab-B, 2026-11-12)", test_company_clown_from_the_street_keeps_off_the_plaza}, + .input = {"00.05c: from the street (57..58, 21), the walk keeps off the Wonder Station's plaza (lab-B, 2026-11-12)", test_company_clown_from_the_street_keeps_off_the_plaza}, .expectation = {}, }, { diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp index 09b5dbea02..5ec742a18c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp @@ -163,7 +163,7 @@ const std::set KNOWN_CERTAINTY_GAPS{ "00.05b step 1 below_the_presidents_trigger: needs tile, has set", "00.05b step 10 below_the_company_clown: needs tile, has set", "00.05b step 4 past_the_president: needs tile, has set", - "00.05c step 6 to_the_route_203_street: needs tile, has set", + "00.05c step 6 up_the_main_road: needs tile, has set", "01.01 step 2 west_of_barrys_trigger: needs tile, has set", "01.02 step 1 south_to_the_cliff: needs tile, has set", "01.02 step 10 west_of_the_welcome: needs tile, has set", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp index 51c375a12b..11d4537c32 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp @@ -454,6 +454,23 @@ UnitTestResult missing_coupon_fails_00_05b(Logger& logger){ } return true; } +// 00.05c's walk up the main road on lab-B 2026-11-12 13:32: its open leg +// north ended a row off, the leg east to the wall stopped at the Mart's +// hedges, and the walk took it for (59, 26) and "arrived" below the +// east-exit sign beside them. The end on (59, 21) must hold from a row +// off either way, into 01.01 from there. +UnitTestResult main_road_a_row_off_00_05c(Logger& logger){ + std::string failures; + for (const Direction direction : {Direction::NORTH, Direction::SOUTH}){ + SimWorldKnobs knobs; + knobs.slides = {{.step = "up_the_main_road", .direction = direction, .tiles = 1}}; + const std::string stopped = run_case(logger, "00.05c", "01.01", {.fade = {}, .banner = {}}, std::move(knobs)); + if (!stopped.empty()){ + failures += std::format("\n a row {}: {}", Pokemon::direction_name(direction), stopped); + } + } + return failures.empty() ? UnitTestResult(true) : UnitTestResult("00.05c up the main road:" + failures); +} // 01.01 from a save with no Poketch: Jubilife's east-exit guard would // ask about the Poketch campaign and turn us back (lab-B 2026-11-11, the // walk took him for a trainer); the row stops at its first step instead. @@ -743,6 +760,7 @@ const FailureCase AUTO_STORY_FAILURE_CASES[] = { }}, .expectation = {}}, {.input = {"00.05c a coupon missing (the sign read for the Poketch Company clown): no Poketch, 00.05c fails (lab-B 2026-11-11)", no_poketch_fails_00_05c}, .expectation = {}}, {.input = {"00.05b a coupon missing at its end: the row fails at its coupon check, before the save", missing_coupon_fails_00_05b}, .expectation = {}}, + {.input = {"00.05c the walk up the main road ends a row off: still on (59, 21) below the east-exit sign, into 01.01 (lab-B 2026-11-12 13:32)", main_road_a_row_off_00_05c}, .expectation = {}}, {.input = {"01.01 with no Poketch: the east-exit guard's gate stops the row at its check, not a trainer fight (lab-B 2026-11-11)", gate_guard_stops_01_01}, .expectation = {}}, {.input = {"00.04 to the ledge column with a wild battle on each pass through Route 201's grass (lab-B 2026-11-09 16:14)", [](Logger& logger){ return passes(ledge_walk_in_grass(logger, {})); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index 86c0873d86..ac6bb93290 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -5,7 +5,7 @@ "action": "jubilife_start_probe", "id": "where_we_start", "kind": "game_action", - "why": "a step west: the Poketch Company's sign (14, 19) blocks it (00.05b's end); on the street (58, 22) it goes (a rerun from 01.01's start when no Poketch came)" + "why": "a step west: the Poketch Company's sign (14, 19) blocks it (00.05b's end); below the east-exit sign (59, 21) it goes (a rerun from 01.01's start when no Poketch came)" }, { "action": "town", @@ -97,15 +97,134 @@ "map": "JubilifeCity", "tiles": [ [ - 58, - 22 + 53, + 27 ] ] } }, - "id": "to_the_route_203_street", + "id": "up_the_main_road", "kind": "route", - "why": "up the main road and east along the street" + "why": "up the main road to row 27 west of the Mart's hedges; an open leg can end a row or a few columns off (lab-B 2026-11-12 13:32: a row off, the east leg to the wall stopped at the hedges)", + "declared_after": { + "facing": "east", + "map": "JubilifeCity", + "tiles": [ + [ + 49, + 25 + ], + [ + 50, + 25 + ], + [ + 51, + 25 + ], + [ + 52, + 25 + ], + [ + 53, + 25 + ], + [ + 54, + 25 + ], + [ + 49, + 26 + ], + [ + 50, + 26 + ], + [ + 51, + 26 + ], + [ + 52, + 26 + ], + [ + 53, + 26 + ], + [ + 54, + 26 + ], + [ + 49, + 27 + ], + [ + 50, + 27 + ], + [ + 51, + 27 + ], + [ + 52, + 27 + ], + [ + 53, + 27 + ], + [ + 54, + 27 + ] + ] + } + }, + { + "action": "measured", + "args": { + "fight_wild": false, + "legs": [ + { + "direction": "south", + "tiles": 3 + }, + { + "direction": "east", + "tiles": 8 + }, + { + "direction": "north", + "tiles": 1 + }, + { + "direction": "east", + "tiles": 4 + }, + { + "direction": "north", + "tiles": 6 + } + ] + }, + "declared_after": { + "facing": "north", + "map": "JubilifeCity", + "tiles": [ + [ + 59, + 21 + ] + ] + }, + "id": "below_the_east_exit_sign", + "kind": "legs", + "why": "taps, each leg ended by a wall: south onto row 27 (row 28's wall, columns 49..54), east to the hedges (57, 27), north 1, east along row 26 to (60, 26)'s wall, north up column 59 to the east-exit sign (59, 20); every tile we may be on ends on (59, 21) facing north, west of the guard's trigger column 60 (user 2026-11-12)" } ], "id": "00.05c", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.01.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.01.plan.json index 5eed96c24f..eeff5f14ab 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.01.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.01.plan.json @@ -67,12 +67,12 @@ ], "id": "01.01", "start": { - "facing": "east", + "facing": "north", "map": "JubilifeCity", "tiles": [ [ - 58, - 22 + 59, + 21 ] ] }, From 6be7b0ea4172dbf5a4f02bee6f652b5a23b35d6e Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 13:51:54 -0800 Subject: [PATCH 18/47] BDSP AutoStory: "measured" legs in the story table; route goldens for 00.05c's end below the east-exit sign Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_bench.golden.txt | 4 ++-- .../AutoStory/Data/route_plans.golden.txt | 22 +++++++++---------- .../PokemonBDSP_AutoStory_StoryData.cpp | 4 ++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index dd6bc300d8..38df4c1143 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -40,8 +40,8 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS 00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS 00.05c beside_the_president | 31200 | 31200 | 31200 | 1 | 0 | 0 | 5.43! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS -00.05c to_the_route_203_street | 14250 | 14250 | 14250 | 1 | 0 | 0 | 4.07! | 1.00 | 1.00 | 3500 ms (stand-in) | PASS -01.01 west_of_barrys_trigger | 7300 | 7300 | 7300 | 0 | 0 | 0 | 6.35! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS +00.05c up_the_main_road | 11450 | 11450 | 11450 | 1 | 0 | 0 | 5.09! | 1.00 | 1.00 | 2250 ms (stand-in) | PASS +01.01 west_of_barrys_trigger | 7400 | 7400 | 7400 | 0 | 0 | 0 | 6.17! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 01.02 by_the_gate | 24815 | 26050 | 13700 | 2 | 9 | 0 | 3.60! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS 01.02 west_of_the_hikers_trigger | 3950 | 3950 | 3950 | 2 | 0 | 0 | 8.78! | 1.00 | 2.00! | 450 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 4ae827cec5..84166d8690 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -259,22 +259,22 @@ anchor); 0 from one start tile. 5. east 12 (open) -> Jubilife City (45, 35) totals: 5 legs, 4 turns, 4 open, 0 localization -== 00.05c to_the_route_203_street (costs: line) +== 00.05c up_the_main_road (costs: line) from: JubilifeCity (45, 35) facing east (tile) - target: JubilifeCity (58, 22) facing east (tile) + target: JubilifeCity (53, 27) facing east (tile) start candidates: Jubilife City (45, 35) - 1. north 9 (open) -> Jubilife City (45, 26) - 2. east 14 (to wall) -> Jubilife City (59, 26) - 3. west 1 (open) -> Jubilife City (58, 26) - 4. north 4 (open) -> Jubilife City (58, 22) - totals: 4 legs, 3 turns, 3 open, 0 localization + 1. north 8 (open) -> Jubilife City (45, 27) + 2. east 11 (to wall) -> Jubilife City (56, 27) + 3. west 3 (open) -> Jubilife City (53, 27) + totals: 3 legs, 2 turns, 2 open, 0 localization == 01.01 west_of_barrys_trigger (costs: town) - from: JubilifeCity (58, 22) facing east (tile) + from: JubilifeCity (59, 21) facing north (tile) target: Route203 (4, 18) facing east (tile) - start candidates: Jubilife City (58, 22) - 1. east 9 (open) -> Route 203 (4, 18) - totals: 1 legs, 0 turns, 1 open, 0 localization + start candidates: Jubilife City (59, 21) + 1. south 1 (open) -> Jubilife City (59, 22) + 2. east 8 (open) -> Route 203 (4, 18) + totals: 2 legs, 1 turns, 2 open, 0 localization == 01.02 south_to_the_cliff (costs: route) from: Route203 (5, 17) (5, 18) (5, 19) (5, 20) facing east (set) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp index 63023c1ec7..5547e799e8 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp @@ -61,6 +61,10 @@ void add_legs_actions( actions.push_back({.kind = Pokemon::StoryStepKind::LEGS, .name = "one_short_ok", .args = {legs_arg, fight_wild}}); actions.push_back({.kind = Pokemon::StoryStepKind::LEGS, .name = "counted_wall", .args = {legs_arg, fight_wild}, .console_only = false, .certainty = Pokemon::StoryCertainty{.needs = PoseCertainty::SET, .leaves = PoseEnd::DECLARED}}); + // Taps counted against the map from each tile we may be on: legs each + // ended by a wall take every one of them to the declared end. + actions.push_back({.kind = Pokemon::StoryStepKind::LEGS, .name = "measured", .args = {legs_arg, fight_wild}, + .console_only = false, .certainty = Pokemon::StoryCertainty{.needs = PoseCertainty::SET, .leaves = PoseEnd::DECLARED}}); } // The talks to someone who wanders: each walks in D-pad taps, a whole tile From d9da2c06ce74f5d9597e78498826836aaf6e1db9 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:05:18 -0800 Subject: [PATCH 19/47] BDSP AutoStory: 00.05c ends below the east-exit sign on its planned route, not a measured walk The measured walk inferred its start from tap counts and failed on lab-B (2026-11-12 13:55: east moved 0). The planned route's legs are taps (a turn tap first, a whole tile each) or run to a wall; it ends on (59, 21) facing north from (45, 35), off the guard's column 60. Sim case for the turn tap after the east leg, plan test, goldens. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_bench.golden.txt | 2 +- .../AutoStory/Data/route_plans.golden.txt | 10 +- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 39 ++++++ ...PokemonBDSP_AutoStory_FaultSweep_Tests.cpp | 2 +- ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 12 +- .../AutoStory/StoryData/bdsp-00.05c.plan.json | 127 ++---------------- 6 files changed, 69 insertions(+), 123 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index 38df4c1143..296f7246c7 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -40,7 +40,7 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS 00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS 00.05c beside_the_president | 31200 | 31200 | 31200 | 1 | 0 | 0 | 5.43! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS -00.05c up_the_main_road | 11450 | 11450 | 11450 | 1 | 0 | 0 | 5.09! | 1.00 | 1.00 | 2250 ms (stand-in) | PASS +00.05c below_the_east_exit_sign | 20700 | 20700 | 20700 | 1 | 0 | 0 | 5.52! | 1.00 | 1.00 | 3750 ms (stand-in) | PASS 01.01 west_of_barrys_trigger | 7400 | 7400 | 7400 | 0 | 0 | 0 | 6.17! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 01.02 by_the_gate | 24815 | 26050 | 13700 | 2 | 9 | 0 | 3.60! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 84166d8690..8ca0d13b30 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -259,13 +259,13 @@ anchor); 0 from one start tile. 5. east 12 (open) -> Jubilife City (45, 35) totals: 5 legs, 4 turns, 4 open, 0 localization -== 00.05c up_the_main_road (costs: line) +== 00.05c below_the_east_exit_sign (costs: line) from: JubilifeCity (45, 35) facing east (tile) - target: JubilifeCity (53, 27) facing east (tile) + target: JubilifeCity (59, 21) facing north (tile) start candidates: Jubilife City (45, 35) - 1. north 8 (open) -> Jubilife City (45, 27) - 2. east 11 (to wall) -> Jubilife City (56, 27) - 3. west 3 (open) -> Jubilife City (53, 27) + 1. north 9 (open) -> Jubilife City (45, 26) + 2. east 14 (open) -> Jubilife City (59, 26) + 3. north 5 (to wall) -> Jubilife City (59, 21) totals: 3 legs, 2 turns, 2 open, 0 localization == 01.01 west_of_barrys_trigger (costs: town) 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 03a620d963..2fe3327dda 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -524,6 +524,41 @@ UnitTestResult test_company_clown_after_the_woman_on_row_24(Logger& logger){ return "00.05c beside_the_president: not in the table, or from nowhere known."; } +// 00.05c's end below the east-exit sign (59, 21) facing north, on the +// planned route from the Mart's street (lab-B 2026-11-12 13:55: a "measured" +// walk inferred its start and tapped against the hedges). Each leg is taps +// (a whole tile each, a turn tap first) or a wall's end, and none steps on +// the guard's trigger column 60. +UnitTestResult test_main_road_ends_below_the_east_exit_sign(Logger& logger){ + for (const PlannedStoryRoute& route : plan_story_routes(logger)){ + if (route.name != "00.05c below_the_east_exit_sign"){ + continue; + } + if (!route.legs || route.legs->empty()){ + return "00.05c below_the_east_exit_sign: no plan."; + } + const StoryWorld& world = *route.world; + const auto guard_column = [&](const TilePos& pos){ + const std::optional local = story_to_local(world, "JubilifeCity", pos); + return local && local->x >= 60; + }; + const auto [most, leg] = most_zone_tiles(world, route.from, *route.legs, guard_column); + if (most > 0){ + return std::format("the leg {} steps on {} tiles of column 60 or east.", leg, most); + } + const PlannedLeg& last = route.legs->back(); + const auto on_the_tile = [&](const TilePos& pos){ + const std::optional local = story_to_local(world, "JubilifeCity", pos); + return local && *local == TilePos{59, 21}; + }; + if (last.after.size() != 1 || !on_the_tile(last.after.front()) || last.leg.direction != Direction::NORTH || to_string(last).find("to wall") == std::string::npos){ + return "00.05c below_the_east_exit_sign does not end on (59, 21) facing north against the sign."; + } + return true; + } + return "00.05c below_the_east_exit_sign is not a ROUTE step from a known place."; +} + // 01.08's walk below the Ravaged Path keeps off the row Route 204 South's // youngster_3 wanders, (12, 2) to (14, 2): on lab-B (2026-11-08) the plan // "north 35 (to wall) to (13, 2), west 2 (to wall) to (11, 2)" walked along @@ -792,6 +827,10 @@ const AutoStoryStoryTableCase AUTO_STORY_STORY_TABLE_CASES[] = { .input = {"Story table: every route plans, and none runs along a wander zone", test_story_routes_keep_off_wander_zones}, .expectation = {}, }, + { + .input = {"00.05c: the plan to below the east-exit sign is taps and a wall's end, off the guard's column (lab-B, 2026-11-12 13:55)", test_main_road_ends_below_the_east_exit_sign}, + .expectation = {}, + }, { .input = {"01.08: the walk below the Ravaged Path keeps off the youngster's row (lab-B, 2026-11-08)", test_ravaged_path_keeps_off_the_youngster}, .expectation = {}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp index 5ec742a18c..ebc1e256a1 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp @@ -163,7 +163,7 @@ const std::set KNOWN_CERTAINTY_GAPS{ "00.05b step 1 below_the_presidents_trigger: needs tile, has set", "00.05b step 10 below_the_company_clown: needs tile, has set", "00.05b step 4 past_the_president: needs tile, has set", - "00.05c step 6 up_the_main_road: needs tile, has set", + "00.05c step 6 below_the_east_exit_sign: needs tile, has set", "01.01 step 2 west_of_barrys_trigger: needs tile, has set", "01.02 step 1 south_to_the_cliff: needs tile, has set", "01.02 step 10 west_of_the_welcome: needs tile, has set", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp index 11d4537c32..ea33c16689 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp @@ -463,7 +463,7 @@ UnitTestResult main_road_a_row_off_00_05c(Logger& logger){ std::string failures; for (const Direction direction : {Direction::NORTH, Direction::SOUTH}){ SimWorldKnobs knobs; - knobs.slides = {{.step = "up_the_main_road", .direction = direction, .tiles = 1}}; + knobs.slides = {{.step = "below_the_east_exit_sign", .direction = direction, .tiles = 1}}; const std::string stopped = run_case(logger, "00.05c", "01.01", {.fade = {}, .banner = {}}, std::move(knobs)); if (!stopped.empty()){ failures += std::format("\n a row {}: {}", Pokemon::direction_name(direction), stopped); @@ -471,6 +471,15 @@ UnitTestResult main_road_a_row_off_00_05c(Logger& logger){ } return failures.empty() ? UnitTestResult(true) : UnitTestResult("00.05c up the main road:" + failures); } +// 00.05c on lab-B 2026-11-12 13:55: a short D-pad tap in a new direction +// after the east leg only turned the player, and the walk, counting its +// taps against an inferred start, tapped east against the hedges. Every +// tap leg now turns first and then steps a whole tile, so the walk from +// the street ends on (59, 21) and the row goes on into 01.01. +UnitTestResult turn_tap_after_the_east_leg_00_05c(Logger& logger){ + const std::string stopped = run_case(logger, "00.05c", "01.01", {.fade = {}, .banner = {}}, SimWorldKnobs{}); + return stopped.empty() ? UnitTestResult(true) : UnitTestResult("00.05c to the east-exit sign: " + stopped); +} // 01.01 from a save with no Poketch: Jubilife's east-exit guard would // ask about the Poketch campaign and turn us back (lab-B 2026-11-11, the // walk took him for a trainer); the row stops at its first step instead. @@ -761,6 +770,7 @@ const FailureCase AUTO_STORY_FAILURE_CASES[] = { {.input = {"00.05c a coupon missing (the sign read for the Poketch Company clown): no Poketch, 00.05c fails (lab-B 2026-11-11)", no_poketch_fails_00_05c}, .expectation = {}}, {.input = {"00.05b a coupon missing at its end: the row fails at its coupon check, before the save", missing_coupon_fails_00_05b}, .expectation = {}}, {.input = {"00.05c the walk up the main road ends a row off: still on (59, 21) below the east-exit sign, into 01.01 (lab-B 2026-11-12 13:32)", main_road_a_row_off_00_05c}, .expectation = {}}, + {.input = {"00.05c the turn tap after the east leg only turns: the walk ends on (59, 21), into 01.01 (lab-B 2026-11-12 13:55)", turn_tap_after_the_east_leg_00_05c}, .expectation = {}}, {.input = {"01.01 with no Poketch: the east-exit guard's gate stops the row at its check, not a trainer fight (lab-B 2026-11-11)", gate_guard_stops_01_01}, .expectation = {}}, {.input = {"00.04 to the ledge column with a wild battle on each pass through Route 201's grass (lab-B 2026-11-09 16:14)", [](Logger& logger){ return passes(ledge_walk_in_grass(logger, {})); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json index ac6bb93290..37a8be0f66 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-00.05c.plan.json @@ -89,129 +89,29 @@ 26, 43, 27 + ], + [ + 60, + 18, + 70, + 30 ] ], "fight_wild": false, "target": { - "facing": "east", + "facing": "north", "map": "JubilifeCity", "tiles": [ [ - 53, - 27 + 59, + 21 ] ] } }, - "id": "up_the_main_road", + "id": "below_the_east_exit_sign", "kind": "route", - "why": "up the main road to row 27 west of the Mart's hedges; an open leg can end a row or a few columns off (lab-B 2026-11-12 13:32: a row off, the east leg to the wall stopped at the hedges)", - "declared_after": { - "facing": "east", - "map": "JubilifeCity", - "tiles": [ - [ - 49, - 25 - ], - [ - 50, - 25 - ], - [ - 51, - 25 - ], - [ - 52, - 25 - ], - [ - 53, - 25 - ], - [ - 54, - 25 - ], - [ - 49, - 26 - ], - [ - 50, - 26 - ], - [ - 51, - 26 - ], - [ - 52, - 26 - ], - [ - 53, - 26 - ], - [ - 54, - 26 - ], - [ - 49, - 27 - ], - [ - 50, - 27 - ], - [ - 51, - 27 - ], - [ - 52, - 27 - ], - [ - 53, - 27 - ], - [ - 54, - 27 - ] - ] - } - }, - { - "action": "measured", - "args": { - "fight_wild": false, - "legs": [ - { - "direction": "south", - "tiles": 3 - }, - { - "direction": "east", - "tiles": 8 - }, - { - "direction": "north", - "tiles": 1 - }, - { - "direction": "east", - "tiles": 4 - }, - { - "direction": "north", - "tiles": 6 - } - ] - }, + "why": "up the main road and along the street to below the east-exit sign (59, 21) facing north, west of the guard's trigger column 60: tapped legs (each a whole tile, a turn tap first) and legs to a wall, none a held leg ended in the open (lab-B 2026-11-12 13:55)", "declared_after": { "facing": "north", "map": "JubilifeCity", @@ -221,10 +121,7 @@ 21 ] ] - }, - "id": "below_the_east_exit_sign", - "kind": "legs", - "why": "taps, each leg ended by a wall: south onto row 27 (row 28's wall, columns 49..54), east to the hedges (57, 27), north 1, east along row 26 to (60, 26)'s wall, north up column 59 to the east-exit sign (59, 20); every tile we may be on ends on (59, 21) facing north, west of the guard's trigger column 60 (user 2026-11-12)" + } } ], "id": "00.05c", From 76e01a711659a103c3a5d461f9ce59d474b3b28a Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:51:48 -0800 Subject: [PATCH 20/47] BDSP AutoStory: a leg that ends at a wall is a wall leg; no wall-and-back from a known tile lab-B 2026-11-12 14:24, 00.05c: "east 14 (open)" was a run into the wall past (59, 26), and "south 15 (to wall), north 1" ran past a known tile and back. The east-exit avoid zone uncovered its walls (so no wall held the player there); a wall in a zone stays a wall. The robust planner skips an open leg that ends where the leg to the wall does, and no leg follows a wall leg from one known place straight back. plan_fastest_route() no longer adds run-to-the-wall-and-tap-back variants (run_variants). Route plan, bench and leg-trace goldens regenerated. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Navigation/Pokemon_RobustLegPlanner.h | 24 +++- .../AutoStory/Data/route_bench.golden.txt | 32 +++--- .../AutoStory/Data/route_plans.golden.txt | 108 +++++++++--------- ...kemonBDSP_AutoStory_RoutePlanner_Tests.cpp | 3 +- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 58 ++++++++++ .../PokemonBDSP_AutoStory_TableRoutes.cpp | 5 +- .../Simulation/leg_trace_00.04.golden.json | 19 +-- .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 4 +- .../PokemonBDSP_AutoStory_RouteChoice.cpp | 72 +----------- 9 files changed, 164 insertions(+), 161 deletions(-) diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h index a6fb75f8d0..350ff1a243 100644 --- a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h @@ -385,6 +385,11 @@ std::vector> consolidate(const std::vector>& l return consolidated; } +// The way back: the direction opposite `direction`. +inline Direction opposite(Direction direction){ + return Direction(((int)direction + 2) % 4); +} + // Dijkstra over sets of places the player may stand on. template class Search{ @@ -438,8 +443,9 @@ class Search{ void expand(const Spread& spread, long long cost){ for (Direction direction : ALL_DIRECTIONS){ - if (auto wall = to_wall_leg(m_model, spread, direction, m_costs)){ - relax(spread, cost, std::move(*wall)); + const auto wall = to_wall_leg(m_model, spread, direction, m_costs); + if (wall){ + relax(spread, cost, Expansion(*wall)); } // A held leg unsafe at one length may be safe at a longer one. for (int tiles = 1; tiles <= m_costs.max_open_tiles; tiles++){ @@ -447,6 +453,11 @@ class Search{ if (!open){ break; } + // An open leg that ends where the leg to the wall does is + // that leg: it is held until the wall stops the player. + if (wall && wall->leg.tiles == open->leg.tiles && wall->leg.after == open->leg.after){ + continue; + } if (!open->unsafe){ relax(spread, cost, std::move(*open)); } @@ -463,7 +474,14 @@ class Search{ return; } if (spread != m_start){ - const RobustLeg& prev = m_nodes.at(spread).leg; + const Node& arrived = m_nodes.at(spread); + const RobustLeg& prev = arrived.leg; + // A leg to a wall from one place the player is known to be on + // localizes nothing: walking straight back from it is a longer + // way to the tiles a leg open on the first would reach. + if (prev.to_wall && arrived.parent.size() == 1 && expansion.leg.direction == opposite(prev.direction)){ + return; + } if (joins(prev, expansion.leg)){ expansion.cost -= m_costs.per_leg; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index 296f7246c7..6cbcc6d0b0 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -18,32 +18,32 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.01 below_the_flute | 4090 | 4090 | 4090 | 1 | 0 | 0 | 5.84! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 00.01 above_the_door | 7230 | 7230 | 7230 | 1 | 0 | 0 | 4.66! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS 00.01 short_of_barrys_door | 11950 | 11950 | 11950 | 1 | 0 | 0 | 4.35! | 1.00 | 1.00 | 2750 ms (stand-in) | PASS -00.01 above_barrys_door | 7230 | 7230 | 7230 | 1 | 0 | 0 | 4.66! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS +00.01 above_barrys_door | 8200 | 8200 | 8200 | 0 | 0 | 0 | 5.29! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS 00.02 to_the_lake_entrance | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS 00.03 into_rowans_scene | 3030 | 3030 | 3030 | 1 | 0 | 0 | 2.33! | 1.00 | 1.00 | 1300 ms (stand-in) | PASS -00.03 into_dawns_scene | 61510 | 46690 | 34340 | 4 | 22 | 0 | 5.37! | 1.15 | 56.00! | 11450 ms (stand-in) | PASS +00.03 into_dawns_scene | 62650 | 47830 | 35480 | 4 | 22 | 0 | 5.47! | 1.15 | 75.00! | 11450 ms (stand-in) | PASS 00.04 onto_the_path | 4050 | 4050 | 4050 | 2 | 0 | 0 | 5.79! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 00.04 to_ledge_column | 3850 | 3850 | 3850 | 1 | 0 | 0 | 3.21! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 00.04 along_route_201_road | 36400 | 36400 | 36400 | 0 | 0 | 0 | 2.98! | 1.00 | 0.60 | 12200 ms (user's route) | PASS -00.04 into_twinleaf | 10200 | 10200 | 10200 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 10200 ms (user's route) | PASS +00.04 into_twinleaf | 26500 | 26500 | 26500 | 0 | 0 | 0 | 2.60! | 1.00 | 1.00 | 10200 ms (user's route) | PASS 00.04 to_moms_doorstep | 4100 | 4100 | 4100 | 0 | 0 | 0 | 5.47! | 1.00 | 1.00 | 750 ms (stand-in) | PASS 00.04 beside_mom | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS 00.04 into_moms_call | 2550 | 2550 | 2550 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 2550 ms (user's route) | PASS -00.04 short_of_the_catch_tutorial | 84001 | 81950 | 49900 | 6 | 19 | 7 | 4.73! | 1.00 | 57.00! | 17750 ms (stand-in) | PASS +00.04 short_of_the_catch_tutorial | 87051 | 85000 | 52950 | 7 | 19 | 7 | 4.90! | 1.00 | 99.00! | 17750 ms (stand-in) | PASS 00.04b to_catch_grass | 11689 | 38550 | 6300 | 2 | 34 | 1 | 17.98! | 17.50! | 2.00! | 650 ms (stand-in) | PASS 00.04b into_sandgem | 9520 | 19400 | 7050 | 3 | 12 | 0 | 2.93! | 4.33! | 1.00 | 3250 ms (stand-in) | PASS -00.04d north_to_jubilife | 73575 | 42700 | 30350 | 8 | 35 | 0 | 7.21! | 1.24 | 80.00! | 10200 ms (stand-in) | PASS +00.04d north_to_jubilife | 73675 | 42800 | 30450 | 8 | 35 | 0 | 7.22! | 1.24 | 81.00! | 10200 ms (stand-in) | PASS 00.05b below_the_presidents_trigger | 4900 | 4900 | 4900 | 0 | 0 | 0 | 5.76! | 1.00 | 1.00 | 850 ms (stand-in) | PASS 00.05b past_the_president | 1700 | 1700 | 1700 | 0 | 0 | 0 | 3.78! | 1.00 | 1.00 | 450 ms (stand-in) | PASS 00.05b below_the_mart_clown | 5450 | 5450 | 5450 | 1 | 0 | 0 | 3.30! | 1.00 | 1.00 | 1650 ms (stand-in) | PASS -00.05b below_the_tv_clown | 27350 | 27350 | 27350 | 1 | 0 | 0 | 6.29! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS +00.05b below_the_tv_clown | 27500 | 27500 | 27500 | 0 | 0 | 0 | 6.32! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS 00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS -00.05c beside_the_president | 31200 | 31200 | 31200 | 1 | 0 | 0 | 5.43! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS -00.05c below_the_east_exit_sign | 20700 | 20700 | 20700 | 1 | 0 | 0 | 5.52! | 1.00 | 1.00 | 3750 ms (stand-in) | PASS +00.05c beside_the_president | 38000 | 38000 | 38000 | 0 | 0 | 0 | 6.61! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS +00.05c below_the_east_exit_sign | 12150 | 12150 | 12150 | 2 | 0 | 0 | 3.24! | 1.00 | 1.00 | 3750 ms (stand-in) | PASS 01.01 west_of_barrys_trigger | 7400 | 7400 | 7400 | 0 | 0 | 0 | 6.17! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS -01.02 by_the_gate | 24815 | 26050 | 13700 | 2 | 9 | 0 | 3.60! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS +01.02 by_the_gate | 26465 | 27700 | 15350 | 1 | 9 | 0 | 3.84! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS 01.02 west_of_the_hikers_trigger | 3950 | 3950 | 3950 | 2 | 0 | 0 | 8.78! | 1.00 | 2.00! | 450 ms (stand-in) | PASS 01.02 past_curtis | 10500 | 10500 | 10500 | 0 | 0 | 0 | 6.77! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS 01.02 by_the_east_mouth | 4900 | 4900 | 4900 | 0 | 0 | 0 | 5.76! | 1.00 | 1.00 | 850 ms (stand-in) | PASS @@ -56,17 +56,17 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 01.06 below_rowans_trigger | 1950 | 1950 | 1950 | 1 | 0 | 0 | 2.29! | 1.00 | 1.00 | 850 ms (stand-in) | PASS 01.08 west_to_the_wall | 1650 | 1650 | 1650 | 1 | 0 | 0 | 3.00! | 1.00 | 1.00 | 550 ms (stand-in) | PASS 01.08 below_the_ravaged_path | 24815 | 26050 | 13700 | 2 | 9 | 0 | 4.24! | 1.00 | 6.00! | 5850 ms (stand-in) | PASS -01.09 west_of_the_rock | 7050 | 7050 | 7050 | 1 | 0 | 0 | 4.70! | 1.00 | 1.00 | 1500 ms (stand-in) | PASS +01.09 west_of_the_rock | 7400 | 7400 | 7400 | 0 | 0 | 0 | 4.93! | 1.00 | 1.00 | 1500 ms (stand-in) | PASS 01.09 above_the_way_out | 4550 | 4550 | 4550 | 2 | 0 | 0 | 4.14! | 1.00 | 2.00! | 1100 ms (stand-in) | PASS 01.10 line_1 | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS -01.10 line_2 | 3250 | 3250 | 3250 | 1 | 0 | 0 | 2.83! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS +01.10 line_2 | 7300 | 7300 | 7300 | 0 | 0 | 0 | 6.35! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS 01.10 line_3 | 4100 | 4100 | 4100 | 0 | 0 | 0 | 4.10! | 1.00 | 1.00 | 1000 ms (stand-in) | PASS -01.10 line_4 | 4050 | 4050 | 4050 | 1 | 0 | 0 | 3.86! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS -01.10 line_5 | 15110 | 20050 | 7700 | 1 | 6 | 0 | 7.75! | 1.17 | 1.00 | 1950 ms (stand-in) | PASS -01.10 line_6 | 3150 | 3150 | 3150 | 1 | 0 | 0 | 3.00! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS +01.10 line_4 | 6500 | 6500 | 6500 | 0 | 0 | 0 | 6.19! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS +01.10 line_5 | 20388 | 39400 | 8100 | 0 | 6 | 6 | 10.46! | 1.17 | 7.00! | 1950 ms (stand-in) | PASS +01.10 line_6 | 6500 | 6500 | 6500 | 0 | 0 | 0 | 6.19! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS TARGET 00.04 along_route_201_road | 12200 | 12200 | 12200 | 2 | 0 | 0 | 1.00 | 1.00 | 1.00 | 12200 ms (user's route) | PASS TARGET 00.04 into_twinleaf | 10200 | 10200 | 10200 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 10200 ms (user's route) | PASS TARGET 00.04 into_moms_call | 2550 | 2550 | 2550 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 2550 ms (user's route) | PASS 00.04 into_twinleaf after run 4's block, planned from the counted tile | 11250 | 11250 | 11250 | 1 | 0 | 0 | 5.00! | 1.00 | 2.00! | 2250 ms (stand-in) | FAIL (may end on (47, 85), off the goal) -00.04 into_twinleaf after run 4's block | 10750 | 10750 | 10750 | 3 | 0 | 0 | 4.78! | 1.00 | 2.00! | 2250 ms (stand-in) | PASS -00.04d north_to_jubilife, planned with the route's own costs (taps in the grass) | 84645 | 66250 | 33200 | 6 | 35 | 5 | 8.30! | 1.24 | 85.00! | 10200 ms (stand-in) | PASS +00.04 into_twinleaf after run 4's block | 12750 | 12750 | 12750 | 2 | 0 | 0 | 5.67! | 1.00 | 2.00! | 2250 ms (stand-in) | PASS +00.04d north_to_jubilife, planned with the route's own costs (taps in the grass) | 95551 | 64000 | 34250 | 8 | 37 | 11 | 9.37! | 1.31 | 90.00! | 10200 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 8ca0d13b30..c3a79c3399 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -47,10 +47,9 @@ anchor); 0 from one start tile. from: RivalHouse1F (2, 3) (tile) target: RivalHouse1F (6, 9) facing south (tile) start candidates: RivalHouse1F (2, 3) - 1. south 7 (to wall) -> RivalHouse1F (2, 10) - 2. north 1 (open) -> RivalHouse1F (2, 9) - 3. east 4 (open) -> RivalHouse1F (6, 9) - totals: 3 legs, 2 turns, 2 open, 0 localization + 1. south 6 (open) -> RivalHouse1F (2, 9) + 2. east 4 (open) -> RivalHouse1F (6, 9) + totals: 2 legs, 1 turns, 2 open, 0 localization == 00.01 below_the_lake_entrance (costs: route) from: unknown @@ -78,11 +77,12 @@ anchor); 0 from one start tile. 1. west 3 (open) -> Twinleaf Town (17, 22) 2. north 34 (to wall) -> Route 201 (17, 13) 3. east 40 (to wall) -> Route 201 (57, 13) - 4. west 7 (open) -> Route 201 (50, 13) - 5. north 10 (to wall) -> Route 201 (50, 3) - 6. east 13 (to wall) -> Route 201 (63, 3) - 7. south 2 (open) -> Route 201 (63, 5) - totals: 7 legs, 6 turns, 3 open, 0 localization + 4. south 1 (open) -> Route 201 (57, 14) + 5. west 7 (open) -> Route 201 (50, 14) + 6. north 11 (to wall) -> Route 201 (50, 3) + 7. east 13 (to wall) -> Route 201 (63, 3) + 8. south 2 (open) -> Route 201 (63, 5) + totals: 8 legs, 7 turns, 4 open, 0 localization == 00.04 onto_the_path (costs: town) from: SandgemTown (26, 11) (27, 11) (28, 11) (26, 12) (27, 12) (28, 12) facing north (set) @@ -116,9 +116,8 @@ anchor); 0 from one start tile. from: Route201 (15, 14) facing west (tile) target: TwinleafTown (15, 22) facing south (tile) start candidates: Route 201 (15, 14) - 1. south 37 (to wall) -> Twinleaf Town (15, 26) - 2. north 4 (open) -> Twinleaf Town (15, 22) - totals: 2 legs, 1 turns, 1 open, 0 localization + 1. south 33 (open) -> Twinleaf Town (15, 22) + totals: 1 legs, 0 turns, 1 open, 0 localization == 00.04 to_moms_doorstep (costs: line) from: TwinleafTown (15, 22) facing south (tile) @@ -151,14 +150,16 @@ anchor); 0 from one start tile. 2. east 8 (open) -> Twinleaf Town (14, 4) 3. north 16 (to wall) -> Route 201 (14, 13) 4. east 43 (to wall) -> Route 201 (57, 13) - 5. west 7 (open) -> Route 201 (50, 13) - 6. north 7 (open) -> Route 201 (50, 6) - 7. east 43 (to wall) -> Sandgem Town (29, 13) - 8. west 5 (open) -> Sandgem Town (24, 13) - 9. north 21 (to wall) -> Route 202 (25, 24) - 10. west 3 (to wall) -> Route 202 (22, 24) - 11. south 3 (open) -> Route 202 (22, 27) - totals: 11 legs, 10 turns, 5 open, 1 localization + 5. south 1 (open) -> Route 201 (57, 14) + 6. west 7 (open) -> Route 201 (50, 14) + 7. north 8 (open) -> Route 201 (50, 6) + 8. east 43 (to wall) -> Sandgem Town (29, 13) + 9. north 2 (to wall) -> Sandgem Town (29, 11) + 10. west 5 (open) -> Sandgem Town (24, 11) + 11. north 19 (to wall) -> Route 202 (25, 24) + 12. west 3 (to wall) -> Route 202 (22, 24) + 13. south 3 (open) -> Route 202 (22, 27) + totals: 13 legs, 12 turns, 6 open, 1 localization == 00.04b to_catch_grass (costs: route) 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) (set) @@ -189,12 +190,13 @@ anchor); 0 from one start tile. 5. south 8 (to wall) -> Route 202 (17, 22) 6. east 13 (to wall) -> Route 202 (30, 22) 7. north 18 (to wall) -> Route 202 (30, 4) - 8. south 1 (open) -> Route 202 (30, 5) - 9. west 5 (open) -> Route 202 (25, 5) - 10. north 1 (to wall) -> Route 202 (25, 4) - 11. west 7 (to wall) -> Route 202 (18, 4) - 12. north 1 (open) -> Route 202 (18, 3) - totals: 12 legs, 11 turns, 4 open, 0 localization + 8. west 1 (open) -> Route 202 (29, 4) + 9. south 1 (open) -> Route 202 (29, 5) + 10. west 4 (open) -> Route 202 (25, 5) + 11. north 1 (to wall) -> Route 202 (25, 4) + 12. west 7 (to wall) -> Route 202 (18, 4) + 13. north 1 (open) -> Route 202 (18, 3) + totals: 13 legs, 12 turns, 5 open, 0 localization == 00.05 to_the_school (costs: town) from: unknown @@ -228,10 +230,9 @@ anchor); 0 from one start tile. target: JubilifeCity (36, 17) facing north (tile) start candidates: Jubilife City (56, 31) 1. west 8 (open) -> Jubilife City (48, 31) - 2. north 22 (to wall) -> Jubilife City (48, 9) - 3. south 8 (open) -> Jubilife City (48, 17) - 4. west 12 (open) -> Jubilife City (36, 17) - totals: 4 legs, 3 turns, 3 open, 0 localization + 2. north 14 (open) -> Jubilife City (48, 17) + 3. west 12 (open) -> Jubilife City (36, 17) + totals: 3 legs, 2 turns, 3 open, 0 localization == 00.05b below_the_company_clown (costs: town) from: JubilifeCity (36, 17) facing north (tile) @@ -252,21 +253,20 @@ anchor); 0 from one start tile. from: JubilifeCity (14, 19) facing west (tile) target: JubilifeCity (45, 35) facing east (tile) start candidates: Jubilife City (14, 19) - 1. south 2 (open) -> Jubilife City (14, 21) - 2. east 19 (open) -> Jubilife City (33, 21) - 3. south 15 (to wall) -> Jubilife City (33, 36) - 4. north 1 (open) -> Jubilife City (33, 35) - 5. east 12 (open) -> Jubilife City (45, 35) - totals: 5 legs, 4 turns, 4 open, 0 localization + 1. south 4 (open) -> Jubilife City (14, 23) + 2. east 19 (open) -> Jubilife City (33, 23) + 3. south 12 (open) -> Jubilife City (33, 35) + 4. east 12 (open) -> Jubilife City (45, 35) + totals: 4 legs, 3 turns, 4 open, 0 localization == 00.05c below_the_east_exit_sign (costs: line) from: JubilifeCity (45, 35) facing east (tile) target: JubilifeCity (59, 21) facing north (tile) start candidates: Jubilife City (45, 35) 1. north 9 (open) -> Jubilife City (45, 26) - 2. east 14 (open) -> Jubilife City (59, 26) + 2. east 14 (to wall) -> Jubilife City (59, 26) 3. north 5 (to wall) -> Jubilife City (59, 21) - totals: 3 legs, 2 turns, 2 open, 0 localization + totals: 3 legs, 2 turns, 1 open, 0 localization == 01.01 west_of_barrys_trigger (costs: town) from: JubilifeCity (59, 21) facing north (tile) @@ -289,9 +289,8 @@ anchor); 0 from one start tile. start candidates: Route 203 (5, 20) 1. north 2 (open) -> Route 203 (5, 18) 2. east 50 (to wall) -> Route 203 (55, 18) - 3. north 12 (to wall) -> Route 203 (55, 6) - 4. south 3 (open) -> Route 203 (55, 9) - totals: 4 legs, 3 turns, 2 open, 0 localization + 3. north 9 (open) -> Route 203 (55, 9) + totals: 3 legs, 2 turns, 2 open, 0 localization == 01.02 west_of_the_hikers_trigger (costs: route) from: OreburghGate (4, 22) (5, 22) facing east (set) @@ -411,10 +410,9 @@ anchor); 0 from one start tile. from: RavagedPath (19, 50) facing north (tile) target: RavagedPath (21, 43) facing east (tile) start candidates: RavagedPath (19, 50) - 1. north 10 (to wall) -> RavagedPath (19, 40) - 2. south 3 (open) -> RavagedPath (19, 43) - 3. east 2 (open) -> RavagedPath (21, 43) - totals: 3 legs, 2 turns, 2 open, 0 localization + 1. north 7 (open) -> RavagedPath (19, 43) + 2. east 2 (open) -> RavagedPath (21, 43) + totals: 2 legs, 1 turns, 2 open, 0 localization == 01.09 above_the_way_out (costs: route) from: RavagedPath (21, 43) facing east (tile) @@ -436,9 +434,8 @@ anchor); 0 from one start tile. from: Route204North (20, 27) (tile) target: Route204North (11, 27) (tile) start candidates: Route 204 (20, 27) - 1. west 10 (to wall) -> Route 204 (10, 27) - 2. east 1 (open) -> Route 204 (11, 27) - totals: 2 legs, 1 turns, 1 open, 0 localization + 1. west 9 (open) -> Route 204 (11, 27) + totals: 1 legs, 0 turns, 1 open, 0 localization == 01.10 line_3 (costs: line) from: Route204North (11, 27) (tile) @@ -451,22 +448,19 @@ anchor); 0 from one start tile. from: Route204North (11, 22) (tile) target: Route204North (19, 22) (tile) start candidates: Route 204 (11, 22) - 1. east 10 (to wall) -> Route 204 (21, 22) - 2. west 2 (open) -> Route 204 (19, 22) - totals: 2 legs, 1 turns, 1 open, 0 localization + 1. east 8 (open) -> Route 204 (19, 22) + totals: 1 legs, 0 turns, 1 open, 0 localization == 01.10 line_5 (costs: line) from: Route204North (19, 22) (tile) target: Route204North (19, 12) (tile) start candidates: Route 204 (19, 22) - 1. north 15 (to wall) -> Route 204 (19, 7) - 2. south 5 (open) -> Route 204 (19, 12) - totals: 2 legs, 1 turns, 1 open, 0 localization + 1. north 10 (open) -> Route 204 (19, 12) + totals: 1 legs, 0 turns, 1 open, 0 localization == 01.10 line_6 (costs: line) from: Route204North (19, 12) (tile) target: Route204North (11, 12) (tile) start candidates: Route 204 (19, 12) - 1. west 9 (to wall) -> Route 204 (10, 12) - 2. east 1 (open) -> Route 204 (11, 12) - totals: 2 legs, 1 turns, 1 open, 0 localization + 1. west 8 (open) -> Route 204 (11, 12) + totals: 1 legs, 0 turns, 1 open, 0 localization diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp index 995f476ce9..3c02c2ea4f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp @@ -128,8 +128,9 @@ UnitTestResult test_plan_robust_route(Logger&){ const std::vector cases{ {.name = "two starts meet at the wall", .from = {{1, 1}, {2, 1}}, .goal = {4, 1}, .legs = "east 3 (to wall) to (4, 1)"}, {.name = "an open stop is never sure", .from = {{1, 1}}, .goal = {3, 1}, .legs = ""}, + // Known exactly, the player is not run to the wall and walked back: two exact steps. {.name = "unless a one-tile step is exact", .from = {{1, 1}}, .goal = {3, 1}, .costs = exact_step, - .legs = "east 3 (to wall) to (4, 1); west 1 (open) to (3, 1)"}, + .legs = "east 2 (open) to (3, 1)"}, }; for (const RobustCase& item : cases){ const auto legs = plan_robust_route(world, item.from, [&](const TilePos& pos){ return pos == item.goal; }, item.costs); 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 2fe3327dda..7cf429c6a3 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -559,6 +559,56 @@ UnitTestResult test_main_road_ends_below_the_east_exit_sign(Logger& logger){ return "00.05c below_the_east_exit_sign is not a ROUTE step from a known place."; } +// A leg whose end has a wall (or the maps' edge) right after it in the +// leg's direction is a leg to the wall: held until the wall stops the +// player, which localizes, not tapped to a tile and left open (lab-B, +// 2026-11-12 14:24: 00.05c's "east 14 (open)" to (59, 26) was a run into +// the wall past it). +UnitTestResult test_legs_ending_at_a_wall_are_wall_legs(Logger& logger){ + std::vector found; + for (const PlannedStoryRoute& route : plan_story_routes(logger)){ + for (const PlannedLeg& planned : route.legs ? *route.legs : std::vector{}){ + const bool at_wall_end = !planned.after.empty() && std::all_of(planned.after.begin(), planned.after.end(), [&](const TilePos& pos){ + return at_wall(*route.world, pos, planned.leg.direction); + }); + if (!planned.leg.ends_at_wall && at_wall_end){ + found.push_back(std::format("{}: {}.", route.name, to_string(planned))); + } + } + } + std::string out; + for (const std::string& line : found){ + out += "\n " + line; + } + return found.empty() ? UnitTestResult(true) : UnitTestResult("open legs that end at a wall:" + out); +} + +// A leg to a wall from a place the walk knows exactly localizes nothing: +// it is not followed by a leg straight back (00.05c's "south 15 (to wall)" +// then "north 1"). A walk is held to a wall to bring several possible +// places to one, or after a blocked leg, not from one known tile. +UnitTestResult test_known_place_has_no_wall_and_back(Logger& logger){ + std::vector found; + for (const PlannedStoryRoute& route : plan_story_routes(logger)){ + if (!route.legs){ + continue; + } + const std::vector& legs = *route.legs; + for (size_t i = 1; i < legs.size(); i++){ + const size_t known_before = i == 1 ? route.from.size() : legs[i - 2].after.size(); + const bool back = (int)legs[i].leg.direction == ((int)legs[i - 1].leg.direction + 2) % 4; + if (known_before == 1 && legs[i - 1].leg.ends_at_wall && back){ + found.push_back(std::format("{}: {} then {}.", route.name, to_string(legs[i - 1]), to_string(legs[i]))); + } + } + } + std::string out; + for (const std::string& line : found){ + out += "\n " + line; + } + return found.empty() ? UnitTestResult(true) : UnitTestResult("a wall and back from a known place:" + out); +} + // 01.08's walk below the Ravaged Path keeps off the row Route 204 South's // youngster_3 wanders, (12, 2) to (14, 2): on lab-B (2026-11-08) the plan // "north 35 (to wall) to (13, 2), west 2 (to wall) to (11, 2)" walked along @@ -831,6 +881,14 @@ const AutoStoryStoryTableCase AUTO_STORY_STORY_TABLE_CASES[] = { .input = {"00.05c: the plan to below the east-exit sign is taps and a wall's end, off the guard's column (lab-B, 2026-11-12 13:55)", test_main_road_ends_below_the_east_exit_sign}, .expectation = {}, }, + { + .input = {"a leg that ends at a wall is planned as a leg to the wall (00.05c east 14 to (59, 26), lab-B 2026-11-12 14:24)", test_legs_ending_at_a_wall_are_wall_legs}, + .expectation = {}, + }, + { + .input = {"a known place is not run to a wall and walked back from (00.05c south 15, north 1, lab-B 2026-11-12 14:24)", test_known_place_has_no_wall_and_back}, + .expectation = {}, + }, { .input = {"01.08: the walk below the Ravaged Path keeps off the youngster's row (lab-B, 2026-11-08)", test_ravaged_path_keeps_off_the_youngster}, .expectation = {}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_TableRoutes.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_TableRoutes.cpp index 41760bffbf..126aa0c968 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_TableRoutes.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_TableRoutes.cpp @@ -85,11 +85,12 @@ std::vector world_tiles(const StoryWorld& world, const Pokemon::Pose& p RouteStepPlan plan_table_route(const TableRoute& route){ // As walk_route() plans: the step's avoided tiles off the map, but - // where it starts. + // where it starts, and a wall in a zone stays a wall (a leg that ends + // against it is a leg to the wall). StoryWorld world = *route.world; const std::vector from = world_tiles(world, *route.from); for (const TilePos& pos : story_route_tiles(world, *route.step, "avoid")){ - if (std::find(from.begin(), from.end(), pos) == from.end()){ + if (world.tile(pos) != Pokemon::TileKind::WALL && std::find(from.begin(), from.end(), pos) == from.end()){ world.uncover(pos); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json index 768074a022..55c3fbc532 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json @@ -13,8 +13,7 @@ {"checkpoint":"00.04","chunks":3,"dir":"north","end":[["Route 201",39,11]],"end_kind":"open","event":"along_route_201_road","interrupts":[],"known":"dead_reckoned","leg":2,"moved":3,"ms":2400,"planned_end":[["Route 201",39,11]],"tiles":3}, {"checkpoint":"00.04","chunks":24,"dir":"west","end":[["Route 201",15,11]],"end_kind":"open","event":"along_route_201_road","interrupts":[],"known":"dead_reckoned","leg":3,"moved":24,"ms":19200,"planned_end":[["Route 201",15,11]],"tiles":24}, {"checkpoint":"00.04","chunks":2,"dir":"south","end":[["Route 201",15,14]],"end_kind":"open","event":"along_route_201_road","interrupts":[],"known":"dead_reckoned","leg":4,"moved":2,"ms":1600,"planned_end":[["Route 201",15,14]],"tiles":2}, - {"checkpoint":"00.04","chunks":37,"dir":"south","end":[["Twinleaf Town",15,26]],"end_kind":"wall","event":"into_twinleaf","interrupts":[],"known":"wall","leg":1,"ms":6600,"planned_end":[["Twinleaf Town",15,26]],"tiles":37}, - {"checkpoint":"00.04","chunks":4,"dir":"north","end":[["Twinleaf Town",15,22]],"end_kind":"open","event":"into_twinleaf","interrupts":[],"known":"dead_reckoned","leg":2,"moved":4,"ms":3200,"planned_end":[["Twinleaf Town",15,22]],"tiles":4}, + {"checkpoint":"00.04","chunks":33,"dir":"south","end":[["Twinleaf Town",15,22]],"end_kind":"open","event":"into_twinleaf","interrupts":[],"known":"dead_reckoned","leg":1,"moved":33,"ms":26400,"planned_end":[["Twinleaf Town",15,22]],"tiles":33}, {"checkpoint":"00.04","chunks":5,"dir":"east","end":[["Twinleaf Town",20,22]],"end_kind":"open","event":"to_moms_doorstep","interrupts":[],"known":"dead_reckoned","leg":1,"moved":5,"ms":4000,"planned_end":[["Twinleaf Town",20,22]],"tiles":5}, {"checkpoint":"00.04","chunks":1,"dir":"north","end":[["PlayerHouse1F",6,8]],"end_kind":"open","event":"beside_mom","interrupts":[],"known":"dead_reckoned","leg":1,"moved":1,"ms":800,"planned_end":[["PlayerHouse1F",6,8]],"tiles":1}, {"checkpoint":"00.04","chunks":0,"dir":"north","end":[],"end_kind":"wall","event":"into_the_east_corner","interrupts":[],"known":"wall","leg":1,"ms":0,"planned_end":[],"tiles":4}, @@ -28,12 +27,14 @@ {"checkpoint":"00.04","chunks":8,"dir":"east","end":[["Twinleaf Town",14,4]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":2,"moved":8,"ms":6400,"planned_end":[["Twinleaf Town",14,4]],"tiles":8}, {"checkpoint":"00.04","chunks":16,"dir":"north","end":[["Route 201",14,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":3,"ms":3450,"planned_end":[["Route 201",14,13]],"tiles":16}, {"checkpoint":"00.04","chunks":43,"dir":"east","end":[["Route 201",57,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":4,"ms":5350,"planned_end":[["Route 201",57,13]],"tiles":43}, - {"checkpoint":"00.04","chunks":7,"dir":"west","end":[["Route 201",50,13]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":5,"moved":7,"ms":5600,"planned_end":[["Route 201",50,13]],"tiles":7}, - {"checkpoint":"00.04","chunks":7,"dir":"north","end":[["Route 201",50,6]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":6,"moved":7,"ms":5600,"planned_end":[["Route 201",50,6]],"tiles":7}, - {"checkpoint":"00.04","chunks":43,"dir":"east","end":[["Sandgem Town",29,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":7,"ms":5350,"planned_end":[["Sandgem Town",29,13]],"tiles":43}, - {"checkpoint":"00.04","chunks":5,"dir":"west","end":[["Sandgem Town",24,13]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":8,"moved":5,"ms":4000,"planned_end":[["Sandgem Town",24,13]],"tiles":5}, - {"checkpoint":"00.04","chunks":21,"dir":"north","end":[["Route 202",25,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":9,"ms":4200,"planned_end":[["Route 202",25,24]],"tiles":21}, - {"checkpoint":"00.04","chunks":3,"dir":"west","end":[["Route 202",22,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":10,"ms":1350,"planned_end":[["Route 202",22,24]],"tiles":3}, - {"checkpoint":"00.04","chunks":3,"dir":"south","end":[["Route 202",22,27]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":11,"moved":3,"ms":2400,"planned_end":[["Route 202",22,27]],"tiles":3} + {"checkpoint":"00.04","chunks":1,"dir":"south","end":[["Route 201",57,14]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":5,"moved":1,"ms":800,"planned_end":[["Route 201",57,14]],"tiles":1}, + {"checkpoint":"00.04","chunks":7,"dir":"west","end":[["Route 201",50,14]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":6,"moved":7,"ms":5600,"planned_end":[["Route 201",50,14]],"tiles":7}, + {"checkpoint":"00.04","chunks":8,"dir":"north","end":[["Route 201",50,6]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":7,"moved":8,"ms":6400,"planned_end":[["Route 201",50,6]],"tiles":8}, + {"checkpoint":"00.04","chunks":43,"dir":"east","end":[["Sandgem Town",29,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":8,"ms":5350,"planned_end":[["Sandgem Town",29,13]],"tiles":43}, + {"checkpoint":"00.04","chunks":2,"dir":"north","end":[["Sandgem Town",29,11]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":9,"ms":1350,"planned_end":[["Sandgem Town",29,11]],"tiles":2}, + {"checkpoint":"00.04","chunks":5,"dir":"west","end":[["Sandgem Town",24,11]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":10,"moved":5,"ms":4000,"planned_end":[["Sandgem Town",24,11]],"tiles":5}, + {"checkpoint":"00.04","chunks":19,"dir":"north","end":[["Route 202",25,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":11,"ms":3900,"planned_end":[["Route 202",25,24]],"tiles":19}, + {"checkpoint":"00.04","chunks":3,"dir":"west","end":[["Route 202",22,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":12,"ms":1350,"planned_end":[["Route 202",22,24]],"tiles":3}, + {"checkpoint":"00.04","chunks":3,"dir":"south","end":[["Route 202",22,27]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":13,"moved":3,"ms":2400,"planned_end":[["Route 202",22,27]],"tiles":3} ] } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index 0eeca444cf..b73ff4ef8b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -332,9 +332,9 @@ class RouteWalker{ RouteEnd RouteWalker::run(std::vector from){ // Tiles to avoid are ground the game lets us walk on (a trainer's line // of sight), so they are off the map, not walls: a leg must not end - // "at" one, or the walk would run on through it. + // "at" one, or the walk would run on through it. Walls stay walls. for (const TilePos& pos : m_plan.avoid){ - if (std::find(from.begin(), from.end(), pos) == from.end()){ + if (m_grid.tile(pos) != Pokemon::TileKind::WALL && std::find(from.begin(), from.end(), pos) == from.end()){ m_grid.uncover(pos); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp index b5f91a50d4..eb7d46a0a1 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp @@ -49,11 +49,6 @@ constexpr long long REPLAN_MS = 2000; constexpr int REPLAN_OPEN_GRASS_COST = 60; // Longest run into a trigger tried (trigger_runs()). constexpr size_t TRIGGER_RUN_TILES = 32; -// Shortest open leg run_variants() runs on or holds: shorter taps cost -// little, and each variant is a plan to score on every step's first plan -// (the BDSP sims plan thousands). -constexpr size_t RUN_VARIANT_TILES = 6; - // Expected time a plan must save for each tile it walks back beyond the // route's own plan: the user's road route on Route 201 walks back 3 @@ -112,71 +107,6 @@ class CachedReplanner{ std::map, std::optional>, TileLess> m_plans; }; -Direction opposite(Direction direction){ - return Direction(((int)direction + 2) % 4); -} - -// Where every tile of `from` stops walking `direction` to a wall, or -// nothing unless each is held at one (WallHit::anchored). -std::optional wall_leg_from(const StoryWorld& world, const std::vector& from, Direction direction){ - PlannedLeg out{.leg = {.direction = direction, .tiles = 0, .ends_at_wall = true, .held = false}, .after = {}}; - for (const TilePos& pos : from){ - const WallHit hit = slide_to_wall(world, pos, direction); - if (!hit.anchored || hit.tiles == 0){ - return std::nullopt; - } - out.leg.tiles = std::max(out.leg.tiles, hit.tiles); - if (std::find(out.after.begin(), out.after.end(), hit.stop) == out.after.end()){ - out.after.push_back(hit.stop); - } - } - return out; -} - -// `legs` with its open leg `index`, from the one tile `from`, run on to -// the wall past its end and tapped back: 00.04 into_twinleaf, "south 33" -// tapped (26.5 s) or run south 37 to the wall and 4 taps north (10.2 s). -std::optional> overshoot_to_wall( - const StoryWorld& world, const TilePos& from, const std::vector& legs, size_t index -){ - const PlannedLeg& open = legs[index]; - const std::optional wall = wall_leg_from(world, {from}, open.leg.direction); - if (!wall || open.after.size() != 1 || wall->leg.tiles <= open.leg.tiles){ - return std::nullopt; - } - const TilePos end = open.after.front(); - const TilePos stop = wall->after.front(); - const size_t back = (size_t)(std::abs(stop.x - end.x) + std::abs(stop.y - end.y)); - if (stop.x != end.x && stop.y != end.y){ - return std::nullopt; - } - std::vector out(legs.begin(), legs.begin() + index); - out.push_back(*wall); - out.push_back({.leg = {.direction = opposite(open.leg.direction), .tiles = back, .ends_at_wall = false, .held = false}, .after = {end}}); - out.insert(out.end(), legs.begin() + index + 1, legs.end()); - return out; -} - -// Plans made from `legs` the way a player runs: each open leg from a -// known tile run on to a wall and tapped back. An open leg is never held -// for its time: a timed run overshoots by up to a third (lab-B -// 2026-11-11, Jubilife: runs timed for 10 tiles went about 13), so open -// legs are tapped and only legs to a wall are held. -std::vector> run_variants(const ScoredRoute& route, const std::vector& legs){ - std::vector> out; - std::vector at = route.from; - for (size_t i = 0; i < legs.size(); i++){ - const TileLeg& leg = legs[i].leg; - if (!leg.ends_at_wall && !leg.held && leg.tiles >= RUN_VARIANT_TILES && at.size() == 1){ - if (std::optional> legs_out = overshoot_to_wall(route.world, at.front(), legs, i)){ - out.push_back(std::move(*legs_out)); - } - } - at = legs[i].after; - } - return out; -} - // The tiles where someone wanders that `legs` enter, from every tile of // `from`: a run on to a wall or a trigger may enter a zone the route's own // plan keeps off (RobustPlanCosts::per_wander_tile). @@ -268,7 +198,7 @@ Pokemon::RouteScore score_with(const ScoredRoute& route, const std::vector> candidate_plans(const ScoredRoute& route, const std::vector& own){ - std::vector> out = run_variants(route, own); + std::vector> out; for (std::vector& legs : trigger_runs(route, own)){ out.push_back(std::move(legs)); } From 468a5036b37d8f305decb3bbb8fa90f6edec58b5 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 14:51:48 -0800 Subject: [PATCH 21/47] BDSP AutoStory: regenerate the simulation's plan golden (it was stale) "Simulation: plans match the golden" no longer matched the table (rows and steps it stored are gone); regenerated from the test's own log. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_PlanGolden.h | 244 +++++++----------- 1 file changed, 96 insertions(+), 148 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index e63fe2d69b..2aff88aa64 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -25,9 +25,6 @@ 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)", @@ -36,86 +33,74 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 below_the_lake_entrance costs=default from Route201 (14, 16) to VerityLakefront (17, 14)", + "00.01 west 28 (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 into_rowans_scene costs=into_scene from VerityLakefront (17, 14) (17, 15) to VerityLakefront (17, 21)", "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 into_dawns_scene costs=into_scene 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 south 1 (open) -> Route 201 (57, 14)", + "00.03 west 7 (open) -> Route 201 (50, 14)", + "00.03 north 11 (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 to_ledge_column costs=line from Route201 (57, 4) (58, 4) (59, 4) (60, 4) (61, 4) (62, 4) (63, 4) to Route201 (55, 5)", + "00.04 west 7 (to wall) -> Route 201 (56, 4)", + "00.04 south 1 (open) -> Route 201 (56, 5)", + "00.04 west 1 (open) -> Route 201 (55, 5)", + "00.04 along_route_201_road costs=line from Route201 (55, 14) to Route201 (15, 14)", + "00.04 west 16 (open) -> Route 201 (39, 14)", + "00.04 north 3 (open) -> Route 201 (39, 11)", + "00.04 west 24 (open) -> Route 201 (15, 11)", + "00.04 south 2 (open) -> Route 201 (15, 14)", + "00.04 into_twinleaf costs=line from Route201 (15, 14) to TwinleafTown (15, 22)", + "00.04 south 33 (open) -> Twinleaf Town (15, 22)", + "00.04 to_moms_doorstep costs=line from TwinleafTown (15, 22) to TwinleafTown (20, 22)", + "00.04 east 5 (open) -> Twinleaf Town (20, 22)", + "00.04 beside_mom costs=default from PlayerHouse1F (6, 9) to PlayerHouse1F (6, 8)", + "00.04 north 1 (open) -> PlayerHouse1F (6, 8)", + "00.04 into_moms_call costs=trigger from PlayerHouse1F (11, 8) to PlayerHouse1F (6, 9)", + "00.04 west 1 (open) -> PlayerHouse1F (10, 8)", + "00.04 south 1 (open) -> PlayerHouse1F (10, 9)", + "00.04 west 4 (open) -> PlayerHouse1F (6, 9)", + "00.04 short_of_the_catch_tutorial costs=default from TwinleafTown (6, 22) (6, 23) to Route202 (22, 27)", + "00.04 north 19 (to wall) -> Twinleaf Town (6, 4)", + "00.04 east 8 (open) -> Twinleaf Town (14, 4)", + "00.04 north 16 (to wall) -> Route 201 (14, 13)", + "00.04 east 43 (to wall) -> Route 201 (57, 13)", + "00.04 south 1 (open) -> Route 201 (57, 14)", + "00.04 west 7 (open) -> Route 201 (50, 14)", + "00.04 north 8 (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 north 2 (to wall) -> Sandgem Town (29, 11)", + "00.04 west 5 (open) -> Sandgem Town (24, 11)", + "00.04 north 19 (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 north 4 (to wall) -> Route 202 (15, 25) Route 202 (16, 25) Route 202 (17, 25) Route 202 (18, 25) Route 202 (19, 25) Route 202 (20, 25) Route 202 (21, 25)", + "00.04b east 8 (to wall) -> Route 202 (23, 25)", + "00.04b west 3 (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)", @@ -123,43 +108,40 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 21 (open) -> Jubilife City (47, 41)", - "00.05 east 5 (open) -> Jubilife City (52, 41)", + "00.04d north 13 (open) -> Route 202 (30, 9)", + "00.04d west 8 (to wall) -> Route 202 (22, 9)", + "00.04d north 5 (to wall) -> Route 202 (22, 4)", + "00.04d west 4 (to wall) -> Route 202 (18, 4)", + "00.04d north 1 (open) -> Route 202 (18, 3)", "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_mart_clown costs=town from JubilifeCity (48, 40) to JubilifeCity (56, 36)", + "00.05b north 4 (open) -> Jubilife City (48, 36)", + "00.05b east 8 (to wall) -> Jubilife City (56, 36)", + "00.05b below_the_tv_clown costs=town from JubilifeCity (56, 31) to JubilifeCity (36, 17)", + "00.05b west 8 (open) -> Jubilife City (48, 31)", + "00.05b north 14 (open) -> Jubilife City (48, 17)", + "00.05b west 12 (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 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 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 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)", + "00.05b beside_the_company_sign costs=line from JubilifeCity (14, 19) to JubilifeCity (14, 19)", + "00.05c beside_the_president costs=town from JubilifeCity (14, 19) to JubilifeCity (45, 35)", + "00.05c south 4 (open) -> Jubilife City (14, 23)", + "00.05c east 31 (open) -> Jubilife City (45, 23)", + "00.05c south 12 (open) -> Jubilife City (45, 35)", + "00.05c below_the_east_exit_sign costs=line from JubilifeCity (45, 35) to JubilifeCity (59, 21)", + "00.05c north 9 (open) -> Jubilife City (45, 26)", + "00.05c east 14 (to wall) -> Jubilife City (59, 26)", + "00.05c north 5 (to wall) -> Jubilife City (59, 21)", + "01.01 west_of_barrys_trigger costs=town from JubilifeCity (59, 21) to Route203 (4, 18)", + "01.01 south 1 (open) -> Jubilife City (59, 22)", + "01.01 east 8 (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)", @@ -172,80 +154,54 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 by_the_east_mouth costs=default from OreburghGate (20, 22) to OreburghGate (26, 22)", + "01.02 east 6 (open) -> OreburghGate (26, 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.02b below_the_centers_door costs=town from OreburghCity (26, 22) to OreburghCity (47, 21)", + "01.02b east 22 (to wall) -> Oreburgh City (48, 22)", + "01.02b north 1 (to wall) -> Oreburgh City (48, 21)", + "01.02b west 1 (open) -> Oreburgh City (47, 21)", + "01.03 above_the_mine costs=town from OreburghCity (47, 21) (46, 21) to OreburghCity (46, 57)", + "01.03 east 2 (to wall) -> Oreburgh City (48, 21)", + "01.03 west 4 (open) -> Oreburgh City (44, 21)", "01.03 south 20 (to wall) -> Oreburgh City (44, 41)", - "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)", - "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.03 west 1 (open) -> Oreburgh City (43, 41)", + "01.03 south 16 (to wall) -> Oreburgh City (43, 57)", + "01.03 east 3 (open) -> Oreburgh City (46, 57)", "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 south 5 (to wall) -> Oreburgh City (26, 26)", + "01.05 west 2 (to wall) -> Oreburgh City (24, 26)", + "01.05 north 5 (to wall) -> Oreburgh City (24, 21)", + "01.05 west 9 (open) -> Oreburgh City (15, 21)", + "01.05 north 8 (open) -> Oreburgh City (15, 13)", + "01.05 west 8 (open) -> Oreburgh City (7, 13)", + "01.05 through_the_gate costs=default from OreburghGate (27, 22) (26, 22) to OreburghGate (5, 22)", + "01.05 north 2 (to wall) -> OreburghGate (27, 20) OreburghGate (26, 21)", + "01.05 east 1 (to wall) -> OreburghGate (27, 20) OreburghGate (27, 21)", + "01.05 south 3 (to wall) -> 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.05 west 3 (open) -> OreburghGate (5, 22)", + "01.06 up_jubilifes_road costs=town from Route203 (55, 9) to JubilifeCity (41, 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 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.06 west 60 (open) -> Jubilife City (41, 22)", + "01.06 north 14 (to wall) -> Jubilife City (41, 8)", + "01.06 below_rowans_trigger costs=town from JubilifeCity (41, 8) to JubilifeCity (47, 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 below_the_ravaged_path costs=town from JubilifeCity (44, 5) to Route204South (11, 3)", "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.08 west 4 (open) -> Route 204 (10, 18)", + "01.08 north 15 (to wall) -> Route 204 (10, 3)", + "01.08 east 1 (open) -> Route 204 (11, 3)", "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)", @@ -265,14 +221,6 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 From a456c279a6e9a6b39156edc2a41f4c44002f0294 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 15:08:53 -0800 Subject: [PATCH 22/47] BDSP AutoStory: a wall leg held up with a start tile at its wall ends there, not in failure (lab-B 2026-11-12 14:50) The sim case reproduces 01.02 south 3 (to wall) from (5,17..20): the turn after the battle counted as a moved chunk, no tile of the leg fit, and the leg failed. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 39 ++++++++++++++++++- .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 28 ++++++------- 2 files changed, 51 insertions(+), 16 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 256dabe73f..6829efbb43 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -162,7 +162,7 @@ enum class AfterTalk{ NO_BATTLE, }; -ScriptedWalk walk_script(const StoryWorld& maps, const TilePos& from, const TilePos& goal, std::vector sights, Script& script, +ScriptedWalk walk_script_from(const StoryWorld& maps, std::vector from, const TilePos& goal, std::vector sights, Script& script, AfterTalk after_talk = AfterTalk::BATTLE ){ ScriptedWalk out; @@ -172,7 +172,7 @@ ScriptedWalk walk_script(const StoryWorld& maps, const TilePos& from, const Tile }; ScriptedRouteIO io(script); try{ - out.at = walk_route(io, maps, {from}, trainers, { + out.at = walk_route(io, maps, std::move(from), trainers, { .goal = [goal](const TilePos& pos){ return pos == goal; }, .label = "T", .avoid = {}, @@ -185,6 +185,12 @@ ScriptedWalk walk_script(const StoryWorld& maps, const TilePos& from, const Tile return out; } +ScriptedWalk walk_script(const StoryWorld& maps, const TilePos& from, const TilePos& goal, std::vector sights, Script& script, + AfterTalk after_talk = AfterTalk::BATTLE +){ + return walk_script_from(maps, {from}, goal, std::move(sights), script, after_talk); +} + // The script's calls all made, or which are left. std::string script_left(const Script& script){ if (script.next == script.steps.size()){ @@ -669,6 +675,31 @@ UnitTestResult test_wall_leg_held_up_is_not_at_its_wall(Logger&){ return left.empty() ? UnitTestResult(true) : UnitTestResult(left); } +// lab-B 2026-11-12 14:50, 01.02 "south 3 (to wall)" on Route 203, straight +// after a battle: the start is one of four tiles, the player already stands +// at the wall, and the walk's three moved chunks (a turn counted as one) +// and 2000 ms read as held up. No tile of the leg past the wall fits, but +// the tile at the wall does: the leg ends there, it must not fail. +UnitTestResult test_wall_leg_at_its_wall_among_the_start_tiles(Logger&){ + const StoryWorld corridor = make_world({"###", "#.#", "#.#", "#.#", "#.#", "###"}); + Script script{.steps = { + walk_step("wall: T: south 3 (to wall)", WalkStop::BLOCKED, 2000ms, 3), + }}; + ScriptedWalk walk; + try{ + walk = walk_script_from(corridor, {{1, 1}, {1, 2}, {1, 3}, {1, 4}}, {1, 4}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (!walk.failure.empty()){ + return "failed: " + walk.failure; + } + if (walk.at != std::vector{{1, 4}}){ + return "did not end at the wall (1, 4)."; + } + return true; +} + struct PlannedRouteInput{ std::string name; std::function body; @@ -744,6 +775,10 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .input = {"a wall leg held up on the way is not at its wall (lab-B 2026-11-11 21:00)", test_wall_leg_held_up_is_not_at_its_wall}, .expectation = {}, }, + { + .input = {"a wall leg that stood at its wall among the start tiles does not fail (lab-B 2026-11-12 14:50)", test_wall_leg_at_its_wall_among_the_start_tiles}, + .expectation = {}, + }, }; void add_tests_AutoStory_PlannedRoute(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index b73ff4ef8b..60efe9a3d5 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -165,12 +165,9 @@ size_t moved_on(const WalkResult& walk, Milliseconds per_tile){ // Whether a walk to the wall never moved: no chunk changed and its time // counts no tile. It stopped where it began, so whoever stopped it stands // on the next tile, however short the leg. On lab-B (2026-11-08 16:50, -// 01.08) Route 204's youngster, who wanders (12, 2) to (14, 2), stood a -// tile ahead of the leg "west 2 (to wall)" from (13, 2). The wait for the -// way needed a stop three tiles short of the wall, so he was talked to at -// once, and the replan from both (12, 2) and (13, 2) found no plan: an -// uncertain start needs a wall both tiles reach, and no wall is anchored -// from a tile someone wanders on. +// 01.08) Route 204's wandering youngster stood a tile ahead of "west 2 (to +// wall)" from (13, 2), and a replan from (12, 2) and (13, 2) found no plan: +// no wall is anchored from a tile someone wanders on. bool never_moved(const WalkResult& walk, size_t walked_tiles){ return walk.stop == WalkStop::BLOCKED && walk.moved_chunks == 0 && walked_tiles == 0; } @@ -178,11 +175,8 @@ bool never_moved(const WalkResult& walk, size_t walked_tiles){ // Whether a walk to the wall that stopped took far longer than the tiles // to its nearest wall `nearest` allow, past the walker's slack: two of its // 400 ms chunks, or 30% of the tiles' time on a long leg. Something held -// it up on the way, and its time no longer counts tiles. On lab-B -// (2026-11-11 21:00, 00.05b) "east 8 (to wall)" stopped after 2800 ms -// against a boy below the Mart, about 5 tiles in, with 5 moved chunks -// where an 8-tile run moves about 3; the time counted 17 tiles, and the -// route went on from (56, 34) as if at the wall. +// it up on the way, and its time no longer counts tiles. On lab-B (2026-11-11 21:00, 00.05b) "east 8 (to wall)" stopped after 2800 ms +// against a boy below the Mart, about 5 tiles in, but the time counted 17. bool held_up(const WalkResult& walk, size_t nearest, Milliseconds per_tile){ if (walk.stop != WalkStop::BLOCKED || walk.wild_battles > 0){ return false; @@ -1177,14 +1171,20 @@ void RouteWalker::mark_tiles_past(const LegWalk& walk, const std::vector stopped; for (const TilePos& pos : m_from){ - if (walk.result.moved_chunks == 0){ + // At its wall, a start tile stands there whatever moved (lab-B 2026-11-12 14:50). + const bool at_wall = slide_to_wall(m_grid, pos, walk.planned.leg.direction).tiles == 0; + if (walk.result.moved_chunks == 0 || at_wall){ stopped.push_back(pos); } + if (at_wall && walk.result.moved_chunks > 0){ + m_io.note(std::format("[Route] {}: {} is at its wall; {} moved chunks include a turn.", walk.label, + describe(m_maps, pos), walk.result.moved_chunks), RouteNote::WARNING); + } const std::vector path = leg_path(m_grid, pos, walk.planned.leg.direction, nearest); stopped.insert(stopped.end(), path.begin(), path.end()); } From 43cc360eeeff81edcb0ce614d8cc3e7555a1bc89 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 15:29:41 -0800 Subject: [PATCH 23/47] BDSP AutoStory: run to the wall and tap back again, except after a tapped leg A held run on to a wall and tapped back is fast and exact (00.04 into_twinleaf: south 37 to the wall, north 4: 10.2 s, not 26.5 s tapped), so plan_fastest_route()'s run_variants() and the robust planner's wall-and-back are back. Not after a tapped leg: the player is exactly where the taps left them, and a run past that tile and back only adds a turn (00.05c, lab-B 2026-11-12 14:24). The leg that ends where its wall does stays a wall leg. Route plan, bench, leg-trace and simulation plan goldens regenerated; the sidestep plans in 00.03/00.04/00.04d are gone. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Navigation/Pokemon_RobustLegPlanner.h | 13 +-- .../AutoStory/Data/route_bench.golden.txt | 26 +++--- .../AutoStory/Data/route_plans.golden.txt | 87 ++++++++++--------- .../PokemonBDSP_AutoStory_PlanGolden.h | 19 ++-- ...kemonBDSP_AutoStory_RoutePlanner_Tests.cpp | 37 +++++++- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 22 ++--- .../Simulation/leg_trace_00.04.golden.json | 20 ++--- .../PokemonBDSP_AutoStory_RouteChoice.cpp | 75 +++++++++++++++- 8 files changed, 205 insertions(+), 94 deletions(-) diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h index 350ff1a243..0f36ff63fe 100644 --- a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_RobustLegPlanner.h @@ -476,11 +476,14 @@ class Search{ if (spread != m_start){ const Node& arrived = m_nodes.at(spread); const RobustLeg& prev = arrived.leg; - // A leg to a wall from one place the player is known to be on - // localizes nothing: walking straight back from it is a longer - // way to the tiles a leg open on the first would reach. - if (prev.to_wall && arrived.parent.size() == 1 && expansion.leg.direction == opposite(prev.direction)){ - return; + // A run to a wall and back after a tapped leg: the taps left the + // player on a known tile, so the run past it and back adds a + // turn for nothing. From the start or after a leg to a wall it + // is how a long leg is made fast and exact. + if (prev.to_wall && arrived.parent != m_start && expansion.leg.direction == opposite(prev.direction)){ + if (!m_nodes.at(arrived.parent).leg.to_wall){ + return; + } } if (joins(prev, expansion.leg)){ expansion.cost -= m_costs.per_leg; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index 6cbcc6d0b0..f4b9f6dcb6 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -18,21 +18,21 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.01 below_the_flute | 4090 | 4090 | 4090 | 1 | 0 | 0 | 5.84! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 00.01 above_the_door | 7230 | 7230 | 7230 | 1 | 0 | 0 | 4.66! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS 00.01 short_of_barrys_door | 11950 | 11950 | 11950 | 1 | 0 | 0 | 4.35! | 1.00 | 1.00 | 2750 ms (stand-in) | PASS -00.01 above_barrys_door | 8200 | 8200 | 8200 | 0 | 0 | 0 | 5.29! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS +00.01 above_barrys_door | 7230 | 7230 | 7230 | 1 | 0 | 0 | 4.66! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS 00.02 to_the_lake_entrance | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS 00.03 into_rowans_scene | 3030 | 3030 | 3030 | 1 | 0 | 0 | 2.33! | 1.00 | 1.00 | 1300 ms (stand-in) | PASS -00.03 into_dawns_scene | 62650 | 47830 | 35480 | 4 | 22 | 0 | 5.47! | 1.15 | 75.00! | 11450 ms (stand-in) | PASS +00.03 into_dawns_scene | 61510 | 46690 | 34340 | 4 | 22 | 0 | 5.37! | 1.15 | 56.00! | 11450 ms (stand-in) | PASS 00.04 onto_the_path | 4050 | 4050 | 4050 | 2 | 0 | 0 | 5.79! | 1.00 | 1.00 | 700 ms (stand-in) | PASS 00.04 to_ledge_column | 3850 | 3850 | 3850 | 1 | 0 | 0 | 3.21! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 00.04 along_route_201_road | 36400 | 36400 | 36400 | 0 | 0 | 0 | 2.98! | 1.00 | 0.60 | 12200 ms (user's route) | PASS -00.04 into_twinleaf | 26500 | 26500 | 26500 | 0 | 0 | 0 | 2.60! | 1.00 | 1.00 | 10200 ms (user's route) | PASS +00.04 into_twinleaf | 10200 | 10200 | 10200 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 10200 ms (user's route) | PASS 00.04 to_moms_doorstep | 4100 | 4100 | 4100 | 0 | 0 | 0 | 5.47! | 1.00 | 1.00 | 750 ms (stand-in) | PASS 00.04 beside_mom | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS 00.04 into_moms_call | 2550 | 2550 | 2550 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 2550 ms (user's route) | PASS -00.04 short_of_the_catch_tutorial | 87051 | 85000 | 52950 | 7 | 19 | 7 | 4.90! | 1.00 | 99.00! | 17750 ms (stand-in) | PASS +00.04 short_of_the_catch_tutorial | 84406 | 81950 | 51250 | 7 | 19 | 7 | 4.76! | 1.00 | 62.00! | 17750 ms (stand-in) | PASS 00.04b to_catch_grass | 11689 | 38550 | 6300 | 2 | 34 | 1 | 17.98! | 17.50! | 2.00! | 650 ms (stand-in) | PASS 00.04b into_sandgem | 9520 | 19400 | 7050 | 3 | 12 | 0 | 2.93! | 4.33! | 1.00 | 3250 ms (stand-in) | PASS -00.04d north_to_jubilife | 73675 | 42800 | 30450 | 8 | 35 | 0 | 7.22! | 1.24 | 81.00! | 10200 ms (stand-in) | PASS +00.04d north_to_jubilife | 73575 | 42700 | 30350 | 8 | 35 | 0 | 7.21! | 1.24 | 80.00! | 10200 ms (stand-in) | PASS 00.05b below_the_presidents_trigger | 4900 | 4900 | 4900 | 0 | 0 | 0 | 5.76! | 1.00 | 1.00 | 850 ms (stand-in) | PASS 00.05b past_the_president | 1700 | 1700 | 1700 | 0 | 0 | 0 | 3.78! | 1.00 | 1.00 | 450 ms (stand-in) | PASS 00.05b below_the_mart_clown | 5450 | 5450 | 5450 | 1 | 0 | 0 | 3.30! | 1.00 | 1.00 | 1650 ms (stand-in) | PASS @@ -43,7 +43,7 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05c below_the_east_exit_sign | 12150 | 12150 | 12150 | 2 | 0 | 0 | 3.24! | 1.00 | 1.00 | 3750 ms (stand-in) | PASS 01.01 west_of_barrys_trigger | 7400 | 7400 | 7400 | 0 | 0 | 0 | 6.17! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS -01.02 by_the_gate | 26465 | 27700 | 15350 | 1 | 9 | 0 | 3.84! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS +01.02 by_the_gate | 24815 | 26050 | 13700 | 2 | 9 | 0 | 3.60! | 1.00 | 1.00 | 6900 ms (stand-in) | PASS 01.02 west_of_the_hikers_trigger | 3950 | 3950 | 3950 | 2 | 0 | 0 | 8.78! | 1.00 | 2.00! | 450 ms (stand-in) | PASS 01.02 past_curtis | 10500 | 10500 | 10500 | 0 | 0 | 0 | 6.77! | 1.00 | 1.00 | 1550 ms (stand-in) | PASS 01.02 by_the_east_mouth | 4900 | 4900 | 4900 | 0 | 0 | 0 | 5.76! | 1.00 | 1.00 | 850 ms (stand-in) | PASS @@ -56,17 +56,17 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 01.06 below_rowans_trigger | 1950 | 1950 | 1950 | 1 | 0 | 0 | 2.29! | 1.00 | 1.00 | 850 ms (stand-in) | PASS 01.08 west_to_the_wall | 1650 | 1650 | 1650 | 1 | 0 | 0 | 3.00! | 1.00 | 1.00 | 550 ms (stand-in) | PASS 01.08 below_the_ravaged_path | 24815 | 26050 | 13700 | 2 | 9 | 0 | 4.24! | 1.00 | 6.00! | 5850 ms (stand-in) | PASS -01.09 west_of_the_rock | 7400 | 7400 | 7400 | 0 | 0 | 0 | 4.93! | 1.00 | 1.00 | 1500 ms (stand-in) | PASS +01.09 west_of_the_rock | 7050 | 7050 | 7050 | 1 | 0 | 0 | 4.70! | 1.00 | 1.00 | 1500 ms (stand-in) | PASS 01.09 above_the_way_out | 4550 | 4550 | 4550 | 2 | 0 | 0 | 4.14! | 1.00 | 2.00! | 1100 ms (stand-in) | PASS 01.10 line_1 | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS -01.10 line_2 | 7300 | 7300 | 7300 | 0 | 0 | 0 | 6.35! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS +01.10 line_2 | 3250 | 3250 | 3250 | 1 | 0 | 0 | 2.83! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS 01.10 line_3 | 4100 | 4100 | 4100 | 0 | 0 | 0 | 4.10! | 1.00 | 1.00 | 1000 ms (stand-in) | PASS -01.10 line_4 | 6500 | 6500 | 6500 | 0 | 0 | 0 | 6.19! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS -01.10 line_5 | 20388 | 39400 | 8100 | 0 | 6 | 6 | 10.46! | 1.17 | 7.00! | 1950 ms (stand-in) | PASS -01.10 line_6 | 6500 | 6500 | 6500 | 0 | 0 | 0 | 6.19! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS +01.10 line_4 | 4050 | 4050 | 4050 | 1 | 0 | 0 | 3.86! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS +01.10 line_5 | 15110 | 20050 | 7700 | 1 | 6 | 0 | 7.75! | 1.17 | 1.00 | 1950 ms (stand-in) | PASS +01.10 line_6 | 3150 | 3150 | 3150 | 1 | 0 | 0 | 3.00! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS TARGET 00.04 along_route_201_road | 12200 | 12200 | 12200 | 2 | 0 | 0 | 1.00 | 1.00 | 1.00 | 12200 ms (user's route) | PASS TARGET 00.04 into_twinleaf | 10200 | 10200 | 10200 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 10200 ms (user's route) | PASS TARGET 00.04 into_moms_call | 2550 | 2550 | 2550 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 2550 ms (user's route) | PASS 00.04 into_twinleaf after run 4's block, planned from the counted tile | 11250 | 11250 | 11250 | 1 | 0 | 0 | 5.00! | 1.00 | 2.00! | 2250 ms (stand-in) | FAIL (may end on (47, 85), off the goal) -00.04 into_twinleaf after run 4's block | 12750 | 12750 | 12750 | 2 | 0 | 0 | 5.67! | 1.00 | 2.00! | 2250 ms (stand-in) | PASS -00.04d north_to_jubilife, planned with the route's own costs (taps in the grass) | 95551 | 64000 | 34250 | 8 | 37 | 11 | 9.37! | 1.31 | 90.00! | 10200 ms (stand-in) | PASS +00.04 into_twinleaf after run 4's block | 10750 | 10750 | 10750 | 3 | 0 | 0 | 4.78! | 1.00 | 2.00! | 2250 ms (stand-in) | PASS +00.04d north_to_jubilife, planned with the route's own costs (taps in the grass) | 84645 | 66250 | 33200 | 6 | 35 | 5 | 8.30! | 1.24 | 85.00! | 10200 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index c3a79c3399..431271a183 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -47,9 +47,10 @@ anchor); 0 from one start tile. from: RivalHouse1F (2, 3) (tile) target: RivalHouse1F (6, 9) facing south (tile) start candidates: RivalHouse1F (2, 3) - 1. south 6 (open) -> RivalHouse1F (2, 9) - 2. east 4 (open) -> RivalHouse1F (6, 9) - totals: 2 legs, 1 turns, 2 open, 0 localization + 1. south 7 (to wall) -> RivalHouse1F (2, 10) + 2. north 1 (open) -> RivalHouse1F (2, 9) + 3. east 4 (open) -> RivalHouse1F (6, 9) + totals: 3 legs, 2 turns, 2 open, 0 localization == 00.01 below_the_lake_entrance (costs: route) from: unknown @@ -77,12 +78,11 @@ anchor); 0 from one start tile. 1. west 3 (open) -> Twinleaf Town (17, 22) 2. north 34 (to wall) -> Route 201 (17, 13) 3. east 40 (to wall) -> Route 201 (57, 13) - 4. south 1 (open) -> Route 201 (57, 14) - 5. west 7 (open) -> Route 201 (50, 14) - 6. north 11 (to wall) -> Route 201 (50, 3) - 7. east 13 (to wall) -> Route 201 (63, 3) - 8. south 2 (open) -> Route 201 (63, 5) - totals: 8 legs, 7 turns, 4 open, 0 localization + 4. west 7 (open) -> Route 201 (50, 13) + 5. north 10 (to wall) -> Route 201 (50, 3) + 6. east 13 (to wall) -> Route 201 (63, 3) + 7. south 2 (open) -> Route 201 (63, 5) + totals: 7 legs, 6 turns, 3 open, 0 localization == 00.04 onto_the_path (costs: town) from: SandgemTown (26, 11) (27, 11) (28, 11) (26, 12) (27, 12) (28, 12) facing north (set) @@ -116,8 +116,9 @@ anchor); 0 from one start tile. from: Route201 (15, 14) facing west (tile) target: TwinleafTown (15, 22) facing south (tile) start candidates: Route 201 (15, 14) - 1. south 33 (open) -> Twinleaf Town (15, 22) - totals: 1 legs, 0 turns, 1 open, 0 localization + 1. south 37 (to wall) -> Twinleaf Town (15, 26) + 2. north 4 (open) -> Twinleaf Town (15, 22) + totals: 2 legs, 1 turns, 1 open, 0 localization == 00.04 to_moms_doorstep (costs: line) from: TwinleafTown (15, 22) facing south (tile) @@ -150,16 +151,15 @@ anchor); 0 from one start tile. 2. east 8 (open) -> Twinleaf Town (14, 4) 3. north 16 (to wall) -> Route 201 (14, 13) 4. east 43 (to wall) -> Route 201 (57, 13) - 5. south 1 (open) -> Route 201 (57, 14) - 6. west 7 (open) -> Route 201 (50, 14) - 7. north 8 (open) -> Route 201 (50, 6) - 8. east 43 (to wall) -> Sandgem Town (29, 13) - 9. north 2 (to wall) -> Sandgem Town (29, 11) - 10. west 5 (open) -> Sandgem Town (24, 11) - 11. north 19 (to wall) -> Route 202 (25, 24) - 12. west 3 (to wall) -> Route 202 (22, 24) - 13. south 3 (open) -> Route 202 (22, 27) - totals: 13 legs, 12 turns, 6 open, 1 localization + 5. west 7 (open) -> Route 201 (50, 13) + 6. north 7 (open) -> Route 201 (50, 6) + 7. east 43 (to wall) -> Sandgem Town (29, 13) + 8. north 2 (to wall) -> Sandgem Town (29, 11) + 9. west 5 (open) -> Sandgem Town (24, 11) + 10. north 19 (to wall) -> Route 202 (25, 24) + 11. west 3 (to wall) -> Route 202 (22, 24) + 12. south 3 (open) -> Route 202 (22, 27) + totals: 12 legs, 11 turns, 5 open, 1 localization == 00.04b to_catch_grass (costs: route) 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) (set) @@ -190,13 +190,12 @@ anchor); 0 from one start tile. 5. south 8 (to wall) -> Route 202 (17, 22) 6. east 13 (to wall) -> Route 202 (30, 22) 7. north 18 (to wall) -> Route 202 (30, 4) - 8. west 1 (open) -> Route 202 (29, 4) - 9. south 1 (open) -> Route 202 (29, 5) - 10. west 4 (open) -> Route 202 (25, 5) - 11. north 1 (to wall) -> Route 202 (25, 4) - 12. west 7 (to wall) -> Route 202 (18, 4) - 13. north 1 (open) -> Route 202 (18, 3) - totals: 13 legs, 12 turns, 5 open, 0 localization + 8. south 1 (open) -> Route 202 (30, 5) + 9. west 5 (open) -> Route 202 (25, 5) + 10. north 1 (to wall) -> Route 202 (25, 4) + 11. west 7 (to wall) -> Route 202 (18, 4) + 12. north 1 (open) -> Route 202 (18, 3) + totals: 12 legs, 11 turns, 4 open, 0 localization == 00.05 to_the_school (costs: town) from: unknown @@ -289,8 +288,9 @@ anchor); 0 from one start tile. start candidates: Route 203 (5, 20) 1. north 2 (open) -> Route 203 (5, 18) 2. east 50 (to wall) -> Route 203 (55, 18) - 3. north 9 (open) -> Route 203 (55, 9) - totals: 3 legs, 2 turns, 2 open, 0 localization + 3. north 12 (to wall) -> Route 203 (55, 6) + 4. south 3 (open) -> Route 203 (55, 9) + totals: 4 legs, 3 turns, 2 open, 0 localization == 01.02 west_of_the_hikers_trigger (costs: route) from: OreburghGate (4, 22) (5, 22) facing east (set) @@ -410,9 +410,10 @@ anchor); 0 from one start tile. from: RavagedPath (19, 50) facing north (tile) target: RavagedPath (21, 43) facing east (tile) start candidates: RavagedPath (19, 50) - 1. north 7 (open) -> RavagedPath (19, 43) - 2. east 2 (open) -> RavagedPath (21, 43) - totals: 2 legs, 1 turns, 2 open, 0 localization + 1. north 10 (to wall) -> RavagedPath (19, 40) + 2. south 3 (open) -> RavagedPath (19, 43) + 3. east 2 (open) -> RavagedPath (21, 43) + totals: 3 legs, 2 turns, 2 open, 0 localization == 01.09 above_the_way_out (costs: route) from: RavagedPath (21, 43) facing east (tile) @@ -434,8 +435,9 @@ anchor); 0 from one start tile. from: Route204North (20, 27) (tile) target: Route204North (11, 27) (tile) start candidates: Route 204 (20, 27) - 1. west 9 (open) -> Route 204 (11, 27) - totals: 1 legs, 0 turns, 1 open, 0 localization + 1. west 10 (to wall) -> Route 204 (10, 27) + 2. east 1 (open) -> Route 204 (11, 27) + totals: 2 legs, 1 turns, 1 open, 0 localization == 01.10 line_3 (costs: line) from: Route204North (11, 27) (tile) @@ -448,19 +450,22 @@ anchor); 0 from one start tile. from: Route204North (11, 22) (tile) target: Route204North (19, 22) (tile) start candidates: Route 204 (11, 22) - 1. east 8 (open) -> Route 204 (19, 22) - totals: 1 legs, 0 turns, 1 open, 0 localization + 1. east 10 (to wall) -> Route 204 (21, 22) + 2. west 2 (open) -> Route 204 (19, 22) + totals: 2 legs, 1 turns, 1 open, 0 localization == 01.10 line_5 (costs: line) from: Route204North (19, 22) (tile) target: Route204North (19, 12) (tile) start candidates: Route 204 (19, 22) - 1. north 10 (open) -> Route 204 (19, 12) - totals: 1 legs, 0 turns, 1 open, 0 localization + 1. north 15 (to wall) -> Route 204 (19, 7) + 2. south 5 (open) -> Route 204 (19, 12) + totals: 2 legs, 1 turns, 1 open, 0 localization == 01.10 line_6 (costs: line) from: Route204North (19, 12) (tile) target: Route204North (11, 12) (tile) start candidates: Route 204 (19, 12) - 1. west 8 (open) -> Route 204 (11, 12) - totals: 1 legs, 0 turns, 1 open, 0 localization + 1. west 9 (to wall) -> Route 204 (10, 12) + 2. east 1 (open) -> Route 204 (11, 12) + totals: 2 legs, 1 turns, 1 open, 0 localization diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index 2aff88aa64..d08fd3dab5 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -51,9 +51,8 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 south 1 (open) -> Route 201 (57, 14)", - "00.03 west 7 (open) -> Route 201 (50, 14)", - "00.03 north 11 (to wall) -> Route 201 (50, 3)", + "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)", @@ -84,9 +83,8 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "00.04 east 8 (open) -> Twinleaf Town (14, 4)", "00.04 north 16 (to wall) -> Route 201 (14, 13)", "00.04 east 43 (to wall) -> Route 201 (57, 13)", - "00.04 south 1 (open) -> Route 201 (57, 14)", - "00.04 west 7 (open) -> Route 201 (50, 14)", - "00.04 north 8 (open) -> Route 201 (50, 6)", + "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 north 2 (to wall) -> Sandgem Town (29, 11)", "00.04 west 5 (open) -> Sandgem Town (24, 11)", @@ -108,11 +106,10 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 13 (open) -> Route 202 (30, 9)", - "00.04d west 8 (to wall) -> Route 202 (22, 9)", - "00.04d north 5 (to wall) -> Route 202 (22, 4)", - "00.04d west 4 (to wall) -> Route 202 (18, 4)", - "00.04d north 1 (open) -> Route 202 (18, 3)", + "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_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)", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp index 3c02c2ea4f..686b5c937e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp @@ -128,9 +128,8 @@ UnitTestResult test_plan_robust_route(Logger&){ const std::vector cases{ {.name = "two starts meet at the wall", .from = {{1, 1}, {2, 1}}, .goal = {4, 1}, .legs = "east 3 (to wall) to (4, 1)"}, {.name = "an open stop is never sure", .from = {{1, 1}}, .goal = {3, 1}, .legs = ""}, - // Known exactly, the player is not run to the wall and walked back: two exact steps. {.name = "unless a one-tile step is exact", .from = {{1, 1}}, .goal = {3, 1}, .costs = exact_step, - .legs = "east 2 (open) to (3, 1)"}, + .legs = "east 3 (to wall) to (4, 1); west 1 (open) to (3, 1)"}, }; for (const RobustCase& item : cases){ const auto legs = plan_robust_route(world, item.from, [&](const TilePos& pos){ return pos == item.goal; }, item.costs); @@ -146,6 +145,36 @@ UnitTestResult test_plan_robust_route(Logger&){ return true; } +// A held run on to a wall and tapped back is fine from the start, but not +// after a tapped leg: the player is exactly where the taps left them, and a +// run past that tile and back only adds a turn (lab-B 2026-11-12 14:24, 00.05c +// "south 15 (to wall), north 1" after "east 19 (open)"). +UnitTestResult test_robust_wall_and_back_not_after_taps(Logger&){ + // East along the top row, which goes on past column 5, then down column 5 + // to the goal a few tiles above the wall. + std::vector rows{"#########", "#.......#"}; + for (int y = 0; y < 40; y++){ + rows.push_back("#####.###"); + } + rows.push_back("#########"); + const StoryWorld world = make_world(rows); + RobustPlanCosts costs; + costs.exact_open_tiles = costs.max_open_tiles; + const auto legs = plan_robust_route(world, {{1, 1}}, [](const TilePos& pos){ return pos == TilePos{5, 38}; }, costs); + if (!legs){ + return std::string("no plan."); + } + for (size_t i = 1; i + 1 < legs->size(); i++){ + const TileLeg& before = (*legs)[i - 1].leg; + const TileLeg& wall = (*legs)[i].leg; + const TileLeg& back = (*legs)[i + 1].leg; + if (!before.ends_at_wall && wall.ends_at_wall && (int)back.direction == ((int)wall.direction + 2) % 4){ + return "a run to the wall and back after a tapped leg: " + describe(*legs); + } + } + return true; +} + // Someone wanders a row, (2..4, 2): a leg may cross the row through one of // their tiles, but not run along it through two, the leg's start among // them. On lab-B (2026-11-08, 01.08) Route 204's youngster stopped a leg @@ -393,6 +422,10 @@ const RoutePlannerCase ROUTE_PLANNER_CASES[] = { .input = {"robust plans", test_plan_robust_route}, .expectation = {}, }, + { + .input = {"a run to the wall and back is not planned after a tapped leg", test_robust_wall_and_back_not_after_taps}, + .expectation = {}, + }, { .input = {"robust plans cross a wander zone, never along it", test_plan_robust_route_wander_zone}, .expectation = {}, 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 7cf429c6a3..a4cfcb48f6 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -583,22 +583,22 @@ UnitTestResult test_legs_ending_at_a_wall_are_wall_legs(Logger& logger){ return found.empty() ? UnitTestResult(true) : UnitTestResult("open legs that end at a wall:" + out); } -// A leg to a wall from a place the walk knows exactly localizes nothing: -// it is not followed by a leg straight back (00.05c's "south 15 (to wall)" -// then "north 1"). A walk is held to a wall to bring several possible -// places to one, or after a blocked leg, not from one known tile. -UnitTestResult test_known_place_has_no_wall_and_back(Logger& logger){ +// After a tapped leg the walk knows its place exactly: a leg to a wall +// from it is not followed by a leg straight back (00.05c's "east 19 +// (open)", "south 15 (to wall)", then "north 1"). Run to a wall and back is +// fine from the start or after a wall (00.04 into_twinleaf, south 37). +UnitTestResult test_no_wall_and_back_after_taps(Logger& logger){ std::vector found; for (const PlannedStoryRoute& route : plan_story_routes(logger)){ if (!route.legs){ continue; } const std::vector& legs = *route.legs; - for (size_t i = 1; i < legs.size(); i++){ - const size_t known_before = i == 1 ? route.from.size() : legs[i - 2].after.size(); + for (size_t i = 2; i < legs.size(); i++){ const bool back = (int)legs[i].leg.direction == ((int)legs[i - 1].leg.direction + 2) % 4; - if (known_before == 1 && legs[i - 1].leg.ends_at_wall && back){ - found.push_back(std::format("{}: {} then {}.", route.name, to_string(legs[i - 1]), to_string(legs[i]))); + const TileLeg& taps = legs[i - 2].leg; + if (!taps.ends_at_wall && !taps.held && legs[i - 1].leg.ends_at_wall && back){ + found.push_back(std::format("{}: {}, {} then {}.", route.name, to_string(legs[i - 2]), to_string(legs[i - 1]), to_string(legs[i]))); } } } @@ -606,7 +606,7 @@ UnitTestResult test_known_place_has_no_wall_and_back(Logger& logger){ for (const std::string& line : found){ out += "\n " + line; } - return found.empty() ? UnitTestResult(true) : UnitTestResult("a wall and back from a known place:" + out); + return found.empty() ? UnitTestResult(true) : UnitTestResult("a wall and back after a tapped leg:" + out); } // 01.08's walk below the Ravaged Path keeps off the row Route 204 South's @@ -886,7 +886,7 @@ const AutoStoryStoryTableCase AUTO_STORY_STORY_TABLE_CASES[] = { .expectation = {}, }, { - .input = {"a known place is not run to a wall and walked back from (00.05c south 15, north 1, lab-B 2026-11-12 14:24)", test_known_place_has_no_wall_and_back}, + .input = {"no run to a wall and back after a tapped leg (00.05c east 19, south 15, north 1, lab-B 2026-11-12 14:24)", test_no_wall_and_back_after_taps}, .expectation = {}, }, { diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json index 55c3fbc532..8d6959e03f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/leg_trace_00.04.golden.json @@ -13,7 +13,8 @@ {"checkpoint":"00.04","chunks":3,"dir":"north","end":[["Route 201",39,11]],"end_kind":"open","event":"along_route_201_road","interrupts":[],"known":"dead_reckoned","leg":2,"moved":3,"ms":2400,"planned_end":[["Route 201",39,11]],"tiles":3}, {"checkpoint":"00.04","chunks":24,"dir":"west","end":[["Route 201",15,11]],"end_kind":"open","event":"along_route_201_road","interrupts":[],"known":"dead_reckoned","leg":3,"moved":24,"ms":19200,"planned_end":[["Route 201",15,11]],"tiles":24}, {"checkpoint":"00.04","chunks":2,"dir":"south","end":[["Route 201",15,14]],"end_kind":"open","event":"along_route_201_road","interrupts":[],"known":"dead_reckoned","leg":4,"moved":2,"ms":1600,"planned_end":[["Route 201",15,14]],"tiles":2}, - {"checkpoint":"00.04","chunks":33,"dir":"south","end":[["Twinleaf Town",15,22]],"end_kind":"open","event":"into_twinleaf","interrupts":[],"known":"dead_reckoned","leg":1,"moved":33,"ms":26400,"planned_end":[["Twinleaf Town",15,22]],"tiles":33}, + {"checkpoint":"00.04","chunks":37,"dir":"south","end":[["Twinleaf Town",15,26]],"end_kind":"wall","event":"into_twinleaf","interrupts":[],"known":"wall","leg":1,"ms":6600,"planned_end":[["Twinleaf Town",15,26]],"tiles":37}, + {"checkpoint":"00.04","chunks":4,"dir":"north","end":[["Twinleaf Town",15,22]],"end_kind":"open","event":"into_twinleaf","interrupts":[],"known":"dead_reckoned","leg":2,"moved":4,"ms":3200,"planned_end":[["Twinleaf Town",15,22]],"tiles":4}, {"checkpoint":"00.04","chunks":5,"dir":"east","end":[["Twinleaf Town",20,22]],"end_kind":"open","event":"to_moms_doorstep","interrupts":[],"known":"dead_reckoned","leg":1,"moved":5,"ms":4000,"planned_end":[["Twinleaf Town",20,22]],"tiles":5}, {"checkpoint":"00.04","chunks":1,"dir":"north","end":[["PlayerHouse1F",6,8]],"end_kind":"open","event":"beside_mom","interrupts":[],"known":"dead_reckoned","leg":1,"moved":1,"ms":800,"planned_end":[["PlayerHouse1F",6,8]],"tiles":1}, {"checkpoint":"00.04","chunks":0,"dir":"north","end":[],"end_kind":"wall","event":"into_the_east_corner","interrupts":[],"known":"wall","leg":1,"ms":0,"planned_end":[],"tiles":4}, @@ -27,14 +28,13 @@ {"checkpoint":"00.04","chunks":8,"dir":"east","end":[["Twinleaf Town",14,4]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":2,"moved":8,"ms":6400,"planned_end":[["Twinleaf Town",14,4]],"tiles":8}, {"checkpoint":"00.04","chunks":16,"dir":"north","end":[["Route 201",14,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":3,"ms":3450,"planned_end":[["Route 201",14,13]],"tiles":16}, {"checkpoint":"00.04","chunks":43,"dir":"east","end":[["Route 201",57,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":4,"ms":5350,"planned_end":[["Route 201",57,13]],"tiles":43}, - {"checkpoint":"00.04","chunks":1,"dir":"south","end":[["Route 201",57,14]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":5,"moved":1,"ms":800,"planned_end":[["Route 201",57,14]],"tiles":1}, - {"checkpoint":"00.04","chunks":7,"dir":"west","end":[["Route 201",50,14]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":6,"moved":7,"ms":5600,"planned_end":[["Route 201",50,14]],"tiles":7}, - {"checkpoint":"00.04","chunks":8,"dir":"north","end":[["Route 201",50,6]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":7,"moved":8,"ms":6400,"planned_end":[["Route 201",50,6]],"tiles":8}, - {"checkpoint":"00.04","chunks":43,"dir":"east","end":[["Sandgem Town",29,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":8,"ms":5350,"planned_end":[["Sandgem Town",29,13]],"tiles":43}, - {"checkpoint":"00.04","chunks":2,"dir":"north","end":[["Sandgem Town",29,11]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":9,"ms":1350,"planned_end":[["Sandgem Town",29,11]],"tiles":2}, - {"checkpoint":"00.04","chunks":5,"dir":"west","end":[["Sandgem Town",24,11]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":10,"moved":5,"ms":4000,"planned_end":[["Sandgem Town",24,11]],"tiles":5}, - {"checkpoint":"00.04","chunks":19,"dir":"north","end":[["Route 202",25,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":11,"ms":3900,"planned_end":[["Route 202",25,24]],"tiles":19}, - {"checkpoint":"00.04","chunks":3,"dir":"west","end":[["Route 202",22,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":12,"ms":1350,"planned_end":[["Route 202",22,24]],"tiles":3}, - {"checkpoint":"00.04","chunks":3,"dir":"south","end":[["Route 202",22,27]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":13,"moved":3,"ms":2400,"planned_end":[["Route 202",22,27]],"tiles":3} + {"checkpoint":"00.04","chunks":7,"dir":"west","end":[["Route 201",50,13]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":5,"moved":7,"ms":5600,"planned_end":[["Route 201",50,13]],"tiles":7}, + {"checkpoint":"00.04","chunks":7,"dir":"north","end":[["Route 201",50,6]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":6,"moved":7,"ms":5600,"planned_end":[["Route 201",50,6]],"tiles":7}, + {"checkpoint":"00.04","chunks":43,"dir":"east","end":[["Sandgem Town",29,13]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":7,"ms":5350,"planned_end":[["Sandgem Town",29,13]],"tiles":43}, + {"checkpoint":"00.04","chunks":2,"dir":"north","end":[["Sandgem Town",29,11]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":8,"ms":1350,"planned_end":[["Sandgem Town",29,11]],"tiles":2}, + {"checkpoint":"00.04","chunks":5,"dir":"west","end":[["Sandgem Town",24,11]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":9,"moved":5,"ms":4000,"planned_end":[["Sandgem Town",24,11]],"tiles":5}, + {"checkpoint":"00.04","chunks":19,"dir":"north","end":[["Route 202",25,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":10,"ms":3900,"planned_end":[["Route 202",25,24]],"tiles":19}, + {"checkpoint":"00.04","chunks":3,"dir":"west","end":[["Route 202",22,24]],"end_kind":"wall","event":"short_of_the_catch_tutorial","interrupts":[],"known":"wall","leg":11,"ms":1350,"planned_end":[["Route 202",22,24]],"tiles":3}, + {"checkpoint":"00.04","chunks":3,"dir":"south","end":[["Route 202",22,27]],"end_kind":"open","event":"short_of_the_catch_tutorial","interrupts":[],"known":"dead_reckoned","leg":12,"moved":3,"ms":2400,"planned_end":[["Route 202",22,27]],"tiles":3} ] } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp index eb7d46a0a1..06273b8a3e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteChoice.cpp @@ -49,6 +49,10 @@ constexpr long long REPLAN_MS = 2000; constexpr int REPLAN_OPEN_GRASS_COST = 60; // Longest run into a trigger tried (trigger_runs()). constexpr size_t TRIGGER_RUN_TILES = 32; +// Shortest open leg run_variants() runs on or holds: shorter taps cost +// little, and each variant is a plan to score on every step's first plan +// (the BDSP sims plan thousands). +constexpr size_t RUN_VARIANT_TILES = 6; // Expected time a plan must save for each tile it walks back beyond the // route's own plan: the user's road route on Route 201 walks back 3 @@ -107,6 +111,75 @@ class CachedReplanner{ std::map, std::optional>, TileLess> m_plans; }; +Direction opposite(Direction direction){ + return Direction(((int)direction + 2) % 4); +} + +// Where every tile of `from` stops walking `direction` to a wall, or +// nothing unless each is held at one (WallHit::anchored). +std::optional wall_leg_from(const StoryWorld& world, const std::vector& from, Direction direction){ + PlannedLeg out{.leg = {.direction = direction, .tiles = 0, .ends_at_wall = true, .held = false}, .after = {}}; + for (const TilePos& pos : from){ + const WallHit hit = slide_to_wall(world, pos, direction); + if (!hit.anchored || hit.tiles == 0){ + return std::nullopt; + } + out.leg.tiles = std::max(out.leg.tiles, hit.tiles); + if (std::find(out.after.begin(), out.after.end(), hit.stop) == out.after.end()){ + out.after.push_back(hit.stop); + } + } + return out; +} + +// `legs` with its open leg `index`, from the one tile `from`, run on to +// the wall past its end and tapped back: 00.04 into_twinleaf, "south 33" +// tapped (26.5 s) or run south 37 to the wall and 4 taps north (10.2 s). +std::optional> overshoot_to_wall( + const StoryWorld& world, const TilePos& from, const std::vector& legs, size_t index +){ + const PlannedLeg& open = legs[index]; + const std::optional wall = wall_leg_from(world, {from}, open.leg.direction); + if (!wall || open.after.size() != 1 || wall->leg.tiles <= open.leg.tiles){ + return std::nullopt; + } + const TilePos end = open.after.front(); + const TilePos stop = wall->after.front(); + const size_t back = (size_t)(std::abs(stop.x - end.x) + std::abs(stop.y - end.y)); + if (stop.x != end.x && stop.y != end.y){ + return std::nullopt; + } + std::vector out(legs.begin(), legs.begin() + index); + out.push_back(*wall); + out.push_back({.leg = {.direction = opposite(open.leg.direction), .tiles = back, .ends_at_wall = false, .held = false}, .after = {end}}); + out.insert(out.end(), legs.begin() + index + 1, legs.end()); + return out; +} + +// Plans made from `legs` the way a player runs: each open leg from a +// known tile (not after a tapped leg) run on to a wall and tapped back. An open leg is never held +// for its time: a timed run overshoots by up to a third (lab-B +// 2026-11-11, Jubilife: runs timed for 10 tiles went about 13), so open +// legs are tapped and only legs to a wall are held. +std::vector> run_variants(const ScoredRoute& route, const std::vector& legs){ + std::vector> out; + std::vector at = route.from; + for (size_t i = 0; i < legs.size(); i++){ + const TileLeg& leg = legs[i].leg; + // After a tapped leg the player is exactly where the taps left them + // (00.05c, lab-B 2026-11-12 14:24): a run past that tile and back + // adds a turn. At the start or after a wall it is fast and exact. + const bool after_taps = i > 0 && !legs[i - 1].leg.ends_at_wall && !legs[i - 1].leg.held; + if (!leg.ends_at_wall && !leg.held && leg.tiles >= RUN_VARIANT_TILES && at.size() == 1 && !after_taps){ + if (std::optional> legs_out = overshoot_to_wall(route.world, at.front(), legs, i)){ + out.push_back(std::move(*legs_out)); + } + } + at = legs[i].after; + } + return out; +} + // The tiles where someone wanders that `legs` enter, from every tile of // `from`: a run on to a wall or a trigger may enter a zone the route's own // plan keeps off (RobustPlanCosts::per_wander_tile). @@ -198,7 +271,7 @@ Pokemon::RouteScore score_with(const ScoredRoute& route, const std::vector> candidate_plans(const ScoredRoute& route, const std::vector& own){ - std::vector> out; + std::vector> out = run_variants(route, own); for (std::vector& legs : trigger_runs(route, own)){ out.push_back(std::move(legs)); } From 2d3712a7cb67cb3bd32fc1da90c6512543199916 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 15:38:52 -0800 Subject: [PATCH 24/47] BDSP AutoStory: a leg to a wall turns first; with the facing unknown its first moved chunk may be the turn Facing another way than the leg goes, the walker turns with a tap that only turns and the held walk counts from its first step. With the facing unknown (after a battle) a walk that stopped with a moved chunk does not count the first one: it may be the turn (lab-B 2026-11-12 14:55, 01.02 south_to_the_cliff after Barry: three chunks over-counted). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 62 +++++++++++++++++++ .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 12 ++++ 2 files changed, 74 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 6829efbb43..7895bc8371 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -191,6 +191,14 @@ ScriptedWalk walk_script(const StoryWorld& maps, const TilePos& from, const Tile return walk_script_from(maps, {from}, goal, std::move(sights), script, after_talk); } +std::string joined_notes(const Script& script){ + std::string out; + for (const std::string& note : script.notes){ + out += "\n " + note; + } + return out; +} + // The script's calls all made, or which are left. std::string script_left(const Script& script){ if (script.next == script.steps.size()){ @@ -380,6 +388,7 @@ UnitTestResult test_open_leg_known_trainer(Logger&){ Script script{.steps = { press_step("D-pad west 50 ms x1"), walk_step("6 taps: T: west 6 (open)", WalkStop::DIALOG, 1500ms, 3), + press_step("D-pad east 50 ms x1"), walk_step("wall: T: east 4 (to wall)", WalkStop::BLOCKED, 2000ms, 0), answer_step("dialog within 500 ms", false), press_step("D-pad west 50 ms x1"), @@ -700,6 +709,51 @@ UnitTestResult test_wall_leg_at_its_wall_among_the_start_tiles(Logger&){ return true; } +// A leg to a wall in another direction than the player faces turns first, +// with a tap that only turns; the held walk then counts from its first +// step, not a turn (lab-B 2026-11-12 14:55, 01.02 south_to_the_cliff). +UnitTestResult test_wall_leg_turns_before_the_walk(Logger&){ + const StoryWorld bend = make_world({"#####", "#...#", "###.#", "###.#", "#####"}); + Script script{.steps = { + walk_step("wall: T: east 2 (to wall)", WalkStop::BLOCKED, 1900ms, 2), + answer_step("dialog within 500 ms", false), + press_step("D-pad south 50 ms x1"), + walk_step("wall: T: south 2 (to wall)", WalkStop::BLOCKED, 1900ms, 2), + answer_step("dialog within 500 ms", false), + }}; + ScriptedWalk walk; + try{ + walk = walk_script(bend, {1, 1}, {3, 3}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (!walk.failure.empty()){ + return "failed: " + walk.failure; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + +// Facing unknown (after a battle), the first walk's chunk that changed the +// screen may be the turn: a leg to a wall that stopped with that one chunk +// has not moved, and whoever stopped it stands on the next tile. +UnitTestResult test_wall_leg_one_chunk_is_a_turn_when_facing_is_unknown(Logger&){ + const StoryWorld corridor = make_world({"###########", "#.........#", "###########"}); + Script script{.steps = { + walk_step("wall: T: east 8 (to wall)", WalkStop::BLOCKED, 800ms, 1), + }}; + ScriptedWalk walk; + try{ + walk = walk_script(corridor, {1, 1}, {9, 1}, {}, script); + }catch (const ScriptMismatch& e){ + script.notes.push_back(e.message); + } + const bool never_moved = std::any_of(script.notes.begin(), script.notes.end(), [](const std::string& note){ + return note.find("the first moved chunk may be the turn") != std::string::npos; + }); + return never_moved ? UnitTestResult(true) : UnitTestResult(std::format("the turn counted as a moved chunk (step {}, {} notes): {}{}", script.next, script.notes.size(), walk.failure, joined_notes(script))); +} + struct PlannedRouteInput{ std::string name; std::function body; @@ -775,6 +829,14 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .input = {"a wall leg held up on the way is not at its wall (lab-B 2026-11-11 21:00)", test_wall_leg_held_up_is_not_at_its_wall}, .expectation = {}, }, + { + .input = {"a leg to a wall turns first when its way differs from the facing (lab-B 2026-11-12 14:55)", test_wall_leg_turns_before_the_walk}, + .expectation = {}, + }, + { + .input = {"one chunk of a walk with unknown facing is a turn, not a move (lab-B 2026-11-12 14:55)", test_wall_leg_one_chunk_is_a_turn_when_facing_is_unknown}, + .expectation = {}, + }, { .input = {"a wall leg that stood at its wall among the start tiles does not fail (lab-B 2026-11-12 14:50)", test_wall_leg_at_its_wall_among_the_start_tiles}, .expectation = {}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index 60efe9a3d5..081dbfd710 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -488,7 +488,19 @@ std::vector RouteWalker::arrive() const{ LegNext RouteWalker::wall_leg(LegWalk& walk){ const TileLeg& leg = walk.planned.leg; const Milliseconds limit = wall_limit(leg); + // Already turned the way when the leg goes on from the last: nothing to + // turn to. Facing another way (known), a tap that only turns comes first, + // so the walk counts from its first step. Facing unknown (after a battle), + // the walk's first chunk that changed the screen may be the turn. + if (m_facing && *m_facing != leg.direction){ + turn_tap(walk); + } + const bool facing_unknown = !m_facing; walk.result = m_io.walk_to_wall({.direction = walk.planned.leg.direction, .limit = limit, .label = walk.label, .options = run_watching(walk)}); + if (facing_unknown && walk.result.stop == WalkStop::BLOCKED && walk.result.moved_chunks > 0){ + m_io.note(std::format("[Route] {}: facing unknown; the first moved chunk may be the turn, not counted.", walk.label), RouteNote::LOG); + walk.result.moved_chunks--; + } if (const std::optional next = finish_interrupted_wall(walk, limit)){ return *next; } From 53d281c3d23abe44b70f6d24d505634d6663622f Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 15:43:11 -0800 Subject: [PATCH 25/47] BDSP AutoStory: a Trainer battle met by a wall leg is fought as a trainer battle The wild escape policy ended a Run on 'no running from a Trainer battle' only after five refused Runs. A NO_RUNNING outcome (read from the box after Run) now stops the attempts at once and fights it like the story's trainer battles, with the potion check after. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_WildBattle.cpp | 33 +++++++++++++++++-- .../PokemonBDSP_AutoStory_GridSim.cpp | 10 +++++- ...PokemonBDSP_AutoStory_WildBattlePolicy.cpp | 4 +++ .../PokemonBDSP_AutoStory_WildBattlePolicy.h | 13 +++++++- ...nBDSP_AutoStory_WildBattlePolicy_Tests.cpp | 30 ++++++++++++++--- 5 files changed, 82 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WildBattle.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WildBattle.cpp index 5994605164..a779393868 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WildBattle.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_WildBattle.cpp @@ -20,6 +20,7 @@ #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/Async/InferenceRoutines.h" #include "CommonTools/OCR/OCR_RawTesseractOCR.h" +#include "CommonTools/OCR/OCR_Routines.h" #include "CommonTools/VisualDetectors/BlackScreenDetector.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonBDSP/Inference/Battles/PokemonBDSP_BattleMenuDetector.h" @@ -32,7 +33,10 @@ #include "PokemonBDSP/Inference/PokemonBDSP_MenuDetector.h" #include "PokemonBDSP/Inference/PokemonBDSP_ReceivePokemonDetector.h" #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h" +#include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_StoryLanguage.h" +#include "PokemonBDSP_AutoStory_Bag.h" #include "PokemonBDSP_AutoStory_Battle.h" +#include "PokemonBDSP_AutoStory_Talks.h" #include "PokemonBDSP_AutoStory_WildBattle.h" namespace PokemonAutomation{ @@ -223,6 +227,11 @@ class ConsoleWildBattleEscape : public WildBattleEscapeActions{ virtual void fight() override{ fight_wild_battle(m_stream, m_context, "Mine escape"); } + virtual void fight_trainer() override{ + PokemonBDSP::fight_trainer(m_stream, m_context, "Mine escape"); + m_context.wait_for_all_requests(); + use_potion_first_pokemon(m_stream, m_context, 0.8); + } virtual void note(const std::string& text) override{ m_stream.log("[Mine escape] " + text); } @@ -235,6 +244,9 @@ class ConsoleWildBattleEscape : public WildBattleEscapeActions{ private: // B, then the exit (0) or the battle menu (1) within three seconds; -1 for neither. int exit_or_menu(); + // After A on Run: whether the box under the battle says a Trainer + // battle cannot be run from. Read while its text is still up. + bool says_no_running(); VideoStream& m_stream; ProControllerContext& m_context; @@ -249,6 +261,20 @@ int ConsoleWildBattleEscape::exit_or_menu(){ return wait_until(m_stream, m_context, 3s, {{m_battle_end}, {menu_ready}}); } +bool ConsoleWildBattleEscape::says_no_running(){ + // The refusal's box: the bottom of the battle screen, as a dialogue's. + const ImageFloatBox text_box(0.19, 0.80, 0.64, 0.18); + pbf_press_button(m_context, BUTTON_A, 80ms, 600ms); + m_context.wait_for_all_requests(); + const VideoSnapshot frame = m_stream.video().snapshot(); + if (!frame){ + return false; + } + const std::string text = OCR::ocr_read(story_language(), extract_box_reference(frame, text_box), OCR::PageSegMode::SINGLE_BLOCK); + m_stream.log("[Mine escape] Text after Run: \"" + text + "\""); + return sign_text_matches(text, "trainer"); +} + WildRunOutcome ConsoleWildBattleEscape::run(){ const int ready = exit_or_menu(); if (ready == 0){ @@ -257,6 +283,9 @@ WildRunOutcome ConsoleWildBattleEscape::run(){ if (ready != 1 || !mine_select_run(m_stream, m_context, m_battle_type)){ return WildRunOutcome::UNCERTAIN; } + if (says_no_running()){ + return WildRunOutcome::NO_RUNNING; + } m_stream.log("[Mine escape] Run input sent; watching for black-screen exit."); const int result = run_until(m_stream, m_context, @@ -435,8 +464,8 @@ void escape_wild_battle(VideoStream& stream, const WildBattleEscapePolicy& policy){ ConsoleWildBattleEscape actions(stream, context, battle_type); WildEscapeResult result = escape_wild_battle(actions, policy); - if (result == WildEscapeResult::FOUGHT){ - // fight_wild_battle() ended on the overworld. + if (result == WildEscapeResult::FOUGHT || result == WildEscapeResult::TRAINER_FOUGHT){ + // fight_wild_battle() and fight_trainer() ended on the overworld. return; } if (result == WildEscapeResult::UNCONFIRMED && actions.exit_within(10s)){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp index 6fd9f3a409..180960cc20 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp @@ -438,6 +438,9 @@ class SimWildBattleEscape : public WildBattleEscapeActions{ virtual void fight() override{ m_notes.push_back("[Sim escape] Fought with the best move until the battle ended."); } + virtual void fight_trainer() override{ + m_notes.push_back("[Sim escape] Fought as a trainer battle, then a potion check."); + } virtual void note(const std::string& text) override{ m_notes.push_back("[Sim escape] " + text); } @@ -467,7 +470,12 @@ void GridSimRouteIO::escape_scripted_battle(const SimWildBattle& battle, const s if (result == WildEscapeResult::UNCONFIRMED){ note(std::format("escape_wild_battle: {}: the Run attempts ran out without the exit.", label), RouteNote::FAILURE); } - const std::string_view ended = result == WildEscapeResult::FOUGHT ? "fought to its end" : "run from"; + std::string_view ended = "run from"; + if (result == WildEscapeResult::FOUGHT){ + ended = "fought to its end"; + }else if (result == WildEscapeResult::TRAINER_FOUGHT){ + ended = "fought as a trainer battle"; + } m_notes.push_back(std::format("[Sim] {}: wild battle {}.", label, ended)); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.cpp index 26a20e6fd4..95cdd6c45d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.cpp @@ -28,6 +28,10 @@ WildEscapeResult escape_wild_battle(WildBattleEscapeActions& actions, const Wild return WildEscapeResult::FOUGHT; } break; + case WildRunOutcome::NO_RUNNING: + actions.note("A Trainer battle: there is no running; fighting it as a trainer battle."); + actions.fight_trainer(); + return WildEscapeResult::TRAINER_FOUGHT; case WildRunOutcome::UNCERTAIN: break; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.h index 9c0fb3ff12..686f528d64 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.h @@ -24,6 +24,7 @@ enum class WildRunOutcome{ ESCAPED, // the battle's exit transition showed TRAPPED, // the battle menu came back: the game refused the escape UNCERTAIN, // neither showed within the wait: text still scrolling, cursor unread + NO_RUNNING, // "There's no running from a Trainer battle!": not a wild battle }; // The game steps escape_wild_battle() takes, injected so its decisions run @@ -40,6 +41,11 @@ class WildBattleEscapeActions{ // the battle ends, on the overworld when it returns. virtual void fight() = 0; + // After NO_RUNNING, on the battle menu: the trainer battle as the story's + // trainer battles are fought (best move to the end, then a potion if the + // lead is low), on the overworld when it returns. + virtual void fight_trainer() = 0; + // A line of the escape's log. virtual void note(const std::string& text) = 0; }; @@ -65,12 +71,17 @@ struct WildBattleEscapePolicy{ enum class WildEscapeResult{ ESCAPED, FOUGHT, // the game kept refusing the escape; the battle was fought to its end + TRAINER_FOUGHT, // a Trainer battle, which cannot be run from: fought as the story's are UNCONFIRMED, // the attempts ran out without the exit }; // The decisions of escape_wild_battle(): Run on the battle menu until the // exit shows, within `policy.attempts` tries; after `policy.run_refusals` -// refused Runs, `policy.fallback`. +// refused Runs, `policy.fallback`. A Run the game answers with "no running +// from a Trainer battle" ends the attempts at once: it is fought as a +// trainer battle (a wild battle's refusals are worth repeating, a trainer's +// never change: lab-B 2026-11-12 14:55, Route 203, five Runs and a faint +// misread before it was fought). WildEscapeResult escape_wild_battle(WildBattleEscapeActions& actions, const WildBattleEscapePolicy& policy); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy_Tests.cpp index bef6b85725..3938a2cff4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy_Tests.cpp @@ -34,6 +34,9 @@ class ScriptedEscapeActions : public WildBattleEscapeActions{ virtual void fight() override{ m_fights++; } + virtual void fight_trainer() override{ + m_trainer_fights++; + } virtual void note(const std::string&) override{} size_t runs() const{ @@ -42,11 +45,15 @@ class ScriptedEscapeActions : public WildBattleEscapeActions{ size_t fights() const{ return m_fights; } + size_t trainer_fights() const{ + return m_trainer_fights; + } private: std::vector m_outcomes; size_t m_runs = 0; size_t m_fights = 0; + size_t m_trainer_fights = 0; }; std::string_view result_name(WildEscapeResult result){ @@ -55,6 +62,8 @@ std::string_view result_name(WildEscapeResult result){ return "ESCAPED"; case WildEscapeResult::FOUGHT: return "FOUGHT"; + case WildEscapeResult::TRAINER_FOUGHT: + return "TRAINER_FOUGHT"; case WildEscapeResult::UNCONFIRMED: return "UNCONFIRMED"; } @@ -70,6 +79,7 @@ struct EscapePolicyExpectation{ WildEscapeResult result = WildEscapeResult::ESCAPED; size_t runs = 0; size_t fights = 0; + size_t trainer_fights = 0; }; struct EscapePolicyCase{ EscapePolicyInput input; @@ -86,10 +96,12 @@ class Test_WildBattlePolicy : public UnitTest{ ScriptedEscapeActions actions(m_case.input.outcomes); const WildEscapeResult result = escape_wild_battle(actions, m_case.input.policy); const EscapePolicyExpectation& expected = m_case.expectation; - if (result != expected.result || actions.runs() != expected.runs || actions.fights() != expected.fights){ - return std::format("expected {} after {} Run presses and {} fights, got {} after {} and {}.", - result_name(expected.result), expected.runs, expected.fights, - result_name(result), actions.runs(), actions.fights()); + if (result != expected.result || actions.runs() != expected.runs || actions.fights() != expected.fights || + actions.trainer_fights() != expected.trainer_fights + ){ + return std::format("expected {} after {} Run presses, {} fights and {} trainer fights, got {} after {}, {} and {}.", + result_name(expected.result), expected.runs, expected.fights, expected.trainer_fights, + result_name(result), actions.runs(), actions.fights(), actions.trainer_fights()); } return true; } @@ -101,6 +113,7 @@ class Test_WildBattlePolicy : public UnitTest{ constexpr WildRunOutcome ESCAPED = WildRunOutcome::ESCAPED; constexpr WildRunOutcome TRAPPED = WildRunOutcome::TRAPPED; constexpr WildRunOutcome UNCERTAIN = WildRunOutcome::UNCERTAIN; +constexpr WildRunOutcome NO_RUNNING = WildRunOutcome::NO_RUNNING; const EscapePolicyCase WILD_BATTLE_POLICY_CASES[] = { { @@ -128,6 +141,15 @@ const EscapePolicyCase WILD_BATTLE_POLICY_CASES[] = { .input = {.name = "refusals between scrolling text count up to the fight", .outcomes = {TRAPPED, UNCERTAIN, TRAPPED, UNCERTAIN, TRAPPED}}, .expectation = {.result = WildEscapeResult::FOUGHT, .runs = 5, .fights = 1}, }, + // lab-B 2026-11-12 14:55, Route 203: a trainer's battle taken for a wild one. + { + .input = {.name = "no running from a Trainer battle: one Run, then fought as a trainer's", .outcomes = {NO_RUNNING}}, + .expectation = {.result = WildEscapeResult::TRAINER_FOUGHT, .runs = 1, .trainer_fights = 1}, + }, + { + .input = {.name = "no running after a refusal that was not sure: still one trainer fight", .outcomes = {UNCERTAIN, NO_RUNNING}}, + .expectation = {.result = WildEscapeResult::TRAINER_FOUGHT, .runs = 2, .trainer_fights = 1}, + }, { .input = {.name = "bound with the fight turned off: the attempts run out", .outcomes = {TRAPPED}, .policy = {.attempts = 6, .fallback = TrappedFallback::GIVE_UP}}, .expectation = {.result = WildEscapeResult::UNCONFIRMED, .runs = 6}, From 91c202d6d5d50975ad685a8670ac02b2c2b29a00 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 15:52:41 -0800 Subject: [PATCH 26/47] BDSP AutoStory: walk_to_wall_turning() takes the wall leg's turn and its uncounted chunk out of RouteWalker Keeps PlannedRoute.cpp within its code-health size limits. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 16 ++-------- .../Utils/PokemonBDSP_AutoStory_WallWalk.cpp | 31 ++++++++++++++++++ .../Utils/PokemonBDSP_AutoStory_WallWalk.h | 32 +++++++++++++++++++ SerialPrograms/cmake/SourceFiles.cmake | 2 ++ 4 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index 081dbfd710..e887d708df 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -21,6 +21,7 @@ #include "PokemonBDSP_AutoStory_PlannedRoute.h" #include "PokemonBDSP_AutoStory_RouteSteps.h" #include "PokemonBDSP_AutoStory_WalkDpad.h" +#include "PokemonBDSP_AutoStory_WallWalk.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -482,25 +483,12 @@ std::vector RouteWalker::arrive() const{ return m_from; } - // Run (B held) on the D-pad: a leg to a wall ends at the wall however fast // we get there, and the D-pad keeps to the row. LegNext RouteWalker::wall_leg(LegWalk& walk){ const TileLeg& leg = walk.planned.leg; const Milliseconds limit = wall_limit(leg); - // Already turned the way when the leg goes on from the last: nothing to - // turn to. Facing another way (known), a tap that only turns comes first, - // so the walk counts from its first step. Facing unknown (after a battle), - // the walk's first chunk that changed the screen may be the turn. - if (m_facing && *m_facing != leg.direction){ - turn_tap(walk); - } - const bool facing_unknown = !m_facing; - walk.result = m_io.walk_to_wall({.direction = walk.planned.leg.direction, .limit = limit, .label = walk.label, .options = run_watching(walk)}); - if (facing_unknown && walk.result.stop == WalkStop::BLOCKED && walk.result.moved_chunks > 0){ - m_io.note(std::format("[Route] {}: facing unknown; the first moved chunk may be the turn, not counted.", walk.label), RouteNote::LOG); - walk.result.moved_chunks--; - } + walk.result = walk_to_wall_turning(m_io, m_facing, {.direction = leg.direction, .limit = limit, .label = walk.label, .options = run_watching(walk)}); if (const std::optional next = finish_interrupted_wall(walk, limit)){ return *next; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp new file mode 100644 index 0000000000..ec395d884d --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp @@ -0,0 +1,31 @@ +/* BDSP AutoStory - Wall walk + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "PokemonBDSP_AutoStory_RouteSteps.h" +#include "PokemonBDSP_AutoStory_WallWalk.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +WalkResult walk_to_wall_turning(RouteIO& io, std::optional facing, const RouteWallWalk& walk){ + if (facing && *facing != walk.direction){ + turn(io, walk.direction); + } + WalkResult result = io.walk_to_wall(walk); + if (!facing && result.stop == WalkStop::BLOCKED && result.moved_chunks > 0){ + io.note(std::format("[Route] {}: facing unknown; the first moved chunk may be the turn, not counted.", walk.label), RouteNote::LOG); + result.moved_chunks--; + } + return result; +} + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h new file mode 100644 index 0000000000..73424d2e19 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h @@ -0,0 +1,32 @@ +/* BDSP AutoStory - Wall walk + * + * From: https://github.com/PokemonAutomation/ + * + * A walk to a wall, turned the way first. + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_WallWalk_H +#define PokemonAutomation_PokemonBDSP_AutoStory_WallWalk_H + +#include +#include "Pokemon/Navigation/Pokemon_Grid.h" +#include "PokemonBDSP_AutoStory_RouteIO.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +// io.walk_to_wall(), with a leading turn not counted as a moved chunk: +// facing another way (`facing` known), a tap that only turns comes first, so +// the walk counts from its first step. Facing unknown (after a battle), the +// walk's first chunk that changed the screen may be the turn: it is not +// counted when the walk ends at the wall. +WalkResult walk_to_wall_turning(RouteIO& io, std::optional facing, const RouteWallWalk& walk); + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index fcbcfa94db..c52b4a79f1 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1899,6 +1899,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkProbe.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkResult.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h + Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp + Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.cpp Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy_Tests.cpp From e0e1094ad50d6d11205fec8a43b1f18d191abc54 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 16:06:06 -0800 Subject: [PATCH 27/47] CI: check out the Packages commit that carries the BDSP AutoStory option templates The AutoStoryResources test found 22 Autostory/Options PNGs missing in CI: they are not in PokemonAutomation/Packages master. dayfine/Packages bdsp/autostory-options is upstream master plus exactly those files. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .github/workflows/cpp-ci-serial-programs-base.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp-ci-serial-programs-base.yml b/.github/workflows/cpp-ci-serial-programs-base.yml index 358de17122..7732433142 100644 --- a/.github/workflows/cpp-ci-serial-programs-base.yml +++ b/.github/workflows/cpp-ci-serial-programs-base.yml @@ -84,8 +84,10 @@ jobs: - name: Checkout Packages uses: actions/checkout@v7 with: - repository: 'PokemonAutomation/Packages' - ref: 'master' + # Upstream master plus the BDSP AutoStory option-screen templates (22 PNGs the + # AutoStoryResources test requires); drop this once they are merged upstream. + repository: 'dayfine/Packages' + ref: '7d108a255bfbd4923af1fb0cf49245f2c2483594' path: 'Arduino-Source/Packages' - name: Prepare pinned BDSP map resources From 046d7e3fdb346042f6904da536f72752f91f4890 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 18:13:40 -0800 Subject: [PATCH 28/47] BDSP AutoStory: a trainer who freezes the walk a tile short of a wall is not the wall A trainer the map lacks, seen from one tile short of a leg's wall, freezes the player with the "!": the hold reads as stopped, as at the wall, and the dialogue opens after it. The walk on to the wall after a battle did not look for one, and a battle on the next leg's first press went on from the wrong column (lab-B 2026-11-12 17:45, 01.02 by_the_gate, Route 203). The walk on now looks for a dialogue after it stops and fights; a battle that begins before a leg moved, right after a leg to a wall, walks on to that wall again first. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Source/PokemonBDSP/PokemonBDSP_Tests.cpp | 2 + ...emonBDSP_AutoStory_FrozenTrainer_Tests.cpp | 178 ++++++++++++++++++ ...okemonBDSP_AutoStory_FrozenTrainer_Tests.h | 26 +++ .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 15 +- .../Utils/PokemonBDSP_AutoStory_WallWalk.cpp | 44 +++++ .../Utils/PokemonBDSP_AutoStory_WallWalk.h | 23 ++- SerialPrograms/cmake/SourceFiles.cmake | 2 + 7 files changed, 281 insertions(+), 9 deletions(-) create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.h diff --git a/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp index c51b846fd4..2b5857e0ed 100644 --- a/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp @@ -8,6 +8,7 @@ #include "Inference/PokemonBDSP_DialogDetector.h" #include "Inference/PokemonBDSP_MenuDetector.h" #include "Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Actions_Tests.h" +#include "Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.h" #include "Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.h" #include "Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.h" #include "Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.h" @@ -54,6 +55,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_AutoStory_PlannedRoute(database); add_tests_AutoStory_SimulatedRoute(database); add_tests_AutoStory_GridSim(database); + add_tests_AutoStory_FrozenTrainer(database); add_tests_AutoStory_WallBattleSim(database); add_tests_AutoStory_RecoveryWalk(database); add_tests_AutoStory_StorySim(database); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp new file mode 100644 index 0000000000..ab2ae2ad75 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp @@ -0,0 +1,178 @@ +/* BDSP AutoStory Grid Simulation - Frozen Trainer Tests + * + * From: https://github.com/PokemonAutomation/ + * + * A trainer the map lacks sees the player one tile short of a leg's wall: + * the "!" freezes the player, the hold reads as stopped, as at the wall, + * and the dialogue opens later. Lab-B 2026-11-12 17:45, 01.02 by_the_gate: + * after the Youngster's battle the walk east along Route 203's row 18 was + * frozen at (54, 18), the stop was taken for the wall at (55, 18), and + * every later leg ran one column off. + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "Pokemon/Navigation/Pokemon_Grid.h" +#include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_PlanCosts.h" +#include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryWorld.h" +#include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TrainerSight.h" +#include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.h" +#include "PokemonBDSP_AutoStory_FrozenTrainer_Tests.h" +#include "PokemonBDSP_AutoStory_GridSim.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ +using namespace detail; + + +namespace{ + +using Pokemon::Direction; +using Pokemon::TilePos; + + +// Row 16 of 18, with a block between the columns 1-2 and 11-12 above it: +// east along the bottom rows to the wall, then north up column 12. +StoryWorld make_room(){ + Pokemon::MapData map; + map.name = "Test"; + map.tiles = Pokemon::Grid{14, 18, {}}; + for (int y = 0; y < 18; y++){ + for (int x = 0; x < 14; x++){ + const bool wall = x == 0 || x == 13 || y == 0 || y == 17 || (y <= 12 && x >= 3 && x <= 10); + map.tiles.cells.push_back(*Pokemon::tile_from_glyph(wall ? '#' : '.')); + } + } + StoryWorld world; + world.add("Test", map, {0, 0}); + return world; +} + +// The hold toward a wall that a trainer's sight stops reads as stopped, as +// at a wall, when the trainer is `trainer`; `seen`: whether a look right +// after finds their dialogue open. If not, it is open on the next input. +class FrozenTrainerRouteIO : public GridSimRouteIO{ +public: + FrozenTrainerRouteIO(GridSim& sim, std::vector& notes, std::string trainer, bool seen) + : GridSimRouteIO(sim, notes) + , m_sim(sim) + , m_trainer(std::move(trainer)) + , m_seen(seen) + {} + + virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override{ + m_frozen = false; + const bool open = m_sim.player().dialog; + WalkResult result = GridSimRouteIO::walk_to_wall(walk); + if (!open && result.stop == WalkStop::DIALOG && m_sim.player().trainer == m_trainer){ + result.stop = WalkStop::BLOCKED; + m_frozen = !m_seen; + } + return result; + } + virtual void press(const RouteInput& input) override{ + m_frozen = false; + GridSimRouteIO::press(input); + } + virtual bool dialog_within(Milliseconds wait, Color color) override{ + return !m_frozen && GridSimRouteIO::dialog_within(wait, color); + } + +private: + GridSim& m_sim; + std::string m_trainer; + bool m_seen; + bool m_frozen = false; +}; + +struct FrozenTrainerCase{ + std::string name; + // Whether a look right after the frozen stop finds the dialogue open. + bool seen; +}; + +// East along row 16 meets a known trainer at (6, 14), whose sight covers +// (6, 15) and (6, 16); after the battle the walk on to the wall is frozen +// at (11, 16), a tile short, by a trainer the map lacks at (11, 13). The +// route must still end on (12, 4), by the wall at (12, 16) and the wall at +// (12, 1). +UnitTestResult run_frozen_trainer(Logger& logger, const FrozenTrainerCase& item){ + const StoryWorld room = make_room(); + const TilePos start{1, 16}; + const TilePos target{12, 4}; + const TrainerSight known{.name = "known", .pos = {6, 14}, .facing = Direction::SOUTH, .range = 2}; + const TrainerSight hidden{.name = "hidden", .pos = {11, 13}, .facing = Direction::SOUTH, .range = 3}; + GridSim sim({.world = &room, .trainers = {known, hidden}}, start, Direction::NORTH, true); + std::vector notes; + FrozenTrainerRouteIO sim_io(sim, notes, "hidden", item.seen); + RouteTrainers trainers{{known}, [&sim](const std::string&){ sim.end_dialogue(); return true; }}; + std::vector believed; + std::string failure; + try{ + believed = walk_route(sim_io, room, {start}, trainers, { + .goal = [&](const TilePos& pos){ return pos == target; }, + .label = "by_the_gate", + .avoid = {}, + .costs = *story_route_costs("town"), + .speed = MoveSpeed::RUN, + }); + }catch (const GridSimFailure& e){ + failure = "failed: " + e.message; + } + for (const std::string& note : notes){ + logger.log(note); + } + const TilePos at = nearest_tile(sim.player().pos); + if (!failure.empty()){ + return failure; + } + if (at != target || believed != std::vector{target}){ + return std::format("ended on ({}, {}), believed {} tile(s), not on (12, 4).", at.x, at.y, believed.size()); + } + return true; +} + +class Test_FrozenTrainer : public UnitTest{ +public: + explicit Test_FrozenTrainer(FrozenTrainerCase item) + : UnitTest("PokemonBDSP::AutoStory - Frozen trainer: " + item.name) + , m_case(std::move(item)) + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + try{ + return run_frozen_trainer(logger, m_case); + }catch (Exception& e){ + return std::string(e.name()) + ": " + e.message(); + } + } + +private: + FrozenTrainerCase m_case; +}; + +const FrozenTrainerCase FROZEN_TRAINER_CASES[] = { + {.name = "01.02, a trainer the map lacks freezes us a tile short of the wall, found on the stop (lab-B, 2026-11-12 17:45)", .seen = true}, + {.name = "01.02, a trainer the map lacks freezes us a tile short of the wall, talks on the next leg (lab-B, 2026-11-12 17:45)", .seen = false}, +}; + +} // namespace + + +void add_tests_AutoStory_FrozenTrainer(UnitTestDatabase& database){ + for (const FrozenTrainerCase& item : FROZEN_TRAINER_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.h new file mode 100644 index 0000000000..16b96729aa --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.h @@ -0,0 +1,26 @@ +/* BDSP AutoStory Grid Simulation - Frozen Trainer Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_FrozenTrainer_Tests_H +#define PokemonAutomation_PokemonBDSP_AutoStory_FrozenTrainer_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + + +// A trainer the map lacks freezes the player a tile short of a wall. +void add_tests_AutoStory_FrozenTrainer(UnitTestDatabase& database); + + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index e887d708df..2730a0d76c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -316,6 +316,7 @@ class RouteWalker{ std::vector m_from; // Which way the player faces, once a leg has set it. std::optional m_facing; + std::optional m_prev_wall; // the leg before this one, if it went to a wall // Every banner read on the way, to check the map we arrive on against. std::vector m_all_banners; std::string m_map_start; @@ -436,6 +437,7 @@ LegNext RouteWalker::walk_leg(const PlannedLeg& planned, size_t number, size_t c }; const LegNext next = planned.leg.ends_at_wall ? wall_leg(walk) : open_leg(walk); if (next == LegNext::REPLAN){ + m_prev_wall.reset(); return next; } m_facing = planned.leg.direction; @@ -448,7 +450,9 @@ LegNext RouteWalker::walk_leg(const PlannedLeg& planned, size_t number, size_t c return LegNext::ARRIVED_EARLY; } check_banners(walk); - return after_leg(walk); + const LegNext done = after_leg(walk); + m_prev_wall = done == LegNext::NEXT_LEG && planned.leg.ends_at_wall ? std::optional{{planned.leg.direction, wall_limit(planned.leg)}} : std::nullopt; + return done; } // Legs whose ends span two maps skip the per-leg check; the walk as a @@ -763,10 +767,9 @@ LegNext RouteWalker::check_at_wall(LegWalk& walk, size_t walked_tiles, size_t ex // After a battle on a leg to a wall: a leg to a wall ends at its wall // however far it got, so walk on to it and carry on. LegNext RouteWalker::on_to_wall(LegWalk& walk){ - m_io.note("[Route] " + walk.label + ": on to the wall after the battle.", RouteNote::WARNING); const Milliseconds limit = wall_limit(walk.planned.leg); - walk.result = m_io.walk_to_wall({.direction = walk.planned.leg.direction, .limit = limit, - .label = walk.label + ": on to the wall", .options = run_watching(walk)}); + walk.result = walk_on_to_wall(m_io, m_trainers, m_prev_wall, walk.result.moved_chunks + walk.turn_moved == 0, + {.direction = walk.planned.leg.direction, .limit = limit, .label = walk.label + ": on to the wall", .options = run_watching(walk)}); std::optional next = finish_interrupted_wall(walk, limit); if (!next && walk.result.stop != WalkStop::BLOCKED){ next = check_at_wall(walk); @@ -779,7 +782,6 @@ LegNext RouteWalker::on_to_wall(LegWalk& walk){ return LegNext::NEXT_LEG; } - // Whole tiles on the D-pad, a tap each: a tap moves exactly one tile, while // a stick hold timed for three moved one in the Ravaged Path (r235b) and the // belief drifted four rows. @@ -890,7 +892,6 @@ LegNext RouteWalker::mark_and_replan(LegWalk& walk, size_t moved, Blocker blocke "blocked after " + std::to_string(moved) + " of " + std::to_string(walk.planned.leg.tiles) + " tiles"); } - // Entering another map shows its name; a missing or wrong name means the // walk did not end where the plan says. From tiles on several maps (a leg // not confirmed) the banner may already have shown. @@ -1054,7 +1055,6 @@ LegNext RouteWalker::known_trainer(LegWalk& walk, const std::vector stopp } // namespace - std::vector walk_route( VideoStream& stream, ProControllerContext& context, const WildBattleEscape& escape, const StoryWorld& maps, std::vector from, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp index ec395d884d..28152bdd95 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp @@ -13,6 +13,29 @@ namespace NintendoSwitch{ namespace PokemonBDSP{ +namespace{ + +// How long after a walk to a wall stopped to look for a dialogue. +constexpr Milliseconds FROZEN_DIALOG_WAIT = 1000ms; +constexpr size_t MAX_FROZEN_FIGHTS = 3; + +WalkResult walk_fighting(RouteIO& io, RouteTrainers& trainers, std::optional facing, const RouteWallWalk& walk){ + for (size_t fights = 0;; fights++){ + const WalkResult result = walk_to_wall_turning(io, facing, walk); + if (fights == MAX_FROZEN_FIGHTS || result.stop != WalkStop::BLOCKED || !io.dialog_within(FROZEN_DIALOG_WAIT, COLOR_YELLOW)){ + return result; + } + io.note(std::format("[Route] {}: a trainer froze us short of the wall; battling.", walk.label), RouteNote::WARNING); + if (!trainers.fight("a trainer at the wall")){ + return result; + } + facing.reset(); + } +} + +} // namespace + + WalkResult walk_to_wall_turning(RouteIO& io, std::optional facing, const RouteWallWalk& walk){ if (facing && *facing != walk.direction){ turn(io, walk.direction); @@ -25,6 +48,27 @@ WalkResult walk_to_wall_turning(RouteIO& io, std::optional f return result; } +WalkResult walk_on_to_wall( + RouteIO& io, RouteTrainers& trainers, + const std::optional& before, bool began_still, + const RouteWallWalk& walk +){ + io.note(std::format("[Route] {}: on to the wall after the battle.", walk.label), RouteNote::WARNING); + std::optional facing; + if (before && began_still){ + io.note(std::format("[Route] {}: the battle began before this leg moved; on to the wall before it first.", walk.label), RouteNote::WARNING); + RouteWallWalk back = walk; + back.direction = before->direction; + back.limit = before->limit; + const WalkResult result = walk_fighting(io, trainers, std::nullopt, back); + if (result.stop != WalkStop::BLOCKED && result.stop != WalkStop::LIMIT){ + fail(io, std::format("{}: {} on the walk on to the wall before it: not where the plan has us.", walk.label, walk_stop_name(result.stop))); + } + facing = before->direction; + } + return walk_fighting(io, trainers, facing, walk); +} + } // namespace PokemonBDSP } // namespace NintendoSwitch diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h index 73424d2e19..2561a177bf 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h @@ -2,7 +2,7 @@ * * From: https://github.com/PokemonAutomation/ * - * A walk to a wall, turned the way first. + * A walk to a wall, turned the way first; a walk on to it after a battle. * */ @@ -11,6 +11,7 @@ #include #include "Pokemon/Navigation/Pokemon_Grid.h" +#include "PokemonBDSP_AutoStory_PlannedRoute.h" #include "PokemonBDSP_AutoStory_RouteIO.h" namespace PokemonAutomation{ @@ -25,6 +26,26 @@ namespace PokemonBDSP{ // counted when the walk ends at the wall. WalkResult walk_to_wall_turning(RouteIO& io, std::optional facing, const RouteWallWalk& walk); +// The leg to a wall before the one walked, to walk on to again if a stop on +// it may not have been its wall. +struct WallBefore{ + Pokemon::Direction direction; + Milliseconds limit; +}; + +// A walk on to the wall after a trainer's battle on the way, fighting any +// trainer who froze the walk a tile short of the wall: that stop reads as +// the wall, and the dialogue opens after it (lab-B 2026-11-12 17:46, 01.02: +// Route 203's corner trainer). `began_still`: the battle began before the +// leg moved. After a `before` leg to a wall, that stop may have been such a +// freeze, and the column or row we stand on is then not where the plan has +// it: that wall comes first. +WalkResult walk_on_to_wall( + RouteIO& io, RouteTrainers& trainers, + const std::optional& before, bool began_still, + const RouteWallWalk& walk +); + } // namespace PokemonBDSP } // namespace NintendoSwitch diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index c52b4a79f1..1b41eee4ae 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1842,6 +1842,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.h Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.h + Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp + Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.h Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim_Tests.h Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_LegTrace_Tests.cpp From 6f44b58d183cd6f2c71e4afc490642380c9231a4 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 18:21:31 -0800 Subject: [PATCH 29/47] BDSP AutoStory: frozen-trainer test as input/expectation case; chrono literals in WallWalk Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...emonBDSP_AutoStory_FrozenTrainer_Tests.cpp | 25 +++++++++++++------ .../Utils/PokemonBDSP_AutoStory_WallWalk.cpp | 2 ++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp index ab2ae2ad75..ff937e4a9b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp @@ -23,6 +23,7 @@ #include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryWorld.h" #include "PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TrainerSight.h" #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.h" +#include "PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h" #include "PokemonBDSP_AutoStory_FrozenTrainer_Tests.h" #include "PokemonBDSP_AutoStory_GridSim.h" @@ -92,12 +93,22 @@ class FrozenTrainerRouteIO : public GridSimRouteIO{ bool m_frozen = false; }; -struct FrozenTrainerCase{ +struct FrozenTrainerInput{ std::string name; // Whether a look right after the frozen stop finds the dialogue open. bool seen; }; +struct FrozenTrainerExpectation{ + // Where the route must end, by the wall at x = 12. + TilePos end; +}; + +struct FrozenTrainerCase{ + FrozenTrainerInput input; + FrozenTrainerExpectation expectation; +}; + // East along row 16 meets a known trainer at (6, 14), whose sight covers // (6, 15) and (6, 16); after the battle the walk on to the wall is frozen // at (11, 16), a tile short, by a trainer the map lacks at (11, 13). The @@ -106,12 +117,12 @@ struct FrozenTrainerCase{ UnitTestResult run_frozen_trainer(Logger& logger, const FrozenTrainerCase& item){ const StoryWorld room = make_room(); const TilePos start{1, 16}; - const TilePos target{12, 4}; + const TilePos target = item.expectation.end; const TrainerSight known{.name = "known", .pos = {6, 14}, .facing = Direction::SOUTH, .range = 2}; const TrainerSight hidden{.name = "hidden", .pos = {11, 13}, .facing = Direction::SOUTH, .range = 3}; GridSim sim({.world = &room, .trainers = {known, hidden}}, start, Direction::NORTH, true); std::vector notes; - FrozenTrainerRouteIO sim_io(sim, notes, "hidden", item.seen); + FrozenTrainerRouteIO sim_io(sim, notes, "hidden", item.input.seen); RouteTrainers trainers{{known}, [&sim](const std::string&){ sim.end_dialogue(); return true; }}; std::vector believed; std::string failure; @@ -134,7 +145,7 @@ UnitTestResult run_frozen_trainer(Logger& logger, const FrozenTrainerCase& item) return failure; } if (at != target || believed != std::vector{target}){ - return std::format("ended on ({}, {}), believed {} tile(s), not on (12, 4).", at.x, at.y, believed.size()); + return std::format("ended on ({}, {}), believed {} tile(s), not on ({}, {}).", at.x, at.y, believed.size(), target.x, target.y); } return true; } @@ -142,7 +153,7 @@ UnitTestResult run_frozen_trainer(Logger& logger, const FrozenTrainerCase& item) class Test_FrozenTrainer : public UnitTest{ public: explicit Test_FrozenTrainer(FrozenTrainerCase item) - : UnitTest("PokemonBDSP::AutoStory - Frozen trainer: " + item.name) + : UnitTest("PokemonBDSP::AutoStory - Frozen trainer: " + item.input.name) , m_case(std::move(item)) {} virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ @@ -158,8 +169,8 @@ class Test_FrozenTrainer : public UnitTest{ }; const FrozenTrainerCase FROZEN_TRAINER_CASES[] = { - {.name = "01.02, a trainer the map lacks freezes us a tile short of the wall, found on the stop (lab-B, 2026-11-12 17:45)", .seen = true}, - {.name = "01.02, a trainer the map lacks freezes us a tile short of the wall, talks on the next leg (lab-B, 2026-11-12 17:45)", .seen = false}, + {.input = {.name = "01.02, a trainer the map lacks freezes us a tile short of the wall, found on the stop (lab-B, 2026-11-12 17:45)", .seen = true}, .expectation = {.end = {12, 4}}}, + {.input = {.name = "01.02, a trainer the map lacks freezes us a tile short of the wall, talks on the next leg (lab-B, 2026-11-12 17:45)", .seen = false}, .expectation = {.end = {12, 4}}}, }; } // namespace diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp index 28152bdd95..b2f04f92ba 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp @@ -12,6 +12,8 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonBDSP{ +using namespace std::chrono_literals; + namespace{ From cf59453cc2e569f1ac1701d5aeb279a47006ac35 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 18:50:11 -0800 Subject: [PATCH 30/47] BDSP AutoStory: a leg that may have slid onto a warp looks for the far map's banner; a crossing with its fade unseen ends the route lab-B 2026-11-12 01.02 by_the_east_mouth: the walk ran past its counted end onto the Gate's east warp, the fade went by between frames, the banner was gone by into_oreburgh's taps. RouteIO::banner_within() reads the banner for 2.5 s after a leg with a warp in reach; another map's banner hands the walk over as through the warp (through_already). Sim: SimFade::UNSEEN, red-first case. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 14 ++++++ .../PokemonBDSP_AutoStory_StorySim.cpp | 8 ++++ .../PokemonBDSP_AutoStory_StorySim.h | 8 ++++ .../Utils/PokemonBDSP_AutoStory_LegTraceIO.h | 3 ++ .../Utils/PokemonBDSP_AutoStory_Location.cpp | 44 +++++++++++++------ .../Utils/PokemonBDSP_AutoStory_Location.h | 6 +++ .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 25 +++++++++++ .../Utils/PokemonBDSP_AutoStory_RouteIO.cpp | 7 +++ .../Utils/PokemonBDSP_AutoStory_RouteIO.h | 8 ++++ 9 files changed, 109 insertions(+), 14 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp index ea33c16689..28e60bad09 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp @@ -229,6 +229,19 @@ UnitTestResult night_and_dim_floors(Logger& logger){ return passes(run_case(logger, "01.02", "01.05", {.fade = {}, .banner = {}}, knobs)); } +// lab-B 2026-11-12 18:36, 01.02's by_the_east_mouth: the walk to the east +// mouth's door ran two tiles further east than it counted (a blocked leg +// left its column open, and the wall it stopped against was judged by the +// screen's change), onto the warp, whose fade the walk did not see. The +// step must see the far map's banner after the leg (gone by the next +// step's taps) and take the way through as done, not tap east into the city's fence. +UnitTestResult east_mouth_crossed_unseen(Logger& logger){ + const Pose far = Pokemon::pose_of(*table_step("01.02", "into_oreburgh").pose_after); + const SimWorldKnobs knobs{.slides = {{.step = "by_the_east_mouth", .direction = Direction::EAST, .tiles = 2, + .far = far, .fade = SimFade::UNSEEN, .banner_up = false}}}; + return passes(run_case(logger, "01.02", "01.02", {.fade = {}, .banner = {}}, knobs)); +} + // 01.03: Roark's first line in the mine comes after the camera zooms in on // us, some seconds after the A press (r98; the old event waited 8 s). UnitTestResult roark_speaks_late(Logger& logger){ @@ -732,6 +745,7 @@ const FailureCase AUTO_STORY_FAILURE_CASES[] = { return every_single_miss(logger, ONE_SIGNAL_STEPS); }}, .expectation = {}}, {.input = {"any one fade with its hold unseen from 00.00 to 01.11: every row still passes", every_single_hold_miss}, .expectation = {}}, + {.input = {"01.02 by_the_east_mouth runs onto the Gate's east warp, fade unseen (lab-B 2026-11-12)", east_mouth_crossed_unseen}, .expectation = {}}, {.input = {"01.02 to 01.05 at night, the Gate's dim floor", night_and_dim_floors}, .expectation = {}}, {.input = {"01.03 Roark's first line 7 s after the A press", roark_speaks_late}, .expectation = {}}, {.input = {"01.03 with Oreburgh's people wandering (the pokefan on 45, 37..39)", [](Logger& logger){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp index 79054a7545..524e1d17fa 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp @@ -326,6 +326,10 @@ WalkResult SimKnobRouteIO::slide_on(const SimSlide& slide, WalkResult result){ note("[Sim] slid onto a warp to " + Pokemon::to_string(slide.far) + ".", RouteNote::LOG); m_cross(slide.far); m_misses.banner_up = slide.banner_up ? slide.far.map : ""; + if (slide.fade == SimFade::UNSEEN){ + m_misses.banner_soon = slide.far.map; + return result; + } const double brightness = slide.fade == SimFade::BLACK ? SIM_DOOR_FADE : slide.fade == SimFade::DIM ? SIM_DIM_FADE : SIM_WHITE_FADE; result.warp.fade = fade_of(sim_screen(brightness, SIM_FADE_STDDEV)); if (result.warp.fade != WarpFade::NONE){ @@ -336,6 +340,10 @@ WalkResult SimKnobRouteIO::slide_on(const SimSlide& slide, WalkResult result){ return result; } +std::string SimKnobRouteIO::banner_within(Milliseconds){ + return std::exchange(m_misses.banner_soon, ""); +} + bool SimKnobRouteIO::dialog_within(Milliseconds wait, Color color){ const auto late = m_knobs.first_line.find(m_step); if (late != m_knobs.first_line.end() && late->second > wait){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h index cdc1af068b..cb1daddcf4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h @@ -79,6 +79,9 @@ struct SimMisses{ bool fading_in = false; bool slid = false; std::string banner_up = {}; + // The map whose banner shows a second after a fade the walk missed + // (SimFade::UNSEEN): only a look within a wait reads it. + std::string banner_soon = {}; }; // How a warp's fade looks on the screen (#268's design note); the @@ -93,6 +96,10 @@ enum class SimFade{ // A cave exit's white. The walk's old encounter-flash watcher read it // as a wild battle. WHITE, + // A door's fade the walk's frames miss (a short one between two): the + // walk goes on as if nothing happened and only the banner, a second or + // so later, shows the far map (lab-B 2026-11-12, 01.02's east mouth). + UNSEEN, }; // An open leg that runs on past its end: the walk taps of the step `step` @@ -234,6 +241,7 @@ class SimKnobRouteIO : public GridSimRouteIO{ virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override; virtual WalkResult walk_taps(Pokemon::Direction direction, size_t tiles, const std::string& label) override; virtual bool dialog_within(Milliseconds wait, Color color) override; + virtual std::string banner_within(Milliseconds wait) override; // With SimWorldKnobs::slow_fade_in, fails the move `label` if the last // warp is still fading in (SimMisses::fading_in). void check_fade_in(const std::string& label); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h index 01bc83090f..c3df53fafb 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h @@ -46,6 +46,9 @@ class LegTraceRouteIO : public RouteIO{ virtual bool dialog_within(Milliseconds wait, Color color) override{ return m_inner.dialog_within(wait, color); } + virtual std::string banner_within(Milliseconds wait) override{ + return m_inner.banner_within(wait); + } virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) override{ return m_inner.holding_against_wall(direction, label); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.cpp index e8cb28f935..372388734d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.cpp @@ -111,6 +111,27 @@ std::string read_save_screen_location(const ImageViewRGB32& screen){ return normalize_location_name(OCR::tesseract_ocr_read(Language::English, text)); } +namespace{ +// The edit distance of two normalized names. +size_t name_distance(const std::string& a, const std::string& b){ + // Levenshtein distance. + std::vector row(b.size() + 1); + for (size_t j = 0; j <= b.size(); j++){ + row[j] = j; + } + for (size_t i = 1; i <= a.size(); i++){ + size_t diagonal = row[0]; + row[0] = i; + for (size_t j = 1; j <= b.size(); j++){ + const size_t above = row[j]; + row[j] = std::min({row[j] + 1, row[j - 1] + 1, diagonal + (a[i - 1] == b[j - 1] ? 0 : 1)}); + diagonal = above; + } + } + return row[b.size()]; +} +} // namespace + bool location_banner_matches(const std::string& read, const std::string& expected){ // No reader for the game's language: a banner (or the save card) that // showed is all there is; where we stand is the walk's to say. @@ -125,21 +146,16 @@ bool location_banner_matches(const std::string& read, const std::string& expecte if (digits_of(a) != digits_of(b)){ return false; } - // Levenshtein distance. - std::vector row(b.size() + 1); - for (size_t j = 0; j <= b.size(); j++){ - row[j] = j; - } - for (size_t i = 1; i <= a.size(); i++){ - size_t diagonal = row[0]; - row[0] = i; - for (size_t j = 1; j <= b.size(); j++){ - const size_t above = row[j]; - row[j] = std::min({row[j] + 1, row[j - 1] + 1, diagonal + (a[i - 1] == b[j - 1] ? 0 : 1)}); - diagonal = above; - } + return name_distance(a, b) <= std::max(1, b.size() / 4); +} + +bool location_banner_is_another(const std::string& read, const std::string& current){ + const std::string a = normalize_location_name(read); + const std::string b = normalize_location_name(current); + if (a.empty() || b.empty() || read == UNREAD_LOCATION){ + return false; } - return row[b.size()] <= std::max(1, b.size() / 4); + return digits_of(a) != digits_of(b) || name_distance(a, b) > std::max(1, b.size() / 6); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.h index f341002461..9fe5cabe13 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.h @@ -47,6 +47,12 @@ std::string read_save_screen_location(const ImageViewRGB32& screen); // read as Route 202. bool location_banner_matches(const std::string& read, const std::string& expected); +// Whether the banner's `read` is surely not the map `current`'s: a stricter +// test than !location_banner_matches(), which forgives a quarter of the +// letters ("Oreburgh City" matches "Oreburgh Gate" within it). Only an +// OCR slip or two (a sixth of the letters) still reads as `current`. +bool location_banner_is_another(const std::string& read, const std::string& current); + } // namespace PokemonBDSP diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index 2730a0d76c..98a011bb02 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -212,6 +212,9 @@ enum class LegNext{ enum class Blocker{ THING, PERSON }; // How far past a leg's end a walk that ran on may have gone. constexpr size_t WARP_SLIDE_TILES = 2; +// How long after a leg that may have slid onto a warp the walk looks for the +// banner of the map beyond: it shows about 1.5 s after the fade. +constexpr Milliseconds BANNER_AFTER_SLIDE = 2500ms; // One planned leg as it is walked: where it goes, and the location // banners read on the way. @@ -292,6 +295,7 @@ class RouteWalker{ // After each leg. void check_banners(LegWalk& walk); + bool slid_through_unseen(const LegWalk& walk); LegNext after_leg(LegWalk& walk); std::vector watching_trainers(const std::vector>& paths) const; LegNext unknown_trainer(LegWalk& walk, const std::vector>& paths); @@ -449,12 +453,33 @@ LegNext RouteWalker::walk_leg(const PlannedLeg& planned, size_t number, size_t c m_warp = walk.result.warp; return LegNext::ARRIVED_EARLY; } + if (slid_through_unseen(walk)){ + return LegNext::ARRIVED_EARLY; + } check_banners(walk); const LegNext done = after_leg(walk); m_prev_wall = done == LegNext::NEXT_LEG && planned.leg.ends_at_wall ? std::optional{{planned.leg.direction, wall_limit(planned.leg)}} : std::nullopt; return done; } +// A leg that stayed on its map but could have run on over a warp (a count +// off by a tile or two: lab-B 2026-11-12, 01.02's east mouth) may have gone +// through with its fade between two frames. The banner of another map in +// the next moments says so: the walk is over, through the warp. +bool RouteWalker::slid_through_unseen(const LegWalk& walk){ + const TileLeg& leg = walk.planned.leg; + if (walk.map_before != walk.map_after || !warp_within(m_grid, m_from, leg.direction, leg.tiles + WARP_SLIDE_TILES)){ + return false; + } + const std::string read = m_io.banner_within(BANNER_AFTER_SLIDE); + if (!location_banner_is_another(read, walk.map_before)){ + return false; + } + m_io.note("[Route] " + walk.label + ": the location banner \"" + read + "\" shows after the leg, no fade seen: through the warp; handing over.", RouteNote::WARNING); + m_warp.banner = read; + return true; +} + // Legs whose ends span two maps skip the per-leg check; the walk as a // whole must still have seen the banner of the map it ends on. std::vector RouteWalker::arrive() const{ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp index 842ec7a302..04ba865bd9 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp @@ -10,6 +10,7 @@ #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonBDSP/Inference/PokemonBDSP_DialogDetector.h" +#include "PokemonBDSP_AutoStory_LocationBannerWatcher.h" #include "PokemonBDSP_AutoStory_RouteIO.h" #include "PokemonBDSP_AutoStory_WalkDpad.h" #include "PokemonBDSP_AutoStory_WalkResult.h" @@ -69,6 +70,12 @@ bool ConsoleRouteIO::dialog_within(Milliseconds wait, Color color){ return wait_until(m_stream, m_context, wait, {{dialog}}) == 0; } +std::string ConsoleRouteIO::banner_within(Milliseconds wait){ + LocationBannerWatcher banner; + wait_until(m_stream, m_context, wait, {{banner}}); + return banner.seen(); +} + bool ConsoleRouteIO::holding_against_wall(Direction direction, const std::string& label){ const JoystickPosition stick = route_stick(direction); return PokemonBDSP::holding_against_wall(m_stream, m_context, stick.x, stick.y, label); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h index 09b579378c..18d3f8efae 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h @@ -67,6 +67,13 @@ class RouteIO{ // screen changed less than walking would: we stand at a wall. virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) = 0; + // The location banner that shows within `wait`, "" if none. A door's + // fade can go by between two frames of a walk, and the banner of the + // map beyond shows a second or so after it. Nothing sees one by default. + virtual std::string banner_within(Milliseconds){ + return ""; + } + // Once the presses so far are done, shows `at` the screen, if there is one. virtual void look(const std::function& at) = 0; @@ -88,6 +95,7 @@ class ConsoleRouteIO : public RouteIO{ virtual WalkResult walk_taps(Pokemon::Direction direction, size_t tiles, const std::string& label) override; virtual void press(const RouteInput& input) override; virtual bool dialog_within(Milliseconds wait, Color color) override; + virtual std::string banner_within(Milliseconds wait) override; virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) override; virtual void look(const std::function& at) override; virtual void note(const std::string& text, RouteNote kind) override; From fad3c9645c212a791d7080aa10198f499a7c40cb Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 18:54:18 -0800 Subject: [PATCH 31/47] BDSP AutoStory: RouteIO watches for a dialogue box and the banner in one call; the wall leg's tile counts leave PlannedRoute.cpp Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 7 +- ...monBDSP_AutoStory_SimulatedRoute_Tests.cpp | 4 +- .../PokemonBDSP_AutoStory_StoryWalkSteps.cpp | 6 +- ...emonBDSP_AutoStory_FrozenTrainer_Tests.cpp | 6 +- .../PokemonBDSP_AutoStory_GridSim.cpp | 4 +- .../PokemonBDSP_AutoStory_GridSim.h | 2 +- .../PokemonBDSP_AutoStory_GridSim_Tests.cpp | 4 +- .../PokemonBDSP_AutoStory_StorySim.cpp | 23 ++--- .../PokemonBDSP_AutoStory_StorySim.h | 3 +- ...emonBDSP_AutoStory_WallBattleSim_Tests.cpp | 4 +- .../Utils/PokemonBDSP_AutoStory_LegTraceIO.h | 7 +- .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 68 ++------------- .../PokemonBDSP_AutoStory_PlannedTalk.cpp | 2 +- .../Utils/PokemonBDSP_AutoStory_RouteIO.cpp | 21 +++-- .../Utils/PokemonBDSP_AutoStory_RouteIO.h | 41 ++++++--- .../PokemonBDSP_AutoStory_WallLegCount.cpp | 87 +++++++++++++++++++ .../PokemonBDSP_AutoStory_WallLegCount.h | 43 +++++++++ .../Utils/PokemonBDSP_AutoStory_WallWalk.cpp | 2 +- SerialPrograms/cmake/SourceFiles.cmake | 2 + 19 files changed, 218 insertions(+), 118 deletions(-) create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp create mode 100644 SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h 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 7895bc8371..c8a5bc1b48 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -119,8 +119,11 @@ class ScriptedRouteIO : public RouteIO{ virtual void press(const RouteInput& input) override{ expect(describe(input)); } - virtual bool dialog_within(Milliseconds wait, Color) override{ - return expect(std::format("dialog within {} ms", wait.count())).answer; + virtual RouteSight sight_within(const RouteWatch& watch) override{ + if (!watch.dialog){ + return {}; + } + return {.dialog = expect(std::format("dialog within {} ms", watch.wait.count())).answer}; } virtual bool holding_against_wall(Direction direction, const std::string&) override{ return expect(std::string("holding ") + Pokemon::direction_name(direction)).answer; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_SimulatedRoute_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_SimulatedRoute_Tests.cpp index e786c357c5..23e555d157 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_SimulatedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_SimulatedRoute_Tests.cpp @@ -126,9 +126,9 @@ class SimulatedRouteIO : public RouteIO{ } } } - virtual bool dialog_within(Milliseconds, Color) override{ + virtual RouteSight sight_within(const RouteWatch&) override{ count_call(); - return false; + return {}; } virtual bool holding_against_wall(Direction, const std::string&) override{ count_call(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp index c4c41cb0d0..66565cd374 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp @@ -315,7 +315,7 @@ Outcome StoryWalkSteps::run_to_dialogue(const StoryStep& step){ return Pokemon::outcome_ok(); } // A scene can lock us before its first line: Dawn walks over first (r37). - if (m_route.dialog_within(10000ms, COLOR_CYAN)){ + if (dialog_within(m_route, 10000ms, COLOR_CYAN)){ return Pokemon::outcome_ok(); } return Pokemon::outcome_failed("no_dialogue", std::format("{}: no dialogue in {} tiles {}", step.name, leg.tiles, direction_name(leg.direction))); @@ -741,7 +741,7 @@ Outcome StoryWalkSteps::talk(RunState& state, const StoryStep& step){ .count = 1, .end = RouteInputEnd::DONE}); // Roark's first line in the mine comes after the camera zooms in on // us, which can take some seconds (r98; the old event waited 8 s). - if (!m_route.dialog_within(8000ms, COLOR_YELLOW)){ + if (!dialog_within(m_route, 8000ms, COLOR_YELLOW)){ fail(m_route, label_of(step) + ": nobody answered."); } return Pokemon::outcome_ok(); @@ -752,7 +752,7 @@ Outcome StoryWalkSteps::mash(RunState& state, const StoryStep& step){ m_scene_open = false; // The step before may have played the scene already (a door step settles // its arrival scene), so its first line is not required. - if (!m_route.dialog_within(15000ms, COLOR_CYAN)){ + if (!dialog_within(m_route, 15000ms, COLOR_CYAN)){ m_route.note(label_of(step) + ": no line within 15 s; the step before played it.", RouteNote::WARNING); } m_io.settle(step.action == "a" ? BUTTON_A : BUTTON_B, label_of(step), diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp index ff937e4a9b..ca3aca03be 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FrozenTrainer_Tests.cpp @@ -82,8 +82,10 @@ class FrozenTrainerRouteIO : public GridSimRouteIO{ m_frozen = false; GridSimRouteIO::press(input); } - virtual bool dialog_within(Milliseconds wait, Color color) override{ - return !m_frozen && GridSimRouteIO::dialog_within(wait, color); + virtual RouteSight sight_within(const RouteWatch& watch) override{ + RouteSight sight = GridSimRouteIO::sight_within(watch); + sight.dialog = sight.dialog && !m_frozen; + return sight; } private: diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp index 180960cc20..b989fa548b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.cpp @@ -598,8 +598,8 @@ void GridSimRouteIO::press(const RouteInput& input){ } } -bool GridSimRouteIO::dialog_within(Milliseconds, Color){ - return m_sim.player().dialog; +RouteSight GridSimRouteIO::sight_within(const RouteWatch& watch){ + return {.dialog = watch.dialog && m_sim.player().dialog}; } bool GridSimRouteIO::holding_against_wall(Direction direction, const std::string&){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.h index 5c3d442fcc..8e366beb9e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_GridSim.h @@ -304,7 +304,7 @@ class GridSimRouteIO : public RouteIO{ virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override; virtual WalkResult walk_taps(Pokemon::Direction direction, size_t tiles, const std::string& label) override; virtual void press(const RouteInput& input) override; - virtual bool dialog_within(Milliseconds wait, Color color) override; + virtual RouteSight sight_within(const RouteWatch& watch) override; virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) override; virtual void look(const std::function& at) override; virtual void note(const std::string& text, RouteNote kind) override; 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 61c0871497..0876daa2e5 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 @@ -182,8 +182,8 @@ class StickTurnIO : public RouteIO{ stick.hold = 100ms; m_io.press(stick); } - virtual bool dialog_within(Milliseconds wait, Color color) override{ - return m_io.dialog_within(wait, color); + virtual RouteSight sight_within(const RouteWatch& watch) override{ + return m_io.sight_within(watch); } virtual bool holding_against_wall(Direction direction, const std::string& label) override{ return m_io.holding_against_wall(direction, label); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp index 524e1d17fa..763918ce41 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp @@ -340,17 +340,20 @@ WalkResult SimKnobRouteIO::slide_on(const SimSlide& slide, WalkResult result){ return result; } -std::string SimKnobRouteIO::banner_within(Milliseconds){ - return std::exchange(m_misses.banner_soon, ""); -} - -bool SimKnobRouteIO::dialog_within(Milliseconds wait, Color color){ - const auto late = m_knobs.first_line.find(m_step); - if (late != m_knobs.first_line.end() && late->second > wait){ - note(std::format("[Sim] {}: the first line comes after {} ms, past the {} ms wait.", m_step, late->second.count(), wait.count()), RouteNote::LOG); - return false; +RouteSight SimKnobRouteIO::sight_within(const RouteWatch& watch){ + RouteSight sight; + if (watch.dialog){ + const auto late = m_knobs.first_line.find(m_step); + if (late != m_knobs.first_line.end() && late->second > watch.wait){ + note(std::format("[Sim] {}: the first line comes after {} ms, past the {} ms wait.", m_step, late->second.count(), watch.wait.count()), RouteNote::LOG); + }else{ + sight = GridSimRouteIO::sight_within(watch); + } + } + if (watch.banner){ + sight.banner = std::exchange(m_misses.banner_soon, ""); } - return GridSimRouteIO::dialog_within(wait, color); + return sight; } namespace{ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h index cb1daddcf4..b0c4ae623b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h @@ -240,8 +240,7 @@ class SimKnobRouteIO : public GridSimRouteIO{ virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override; virtual WalkResult walk_taps(Pokemon::Direction direction, size_t tiles, const std::string& label) override; - virtual bool dialog_within(Milliseconds wait, Color color) override; - virtual std::string banner_within(Milliseconds wait) override; + virtual RouteSight sight_within(const RouteWatch& watch) override; // With SimWorldKnobs::slow_fade_in, fails the move `label` if the last // warp is still fading in (SimMisses::fading_in). void check_fade_in(const std::string& label); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp index 09296f0c60..812b024b04 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp @@ -562,8 +562,8 @@ class UncountedTalkIO : public RouteIO{ virtual void press(const RouteInput& input) override{ m_io.press(input); } - virtual bool dialog_within(Milliseconds wait, Color color) override{ - return m_io.dialog_within(wait, color); + virtual RouteSight sight_within(const RouteWatch& watch) override{ + return m_io.sight_within(watch); } virtual bool holding_against_wall(Direction direction, const std::string& label) override{ return m_io.holding_against_wall(direction, label); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h index c3df53fafb..353478d861 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_LegTraceIO.h @@ -43,11 +43,8 @@ class LegTraceRouteIO : public RouteIO{ virtual void press(const RouteInput& input) override{ m_inner.press(input); } - virtual bool dialog_within(Milliseconds wait, Color color) override{ - return m_inner.dialog_within(wait, color); - } - virtual std::string banner_within(Milliseconds wait) override{ - return m_inner.banner_within(wait); + virtual RouteSight sight_within(const RouteWatch& watch) override{ + return m_inner.sight_within(watch); } virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) override{ return m_inner.holding_against_wall(direction, label); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index 98a011bb02..b391ed282d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -21,6 +21,7 @@ #include "PokemonBDSP_AutoStory_PlannedRoute.h" #include "PokemonBDSP_AutoStory_RouteSteps.h" #include "PokemonBDSP_AutoStory_WalkDpad.h" +#include "PokemonBDSP_AutoStory_WallLegCount.h" #include "PokemonBDSP_AutoStory_WallWalk.h" namespace PokemonAutomation{ @@ -142,65 +143,6 @@ constexpr size_t HEAR_OUT_PRESSES = 6; constexpr RouteInput WAIT_FOR_THE_WAY{.kind = RouteInputKind::WAIT, .direction = Direction::NORTH, .hold = 2500ms, .release = 0ms, .count = 1, .end = RouteInputEnd::DONE}; -// Tiles a walk to the wall moved, from the time it walked. -size_t tiles_moved(const WalkResult& walk, Milliseconds per_tile){ - if (walk.stop == WalkStop::LIMIT && walk.moved_chunks > 0){ - const Milliseconds moving = walk.walked - ROUTE_START_DELAY; - const size_t tiles_from_time = moving.count() <= 0 ? (size_t)0 : (size_t)(moving / per_tile); - const size_t tiles_from_chunks = (walk.moved_chunks * 400ms) / per_tile; - return std::min(tiles_from_time, std::max(walk.moved_chunks, tiles_from_chunks)); - } - const Milliseconds moving = walk.walked - ROUTE_START_DELAY - - (walk.stop == WalkStop::BLOCKED ? 800ms : 0ms); - return moving.count() <= 0 ? (size_t)0 : (size_t)(moving / per_tile); -} - -// Tiles a walk on to the wall after a stop moved: none if no chunk moved. -// A push against someone still in the way reads as stopped late, and its -// time counted as tiles put a walk stopped 3 tiles in at its wall 17 tiles -// away (the sim of lab-B 2026-11-12 02:52). -size_t moved_on(const WalkResult& walk, Milliseconds per_tile){ - return walk.moved_chunks == 0 ? 0 : tiles_moved(walk, per_tile); -} - -// Whether a walk to the wall never moved: no chunk changed and its time -// counts no tile. It stopped where it began, so whoever stopped it stands -// on the next tile, however short the leg. On lab-B (2026-11-08 16:50, -// 01.08) Route 204's wandering youngster stood a tile ahead of "west 2 (to -// wall)" from (13, 2), and a replan from (12, 2) and (13, 2) found no plan: -// no wall is anchored from a tile someone wanders on. -bool never_moved(const WalkResult& walk, size_t walked_tiles){ - return walk.stop == WalkStop::BLOCKED && walk.moved_chunks == 0 && walked_tiles == 0; -} - -// Whether a walk to the wall that stopped took far longer than the tiles -// to its nearest wall `nearest` allow, past the walker's slack: two of its -// 400 ms chunks, or 30% of the tiles' time on a long leg. Something held -// it up on the way, and its time no longer counts tiles. On lab-B (2026-11-11 21:00, 00.05b) "east 8 (to wall)" stopped after 2800 ms -// against a boy below the Mart, about 5 tiles in, but the time counted 17. -bool held_up(const WalkResult& walk, size_t nearest, Milliseconds per_tile){ - if (walk.stop != WalkStop::BLOCKED || walk.wild_battles > 0){ - return false; - } - const Milliseconds tiles_time = per_tile * nearest; - const Milliseconds slack = std::max(800ms, tiles_time * 3 / 10); - // 800 ms: the two still chunks that read as stopped (tiles_moved()). - return walk.walked > ROUTE_START_DELAY + tiles_time + 800ms + slack; -} - -// Legs to a wall this many tiles or shorter must walk every tile: a tile -// short is someone in the way, not the time count's slack. On lab-B -// (2026-11-08, 01.08) Route 204's youngster stopped "west 2 (to wall)" -// after 1 tile; a tile short passed as at the wall, the route logged -// arriving at (11, 2) from (13, 2), and the taps north hit the cliff. -constexpr size_t EXACT_WALL_LEG_TILES = 3; - -// The fewest tiles a leg to a wall `expected_tiles` away must have walked -// to count as at its wall. -size_t min_tiles_at_wall(size_t expected_tiles){ - return expected_tiles > EXACT_WALL_LEG_TILES ? expected_tiles * 7 / 10 : expected_tiles; -} - // Whether a leg's walk goes on to the next leg or the route plans again. enum class LegNext{ NEXT_LEG, @@ -471,7 +413,7 @@ bool RouteWalker::slid_through_unseen(const LegWalk& walk){ if (walk.map_before != walk.map_after || !warp_within(m_grid, m_from, leg.direction, leg.tiles + WARP_SLIDE_TILES)){ return false; } - const std::string read = m_io.banner_within(BANNER_AFTER_SLIDE); + const std::string read = banner_within(m_io, BANNER_AFTER_SLIDE); if (!location_banner_is_another(read, walk.map_before)){ return false; } @@ -961,7 +903,7 @@ LegNext RouteWalker::after_leg(LegWalk& walk){ bool talking = walk.result.stop == WalkStop::DIALOG; if (!talking){ const Milliseconds wait = watching.empty() ? 500ms : 4000ms; - talking = m_io.dialog_within(wait, COLOR_YELLOW); + talking = dialog_within(m_io, wait, COLOR_YELLOW); } if (!talking){ m_from = walk.planned.after; @@ -1084,7 +1026,7 @@ LegNext RouteWalker::known_trainer(LegWalk& walk, const std::vector HEAR_OUT_PRESSES){ fail(m_io, std::format("{}: a talk no battle followed still showed after {} press-throughs.", leg_label, HEAR_OUT_PRESSES)); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedTalk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedTalk.cpp index 3a3b1ee3a6..c041c076bc 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedTalk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedTalk.cpp @@ -49,7 +49,7 @@ void talk_to_npc( side == Direction::EAST ? Direction::WEST : Direction::EAST; turn(io, face); io.press(press_a(RouteInputEnd::DONE)); - if (io.dialog_within(2000ms, COLOR_CYAN)){ + if (dialog_within(io, 2000ms, COLOR_CYAN)){ io.note(talk.label + ": talking from " + describe(maps, stand) + ".", RouteNote::STATUS); return; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp index 04ba865bd9..c740bbe10e 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.cpp @@ -65,15 +65,18 @@ void ConsoleRouteIO::press(const RouteInput& input){ press_route_input(m_context, input); } -bool ConsoleRouteIO::dialog_within(Milliseconds wait, Color color){ - ShortDialogWatcher dialog(color); - return wait_until(m_stream, m_context, wait, {{dialog}}) == 0; -} - -std::string ConsoleRouteIO::banner_within(Milliseconds wait){ - LocationBannerWatcher banner; - wait_until(m_stream, m_context, wait, {{banner}}); - return banner.seen(); +RouteSight ConsoleRouteIO::sight_within(const RouteWatch& watch){ + RouteSight sight; + if (watch.dialog){ + ShortDialogWatcher dialog(*watch.dialog); + sight.dialog = wait_until(m_stream, m_context, watch.wait, {{dialog}}) == 0; + } + if (watch.banner){ + LocationBannerWatcher banner; + wait_until(m_stream, m_context, watch.wait, {{banner}}); + sight.banner = banner.seen(); + } + return sight; } bool ConsoleRouteIO::holding_against_wall(Direction direction, const std::string& label){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h index 18d3f8efae..c2bd347b82 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteIO.h @@ -13,6 +13,7 @@ #define PokemonAutomation_PokemonBDSP_AutoStory_RouteIO_H #include +#include #include #include "Common/Cpp/Color.h" #include "Common/Cpp/Time.h" @@ -38,6 +39,20 @@ struct RouteWallWalk{ DpadWalkOptions options; }; +// What to watch for within a wait: a dialogue box (of the given color, for +// the game's text box), and/or the location banner. +struct RouteWatch{ + Milliseconds wait; + std::optional dialog = std::nullopt; + bool banner = false; +}; + +// What RouteWatch saw: whether the dialogue box showed, the banner read ("" if none). +struct RouteSight{ + bool dialog = false; + std::string banner; +}; + // How a line goes to the log. enum class RouteNote{ LOG, @@ -60,20 +75,15 @@ class RouteIO{ // Presses or waits (press_route_input()). virtual void press(const RouteInput& input) = 0; - // Whether a dialogue box shows within `wait`. - virtual bool dialog_within(Milliseconds wait, Color color) = 0; + // What shows within `watch.wait`. A door's fade can go by between two + // frames of a walk, and the banner of the map beyond shows a second or + // so after it. + virtual RouteSight sight_within(const RouteWatch& watch) = 0; // Holds the stick toward `direction` for 1.6 s, and returns whether the // screen changed less than walking would: we stand at a wall. virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) = 0; - // The location banner that shows within `wait`, "" if none. A door's - // fade can go by between two frames of a walk, and the banner of the - // map beyond shows a second or so after it. Nothing sees one by default. - virtual std::string banner_within(Milliseconds){ - return ""; - } - // Once the presses so far are done, shows `at` the screen, if there is one. virtual void look(const std::function& at) = 0; @@ -94,8 +104,7 @@ class ConsoleRouteIO : public RouteIO{ virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override; virtual WalkResult walk_taps(Pokemon::Direction direction, size_t tiles, const std::string& label) override; virtual void press(const RouteInput& input) override; - virtual bool dialog_within(Milliseconds wait, Color color) override; - virtual std::string banner_within(Milliseconds wait) override; + virtual RouteSight sight_within(const RouteWatch& watch) override; virtual bool holding_against_wall(Pokemon::Direction direction, const std::string& label) override; virtual void look(const std::function& at) override; virtual void note(const std::string& text, RouteNote kind) override; @@ -107,6 +116,16 @@ class ConsoleRouteIO : public RouteIO{ }; +// Whether a dialogue box shows within `wait`. +inline bool dialog_within(RouteIO& io, Milliseconds wait, Color color){ + return io.sight_within({.wait = wait, .dialog = color}).dialog; +} + +// The location banner that shows within `wait`, "" if none. +inline std::string banner_within(RouteIO& io, Milliseconds wait){ + return io.sight_within({.wait = wait, .banner = true}).banner; +} + } // namespace PokemonBDSP } // namespace NintendoSwitch diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp new file mode 100644 index 0000000000..938960afa6 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp @@ -0,0 +1,87 @@ +/* BDSP AutoStory - Wall leg count + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "PokemonBDSP_AutoStory_RouteTiming.h" +#include "PokemonBDSP_AutoStory_WallLegCount.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + +using namespace std::chrono_literals; + + +// Legs to a wall this many tiles or shorter must walk every tile: a tile +// short is someone in the way, not the time count's slack. On lab-B +// (2026-11-08, 01.08) Route 204's youngster stopped "west 2 (to wall)" +// after 1 tile; a tile short passed as at the wall, the route logged +// arriving at (11, 2) from (13, 2), and the taps north hit the cliff. +constexpr size_t EXACT_WALL_LEG_TILES = 3; + +// Tiles a walk to the wall moved, from the time it walked. +size_t tiles_moved(const WalkResult& walk, Milliseconds per_tile){ + if (walk.stop == WalkStop::LIMIT && walk.moved_chunks > 0){ + const Milliseconds moving = walk.walked - ROUTE_START_DELAY; + const size_t tiles_from_time = moving.count() <= 0 ? (size_t)0 : (size_t)(moving / per_tile); + const size_t tiles_from_chunks = (walk.moved_chunks * 400ms) / per_tile; + return std::min(tiles_from_time, std::max(walk.moved_chunks, tiles_from_chunks)); + } + const Milliseconds moving = walk.walked - ROUTE_START_DELAY - + (walk.stop == WalkStop::BLOCKED ? 800ms : 0ms); + return moving.count() <= 0 ? (size_t)0 : (size_t)(moving / per_tile); +} + +// Tiles a walk on to the wall after a stop moved: none if no chunk moved. +// A push against someone still in the way reads as stopped late, and its +// time counted as tiles put a walk stopped 3 tiles in at its wall 17 tiles +// away (the sim of lab-B 2026-11-12 02:52). +size_t moved_on(const WalkResult& walk, Milliseconds per_tile){ + return walk.moved_chunks == 0 ? 0 : tiles_moved(walk, per_tile); +} + +// Whether a walk to the wall never moved: no chunk changed and its time +// counts no tile. It stopped where it began, so whoever stopped it stands +// on the next tile, however short the leg. On lab-B (2026-11-08 16:50, +// 01.08) Route 204's wandering youngster stood a tile ahead of "west 2 (to +// wall)" from (13, 2), and a replan from (12, 2) and (13, 2) found no plan: +// no wall is anchored from a tile someone wanders on. +bool never_moved(const WalkResult& walk, size_t walked_tiles){ + return walk.stop == WalkStop::BLOCKED && walk.moved_chunks == 0 && walked_tiles == 0; +} + +// Whether a walk to the wall that stopped took far longer than the tiles +// to its nearest wall `nearest` allow, past the walker's slack: two of its +// 400 ms chunks, or 30% of the tiles' time on a long leg. Something held +// it up on the way, and its time no longer counts tiles. On lab-B (2026-11-11 21:00, 00.05b) "east 8 (to wall)" stopped after 2800 ms +// against a boy below the Mart, about 5 tiles in, but the time counted 17. +bool held_up(const WalkResult& walk, size_t nearest, Milliseconds per_tile){ + if (walk.stop != WalkStop::BLOCKED || walk.wild_battles > 0){ + return false; + } + const Milliseconds tiles_time = per_tile * nearest; + const Milliseconds slack = std::max(800ms, tiles_time * 3 / 10); + // 800 ms: the two still chunks that read as stopped (tiles_moved()). + return walk.walked > ROUTE_START_DELAY + tiles_time + 800ms + slack; +} + +// Legs to a wall this many tiles or shorter must walk every tile: a tile +// short is someone in the way, not the time count's slack. On lab-B +// (2026-11-08, 01.08) Route 204's youngster stopped "west 2 (to wall)" +// after 1 tile; a tile short passed as at the wall, the route logged +// arriving at (11, 2) from (13, 2), and the taps north hit the cliff. + +// The fewest tiles a leg to a wall `expected_tiles` away must have walked +// to count as at its wall. +size_t min_tiles_at_wall(size_t expected_tiles){ + return expected_tiles > EXACT_WALL_LEG_TILES ? expected_tiles * 7 / 10 : expected_tiles; +} + + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h new file mode 100644 index 0000000000..a10e94edd2 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h @@ -0,0 +1,43 @@ +/* BDSP AutoStory - Wall leg count + * + * From: https://github.com/PokemonAutomation/ + * + * What a walk to a wall that stopped says about the tiles it moved. + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_WallLegCount_H +#define PokemonAutomation_PokemonBDSP_AutoStory_WallLegCount_H + +#include "Common/Cpp/Time.h" +#include "PokemonBDSP_AutoStory_WalkResult.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +// Tiles a walk to the wall moved, from the time it walked. +size_t tiles_moved(const WalkResult& walk, Milliseconds per_tile); + +// Tiles a walk on to the wall after a stop moved: none if no chunk moved. +size_t moved_on(const WalkResult& walk, Milliseconds per_tile); + +// Whether a walk to the wall never moved: no chunk changed and its time +// counts no tile. It stopped where it began, so whoever stopped it stands +// on the next tile, however short the leg. +bool never_moved(const WalkResult& walk, size_t walked_tiles); + +// Whether a walk to the wall that stopped took far longer than the tiles +// to its nearest wall `nearest` allow, past the walker's slack. +bool held_up(const WalkResult& walk, size_t nearest, Milliseconds per_tile); + +// The fewest tiles a leg to a wall `expected_tiles` away must have walked +// to count as at its wall. +size_t min_tiles_at_wall(size_t expected_tiles); + + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp index b2f04f92ba..2e439def45 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp @@ -24,7 +24,7 @@ constexpr size_t MAX_FROZEN_FIGHTS = 3; WalkResult walk_fighting(RouteIO& io, RouteTrainers& trainers, std::optional facing, const RouteWallWalk& walk){ for (size_t fights = 0;; fights++){ const WalkResult result = walk_to_wall_turning(io, facing, walk); - if (fights == MAX_FROZEN_FIGHTS || result.stop != WalkStop::BLOCKED || !io.dialog_within(FROZEN_DIALOG_WAIT, COLOR_YELLOW)){ + if (fights == MAX_FROZEN_FIGHTS || result.stop != WalkStop::BLOCKED || !dialog_within(io, FROZEN_DIALOG_WAIT, COLOR_YELLOW)){ return result; } io.note(std::format("[Route] {}: a trainer froze us short of the wall; battling.", walk.label), RouteNote::WARNING); diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 1b41eee4ae..25156664aa 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1901,6 +1901,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkProbe.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkResult.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h + Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp + Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.cpp Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallWalk.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WildBattlePolicy.cpp From 2384e7815fe74acc1ff221dc70d84ba2f339f5ae Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 18:59:06 -0800 Subject: [PATCH 32/47] BDSP AutoStory: the wall leg count's constant goes with its functions into the header Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp | 7 ------- .../AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp index 938960afa6..3f405bd4a4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp @@ -15,13 +15,6 @@ namespace PokemonBDSP{ using namespace std::chrono_literals; -// Legs to a wall this many tiles or shorter must walk every tile: a tile -// short is someone in the way, not the time count's slack. On lab-B -// (2026-11-08, 01.08) Route 204's youngster stopped "west 2 (to wall)" -// after 1 tile; a tile short passed as at the wall, the route logged -// arriving at (11, 2) from (13, 2), and the taps north hit the cliff. -constexpr size_t EXACT_WALL_LEG_TILES = 3; - // Tiles a walk to the wall moved, from the time it walked. size_t tiles_moved(const WalkResult& walk, Milliseconds per_tile){ if (walk.stop == WalkStop::LIMIT && walk.moved_chunks > 0){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h index a10e94edd2..bdeddce487 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h @@ -17,6 +17,13 @@ namespace NintendoSwitch{ namespace PokemonBDSP{ +// Legs to a wall this many tiles or shorter must walk every tile: a tile +// short is someone in the way, not the time count's slack. On lab-B +// (2026-11-08, 01.08) Route 204's youngster stopped "west 2 (to wall)" +// after 1 tile; a tile short passed as at the wall, the route logged +// arriving at (11, 2) from (13, 2), and the taps north hit the cliff. +constexpr size_t EXACT_WALL_LEG_TILES = 3; + // Tiles a walk to the wall moved, from the time it walked. size_t tiles_moved(const WalkResult& walk, Milliseconds per_tile); From 73f04b6b3c56d9a42ad79bff34163fbb936544c2 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 19:40:52 -0800 Subject: [PATCH 33/47] BDSP walk: still persons are anchors on #432 too; goldens and the second greeter tile follow safe_tap uses recovery_hazard instead of the removed OccupancyUse. The plan and bench goldens are regenerated after the merge. With Mom and the still greeter as walls the walk past Jubilife's greeter replans west, so the second talk in the lab-B 07:44 test moves from (47, 29) to (45, 30) on the new path. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_WallRecovery.cpp | 2 +- .../AutoStory/Data/route_bench.golden.txt | 10 +++--- .../AutoStory/Data/route_plans.golden.txt | 34 +++++++++---------- ...emonBDSP_AutoStory_WallBattleSim_Tests.cpp | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_WallRecovery.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_WallRecovery.cpp index bf91d74f0c..ad44da5415 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_WallRecovery.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_WallRecovery.cpp @@ -79,7 +79,7 @@ bool safe_tap(const StoryWorld& world, const TilePos& from, Direction direction) const auto next = step(world, from, direction); const auto local = next ? world.to_local(*next) : std::nullopt; return map && next && *next == from.next(direction) && local && local->map == map->map && standable(world, *next) - && world.occupied(*next, StoryWorld::OccupancyUse::WALL_RECOVERY) != StoryWorld::PERSON; + && !recovery_hazard(world, *next); } // WallPolicy, with a tap where a hold has no wall for every position: a diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index f4b9f6dcb6..663c21842d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -28,7 +28,7 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.04 into_twinleaf | 10200 | 10200 | 10200 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 10200 ms (user's route) | PASS 00.04 to_moms_doorstep | 4100 | 4100 | 4100 | 0 | 0 | 0 | 5.47! | 1.00 | 1.00 | 750 ms (stand-in) | PASS 00.04 beside_mom | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS -00.04 into_moms_call | 2550 | 2550 | 2550 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 2550 ms (user's route) | PASS +00.04 into_moms_call | 3100 | 3100 | 3100 | 2 | 0 | 0 | 1.22 | 1.00 | 1.00 | 2550 ms (user's route) | PASS 00.04 short_of_the_catch_tutorial | 84406 | 81950 | 51250 | 7 | 19 | 7 | 4.76! | 1.00 | 62.00! | 17750 ms (stand-in) | PASS 00.04b to_catch_grass | 11689 | 38550 | 6300 | 2 | 34 | 1 | 17.98! | 17.50! | 2.00! | 650 ms (stand-in) | PASS 00.04b into_sandgem | 9520 | 19400 | 7050 | 3 | 12 | 0 | 2.93! | 4.33! | 1.00 | 3250 ms (stand-in) | PASS @@ -36,10 +36,10 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.05b below_the_presidents_trigger | 4900 | 4900 | 4900 | 0 | 0 | 0 | 5.76! | 1.00 | 1.00 | 850 ms (stand-in) | PASS 00.05b past_the_president | 1700 | 1700 | 1700 | 0 | 0 | 0 | 3.78! | 1.00 | 1.00 | 450 ms (stand-in) | PASS 00.05b below_the_mart_clown | 5450 | 5450 | 5450 | 1 | 0 | 0 | 3.30! | 1.00 | 1.00 | 1650 ms (stand-in) | PASS -00.05b below_the_tv_clown | 27500 | 27500 | 27500 | 0 | 0 | 0 | 6.32! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS +00.05b below_the_tv_clown | 24300 | 24300 | 24300 | 1 | 0 | 0 | 5.59! | 1.00 | 1.00 | 4350 ms (stand-in) | PASS 00.05b below_the_company_clown | 21900 | 21900 | 21900 | 0 | 0 | 0 | 6.74! | 1.00 | 3.00! | 3250 ms (stand-in) | PASS 00.05b beside_the_company_sign | 0 | 0 | 0 | 0 | 0 | 0 | 0.00 | 1.00 | 1.00 | 250 ms (stand-in) | PASS -00.05c beside_the_president | 38000 | 38000 | 38000 | 0 | 0 | 0 | 6.61! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS +00.05c beside_the_president | 30150 | 30150 | 30150 | 1 | 0 | 0 | 5.24! | 1.00 | 1.00 | 5750 ms (stand-in) | PASS 00.05c below_the_east_exit_sign | 12150 | 12150 | 12150 | 2 | 0 | 0 | 3.24! | 1.00 | 1.00 | 3750 ms (stand-in) | PASS 01.01 west_of_barrys_trigger | 7400 | 7400 | 7400 | 0 | 0 | 0 | 6.17! | 1.00 | 1.00 | 1200 ms (stand-in) | PASS 01.02 south_to_the_cliff | 1800 | 1800 | 1800 | 1 | 0 | 0 | 2.57! | 1.00 | 1.00 | 700 ms (stand-in) | PASS @@ -50,9 +50,9 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 01.02 west_of_the_welcome | 8550 | 8550 | 8550 | 2 | 0 | 0 | 9.00! | 1.00 | 4.00! | 950 ms (stand-in) | PASS 01.02b below_the_centers_door | 6663 | 8800 | 5950 | 2 | 1 | 0 | 2.38! | 2.00! | 2.00! | 2800 ms (stand-in) | PASS 01.03 above_the_mine | 16350 | 16350 | 16350 | 3 | 0 | 0 | 2.75! | 1.00 | 5.00! | 5950 ms (stand-in) | PASS -01.05 east_of_barrys_trigger | 26050 | 26050 | 26050 | 3 | 0 | 0 | 7.44! | 1.00 | 14.00! | 3500 ms (stand-in) | PASS +01.05 east_of_barrys_trigger | 19550 | 19550 | 19550 | 2 | 0 | 0 | 5.59! | 1.00 | 13.00! | 3500 ms (stand-in) | PASS 01.05 through_the_gate | 12050 | 12050 | 12050 | 5 | 0 | 0 | 4.92! | 1.00 | 27.00! | 2450 ms (stand-in) | PASS -01.06 up_jubilifes_road | 87286 | 119950 | 58350 | 3 | 10 | 4 | 7.66! | 2.20! | 20.00! | 11400 ms (stand-in) | PASS +01.06 up_jubilifes_road | 82607 | 94600 | 58350 | 3 | 10 | 4 | 7.25! | 2.20! | 20.00! | 11400 ms (stand-in) | PASS 01.06 below_rowans_trigger | 1950 | 1950 | 1950 | 1 | 0 | 0 | 2.29! | 1.00 | 1.00 | 850 ms (stand-in) | PASS 01.08 west_to_the_wall | 1650 | 1650 | 1650 | 1 | 0 | 0 | 3.00! | 1.00 | 1.00 | 550 ms (stand-in) | PASS 01.08 below_the_ravaged_path | 24815 | 26050 | 13700 | 2 | 9 | 0 | 4.24! | 1.00 | 6.00! | 5850 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 431271a183..0defd18f95 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -138,10 +138,10 @@ anchor); 0 from one start tile. from: PlayerHouse1F (11, 8) facing south (tile) target: PlayerHouse1F (6, 9) facing west (tile) start candidates: PlayerHouse1F (11, 8) - 1. west 1 (open) -> PlayerHouse1F (10, 8) - 2. south 1 (open) -> PlayerHouse1F (10, 9) - 3. west 4 (to wall) -> PlayerHouse1F (6, 9) - totals: 3 legs, 2 turns, 2 open, 0 localization + 1. west 3 (to wall) -> PlayerHouse1F (8, 8) + 2. south 1 (open) -> PlayerHouse1F (8, 9) + 3. west 2 (to wall) -> PlayerHouse1F (6, 9) + totals: 3 legs, 2 turns, 1 open, 0 localization == 00.04 short_of_the_catch_tutorial (costs: route) from: TwinleafTown (6, 22) (6, 23) facing west (set) @@ -229,9 +229,10 @@ anchor); 0 from one start tile. target: JubilifeCity (36, 17) facing north (tile) start candidates: Jubilife City (56, 31) 1. west 8 (open) -> Jubilife City (48, 31) - 2. north 14 (open) -> Jubilife City (48, 17) - 3. west 12 (open) -> Jubilife City (36, 17) - totals: 3 legs, 2 turns, 3 open, 0 localization + 2. north 7 (open) -> Jubilife City (48, 24) + 3. west 12 (open) -> Jubilife City (36, 24) + 4. north 7 (to wall) -> Jubilife City (36, 17) + totals: 4 legs, 3 turns, 3 open, 0 localization == 00.05b below_the_company_clown (costs: town) from: JubilifeCity (36, 17) facing north (tile) @@ -253,10 +254,10 @@ anchor); 0 from one start tile. target: JubilifeCity (45, 35) facing east (tile) start candidates: Jubilife City (14, 19) 1. south 4 (open) -> Jubilife City (14, 23) - 2. east 19 (open) -> Jubilife City (33, 23) - 3. south 12 (open) -> Jubilife City (33, 35) - 4. east 12 (open) -> Jubilife City (45, 35) - totals: 4 legs, 3 turns, 4 open, 0 localization + 2. east 18 (open) -> Jubilife City (32, 23) + 3. south 12 (open) -> Jubilife City (32, 35) + 4. east 13 (to wall) -> Jubilife City (45, 35) + totals: 4 legs, 3 turns, 3 open, 0 localization == 00.05c below_the_east_exit_sign (costs: line) from: JubilifeCity (45, 35) facing east (tile) @@ -351,12 +352,11 @@ anchor); 0 from one start tile. target: OreburghCity (7, 13) facing west (tile) start candidates: Oreburgh City (26, 21), Oreburgh City (26, 22) 1. south 5 (to wall) -> Oreburgh City (26, 26) - 2. west 2 (to wall) -> Oreburgh City (24, 26) - 3. north 5 (to wall) -> Oreburgh City (24, 21) - 4. west 9 (open) -> Oreburgh City (15, 21) - 5. north 8 (open) -> Oreburgh City (15, 13) - 6. west 8 (open) -> Oreburgh City (7, 13) - totals: 6 legs, 5 turns, 3 open, 1 localization + 2. north 1 (open) -> Oreburgh City (26, 25) + 3. west 14 (to wall) -> Oreburgh City (12, 25) + 4. north 12 (open) -> Oreburgh City (12, 13) + 5. west 5 (open) -> Oreburgh City (7, 13) + totals: 5 legs, 4 turns, 3 open, 1 localization == 01.05 through_the_gate (costs: route) from: OreburghGate (27, 22) (26, 22) facing west (set) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp index 812b024b04..3e6245d99c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp @@ -653,7 +653,7 @@ class Test_OpenLegTalkSim : public UnitTest{ const OpenLegTalkCase OPEN_LEG_TALK_SIM_CASES[] = { {.input = {.name = "with no tap counted", .talks = {{46, 29}}}, .expectation = {.arrives = true}}, - {.input = {.name = "with no tap counted, then again a tap on (lab-B, 2026-11-12 07:44)", .talks = {{46, 29}, {47, 29}}}, .expectation = {.arrives = true}}, + {.input = {.name = "with no tap counted, then again a tap on (lab-B, 2026-11-12 07:44)", .talks = {{46, 29}, {45, 30}}}, .expectation = {.arrives = true}}, }; } // namespace From ded52744c27a63e8bdcdc2a4b911ca4dd1f99d13 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 20:16:59 -0800 Subject: [PATCH 34/47] BDSP AutoStory: 00.04 into_moms_call back to 2550 ms on #432; the simulation's plan golden follows the anchors Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_bench.golden.txt | 2 +- .../PokemonBDSP_AutoStory_PlanGolden.h | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index 663c21842d..352e051528 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -28,7 +28,7 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 00.04 into_twinleaf | 10200 | 10200 | 10200 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 10200 ms (user's route) | PASS 00.04 to_moms_doorstep | 4100 | 4100 | 4100 | 0 | 0 | 0 | 5.47! | 1.00 | 1.00 | 750 ms (stand-in) | PASS 00.04 beside_mom | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS -00.04 into_moms_call | 3100 | 3100 | 3100 | 2 | 0 | 0 | 1.22 | 1.00 | 1.00 | 2550 ms (user's route) | PASS +00.04 into_moms_call | 2550 | 2550 | 2550 | 1 | 0 | 0 | 1.00 | 1.00 | 1.00 | 2550 ms (user's route) | PASS 00.04 short_of_the_catch_tutorial | 84406 | 81950 | 51250 | 7 | 19 | 7 | 4.76! | 1.00 | 62.00! | 17750 ms (stand-in) | PASS 00.04b to_catch_grass | 11689 | 38550 | 6300 | 2 | 34 | 1 | 17.98! | 17.50! | 2.00! | 650 ms (stand-in) | PASS 00.04b into_sandgem | 9520 | 19400 | 7050 | 3 | 12 | 0 | 2.93! | 4.33! | 1.00 | 3250 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index d08fd3dab5..22c38fe789 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -121,8 +121,9 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "00.05b east 8 (to wall) -> Jubilife City (56, 36)", "00.05b below_the_tv_clown costs=town from JubilifeCity (56, 31) to JubilifeCity (36, 17)", "00.05b west 8 (open) -> Jubilife City (48, 31)", - "00.05b north 14 (open) -> Jubilife City (48, 17)", - "00.05b west 12 (open) -> Jubilife City (36, 17)", + "00.05b north 7 (open) -> Jubilife City (48, 24)", + "00.05b west 12 (open) -> Jubilife City (36, 24)", + "00.05b north 7 (to wall) -> 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 21 (open) -> Jubilife City (15, 21)", @@ -130,8 +131,9 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "00.05b beside_the_company_sign costs=line from JubilifeCity (14, 19) to JubilifeCity (14, 19)", "00.05c beside_the_president costs=town from JubilifeCity (14, 19) to JubilifeCity (45, 35)", "00.05c south 4 (open) -> Jubilife City (14, 23)", - "00.05c east 31 (open) -> Jubilife City (45, 23)", - "00.05c south 12 (open) -> Jubilife City (45, 35)", + "00.05c east 18 (open) -> Jubilife City (32, 23)", + "00.05c south 12 (open) -> Jubilife City (32, 35)", + "00.05c east 13 (to wall) -> Jubilife City (45, 35)", "00.05c below_the_east_exit_sign costs=line from JubilifeCity (45, 35) to JubilifeCity (59, 21)", "00.05c north 9 (open) -> Jubilife City (45, 26)", "00.05c east 14 (to wall) -> Jubilife City (59, 26)", @@ -171,11 +173,10 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "01.03 east 3 (open) -> Oreburgh City (46, 57)", "01.05 east_of_barrys_trigger costs=town from OreburghCity (26, 21) (26, 22) to OreburghCity (7, 13)", "01.05 south 5 (to wall) -> Oreburgh City (26, 26)", - "01.05 west 2 (to wall) -> Oreburgh City (24, 26)", - "01.05 north 5 (to wall) -> Oreburgh City (24, 21)", - "01.05 west 9 (open) -> Oreburgh City (15, 21)", - "01.05 north 8 (open) -> Oreburgh City (15, 13)", - "01.05 west 8 (open) -> Oreburgh City (7, 13)", + "01.05 north 1 (open) -> Oreburgh City (26, 25)", + "01.05 west 14 (to wall) -> Oreburgh City (12, 25)", + "01.05 north 12 (open) -> Oreburgh City (12, 13)", + "01.05 west 5 (open) -> Oreburgh City (7, 13)", "01.05 through_the_gate costs=default from OreburghGate (27, 22) (26, 22) to OreburghGate (5, 22)", "01.05 north 2 (to wall) -> OreburghGate (27, 20) OreburghGate (26, 21)", "01.05 east 1 (to wall) -> OreburghGate (27, 20) OreburghGate (27, 21)", From 8a570a6422aaf8211b3aa7ed13d896f53849cf29 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 20:48:00 -0800 Subject: [PATCH 35/47] BDSP AutoStory: a recovery hold or probe that goes through a warp or keeps moving past the wall leaves the position unknown lab-B 2026-11-12 20:20, 01.02 past_curtis: the 'east 3 (to wall) to find us again' hold walked out of the Gate's east door (screen change 267, fade between frames) and was taken for found at (16, 22); every later leg ran in Oreburgh City. The walk now ends in TRANSITION on a scene change no battle follows, reads banners through that wait, find_again and the at-the-wall probe fail on another map's banner or on movement past the farthest wall, and a wall leg still moving at its limit fails. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- ...kemonBDSP_AutoStory_PlannedRoute_Tests.cpp | 143 ++++++++++++++++++ .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 29 +++- .../Utils/PokemonBDSP_AutoStory_Walk.cpp | 31 +++- .../PokemonBDSP_AutoStory_WallLegCount.cpp | 7 + .../PokemonBDSP_AutoStory_WallLegCount.h | 7 + 5 files changed, 208 insertions(+), 9 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 c8a5bc1b48..f559241a59 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp @@ -757,6 +757,125 @@ UnitTestResult test_wall_leg_one_chunk_is_a_turn_when_facing_is_unknown(Logger&) return never_moved ? UnitTestResult(true) : UnitTestResult(std::format("the turn counted as a moved chunk (step {}, {} notes): {}{}", script.next, script.notes.size(), walk.failure, joined_notes(script))); } +// lab-B 2026-11-12 20:22, 01.02 "east 4 (to wall)": the player had left the +// Gate unseen and ran on in Oreburgh City; the leg hit its time limit still +// moving (6 moved chunks), and the "at the wall?" probe walked on 4 chunks +// more. A leg that is still moving past the farthest wall the map has is +// not where the plan has us: the walk stops, and nothing walks further. +UnitTestResult test_wall_leg_still_moving_at_limit_is_unknown(Logger&){ + Script script{.steps = {walk_step("wall: T: east 4 (to wall)", WalkStop::LIMIT, 2050ms, 6)}}; + ScriptedWalk walk; + try{ + walk = walk_script(make_world({"#.....#"}), {1, 0}, {5, 0}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (walk.failure.find("position unknown") == std::string::npos){ + return "did not stop with the position unknown: \"" + walk.failure + "\""; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + +// The probe after a leg that ran out of time: one that is still moving +// (4 moved chunks in 2000 ms) is not at a wall, so nothing asks the +// holding check and nothing walks on. +UnitTestResult test_wall_check_still_moving_is_unknown(Logger&){ + Script script{.steps = { + walk_step("wall: T: east 4 (to wall)", WalkStop::LIMIT, 2050ms, 0), + walk_step("wall: T: east 4 (to wall): at the wall?", WalkStop::LIMIT, 2000ms, 4), + }}; + ScriptedWalk walk; + try{ + walk = walk_script(make_world({"#.....#"}), {1, 0}, {5, 0}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (walk.failure.find("position unknown") == std::string::npos){ + return "did not stop with the position unknown: \"" + walk.failure + "\""; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + +// A walk the banner of another map shows on, whatever its stop, went +// through a warp unseen. +ScriptStep through_a_warp_step(std::string call, WalkStop stop, Milliseconds walked, size_t moved){ + ScriptStep step = walk_step(std::move(call), stop, walked, moved); + step.walk.warp.banner = "Oreburgh City"; + return step; +} + +UnitTestResult test_wall_check_on_another_map_is_unknown(Logger&){ + Script script{.steps = { + walk_step("wall: T: east 4 (to wall)", WalkStop::LIMIT, 2050ms, 0), + through_a_warp_step("wall: T: east 4 (to wall): at the wall?", WalkStop::BLOCKED, 1200ms, 0), + }}; + ScriptedWalk walk; + try{ + walk = walk_script(make_world({"#.....#"}), {1, 0}, {5, 0}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (walk.failure.find("another map") == std::string::npos){ + return "did not stop on the other map's banner: \"" + walk.failure + "\""; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + +// lab-B 2026-11-12 20:20, 01.02 past_curtis: no plan from the tiles left +// after a battle, so the walk held east "to find us again", ran through the +// Gate's east door unseen (5 moved chunks, 1850 ms against a wall 2 tiles +// away) and took itself for found at the wall. It is not found. +UnitTestResult test_find_again_still_moving_is_unknown(Logger&){ + Script script{.steps = {walk_step("wall: T: east 2 (to wall) to find us again", WalkStop::LIMIT, 1850ms, 5)}}; + ScriptedWalk walk; + try{ + walk = walk_script(make_world({"#...#...#"}), {1, 0}, {7, 0}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (walk.failure.find("position unknown") == std::string::npos){ + return "did not stop with the position unknown: \"" + walk.failure + "\""; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + +UnitTestResult test_find_again_on_another_map_is_unknown(Logger&){ + Script script{.steps = {through_a_warp_step("wall: T: east 2 (to wall) to find us again", WalkStop::BLOCKED, 1200ms, 1)}}; + ScriptedWalk walk; + try{ + walk = walk_script(make_world({"#...#...#"}), {1, 0}, {7, 0}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (walk.failure.find("another map") == std::string::npos){ + return "did not stop on the other map's banner: \"" + walk.failure + "\""; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + +// The same hold when the walk does see the fade: a recovery hold toward a +// door ends in the next map, and the route does not go on as if it were +// still in the old one. +UnitTestResult test_find_again_through_a_door_is_unknown(Logger&){ + Script script{.steps = {walk_step("wall: T: east 2 (to wall) to find us again", WalkStop::TRANSITION, 1200ms, 3)}}; + ScriptedWalk walk; + try{ + walk = walk_script(make_world({"#...#...#"}), {1, 0}, {7, 0}, {}, script); + }catch (const ScriptMismatch& e){ + return e.message; + } + if (walk.failure.find("transition") == std::string::npos){ + return "did not stop on the transition: \"" + walk.failure + "\""; + } + const std::string left = script_left(script); + return left.empty() ? UnitTestResult(true) : UnitTestResult(left); +} + struct PlannedRouteInput{ std::string name; std::function body; @@ -844,6 +963,30 @@ const PlannedRouteCase PLANNED_ROUTE_CASES[] = { .input = {"a wall leg that stood at its wall among the start tiles does not fail (lab-B 2026-11-12 14:50)", test_wall_leg_at_its_wall_among_the_start_tiles}, .expectation = {}, }, + { + .input = {"a wall leg still moving at its time limit is not where the plan has us (lab-B 2026-11-12 20:22)", test_wall_leg_still_moving_at_limit_is_unknown}, + .expectation = {}, + }, + { + .input = {"the at-the-wall check still moving is not at a wall (lab-B 2026-11-12 20:22)", test_wall_check_still_moving_is_unknown}, + .expectation = {}, + }, + { + .input = {"the at-the-wall check on another map's banner went through a warp (lab-B 2026-11-12 20:22)", test_wall_check_on_another_map_is_unknown}, + .expectation = {}, + }, + { + .input = {"finding us again still moving is not found (lab-B 2026-11-12 20:20)", test_find_again_still_moving_is_unknown}, + .expectation = {}, + }, + { + .input = {"finding us again on another map's banner went through a warp (lab-B 2026-11-12 20:20)", test_find_again_on_another_map_is_unknown}, + .expectation = {}, + }, + { + .input = {"finding us again through a door ends in the next map (lab-B 2026-11-12 20:20)", test_find_again_through_a_door_is_unknown}, + .expectation = {}, + }, }; void add_tests_AutoStory_PlannedRoute(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index b391ed282d..472d0ca0c9 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -212,6 +212,7 @@ class RouteWalker{ private: std::optional> plan_legs(bool first) const; bool find_again(); + void fail_if_unknown(const WalkResult& walk, const std::string& label, size_t farthest, Milliseconds per_tile) const; LegNext walk_leg(const PlannedLeg& planned, size_t number, size_t count); std::vector arrive() const; @@ -353,6 +354,7 @@ bool RouteWalker::find_again(){ if (walk.stop != WalkStop::BLOCKED && walk.stop != WalkStop::LIMIT){ fail(m_io, label + ": " + walk_stop_name(walk.stop) + " instead of a wall."); } + fail_if_unknown(walk, label, farthest, route_ms_per_tile(direction, m_plan.speed)); const size_t walked = tiles_moved(walk, route_ms_per_tile(direction, m_plan.speed)); std::vector found; for (const WallHit& hit : hits){ @@ -373,6 +375,22 @@ bool RouteWalker::find_again(){ return false; } +// A walk that went through a warp unseen (the banner of another map shows +// on it) or kept moving well past the farthest wall the map has did not stop +// where the plan has us: its tiles are no longer known, and nothing walks on +// from them. +void RouteWalker::fail_if_unknown(const WalkResult& walk, const std::string& label, size_t farthest, Milliseconds per_tile) const{ + const std::string map = map_of(m_maps, m_from); + if (location_banner_is_another(walk.warp.banner, map)){ + fail(m_io, label + ": the location banner \"" + walk.warp.banner + "\" shows on a walk of " + map + + ": through a warp onto another map, position unknown."); + } + if (ran_past_the_wall(walk, farthest, per_tile)){ + fail(m_io, label + ": still moving after " + std::to_string(tiles_moved(walk, per_tile)) + " tiles, past the wall " + + std::to_string(farthest) + " tiles away at most: position unknown."); + } +} + LegNext RouteWalker::walk_leg(const PlannedLeg& planned, size_t number, size_t count){ m_io.note(route_leg_line(number, count, planned_route_leg(m_maps, planned)), RouteNote::STATUS); LegWalk walk{ @@ -467,8 +485,11 @@ LegNext RouteWalker::wall_leg(LegWalk& walk){ // does not know is in the way. Work out where we stopped from the time // walked, put it on our map and plan again from there. size_t nearest = SIZE_MAX; + size_t farthest = 0; for (const TilePos& pos : m_from){ - nearest = std::min(nearest, slide_to_wall(m_grid, pos, leg.direction).tiles); + const size_t tiles = slide_to_wall(m_grid, pos, leg.direction).tiles; + nearest = std::min(nearest, tiles); + farthest = std::max(farthest, tiles); } size_t walked_tiles = tiles_moved(walk.result, route_ms_per_tile(leg.direction, m_plan.speed)); // Every leg that reaches its wall measures the pace: the tiles are known. @@ -501,6 +522,8 @@ LegNext RouteWalker::wall_leg(LegWalk& walk){ // into the lab). Out of tall grass a stop reads, so walk on: a player // still moving is not where the plan has him. if (walk.result.stop == WalkStop::LIMIT && route_wall_readable(m_grid, walk.planned.after)){ + // Still moving past every wall the map has: not a slow start. + fail_if_unknown(walk.result, walk.label, farthest, route_ms_per_tile(leg.direction, m_plan.speed)); // A short leg a tile short stopped against someone in the way. if (nearest <= EXACT_WALL_LEG_TILES && walked_tiles < nearest){ return stopped_short_of_wall(walk, walked_tiles); @@ -722,6 +745,10 @@ LegNext RouteWalker::check_at_wall(LegWalk& walk, size_t walked_tiles, size_t ex // trainer, and failed on the "dialog"). check = walk.result; } + // A probe that kept moving, or showed another map's banner, is not at a wall. + if (walk.planned.leg.ends_at_wall){ + fail_if_unknown(check, walk.label + ": at the wall?", 0, route_ms_per_tile(walk.planned.leg.direction, m_plan.speed)); + } if (check.stop != WalkStop::BLOCKED && !(check.stop == WalkStop::LIMIT && m_io.holding_against_wall(walk.planned.leg.direction, walk.label + ": at the wall?")) ){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp index ee57909017..3575fd114d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp @@ -161,9 +161,14 @@ bool black_screen_was_battle(VideoStream& stream, ProControllerContext& context) // A grass encounter opens with a leaf animation, neither white nor black, and // shows the battle's text box a few seconds later. After a change of the // whole screen that walking cannot make, wait for the battle to show. -bool battle_follows(VideoStream& stream, ProControllerContext& context, Milliseconds wait = 5000ms){ +// `banner`, if given, keeps reading location banners through the wait: the +// banner of a map a fade took us to shows in it (lab-B 2026-11-12 20:20). +bool battle_follows(VideoStream& stream, ProControllerContext& context, Milliseconds wait = 5000ms, LocationBannerWatcher* banner = nullptr){ BattleMenuWatcher battle_menu(BattleType::STANDARD, COLOR_YELLOW); BattleDialogWatcher battle_dialog(COLOR_YELLOW); + if (banner != nullptr){ + return wait_until(stream, context, wait, {{battle_menu}, {battle_dialog}, {*banner}}) >= 0; + } return wait_until(stream, context, wait, {{battle_menu}, {battle_dialog}}) >= 0; } @@ -423,13 +428,23 @@ class WalkUntil{ const double change = walk_screen_change(*m_before.frame, *after.frame); m_stream.log("[Walk] " + m_spec.label + ": " + std::to_string(m_result.walked.count()) + "ms, screen change " + std::to_string(change) + "."); - if (change > WALK_SCENE_CHANGE && m_spec.wild == WildPolicy::STOP_AT && battle_follows(m_stream, m_context)){ - m_stream.log("[Walk] " + m_spec.label + ": a battle started; a trainer's here."); - return {ChunkNext::STOP, WalkStop::DIALOG}; - } - if (change > WALK_SCENE_CHANGE && battle_follows(m_stream, m_context)){ - escape_battle("wild battle (leaf opening); running.", BattleMovement::STEP_MOVED); - return {ChunkNext::NEXT_CHUNK, WalkStop::LIMIT}; + if (change > WALK_SCENE_CHANGE){ + const bool battle = battle_follows(m_stream, m_context, 5000ms, &m_banner); + m_result.warp.banner = m_banner.seen(); + if (battle){ + if (m_spec.wild == WildPolicy::STOP_AT){ + m_stream.log("[Walk] " + m_spec.label + ": a battle started; a trainer's here."); + return {ChunkNext::STOP, WalkStop::DIALOG}; + } + escape_battle("wild battle (leaf opening); running.", BattleMovement::STEP_MOVED); + return {ChunkNext::NEXT_CHUNK, WalkStop::LIMIT}; + } + // A change walking cannot make and no battle after it: a warp whose + // fade fell between two frames (lab-B 2026-11-12 20:20, a hold east + // through the Gate's door into Oreburgh City, screen change 267). + // The walk is over; the map it ran on is no longer the map it began on. + m_stream.log("[Walk] " + m_spec.label + ": the scene changed and no battle followed: through a warp, its fade unseen."); + return {ChunkNext::STOP, WalkStop::TRANSITION}; } // Two still chunks in a row, so one dropped frame does not stop us. A // frame exactly the same is a stalled video or a game hitch, not a wall: diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp index 3f405bd4a4..91293d4d6f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.cpp @@ -73,6 +73,13 @@ size_t min_tiles_at_wall(size_t expected_tiles){ return expected_tiles > EXACT_WALL_LEG_TILES ? expected_tiles * 7 / 10 : expected_tiles; } +bool ran_past_the_wall(const WalkResult& walk, size_t farthest, Milliseconds per_tile){ + if (walk.stop != WalkStop::LIMIT || walk.moved_chunks == 0){ + return false; + } + return tiles_moved(walk, per_tile) > farthest + std::max(3, farthest * 3 / 10); +} + } // namespace PokemonBDSP diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h index bdeddce487..d79242865b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WallLegCount.h @@ -43,6 +43,13 @@ bool held_up(const WalkResult& walk, size_t nearest, Milliseconds per_tile); // to count as at its wall. size_t min_tiles_at_wall(size_t expected_tiles); +// Whether a walk to the wall that ran out of time while still moving went +// clearly past the farthest wall the map has, `farthest` tiles away: at a +// wall it would have stopped. It is not where the plan has us (lab-B +// 2026-11-12 20:22, 01.02: the player had left the Gate unseen and kept +// running through Oreburgh City). +bool ran_past_the_wall(const WalkResult& walk, size_t farthest, Milliseconds per_tile); + } // namespace PokemonBDSP } // namespace NintendoSwitch From 8f06163a73856196140e07d642a6634c9e699e4a Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:32:29 -0800 Subject: [PATCH 36/47] BDSP AutoStory: 01.02's Gate routes leave by holding east to the door after any interruption lab-B 2026-11-12 21:01: camper_1 stopped the taps on (17, 22), the count read "blocked after 9 of 13", and the walk placed us a tile or two back, marked the beaten camper's tile and planned a six-leg loop round it; the hold to "find us again" then ran on to picnicker_0's line. In the Gate the only way on is the east door along row 22, so past_curtis and by_the_east_mouth (action "exit", leave east) end any interruption in a hold east, fighting what stops us, stepping round a wall, to the door's fade and banner; the step after takes the warp as done. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_plans.golden.txt | 4 +- .../PokemonBDSP_AutoStory_PlanGolden.h | 4 +- .../PokemonBDSP_AutoStory_StoryData.cpp | 11 +- .../PokemonBDSP_AutoStory_StoryExecutor.cpp | 2 +- .../PokemonBDSP_AutoStory_StoryExecutor.h | 3 +- ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 2 +- .../PokemonBDSP_AutoStory_StoryWalkSteps.cpp | 8 ++ ...emonBDSP_AutoStory_WallBattleSim_Tests.cpp | 108 ++++++++++++++++++ .../AutoStory/StoryData/bdsp-01.02.plan.json | 4 + .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 55 +++++++++ .../PokemonBDSP_AutoStory_PlannedRoute.h | 7 ++ 11 files changed, 199 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index ff221a927c..2cd7510453 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -302,14 +302,14 @@ anchor); 0 from one start tile. 3. north 1 (open) -> OreburghGate (6, 22) totals: 3 legs, 2 turns, 1 open, 2 localization -== 01.02 past_curtis (costs: route) +== 01.02 past_curtis (costs: exit) from: OreburghGate (7, 22) facing east (tile) target: OreburghGate (20, 22) facing east (tile) start candidates: OreburghGate (7, 22) 1. east 13 (open) -> OreburghGate (20, 22) totals: 1 legs, 0 turns, 1 open, 0 localization -== 01.02 by_the_east_mouth (costs: route) +== 01.02 by_the_east_mouth (costs: exit) from: OreburghGate (20, 22) facing east (tile) target: OreburghGate (26, 22) facing east (tile) start candidates: OreburghGate (20, 22) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index 22c38fe789..605d1a351f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -151,9 +151,9 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 past_curtis costs=exit 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 (26, 22)", + "01.02 by_the_east_mouth costs=exit from OreburghGate (20, 22) to OreburghGate (26, 22)", "01.02 east 6 (open) -> OreburghGate (26, 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)", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp index 5547e799e8..6af88323f2 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp @@ -89,6 +89,13 @@ void add_wanderer_talks(std::vector& actions){ .console_only = false, .certainty = certainty}); } +// ROUTE "exit": the room's way on is a door this way; a fight or a lost +// count on the way ends in a hold to the door, not a replan. +Pokemon::StoryArgSpec leave_arg(){ + return {.key = "leave", .type = Pokemon::StoryArgType::DIRECTION, .required = false, .fallback = std::nullopt, + .why = "the room's way on is a door this way"}; +} + std::vector make_bdsp_actions(){ std::vector actions( Pokemon::builtin_story_actions().begin(), Pokemon::builtin_story_actions().end() @@ -124,8 +131,8 @@ std::vector make_bdsp_actions(){ .fallback = std::nullopt, .why = "ground on the target's map to keep off: [x, y] tiles, [x0, y0, x1, y1] boxes"}; const Pokemon::StoryArgSpec opt_greeter{.key = "greeter", .type = Pokemon::StoryArgType::INTEGER_ROWS, .required = false, .fallback = std::nullopt, .why = "ground on the target's map where someone walks up and talks, then walks off: [x, y] tiles, [x0, y0, x1, y1] boxes"}; - for (std::string_view cost : {"town", "overworld", "indoors", "caves", "robust", "line", "trigger"}){ - actions.push_back({.kind = Pokemon::StoryStepKind::ROUTE, .name = std::string(cost), .args = {route_target, fight_wild, opt_legs, opt_avoid, opt_greeter}}); + for (std::string_view cost : {"town", "overworld", "indoors", "caves", "robust", "line", "trigger", "exit"}){ + actions.push_back({.kind = Pokemon::StoryStepKind::ROUTE, .name = std::string(cost), .args = {route_target, fight_wild, opt_legs, opt_avoid, opt_greeter, leave_arg()}}); } actions.push_back({.kind = Pokemon::StoryStepKind::ROUTE, .name = "into_scene", .args = {route_target, fight_wild, legs_arg}}); add_legs_actions(actions, legs_arg, fight_wild); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp index 4bfb37b98b..7e768356cb 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp @@ -66,7 +66,7 @@ using Pokemon::story_arg; std::optional story_route_costs(const std::string& action){ - if (action.empty() || action == ROUTE_ONTO_TRIGGER || action == ROUTE_INTO_SCENE || action == "route"){ + if (action.empty() || action == ROUTE_ONTO_TRIGGER || action == ROUTE_INTO_SCENE || action == "route" || action == "exit"){ return route_plan_costs(); } if (action == "town"){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h index 419d93af74..2170a0e0ad 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.h @@ -189,7 +189,8 @@ class StoryExecutor : public Pokemon::TableExecutor{ StoryEnv& m_env; ConsoleStoryStepIO m_io; // The steps that walk and talk, the table's rows for them: - // - ROUTE. Variant: the plan's costs ("" route, "town", "robust", "line"). + // - ROUTE. Variant: the plan's costs ("" route, "town", "robust", "line"; "exit" is route's with "leave": + // a fight or a lost count ends in a hold to the room's door that way). // - LEGS: each leg in D-pad taps, turning first. Variant "one_short_ok": // a leg may end a tile short (a door lined up by sight after). Variant // "to_wall": each leg walks until something stops it, for at most its 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 a4cfcb48f6..af36bc6a71 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -51,7 +51,7 @@ using Pokemon::story_arg; // The actions each kind does itself, besides the story's events. const std::map>& built_in_actions(){ static const std::map> actions{ - {StoryStepKind::ROUTE, {"", "route", "town", "robust", "line", std::string(ROUTE_ONTO_TRIGGER), std::string(ROUTE_INTO_SCENE)}}, + {StoryStepKind::ROUTE, {"", "route", "town", "robust", "line", "exit", std::string(ROUTE_ONTO_TRIGGER), std::string(ROUTE_INTO_SCENE)}}, {StoryStepKind::LEGS, {"", "legs", "one_short_ok", "to_wall", "to_dialogue", "to_map", "counted_wall", "measured"}}, {StoryStepKind::STEP, {"", "face", "to_banner", "tap", "or_legs"}}, {StoryStepKind::MASH, {"", "a"}}, {StoryStepKind::BATTLE, {"", "fight", "doubles", "starter"}}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp index 66565cd374..cd3b7054cc 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp @@ -257,6 +257,7 @@ Pose StoryWalkSteps::walk_to(const Pose& from, const Pose& goal, const StoryStep [&](const TilePos& pos){ return std::find(targets.begin(), targets.end(), pos) != targets.end(); }, label_of(step), story_route_tiles(*maps, step, "avoid"), *costs, m_can_run ? MoveSpeed::RUN : MoveSpeed::WALK, m_scene_next.contains(step.name), step.action == ROUTE_ONTO_TRIGGER, story_route_tiles(*maps, step, "greeter"), + step.args.contains("leave") ? std::optional(story_arg(step.args, "leave")) : std::nullopt, }; RouteEnd end = walk_route_to_warp(m_route, *maps, start, trainers, plan); sights = std::move(trainers.sights); @@ -275,6 +276,13 @@ Pose StoryWalkSteps::walk_to(const Pose& from, const Pose& goal, const StoryStep Outcome StoryWalkSteps::route(RunState& state, const StoryStep& step){ const EventTrace trace(m_legs, m_row, step.name); + // A route before this one left the room through its door (RouteWalkPlan:: + // leave_toward): the way here is walked, and the step after the routes + // takes the warp as done. + if (step.args.contains("leave") && m_warp.any()){ + log(std::format("[{}] {}: already through the door the walk before left by.", m_row, step.name)); + return Pokemon::outcome_ok(state.pose); + } m_warp = {}; if (Pokemon::tiles_of(state.pose).empty()){ return Pokemon::outcome_failed("no_pose", Pokemon::to_string(state.pose)); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp index 3e6245d99c..fcc990e132 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_WallBattleSim_Tests.cpp @@ -656,10 +656,118 @@ const OpenLegTalkCase OPEN_LEG_TALK_SIM_CASES[] = { {.input = {.name = "with no tap counted, then again a tap on (lab-B, 2026-11-12 07:44)", .talks = {{46, 29}, {45, 30}}}, .expectation = {.arrives = true}}, }; +// lab-B 2026-11-12 21:01, 01.02 past_curtis: camper_1's sight on column 17 +// stopped the taps on (17, 22), and the count read "blocked after 9 of 13" +// with the dialogue on the next tap: the walk placed us a tile or two back, +// marked the beaten camper's tile, and planned a loop round it. In the Gate +// the only way on is the east door along row 22, so any fight on the way +// ends in a hold east to the door's fade, fighting what stops us on the way +// (picnicker_0 on column 24). +class DialogOnNextTapIO : public GridSimRouteIO{ +public: + using GridSimRouteIO::GridSimRouteIO; + virtual WalkResult walk_taps(Direction direction, size_t tiles, const std::string& label) override{ + if (m_dialog_next){ + m_dialog_next = false; + return {.stop = WalkStop::DIALOG, .walked = 800ms, .wild_battles = 0, .moved_chunks = 0}; + } + WalkResult result = GridSimRouteIO::walk_taps(direction, tiles, label); + if (result.stop == WalkStop::DIALOG){ + result.stop = WalkStop::BLOCKED; + result.moved_chunks = result.moved_chunks > 0 ? result.moved_chunks - 1 : 0; + m_dialog_next = true; + } + return result; + } + +private: + bool m_dialog_next = false; +}; + +std::string leave_the_gate_by_the_east_door(Logger& logger, bool leave){ + const StoryWorld* world = story_plan_world("OreburghGate", "OreburghGate"); + if (world == nullptr){ + return "no OreburghGate world."; + } + // The Gate's trainers, as the game has them; the walk's map lists none + // of them (map_trainers() has no OreburghGate), so they are people it lacks. + const std::vector gate_trainers{ + {.name = "camper_1", .pos = story_to_world(*world, "OreburghGate", {17, 25}), .facing = Direction::NORTH, .range = 4}, + {.name = "picnicker_0", .pos = story_to_world(*world, "OreburghGate", {24, 21}), .facing = Direction::SOUTH, .range = 2}, + }; + const TilePos start = story_to_world(*world, "OreburghGate", {7, 22}); + const TilePos target = story_to_world(*world, "OreburghGate", {20, 22}); + GridSim sim({.world = world, .trainers = gate_trainers, .triggers = {}}, start, Direction::EAST, true); + std::vector notes; + DialogOnNextTapIO io(sim, notes); + std::vector fought; + RouteTrainers trainers{{}, [&](const std::string& name){ + fought.push_back(name); + sim.end_dialogue(); + return true; + }}; + RouteEnd end; + std::string error; + try{ + end = walk_route_to_warp(io, *world, {start}, trainers, {.goal = [&](const TilePos& pos){ return pos == target; }, + .label = "past curtis", .costs = *story_route_costs("town"), .speed = MoveSpeed::RUN, + .leave_toward = leave ? std::optional(Direction::EAST) : std::nullopt}); + }catch (const GridSimFailure& e){ + error = e.message; + } + for (const std::string& note : notes){ + logger.log(note); + } + if (!error.empty()){ + return error; + } + if (!end.warp.any() || !sim.player().warped){ + return std::format("did not leave by the east door: ended on {} after {} fight(s).", + describe(*world, nearest_tile(sim.player().pos)), fought.size()); + } + return fought.size() >= 2 ? "" : std::format("left after {} fight(s), not camper_1 and picnicker_0.", fought.size()); +} + +struct GateEastOutInput{ + std::string name; +}; +struct GateEastOutExpectation{ + bool leaves; +}; +struct GateEastOutCase{ + GateEastOutInput input; + GateEastOutExpectation expectation; +}; + +class Test_GateEastOut : public UnitTest{ +public: + explicit Test_GateEastOut(GateEastOutCase test_case) + : UnitTest("PokemonBDSP::AutoStory - Grid sim: 01.02 past_curtis, " + test_case.input.name) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const std::string error = leave_the_gate_by_the_east_door(logger, true); + if (error.empty() != m_case.expectation.leaves){ + return error.empty() ? "left" : error; + } + return true; + } + +private: + GateEastOutCase m_case; +}; + +const GateEastOutCase GATE_EAST_OUT_CASES[] = { + {.input = {.name = "a fight in the Gate ends in a hold east through the door (lab-B 2026-11-12 21:01)"}, .expectation = {.leaves = true}}, +}; + } // namespace void add_tests_AutoStory_WallBattleSim(UnitTestDatabase& database){ + for (const GateEastOutCase& item : GATE_EAST_OUT_CASES){ + database.add(item); + } for (const OpenLegTalkCase& item : OPEN_LEG_TALK_SIM_CASES){ database.add(item); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json index fdcd1d665f..647a4a2e1f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json @@ -112,8 +112,10 @@ "why": "HM Rock Smash, then the Hidden Moves card" }, { + "action": "exit", "args": { "fight_wild": false, + "leave": "east", "target": { "facing": "east", "map": "OreburghGate", @@ -130,8 +132,10 @@ "why": "east along row 22 past Camper Curtis's column (17), fighting him" }, { + "action": "exit", "args": { "fight_wild": false, + "leave": "east", "target": { "facing": "east", "map": "OreburghGate", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp index 472d0ca0c9..692d677965 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.cpp @@ -158,6 +158,12 @@ constexpr size_t WARP_SLIDE_TILES = 2; // banner of the map beyond: it shows about 1.5 s after the fade. constexpr Milliseconds BANNER_AFTER_SLIDE = 2500ms; +// The way out (RouteWalkPlan::leave_toward): a hold timed for this many +// tiles (a room's width), and at most this many holds, each ended by a +// fight or a wall stepped round. +constexpr size_t LEAVE_TILES = 30; +constexpr size_t LEAVE_HOLDS = 8; + // One planned leg as it is walked: where it goes, and the location // banners read on the way. struct LegWalk{ @@ -212,6 +218,7 @@ class RouteWalker{ private: std::optional> plan_legs(bool first) const; bool find_again(); + bool leave_toward_the_door(); void fail_if_unknown(const WalkResult& walk, const std::string& label, size_t farthest, Milliseconds per_tile) const; LegNext walk_leg(const PlannedLeg& planned, size_t number, size_t count); std::vector arrive() const; @@ -286,6 +293,12 @@ RouteEnd RouteWalker::run(std::vector from){ for (size_t plans = 0; plans < 8; plans++){ const std::optional> planned = plan_legs(plans == 0); if (!planned){ + if (m_plan.leave_toward){ + if (!leave_toward_the_door()){ + fail(m_io, m_plan.label + ": no plan from " + describe(m_maps, m_from) + "."); + } + return {m_from, m_warp, false}; + } if (!find_again()){ fail(m_io, m_plan.label + ": no plan from " + describe(m_maps, m_from) + "."); } @@ -301,6 +314,9 @@ RouteEnd RouteWalker::run(std::vector from){ if (next != LegNext::REPLAN){ return {next == LegNext::NEXT_LEG ? arrive() : m_from, m_warp, next == LegNext::SCENE}; } + if (m_plan.leave_toward && leave_toward_the_door()){ + return {m_from, m_warp, false}; + } } fail(m_io, m_plan.label + ": too many plans."); } @@ -375,6 +391,45 @@ bool RouteWalker::find_again(){ return false; } +// The way out for a plan with RouteWalkPlan::leave_toward: hold that way +// to the door, from wherever we are. A fight on the way (a trainer's sight +// line crosses the row) is fought and the hold goes on; a wall in the way +// is stepped round, a tile north or south, and the hold goes on. The end +// is the door's fade (or the next map's banner); the time running out with +// neither fails. Returns true once through (m_warp has what was seen). +bool RouteWalker::leave_toward_the_door(){ + const Direction toward = *m_plan.leave_toward; + const std::string map = map_of(m_maps, m_from); + const TileLeg leg{.direction = toward, .tiles = LEAVE_TILES, .ends_at_wall = true, .held = false}; + Direction sidestep = Direction::NORTH; + for (size_t hold = 0; hold < LEAVE_HOLDS; hold++){ + const std::string label = m_plan.label + ": " + direction_name(toward) + " out of " + map; + m_io.note("[Route] " + label + ": holding to the door; position not replanned.", RouteNote::WARNING); + const WalkResult walk = m_io.walk_to_wall({.direction = toward, .limit = wall_limit(leg), .label = label, + .options = {.arrived = nullptr, .pace = DpadPace::RUN}}); + if (walk.stop == WalkStop::TRANSITION || location_banner_is_another(walk.warp.banner, map)){ + m_warp = walk.warp; + if (m_warp.banner.empty()){ + m_warp.banner = banner_within(m_io, BANNER_AFTER_SLIDE); + } + m_io.note("[Route] " + label + ": through the door (" + describe(m_warp) + "); handing over.", RouteNote::WARNING); + return true; + } + if (walk.stop == WalkStop::DIALOG){ + m_io.note(m_plan.label + ": a trainer stopped us on the way out; fighting.", RouteNote::STATUS); + m_trainers.fight("trainer on the way out"); + continue; + } + if (walk.stop == WalkStop::BLOCKED){ + m_io.walk_taps(sidestep, 1, label + ": round"); + sidestep = sidestep == Direction::NORTH ? Direction::SOUTH : Direction::NORTH; + continue; + } + fail(m_io, label + ": " + walk_stop_name(walk.stop) + " with no door's fade seen."); + } + fail(m_io, m_plan.label + ": held " + direction_name(toward) + " " + std::to_string(LEAVE_HOLDS) + " times and never got through the door."); +} + // A walk that went through a warp unseen (the banner of another map shows // on it) or kept moving well past the farthest wall the map has did not stop // where the plan has us: its tiles are no longer known, and nothing walks on diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.h index 3a62bcd0df..df20e74525 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_PlannedRoute.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include "CommonFramework/Tools/VideoStream.h" @@ -69,6 +70,12 @@ struct RouteWalkPlan{ // explains while we may stand here is theirs: played out and walked on // from, not counted against the walk as a scene the map lacks. std::vector greeter = {}; + // The way out of a room whose one way on is a door in this direction + // (01.02's Oreburgh Gate: row 22 runs open to the east door). Anything + // that interrupts the walk (a fight, a talk, a count that no longer + // fits the map) ends it by holding this way to the door's fade and + // banner, with no plan around what stopped us (lab-B 2026-11-12 21:02). + std::optional leave_toward = std::nullopt; // Whether any of `tiles` is the greeter's ground. bool greeter_near(const std::vector& tiles) const{ From ae2c18f6e7b2cc012518b2e58c47cf4947f76980 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:56:16 -0800 Subject: [PATCH 37/47] wip-plan --- .../AutoStory/StoryData/bdsp-01.02.plan.json | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json index 647a4a2e1f..735635e39f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-01.02.plan.json @@ -71,30 +71,33 @@ "why": "the Gate's west mouth (56, 9)" }, { + "action": "into_scene", "args": { "fight_wild": false, + "legs": [ + { + "direction": "east", + "tiles": 6 + } + ], "target": { "facing": "east", "map": "OreburghGate", "tiles": [ [ - 6, + 4, + 22 + ], + [ + 5, 22 ] ] } }, - "id": "west_of_the_hikers_trigger", + "id": "into_the_hikers_scene", "kind": "route", - "why": "east along row 22" - }, - { - "args": { - "direction": "east" - }, - "id": "hikers_trigger", - "kind": "step", - "why": "the trigger (7, 22): the Hiker walks down to us" + "why": "east along row 22 until the hikers' scene starts (trigger (7, 22))" }, { "declared_after": { @@ -175,30 +178,33 @@ "why": "the Gate's east mouth (28, 22)" }, { + "action": "into_scene", "args": { "fight_wild": false, + "legs": [ + { + "direction": "east", + "tiles": 12 + } + ], "target": { "facing": "east", "map": "OreburghCity", "tiles": [ [ - 9, + 2, + 13 + ], + [ + 3, 13 ] ] } }, - "id": "west_of_the_welcome", + "id": "into_the_welcome_scene", "kind": "route", - "why": "east along row 13" - }, - { - "args": { - "direction": "east" - }, - "id": "welcome_trigger", - "kind": "step", - "why": "the trigger (10, 12..15): the man walks over" + "why": "east along row 13 until the welcome guide's scene starts (trigger (10, 12..15))" }, { "declared_after": { From d995740a00c5e5a22f2ab479982732b757908f2a Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 21:59:29 -0800 Subject: [PATCH 38/47] BDSP AutoStory: 01.02 scenes walked into, mine doors settle as doors, Potion reads HP before the search wip --- .../PokemonBDSP_AutoStory_Actions_Tests.cpp | 26 +++++++ .../Actions/PokemonBDSP_AutoStory_Bag.cpp | 43 ++++++++---- .../Actions/PokemonBDSP_AutoStory_BagScreen.h | 13 ++++ .../PokemonBDSP_AutoStory_StoryData.cpp | 1 + ...PokemonBDSP_AutoStory_StoryTable_Tests.cpp | 70 ++++++++++++++++++- .../PokemonBDSP_AutoStory_StoryWalkSteps.cpp | 8 ++- ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 25 +++++++ .../StoryData/bdsp-mine-01.03.plan.json | 4 ++ 8 files changed, 173 insertions(+), 17 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Actions_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Actions_Tests.cpp index 7efb46838c..b328d00fe2 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Actions_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Actions_Tests.cpp @@ -26,6 +26,7 @@ #include "PokemonBDSP/Programs/AutoStory/Detect/PokemonBDSP_AutoStory_BattleMenuReader.h" #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.h" #include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_StoryLanguage.h" +#include "PokemonBDSP_AutoStory_BagScreen.h" #include "PokemonBDSP_AutoStory_BattleMoves.h" #include "PokemonBDSP_AutoStory_Center.h" #include "PokemonBDSP_AutoStory_Events.h" @@ -562,6 +563,27 @@ UnitTestResult test_move_menu_screenshots(Logger& logger){ } +// The Potion after a fight reads the lead's HP when the Bag opens and goes +// on to the pocket and the list only if a dose is needed (lab-B 2026-11-12: +// it found the Potion, opened the party, read 80% and "no Potion needed"). +UnitTestResult test_potion_need(Logger&){ + struct Case{ std::string_view name; double hp; size_t dose; PotionNeed need; }; + const Case cases[] = { + {"full HP", 1.0, 0, PotionNeed::FULL}, + {"80% on the first dose with the check at 80%", 0.80, 0, PotionNeed::ENOUGH}, + {"a bit over the check", 0.90, 0, PotionNeed::ENOUGH}, + {"under the check", 0.55, 0, PotionNeed::NEEDED}, + {"the second dose heals on until full", 0.85, 1, PotionNeed::NEEDED}, + {"fainted", 0.0, 0, PotionNeed::FAINTED}, + }; + for (const Case& c : cases){ + if (potion_need(c.hp, c.dose, 0.8) != c.need){ + return std::string(c.name) + ": wrong verdict."; + } + } + return true; +} + struct AutoStoryActionsInput{ std::string name; std::function body; @@ -597,6 +619,10 @@ class Test_AutoStoryActions : public UnitTest{ const AutoStoryActionsCase AUTO_STORY_ACTIONS_CASES[] = { + { + .input = {"Potion after a fight: the lead's HP decides before the Bag is searched", test_potion_need}, + .expectation = {}, + }, { .input = {"new-game intro decisions", test_intro_decisions}, .expectation = {}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp index 35ad278940..5e76a53bb2 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_Bag.cpp @@ -201,30 +201,35 @@ enum class Dose{ HEALED, GIVEN, NONE_LEFT }; // One Potion on the lead, from the overworld, its HP read before and after // in the Bag. HEALED when no dose is needed (HP full, or above -// `heal_below` on the first look, or no Potion when only checking) or the +// `heal_below` on the first look) or the // dose filled it; GIVEN when HP rose but is not full yet. Dose potion_dose(VideoStream& stream, ProControllerContext& context, size_t dose, double heal_below){ - stream.log("[Potion] Finding Bag/Medicine/Potion; dose " + std::to_string(dose + 1) + "/3."); - if (!find_bag_item_by_name(stream, context, "potion", 1, 5)){ - // No Potion left is not a failure: the next Center heals. After Roark - // the one Potion went on the first dose and the second found the - // Medicine pocket empty (lab-B, 2026-11-08 15:26). - stream.log("[Potion] No Potion left in the Bag after " + std::to_string(dose) + " dose(s); going on.", COLOR_ORANGE); - return Dose::NONE_LEFT; - } + stream.log("[Potion] Opening the Bag; dose " + std::to_string(dose + 1) + "/3."); + // The lead's HP shows as soon as the Bag opens: read it before the + // pocket is walked and the list scanned for a Potion nobody needs. + open_menu(stream, context, MenuCursorPosition::BAG, 5); + pbf_wait(context, 1000ms); const double before = confirmed_potion_hp(stream, context); stream.log("[Potion] Slot 1 HP bar before use=" + std::to_string(before * 100) + "%."); - if (before >= 0.98){ + switch (potion_need(before, dose, heal_below)){ + case PotionNeed::FULL: return Dose::HEALED; - } - if (dose == 0 && before >= heal_below){ + case PotionNeed::ENOUGH: stream.log("[Potion] Slot 1 HP is at least " + std::to_string(heal_below * 100) + "%; no Potion needed."); return Dose::HEALED; - } - if (before <= 0.005){ + case PotionNeed::FAINTED: OperationFailedExceptionWithScreenshot::fire(ErrorReportMode::SEND_ERROR_REPORT, "Potion: Slot 1 appears fainted; a Potion cannot revive it.", stream); + case PotionNeed::NEEDED: + break; + } + if (!find_bag_item_in_open_bag(stream, context, "potion", 1)){ + // No Potion left is not a failure: the next Center heals. After Roark + // the one Potion went on the first dose and the second found the + // Medicine pocket empty (lab-B, 2026-11-08 15:26). + stream.log("[Potion] No Potion left in the Bag after " + std::to_string(dose) + " dose(s); going on.", COLOR_ORANGE); + return Dose::NONE_LEFT; } pbf_press_button(context, BUTTON_A, 80ms, 500ms); pbf_press_button(context, BUTTON_A, 80ms, 500ms); @@ -326,6 +331,16 @@ bool bag_list_is_empty(const ImageViewRGB32& frame){ return stats.average.r > 220 && stats.average.g > 220 && stats.average.b > 220 && stats.stddev.sum() < 20; } +PotionNeed potion_need(double hp, size_t dose, double heal_below){ + if (hp >= 0.98){ + return PotionNeed::FULL; + } + if (dose == 0 && hp >= heal_below){ + return PotionNeed::ENOUGH; + } + return hp <= 0.005 ? PotionNeed::FAINTED : PotionNeed::NEEDED; +} + BagPocketMovePlan plan_bag_pocket_move(int current, int target){ if (current < 1 || current > 8 || target < 1 || target > 8){ return {}; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagScreen.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagScreen.h index 10b3f3bacd..c402094232 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagScreen.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Actions/PokemonBDSP_AutoStory_BagScreen.h @@ -41,6 +41,19 @@ struct BagPocketMovePlan{ BagPocketMovePlan plan_bag_pocket_move(int current, int target); +// What a first look at the lead's HP says about a Potion. +enum class PotionNeed{ + FULL, // nothing to heal + ENOUGH, // on the first dose, at or above `heal_below`: no Potion needed + FAINTED, // a Potion cannot revive it + NEEDED, +}; +// Whether the lead at `hp` (a fraction of full) needs dose number `dose` +// (0 first) of a Potion. Read before the Bag's pocket is walked for the +// Potion: no search when none is needed. +PotionNeed potion_need(double hp, size_t dose, double heal_below); + + } // namespace PokemonBDSP } // namespace NintendoSwitch } // namespace PokemonAutomation diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp index 6af88323f2..690b1c1184 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp @@ -137,6 +137,7 @@ std::vector make_bdsp_actions(){ actions.push_back({.kind = Pokemon::StoryStepKind::ROUTE, .name = "into_scene", .args = {route_target, fight_wild, legs_arg}}); add_legs_actions(actions, legs_arg, fight_wild); actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "to_banner", .args = {direction_arg}, .console_only = false, .certainty = PINS}); + actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "door", .args = {direction_arg}}); actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "or_legs", .args = {direction_arg, legs_arg}}); add_wanderer_talks(actions); actions.push_back({.kind = Pokemon::StoryStepKind::MASH, .name = "a", .args = {}}); 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 af36bc6a71..c9a2140993 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryTable_Tests.cpp @@ -53,7 +53,7 @@ const std::map>& built_in_actions(){ static const std::map> actions{ {StoryStepKind::ROUTE, {"", "route", "town", "robust", "line", "exit", std::string(ROUTE_ONTO_TRIGGER), std::string(ROUTE_INTO_SCENE)}}, {StoryStepKind::LEGS, {"", "legs", "one_short_ok", "to_wall", "to_dialogue", "to_map", "counted_wall", "measured"}}, - {StoryStepKind::STEP, {"", "face", "to_banner", "tap", "or_legs"}}, {StoryStepKind::MASH, {"", "a"}}, + {StoryStepKind::STEP, {"", "face", "to_banner", "tap", "or_legs", "door"}}, {StoryStepKind::MASH, {"", "a"}}, {StoryStepKind::BATTLE, {"", "fight", "doubles", "starter"}}, {StoryStepKind::TALK, {"", "talk_to_wanderer", "wait_for_wanderer"}}, {StoryStepKind::SHOP, {"", "sandgem_potions"}}, @@ -136,6 +136,66 @@ UnitTestResult test_story_table_rows_join(Logger&){ return true; } +// 01.02: a scene's trigger on an open row is reached by walking toward it +// until the scene starts, not by a localizing detour (south, east to a +// rock, north) to a tile beside the trigger and a step onto it (the +// user's rule, 2026-11-12). The Gate's hikers (trigger (7, 22)) and the +// city's welcome guide (trigger (10, 12..15)) are each one "into_scene" +// route that runs east along the row it arrives on. +UnitTestResult test_oreburgh_scenes_are_walked_into(Logger&){ + for (const StoryCheckpoint& row : story_checkpoints()){ + if (row.id != "01.02"){ + continue; + } + size_t found = 0; + for (size_t i = 0; i < row.steps.size(); i++){ + const Pokemon::StoryStep& step = row.steps[i]; + if (step.name.starts_with("west_of_") || step.name.ends_with("_trigger") || step.name == "welcome_trigger"){ + return std::format("{} {}: a detour to land beside the trigger.", row.id, step.name); + } + if (step.name != "the_hiker" && step.name != "oreburgh_welcome"){ + continue; + } + found++; + const Pokemon::StoryStep& walk = row.steps[i - 1]; + if (walk.kind != StoryStepKind::ROUTE || walk.action != ROUTE_INTO_SCENE){ + return std::format("{}: the step before is {}, not an into_scene route.", step.name, walk.name); + } + const auto& legs = story_arg>(walk.args, "legs"); + if (legs.size() != 1 || legs.front().direction != Direction::EAST){ + return std::format("{}: {} does not run one leg east.", step.name, walk.name); + } + } + return found == 2 ? UnitTestResult(true) : UnitTestResult("01.02 has no hikers and welcome scenes."); + } + return "No 01.02."; +} + +// 01.03's doors into and out of the mine have no text on the far side: they +// settle as a door (the fade back up and a short still spell), not by B +// through the cave's ambient motion for 15 s (lab-B 2026-11-12 21:57, +// into_the_mine 18 s and into_the_coal_room 16.7 s). +UnitTestResult test_mine_doors_settle_as_doors(Logger&){ + for (const StoryCheckpoint& row : story_checkpoints()){ + if (row.id != "01.03"){ + continue; + } + size_t found = 0; + for (const Pokemon::StoryStep& step : row.steps){ + if (step.name == "into_the_mine" || step.name == "into_the_coal_room" || + step.name == "up_to_the_hall" || step.name == "out_of_the_mine" + ){ + found++; + if (step.action != "door"){ + return step.name + ": not a \"door\" step, so it settles as a talk."; + } + } + } + return found == 4 ? UnitTestResult(true) : UnitTestResult("01.03 lacks a mine door step."); + } + return "No 01.03."; +} + struct LadyLeg{ Direction direction; size_t tiles; // 0: walk until the wall @@ -905,6 +965,14 @@ const AutoStoryStoryTableCase AUTO_STORY_STORY_TABLE_CASES[] = { .input = {"00.05c: a plan from (35, 24), (36, 24) past the woman on row 24 (lab-B, 2026-11-12 02:52)", test_company_clown_after_the_woman_on_row_24}, .expectation = {}, }, + { + .input = {"01.02: the hikers' and the welcome scenes are walked into along their rows, no detour to a tile beside the trigger", test_oreburgh_scenes_are_walked_into}, + .expectation = {}, + }, + { + .input = {"01.03: the mine's doors are \"door\" steps, settled as doors (lab-B 2026-11-12 21:57)", test_mine_doors_settle_as_doors}, + .expectation = {}, + }, }; void add_tests_AutoStory_StoryTable(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp index cd3b7054cc..c922a0af02 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp @@ -699,8 +699,12 @@ Outcome StoryWalkSteps::step(RunState& state, const StoryStep& step){ // A fade or the far map's banner is the way through, either one (#268 // slice 1); with neither yet, settle() waits for one. if (step.pose_after && Pokemon::grid_pose_of(*step.pose_after).map != state.pose.map){ + // A "door" step has no text on the far side: its settle is the door's + // (the fade back up and a short still spell), not B through a cave's + // ambient motion for 15 s (lab-B 2026-11-12 21:57, 01.03's mine). + const SettleKind arrived = step.action == "door" ? SettleKind::DOOR : SettleKind::TALK; if (through_already(step)){ - m_io.settle(BUTTON_B, label_of(step), SettleKind::TALK, ""); + m_io.settle(BUTTON_B, label_of(step), arrived, ""); return Pokemon::outcome_ok(); } const std::string banner = story_arrival_banner(state.pose.map, Pokemon::grid_pose_of(*step.pose_after).map); @@ -709,7 +713,7 @@ Outcome StoryWalkSteps::step(RunState& state, const StoryStep& step){ log(std::format("[{}] {}: {} through the door (timeout {} ms, dark from {} ms): {}.", m_row, step.name, direction_name(direction), door.timeout.count(), door.dark_from.count(), seen.any() ? describe(seen) : "nothing yet")); seen = door_from_beside(step, seen, door.timeout, banner); - m_io.settle(BUTTON_B, label_of(step), seen.any() ? SettleKind::TALK : SettleKind::AFTER_WARP, banner); + m_io.settle(BUTTON_B, label_of(step), seen.any() ? arrived : SettleKind::AFTER_WARP, banner); return Pokemon::outcome_ok(); } return one_step(state, step); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp index 28e60bad09..9ea5c6d928 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp @@ -331,6 +331,30 @@ UnitTestResult center_inside_settles(Logger& logger){ return true; } +// 01.03's doors into the mine and the coal room (lab-B 2026-11-12 21:57): +// a plain door with no text, and the cave's ambient motion kept the talk's +// quiet from ever coming, so B was pressed 14 times over 16 to 18 s. The +// door's settle is over within 3 s of the fade back up, banner read or not, +// and the talk's is not (it takes the 15 s calm). +UnitTestResult mine_doors_settle_fast(Logger& logger){ + const Milliseconds fade = 1500ms; + const Milliseconds most = fade + 3000ms; + const SimScene scene{sim_fade("the mine's door fade", fade), sim_pause("the cave's ambient motion", 60000ms, true)}; + for (const bool door : {true, false}){ + const std::string over = play_scene(scene, {.door = door}); + logger.log(std::format("mine door, {}: {}", door ? "door settle" : "talk settle", over)); + long long ms = -1; + const bool parsed = std::sscanf(over.c_str(), "judged over %lld ms in", &ms) == 1; + if (door && (!parsed || ms < fade.count() || ms > most.count())){ + return std::format("the door's settle took more than {} ms: {}", most.count(), over); + } + if (!door && parsed && ms <= most.count()){ + return "the talk's settle ended with the cave still moving: the test no longer shows the bug."; + } + } + return true; +} + // From the door mat, one held run north reaches the nurse's counter, even // at walking pace: the counter is the wall that stops it, and A talks. UnitTestResult nurse_in_one_run(Logger&){ @@ -762,6 +786,7 @@ const FailureCase AUTO_STORY_FAILURE_CASES[] = { }}, .expectation = {}}, {.input = {"01.04 Roark's badge speech: the fanfare's pause, then a scene", roark_badge_speech}, .expectation = {}}, {.input = {"inside a Pokemon Center, the door's settle ends within 3 s of the fade-up with visitors walking, never during the fade", center_inside_settles}, .expectation = {}}, + {.input = {"01.03: a door into the mine or the coal room settles within 3 s of the fade-up, whatever moves in the cave (lab-B 2026-11-12 21:57)", mine_doors_settle_fast}, .expectation = {}}, {.input = {"inside a Pokemon Center, one held run north from the door mat reaches the nurse", nurse_in_one_run}, .expectation = {}}, {.input = {"01.07 after the tag battle the grunts run off before anyone speaks", grunts_run_off_before_rowan}, .expectation = {}}, {.input = {"00.03 Rowan's scene opens with no box and fades home", rowans_scene_opens_with_no_box}, .expectation = {}}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-mine-01.03.plan.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-mine-01.03.plan.json index 184f335520..cbe042f50b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-mine-01.03.plan.json +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData/bdsp-mine-01.03.plan.json @@ -39,6 +39,7 @@ "why": "down the door's column to two above the mine's warp tiles (44..48, 59)" }, { + "action": "door", "args": { "direction": "south" }, @@ -57,6 +58,7 @@ "why": "the warp tile (46, 59)" }, { + "action": "door", "args": { "direction": "south" }, @@ -285,6 +287,7 @@ "why": "east around crate, up column 29, west across row 17, and up corridor to warp doorstep" }, { + "action": "door", "args": { "direction": "north" }, @@ -303,6 +306,7 @@ "why": "the warp tile (15, 1)" }, { + "action": "door", "args": { "direction": "north" }, From 5f49e04fb7f6edbdec7054306a174708cb571fc3 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:05:20 -0800 Subject: [PATCH 39/47] BDSP AutoStory: a whole-screen change ends a walk as a warp only on a fade or a banner; a swirl waits for the battle --- .../PokemonBDSP_AutoStory_Walk_Tests.cpp | 24 +++++++++++++ .../Utils/PokemonBDSP_AutoStory_Walk.cpp | 35 +++++++++++++++---- .../Utils/PokemonBDSP_AutoStory_WalkScreen.h | 15 ++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) 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 36df0774d0..f17dd98dc4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp @@ -357,6 +357,26 @@ UnitTestResult test_row_trainers(Logger&){ return true; } +// A change of the whole screen is a warp only on a fade or a banner read; a +// battle's swirl before its menu is not one, and waits for the battle +// (lab-B 2026-11-12 21:58, 01.03's mine: a Geodude on west 7 ended the leg). +UnitTestResult test_whole_screen_change(Logger&){ + struct Case{ std::string_view name; bool battle; bool evidence; WholeScreenChange want; }; + const Case cases[] = { + {"a cave encounter's swirl, no menu yet, no fade, no banner", false, false, WholeScreenChange::UNCLASSIFIED}, + {"the swirl, then the battle's menu", true, false, WholeScreenChange::BATTLE}, + {"a door's fade", false, true, WholeScreenChange::WARP}, + {"a door's banner", false, true, WholeScreenChange::WARP}, + {"a battle that opens from a fade", true, true, WholeScreenChange::BATTLE}, + }; + for (const Case& c : cases){ + if (classify_whole_screen_change(c.battle, c.evidence) != c.want){ + return std::string(c.name) + ": wrong class."; + } + } + return true; +} + struct AutoStoryWalkInput{ std::string name; std::function body; @@ -431,6 +451,10 @@ class Test_AutoStoryWalk : public UnitTest{ const AutoStoryWalkCase AUTO_STORY_WALK_CASES[] = { + { + .input = {"a whole-screen change ends a walk as a warp only on a fade or a banner; a swirl waits for the battle", test_whole_screen_change}, + .expectation = {}, + }, { .input = {"a turn is a D-pad tap too short to step", test_route_turn_tap}, .expectation = {}, diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp index 3575fd114d..2419cf21cc 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp @@ -172,6 +172,10 @@ bool battle_follows(VideoStream& stream, ProControllerContext& context, Millisec return wait_until(stream, context, wait, {{battle_menu}, {battle_dialog}}) >= 0; } +// How long a change of the whole screen with no fade and no banner waits for +// a battle's menu, after the first 5 s (a cave's swirl can run past them). +constexpr Milliseconds UNCLASSIFIED_CHANGE_BATTLE_WAIT = 10000ms; + // After a white flash: an encounter's, if its battle shows; else a cave // exit's white fade (#268 slice 3), which the walk once fled as a battle. constexpr Milliseconds WHITE_FLASH_BATTLE_WAIT = 8000ms; @@ -429,8 +433,21 @@ class WalkUntil{ m_stream.log("[Walk] " + m_spec.label + ": " + std::to_string(m_result.walked.count()) + "ms, screen change " + std::to_string(change) + "."); if (change > WALK_SCENE_CHANGE){ - const bool battle = battle_follows(m_stream, m_context, 5000ms, &m_banner); + // Only a banner first read now is evidence of a warp. + const std::string banner_before = m_banner.seen(); + const auto new_banner = [&]{ + return !m_banner.seen().empty() && m_banner.seen() != banner_before; + }; + bool battle = battle_follows(m_stream, m_context, 5000ms, &m_banner); m_result.warp.banner = m_banner.seen(); + // Not yet a battle and not a warp: a cave's encounter opens with a + // swirl whose menu came after more than 5 s (lab-B 2026-11-12 21:58, + // 01.03's mine, a wild Geodude on west 7). Only a banner is the + // evidence of a warp; anything else waits on the battle detector. + if (classify_whole_screen_change(battle, new_banner()) == WholeScreenChange::UNCLASSIFIED){ + battle = battle_follows(m_stream, m_context, UNCLASSIFIED_CHANGE_BATTLE_WAIT, &m_banner); + m_result.warp.banner = m_banner.seen(); + } if (battle){ if (m_spec.wild == WildPolicy::STOP_AT){ m_stream.log("[Walk] " + m_spec.label + ": a battle started; a trainer's here."); @@ -439,12 +456,16 @@ class WalkUntil{ escape_battle("wild battle (leaf opening); running.", BattleMovement::STEP_MOVED); return {ChunkNext::NEXT_CHUNK, WalkStop::LIMIT}; } - // A change walking cannot make and no battle after it: a warp whose - // fade fell between two frames (lab-B 2026-11-12 20:20, a hold east - // through the Gate's door into Oreburgh City, screen change 267). - // The walk is over; the map it ran on is no longer the map it began on. - m_stream.log("[Walk] " + m_spec.label + ": the scene changed and no battle followed: through a warp, its fade unseen."); - return {ChunkNext::STOP, WalkStop::TRANSITION}; + // A change walking cannot make, no battle after it and the banner of + // a map: a warp whose fade fell between two frames (lab-B 2026-11-12 + // 20:20, a hold east through the Gate's door into Oreburgh City, + // screen change 267). The walk is over; the map it ran on is no + // longer the map it began on. + if (classify_whole_screen_change(false, new_banner()) == WholeScreenChange::WARP){ + m_stream.log("[Walk] " + m_spec.label + ": the scene changed and the banner \"" + m_result.warp.banner + "\" read: through a warp, its fade unseen."); + return {ChunkNext::STOP, WalkStop::TRANSITION}; + } + m_stream.log("[Walk] " + m_spec.label + ": the scene changed, no fade, banner or battle read; walking on.", COLOR_ORANGE); } // Two still chunks in a row, so one dropped frame does not stop us. A // frame exactly the same is a stalled video or a game hitch, not a wall: diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h index acb7daf3b4..04a0fedc9b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h @@ -36,6 +36,21 @@ constexpr double WALK_TAP_BLOCKED_CHANGE = 16.0; // More than walking changes in 400ms: a new scene, such as a battle opening. constexpr double WALK_SCENE_CHANGE = 120.0; +// What a change of the whole screen walking cannot make turns out to be. +enum class WholeScreenChange{ + BATTLE, // the battle's menu or text box showed + WARP, // positive evidence of a map change: a fade or a banner first read + UNCLASSIFIED, // neither yet: an encounter's swirl before its menu looks like + // this (lab-B 2026-11-12 21:58, a Geodude in 01.03's mine); wait + // for the battle detector, never end the walk on it +}; +inline WholeScreenChange classify_whole_screen_change(bool battle_showed, bool fade_or_banner_read){ + if (battle_showed){ + return WholeScreenChange::BATTLE; + } + return fade_or_banner_read ? WholeScreenChange::WARP : WholeScreenChange::UNCLASSIFIED; +} + // Whether two frames show different scenes: a change walking cannot make // (WALK_SCENE_CHANGE). UNKNOWN without both frames. Pokemon::SceneChange walk_scenes_differ(const Pokemon::TransitionSample& before, const Pokemon::TransitionSample& after); From 73e9ea99494b66ea2df5be797583fb5c37e38add Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:15:15 -0800 Subject: [PATCH 40/47] BDSP sim: qualify coord-event trigger names by map (coord_event_0 collided across maps) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Simulation/PokemonBDSP_AutoStory_SimTriggers.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimTriggers.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimTriggers.cpp index 2593e18a0a..56c1c0120c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimTriggers.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimTriggers.cpp @@ -93,6 +93,9 @@ RowTrigger row_trigger(const std::string& map, const CoordEvent& event, const Va out.trigger.tiles = seen.tiles; } } + // The maps name their events coord_event_0, 1, ...: a scene is spent by name, + // so the map goes in it. + out.trigger.name = map + " " + out.trigger.name; return out; } From 715273c45da7e4946b4577776a275ea8f3b68104 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:19:46 -0800 Subject: [PATCH 41/47] BDSP AutoStory: fault-sweep gap names and plan golden for the Oreburgh scene steps Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonBDSP_AutoStory_PlanGolden.h | 11 ++--------- .../PokemonBDSP_AutoStory_FaultSweep_Tests.cpp | 6 +++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index 605d1a351f..1c610368b4 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -147,19 +147,12 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 into_the_hikers_scene costs=into_scene from OreburghGate (4, 22) (5, 22) to OreburghGate (4, 22) (5, 22)", "01.02 past_curtis costs=exit from OreburghGate (7, 22) to OreburghGate (20, 22)", "01.02 east 13 (open) -> OreburghGate (20, 22)", "01.02 by_the_east_mouth costs=exit from OreburghGate (20, 22) to OreburghGate (26, 22)", "01.02 east 6 (open) -> OreburghGate (26, 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.02 into_the_welcome_scene costs=into_scene from OreburghCity (2, 13) (3, 13) to OreburghCity (2, 13) (3, 13)", "01.02b below_the_centers_door costs=town from OreburghCity (26, 22) to OreburghCity (47, 21)", "01.02b east 22 (to wall) -> Oreburgh City (48, 22)", "01.02b north 1 (to wall) -> Oreburgh City (48, 21)", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp index ebc1e256a1..5dc6906357 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_FaultSweep_Tests.cpp @@ -166,9 +166,9 @@ const std::set KNOWN_CERTAINTY_GAPS{ "00.05c step 6 below_the_east_exit_sign: needs tile, has set", "01.01 step 2 west_of_barrys_trigger: needs tile, has set", "01.02 step 1 south_to_the_cliff: needs tile, has set", - "01.02 step 10 west_of_the_welcome: needs tile, has set", - "01.02 step 4 west_of_the_hikers_trigger: needs tile, has set", - "01.02 step 7 past_curtis: needs tile, has set", + "01.02 step 4 into_the_hikers_scene: needs tile, has set", + "01.02 step 6 past_curtis: needs tile, has set", + "01.02 step 9 into_the_welcome_scene: needs tile, has set", "01.02b step 2 barry: needs tile, has set", "01.02b step 4 below_the_centers_door: needs tile, has set", "01.03 step 1 above_the_mine: needs tile, has set", From d3f78f9d0aace7ec05f5b9b0e7a82a34d904b6f6 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:23:42 -0800 Subject: [PATCH 42/47] BDSP AutoStory: route plans golden for the Oreburgh scene steps Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_plans.golden.txt | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index 2cd7510453..e345f2f742 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -293,14 +293,11 @@ anchor); 0 from one start tile. 4. south 3 (open) -> Route 203 (55, 9) totals: 4 legs, 3 turns, 2 open, 0 localization -== 01.02 west_of_the_hikers_trigger (costs: route) +== 01.02 into_the_hikers_scene (costs: into_scene) from: OreburghGate (4, 22) (5, 22) facing east (set) - target: OreburghGate (6, 22) facing east (tile) + target: OreburghGate (4, 22) (5, 22) facing east (set) start candidates: OreburghGate (4, 22), OreburghGate (5, 22) - 1. south 1 (to wall) -> OreburghGate (4, 23), OreburghGate (5, 23) - 2. east 2 (to wall) -> OreburghGate (6, 23) - 3. north 1 (open) -> OreburghGate (6, 22) - totals: 3 legs, 2 turns, 1 open, 2 localization + totals: 0 legs, 0 turns, 0 open, 0 localization == 01.02 past_curtis (costs: exit) from: OreburghGate (7, 22) facing east (tile) @@ -316,15 +313,11 @@ anchor); 0 from one start tile. 1. east 6 (open) -> OreburghGate (26, 22) totals: 1 legs, 0 turns, 1 open, 0 localization -== 01.02 west_of_the_welcome (costs: route) +== 01.02 into_the_welcome_scene (costs: into_scene) from: OreburghCity (2, 13) (3, 13) facing east (set) - target: OreburghCity (9, 13) facing east (tile) + target: OreburghCity (2, 13) (3, 13) facing east (set) start candidates: Oreburgh City (2, 13), Oreburgh City (3, 13) - 1. north 3 (to wall) -> Oreburgh City (2, 10), Oreburgh City (3, 10) - 2. east 4 (to wall) -> Oreburgh City (6, 10) - 3. south 3 (open) -> Oreburgh City (6, 13) - 4. east 3 (open) -> Oreburgh City (9, 13) - totals: 4 legs, 3 turns, 2 open, 2 localization + totals: 0 legs, 0 turns, 0 open, 0 localization == 01.02b below_the_centers_door (costs: town) from: OreburghCity (26, 22) facing north (tile) From cfc4693ea170caf0381c0c766f0b2d185d081d63 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:24:32 -0800 Subject: [PATCH 43/47] BDSP AutoStory: split look() and the door steps; evidence struct for the whole-screen change Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonBDSP_AutoStory_StoryData.cpp | 15 +++- .../PokemonBDSP_AutoStory_Walk_Tests.cpp | 2 +- .../Utils/PokemonBDSP_AutoStory_Walk.cpp | 73 +++++++++++-------- .../Utils/PokemonBDSP_AutoStory_WalkScreen.h | 17 ++++- 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp index 690b1c1184..184f8d8a02 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.cpp @@ -96,6 +96,17 @@ Pokemon::StoryArgSpec leave_arg(){ .why = "the room's way on is a door this way"}; } +// The steps that end on a door or a banner: to_banner and door (the way to +// step), or_legs (a step, or legs if it did not move). +void add_door_steps( + std::vector& actions, + const Pokemon::StoryArgSpec& direction_arg, const Pokemon::StoryArgSpec& legs_arg +){ + actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "to_banner", .args = {direction_arg}, .console_only = false, .certainty = PINS}); + actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "door", .args = {direction_arg}}); + actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "or_legs", .args = {direction_arg, legs_arg}}); +} + std::vector make_bdsp_actions(){ std::vector actions( Pokemon::builtin_story_actions().begin(), Pokemon::builtin_story_actions().end() @@ -136,9 +147,7 @@ std::vector make_bdsp_actions(){ } actions.push_back({.kind = Pokemon::StoryStepKind::ROUTE, .name = "into_scene", .args = {route_target, fight_wild, legs_arg}}); add_legs_actions(actions, legs_arg, fight_wild); - actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "to_banner", .args = {direction_arg}, .console_only = false, .certainty = PINS}); - actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "door", .args = {direction_arg}}); - actions.push_back({.kind = Pokemon::StoryStepKind::STEP, .name = "or_legs", .args = {direction_arg, legs_arg}}); + add_door_steps(actions, direction_arg, legs_arg); add_wanderer_talks(actions); actions.push_back({.kind = Pokemon::StoryStepKind::MASH, .name = "a", .args = {}}); actions.push_back({.kind = Pokemon::StoryStepKind::BATTLE, .name = "starter", .args = {may_lose}}); 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 f17dd98dc4..077d1f0d04 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walk_Tests.cpp @@ -370,7 +370,7 @@ UnitTestResult test_whole_screen_change(Logger&){ {"a battle that opens from a fade", true, true, WholeScreenChange::BATTLE}, }; for (const Case& c : cases){ - if (classify_whole_screen_change(c.battle, c.evidence) != c.want){ + if (classify_whole_screen_change({.battle_showed = c.battle, .fade_or_banner_read = c.evidence}) != c.want){ return std::string(c.name) + ": wrong class."; } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp index 2419cf21cc..f776ad686c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Walk.cpp @@ -426,6 +426,45 @@ class WalkUntil{ return {ChunkNext::LOOK, WalkStop::LIMIT}; } + // A change of the whole screen walking cannot make: a battle, a warp, or + // neither. nullopt: the walk goes on. + std::optional after_scene_change(){ + // Only a banner first read now is evidence of a warp. + const std::string banner_before = m_banner.seen(); + const auto new_banner = [&]{ + return !m_banner.seen().empty() && m_banner.seen() != banner_before; + }; + bool battle = battle_follows(m_stream, m_context, 5000ms, &m_banner); + m_result.warp.banner = m_banner.seen(); + // Not yet a battle and not a warp: a cave's encounter opens with a + // swirl whose menu came after more than 5 s (lab-B 2026-11-12 21:58, + // 01.03's mine, a wild Geodude on west 7). Only a banner is the + // evidence of a warp; anything else waits on the battle detector. + if (classify_whole_screen_change({.battle_showed = battle, .fade_or_banner_read = new_banner()}) == WholeScreenChange::UNCLASSIFIED){ + battle = battle_follows(m_stream, m_context, UNCLASSIFIED_CHANGE_BATTLE_WAIT, &m_banner); + m_result.warp.banner = m_banner.seen(); + } + if (battle){ + if (m_spec.wild == WildPolicy::STOP_AT){ + m_stream.log("[Walk] " + m_spec.label + ": a battle started; a trainer's here."); + return ChunkVerdict{ChunkNext::STOP, WalkStop::DIALOG}; + } + escape_battle("wild battle (leaf opening); running.", BattleMovement::STEP_MOVED); + return ChunkVerdict{ChunkNext::NEXT_CHUNK, WalkStop::LIMIT}; + } + // A change walking cannot make, no battle after it and the banner of + // a map: a warp whose fade fell between two frames (lab-B 2026-11-12 + // 20:20, a hold east through the Gate's door into Oreburgh City, + // screen change 267). The walk is over; the map it ran on is no + // longer the map it began on. + if (classify_whole_screen_change({.fade_or_banner_read = new_banner()}) == WholeScreenChange::WARP){ + m_stream.log("[Walk] " + m_spec.label + ": the scene changed and the banner \"" + m_result.warp.banner + "\" read: through a warp, its fade unseen."); + return ChunkVerdict{ChunkNext::STOP, WalkStop::TRANSITION}; + } + m_stream.log("[Walk] " + m_spec.label + ": the scene changed, no fade, banner or battle read; walking on.", COLOR_ORANGE); + return std::nullopt; + } + ChunkVerdict look(){ m_context.wait_for_all_requests(); VideoSnapshot after = snapshot_or_fail(m_stream, m_spec.label); @@ -433,39 +472,9 @@ class WalkUntil{ m_stream.log("[Walk] " + m_spec.label + ": " + std::to_string(m_result.walked.count()) + "ms, screen change " + std::to_string(change) + "."); if (change > WALK_SCENE_CHANGE){ - // Only a banner first read now is evidence of a warp. - const std::string banner_before = m_banner.seen(); - const auto new_banner = [&]{ - return !m_banner.seen().empty() && m_banner.seen() != banner_before; - }; - bool battle = battle_follows(m_stream, m_context, 5000ms, &m_banner); - m_result.warp.banner = m_banner.seen(); - // Not yet a battle and not a warp: a cave's encounter opens with a - // swirl whose menu came after more than 5 s (lab-B 2026-11-12 21:58, - // 01.03's mine, a wild Geodude on west 7). Only a banner is the - // evidence of a warp; anything else waits on the battle detector. - if (classify_whole_screen_change(battle, new_banner()) == WholeScreenChange::UNCLASSIFIED){ - battle = battle_follows(m_stream, m_context, UNCLASSIFIED_CHANGE_BATTLE_WAIT, &m_banner); - m_result.warp.banner = m_banner.seen(); - } - if (battle){ - if (m_spec.wild == WildPolicy::STOP_AT){ - m_stream.log("[Walk] " + m_spec.label + ": a battle started; a trainer's here."); - return {ChunkNext::STOP, WalkStop::DIALOG}; - } - escape_battle("wild battle (leaf opening); running.", BattleMovement::STEP_MOVED); - return {ChunkNext::NEXT_CHUNK, WalkStop::LIMIT}; - } - // A change walking cannot make, no battle after it and the banner of - // a map: a warp whose fade fell between two frames (lab-B 2026-11-12 - // 20:20, a hold east through the Gate's door into Oreburgh City, - // screen change 267). The walk is over; the map it ran on is no - // longer the map it began on. - if (classify_whole_screen_change(false, new_banner()) == WholeScreenChange::WARP){ - m_stream.log("[Walk] " + m_spec.label + ": the scene changed and the banner \"" + m_result.warp.banner + "\" read: through a warp, its fade unseen."); - return {ChunkNext::STOP, WalkStop::TRANSITION}; + if (const std::optional verdict = after_scene_change()){ + return *verdict; } - m_stream.log("[Walk] " + m_spec.label + ": the scene changed, no fade, banner or battle read; walking on.", COLOR_ORANGE); } // Two still chunks in a row, so one dropped frame does not stop us. A // frame exactly the same is a stalled video or a game hitch, not a wall: diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h index 04a0fedc9b..36b5ef9747 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h @@ -36,6 +36,7 @@ constexpr double WALK_TAP_BLOCKED_CHANGE = 16.0; // More than walking changes in 400ms: a new scene, such as a battle opening. constexpr double WALK_SCENE_CHANGE = 120.0; +namespace detail{ // What a change of the whole screen walking cannot make turns out to be. enum class WholeScreenChange{ BATTLE, // the battle's menu or text box showed @@ -44,12 +45,22 @@ enum class WholeScreenChange{ // this (lab-B 2026-11-12 21:58, a Geodude in 01.03's mine); wait // for the battle detector, never end the walk on it }; -inline WholeScreenChange classify_whole_screen_change(bool battle_showed, bool fade_or_banner_read){ - if (battle_showed){ +// What the watchers read after the change. +struct WholeScreenEvidence{ + bool battle_showed = false; + bool fade_or_banner_read = false; +}; +// Classifies a whole-screen change from what was read after it. +inline WholeScreenChange classify_whole_screen_change(const WholeScreenEvidence& evidence){ + if (evidence.battle_showed){ return WholeScreenChange::BATTLE; } - return fade_or_banner_read ? WholeScreenChange::WARP : WholeScreenChange::UNCLASSIFIED; + return evidence.fade_or_banner_read ? WholeScreenChange::WARP : WholeScreenChange::UNCLASSIFIED; } +} // namespace detail +using detail::WholeScreenChange; +using detail::WholeScreenEvidence; +using detail::classify_whole_screen_change; // Whether two frames show different scenes: a change walking cannot make // (WALK_SCENE_CHANGE). UNKNOWN without both frames. From 94ccaefb96d8a3249c4765afdc5fba88dbcff414 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 12 Nov 2026 22:29:55 -0800 Subject: [PATCH 44/47] BDSP AutoStory: document the whole-screen change aliases Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h index 36b5ef9747..80c5a47821 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkScreen.h @@ -58,8 +58,11 @@ inline WholeScreenChange classify_whole_screen_change(const WholeScreenEvidence& return evidence.fade_or_banner_read ? WholeScreenChange::WARP : WholeScreenChange::UNCLASSIFIED; } } // namespace detail +// The whole-screen classification, for walks and their tests. using detail::WholeScreenChange; +// The evidence it is made from. using detail::WholeScreenEvidence; +// The classifying function. using detail::classify_whole_screen_change; // Whether two frames show different scenes: a change walking cannot make From 4d026741fd9f1a3fc14805feb763f79c365dfc8a Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 03:59:07 -0800 Subject: [PATCH 45/47] BDSP AutoStory 01.10: a wall leg by a wander zone tells the wall from the wanderer; the cave exit's row is not assumed On lab-B (2026-11-13 02:35 and 02:37) 01.10 walked Route 204's row 28, a row below the plan's, and "west 10 (to wall)" stopped against the youngster who wanders x 14..16 there, 5 tiles in. The push read as stopped late, the time counted 13 tiles, the stop passed as the wall, and every later leg ran 5 columns off until "west 1 (to wall)" ran on to "position unknown". A wall leg whose way passes someone's wander zone (on it or a row beside) and stops where its time counts the wall now presses A: someone who answers is waited for and the walk goes on to the wall; someone still there after two waits stands on a zone tile ahead, and the walk plans again from the tiles before the zone, marking nothing. The cave exit may leave us on row 26 or 27, so 01.09 ends and 01.10 starts on both, and line 1 runs south to the wall below the cave instead of an open step (a leg north could walk back into the cave). Each row's start screen is kept in AutoStory/starts/ to settle the start pose next run. Sim cases for both readings of the console run (red before, green now). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Data/route_bench.golden.txt | 4 +- .../AutoStory/Data/route_plans.golden.txt | 20 +++--- .../PokemonBDSP_AutoStory_PlanGolden.h | 7 +- .../PokemonBDSP_AutoStory_StoryExecutor.cpp | 26 +++++-- .../PokemonBDSP_AutoStory_StoryExecutor.h | 2 + ...PokemonBDSP_AutoStory_FaultSweep_Tests.cpp | 1 - ...onBDSP_AutoStory_SimFailureCases_Tests.cpp | 32 +++++++++ .../AutoStory/StoryData/bdsp-01.09.plan.json | 4 ++ .../AutoStory/StoryData/bdsp-01.10.plan.json | 8 ++- .../PokemonBDSP_AutoStory_PlannedRoute.cpp | 69 +++++++++++++++++++ 10 files changed, 149 insertions(+), 24 deletions(-) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt index 352e051528..9fe25f5a57 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_bench.golden.txt @@ -58,8 +58,8 @@ walk run with no stops) | verdict (why). A ratio above 1.5 is flagged "!". 01.08 below_the_ravaged_path | 24815 | 26050 | 13700 | 2 | 9 | 0 | 4.24! | 1.00 | 6.00! | 5850 ms (stand-in) | PASS 01.09 west_of_the_rock | 7050 | 7050 | 7050 | 1 | 0 | 0 | 4.70! | 1.00 | 1.00 | 1500 ms (stand-in) | PASS 01.09 above_the_way_out | 4550 | 4550 | 4550 | 2 | 0 | 0 | 4.14! | 1.00 | 2.00! | 1100 ms (stand-in) | PASS -01.10 line_1 | 900 | 900 | 900 | 0 | 0 | 0 | 2.25! | 1.00 | 1.00 | 400 ms (stand-in) | PASS -01.10 line_2 | 3250 | 3250 | 3250 | 1 | 0 | 0 | 2.83! | 1.00 | 1.00 | 1150 ms (stand-in) | PASS +01.10 line_1 | 1950 | 1950 | 1950 | 1 | 0 | 0 | 2.29! | 1.00 | 1.00 | 850 ms (stand-in) | PASS +01.10 line_2 | 9800 | 9800 | 9800 | 0 | 0 | 0 | 6.12! | 1.00 | 1.00 | 1600 ms (stand-in) | PASS 01.10 line_3 | 4100 | 4100 | 4100 | 0 | 0 | 0 | 4.10! | 1.00 | 1.00 | 1000 ms (stand-in) | PASS 01.10 line_4 | 4050 | 4050 | 4050 | 1 | 0 | 0 | 3.86! | 1.00 | 1.00 | 1050 ms (stand-in) | PASS 01.10 line_5 | 15110 | 20050 | 7700 | 1 | 6 | 0 | 7.75! | 1.17 | 1.00 | 1950 ms (stand-in) | PASS diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt index e345f2f742..f967f06877 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/route_plans.golden.txt @@ -418,19 +418,19 @@ anchor); 0 from one start tile. totals: 3 legs, 2 turns, 1 open, 0 localization == 01.10 line_1 (costs: line) - from: Route204North (20, 26) facing south (tile) - target: Route204North (20, 27) (tile) - start candidates: Route 204 (20, 26) - 1. south 1 (open) -> Route 204 (20, 27) - totals: 1 legs, 0 turns, 1 open, 0 localization + from: Route204North (20, 26) (20, 27) facing south (set) + target: Route204North (20, 30) (tile) + start candidates: Route 204 (20, 26), Route 204 (20, 27) + 1. south 4 (to wall) -> Route 204 (20, 30) + totals: 1 legs, 0 turns, 0 open, 1 localization == 01.10 line_2 (costs: line) - from: Route204North (20, 27) (tile) + from: Route204North (20, 30) (tile) target: Route204North (11, 27) (tile) - start candidates: Route 204 (20, 27) - 1. west 10 (to wall) -> Route 204 (10, 27) - 2. east 1 (open) -> Route 204 (11, 27) - totals: 2 legs, 1 turns, 1 open, 0 localization + start candidates: Route 204 (20, 30) + 1. north 3 (open) -> Route 204 (20, 27) + 2. west 9 (open) -> Route 204 (11, 27) + totals: 2 legs, 1 turns, 2 open, 0 localization == 01.10 line_3 (costs: line) from: Route204North (11, 27) (tile) diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h index 1c610368b4..47e3e41ac8 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -200,9 +200,10 @@ inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { "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 line_1 costs=line from Route204North (20, 26) (20, 27) to Route204North (20, 30)", + "01.10 south 4 (to wall) -> Route 204 (20, 30)", + "01.10 line_2 costs=line from Route204North (20, 30) to Route204North (11, 27)", + "01.10 north 3 (open) -> Route 204 (20, 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)", diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp index 7e768356cb..b089e41a04 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryExecutor.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Filesystem/Filesystem.h" @@ -91,23 +92,35 @@ std::string label_of(const StoryStep& step){ return label; } -// The screen at a failed step, kept: the retry resets the game. -void save_failure_screenshot(VideoStream& stream, size_t attempt){ +// The screen now, kept in AutoStory/`folder`/ as "