Skip to content

BDSP navigation v4: the walker, with battles passed in - #129

Draft
dayfine wants to merge 188 commits into
nav/grid-story-stepsfrom
bdsp/walk-v4
Draft

dayfine wants to merge 188 commits into
nav/grid-story-stepsfrom
bdsp/walk-v4

Conversation

@dayfine

@dayfine dayfine commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Bottom of the BDSP AutoStory chain (base nav/grid-story-steps); folds in #134 (story maps as JSON) and #127 (nav v4 planner and route records), so the diff shows the maps, the planner and this walker.

The BDSP walker on #127's StoryWorld, with battles passed in, its console steps behind a RouteIO so its decisions can be unit tested.

  • Plans on StoryWorld instead of MapSet/TileGrid. Refactored for code health without changing its steps: options structs instead of long parameter lists and bools, walk_route moved unchanged into PokemonBDSP_AutoStory_PlannedRoute and split into a RouteWalker with one function per decision (git diff --color-moved=dimmed-zebra on b678b4a).
  • RouteIO holds every console call the walker makes; ConsoleRouteIO is today's code, and tests use a scripted one.
  • Fixes from console runs: straight walks and turns go on the D-pad (a 40–80 ms tap only turns; stick taps stopped between tiles, r57–r61); a quiet tap followed by a moving one counts as a step (r67); after a trainer on an open or wall leg the walk replans from the taps and the sight line (r54, r55); no banner read is a warning, only a wrong banner fails; a route gives up after the third dialogue the map does not explain (r14).
  • The transition watchers, the overworld detector and the battle dialog watcher are adapted from [WIP] BDSP Autostory PokemonAutomation/Arduino-Source#1717 by Developer-Butters and credited.
  • AutoStory core stage 7 (a369dcf): WarpFadeWatch follows a warp's fade frame by frame on AutoStory: story steps meet screen state (action table and interrupts between steps) #122's TransitionTracker with BDSP_FADE_PROFILE, so a fade whose hold fell between two frames still shows at the scene after the fall. The walk's own fade watchers keep their behavior and now read their thresholds from the profile.

Testing

Core stage 5: the walk records what its watchers saw as timed screen events (WalkResult::events, the shared ScreenEventLog), and the route walker places a wild battle on an open leg's taps with the shared classifier (Utils/PokemonBDSP_AutoStory_LegBattle): the tap its first timed event's step fell in plus the taps that moved after it, a tile either way, instead of every tile of the leg. Two battles, an UNSETTLED fade or no events keep the whole leg. BDSP's lags (flash 500 ms, battle box 4500 ms after the tap) are not measured yet; they are data in LegBattleTiming and flagged there. Unit test on synthetic walks.

dayfine and others added 2 commits November 1, 2026 12:00
…with tests

The BDSP maps from new game to Floaroma (Twinleaf to Floaroma, the
Oreburgh Mine and Gym, the Ravaged Path), built into the program from
JSON by CMake, their tile grids and the joined StoryMaps world, the
recorded routes and segment 00's walked lines, and the costs the story's
walks are planned with. Carries Pokemon_TileGrid and Pokemon_MapSet
unchanged from the BDSP chain (fork #109).

Tests: the built-in maps parse, and the planned walks out of the catch
area and into Sandgem, the Oreburgh Gym and segment 00's lines plan on
the grids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Walks the planned routes on the BDSP story maps: Walk holds a direction
and stops on what the screen shows (a dialogue, a transition, a wall),
RouteWalk walks a plan's legs, tracks the tiles the player may be on and
plans again after a trainer, and leaves buildings by indoors() and the
door's fade. The walker sees wild battles and trainers start but does
not fight them: a WildBattleEscape runs from a wild battle and a
RouteTrainerFight fights a trainer, both passed in by the program.

Adapted from PokemonAutomation#1717 by Developer-Butters,
kept nearly as written: the AutoStory OverworldDetector and
TransitionWatchers, which the walker uses to see the overworld and an
encounter's white flash.

Tests: indoors() on synthetic screens and screenshots, the door's fade,
and the location banner reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 2 commits November 1, 2026 12:33
PokemonBDSP::add_tests() was never called, so the BDSP map tests did not
run in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine added a commit that referenced this pull request Nov 1, 2026
dayfine and others added 13 commits November 1, 2026 13:20
devtools/maps/bdsp_maps.py writes each map from its world rectangle of the
pret/pokediamond decompilation (Platinum's for the Ravaged Path), with the
named points and regions the story walks to, the objects BDSP shows, and
the tiles the console measured as patches. --check regenerates them and
fails on any difference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
… test them

PokemonBDSP_AutoStory_Maps reads the embedded JSON through the shared
MapData loader: story_map(), map_point(), and map_region() for the numbered
points a region is written as. The tests load every map, check that points
and objects stand where they can, and that the lookups find and refuse
what they should. PokemonBDSP::add_tests() is now run by the unit test
runner, which never called it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The player's and Barry's houses (both floors) and Rowan's lab, from
pokeplatinum at c6689696d5fb, decomp only and not yet checked on the
console: their stairs, doors and the tiles the story talks from, and the
doors' warps to Twinleaf's and Sandgem's door points. The map tests check
that every warp leads to a point that exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The story maps, devtools/maps/bdsp_maps.py and the CMake embed are
maps-v4's (add/add conflicts resolved to its versions); this brings in
nav/story-steps (#122) underneath. The per-map grids still load the maps
here until the next commits move them onto the shared MapData.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…MapData

StoryWorld joins story maps at world offsets (what Pokemon::MapSet did),
with BDSP's step rules on Pokemon::TileKind: ledges hop the arrow's way,
water and signs stop, objects standing still block, wanderers don't, and
tiles no map covers are off the maps. RoutePlanner is Pokemon_TileGrid's
planner moved onto it unchanged in behaviour (walk_to_wall,
plan_tile_route, plan_robust_route, sight lines), now in PokemonBDSP;
plan_robust_route's search is split into functions under the length limit.
Synthetic-map tests for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…s go

StoryMaps, RouteRecords, Segment00Lines and PlanCosts now place
story_map()s in StoryWorlds and take their named tiles from
map_point()/map_region(). The trainers' sight lists move from the per-map
files into StoryMaps. Removed: the per-map Data files, MapGrids, MAPS.md
(its rules are in devtools/maps/bdsp_maps.py), the old MapGrid tests, and
the generic Pokemon_TileGrid and Pokemon_MapSet. The tests are split by
topic: story world, route planner, story maps (with the route records
traced on their maps) and Segment 00's lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…pData

Brings in maps-v4 and nav/story-steps under nav-v4. Conflicts were the
test registration and the source list: the walker's entries are kept,
nav-v4's removed Data files and MapGrid tests stay removed. The walker
follows in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The walker takes a StoryWorld where it took a Pokemon::MapSet or
TileGrid, and the planner's types from PokemonBDSP. Its copy of the world
uncovers the tiles to avoid and blocks what it finds in the way, as it set
them UNKNOWN and BLOCKED before. Nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
catch_save_area, after_training_area, catch_grass and jubilife_exit were
computed by the story code from tile loops; they are now regions of
Route202, and a map test checks each against the loop it replaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…s regions

The planner's walk_to_wall() is now slide_to_wall(), so it no longer
shares a name with the walker's walk_to_wall(), which walks on the
console. story_catch_save_area() and story_after_training_area() read
Route 202's regions instead of looping over its tiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Follows the rename in #127; the walker's own walk_to_wall() is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 9 commits November 1, 2026 14:20
GCC -Werror=dangling-reference flagged story_map("Route202") bound to a
reference: with a const std::string& parameter, the temporary string looks
like what the result refers to. string_view arguments are not flagged;
callers are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Windows clang -Werror,-Wmissing-designated-field-initializers rejected
test rows that left fields out. The rows' optional fields now have
default member initializers, and the MapObjects built in the story world
tests name all their fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
#122 made Grid's at() read-only and added cell_at() for writes; the
story world and the Ravaged Path's smashed rocks follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…ee functions

Code health: StoryWorld had 14 public methods, and its overlap check and
rebuild nested five deep. covered(), standable(), step(), at_wall() and
describe() now take the world as their first argument and read it through
tile() and occupied(); width() and height() are gone. The overlap check and
the painting of a map are split out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Follows #127: standable(), step() and describe() take the world first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 6 commits November 10, 2026 07:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
# Conflicts:
#	SerialPrograms/CMakeLists.txt
#	SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp
Follow nav/story-steps' cell_at(pos, grid) argument order.
Moves only, no logic change. RoutePlanner.h keeps the tile planner;
the trainer sight lines go to TrainerSight.h and the robust planner to
RobustRoute.h. StoryWorld.h keeps the world; the walking rules go to
WalkRules.h. StoryMaps.h keeps the worlds and the lines on them; the
map names go to StoryMapNames.h, the segment 00 spots to StorySpots.h
and the trainers to StoryTrainers.h. Map name constants are inline
std::string; string parameters are std::string_view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Moves only, no logic change. Walk.h keeps the stick walks; how a walk
ended goes to WalkResult.h, the D-pad walks to WalkDpad.h, screen change
and warp fades to WalkScreen.h and the probe to WalkProbe.h. RouteWalk.h
keeps its two helpers and includes its parts: RouteTiming.h,
RouteInput.h, RouteTalk.h and RouteDoor.h. The story language goes from
Location.h to StoryLanguage.h, with one story_reads_text() taking an
optional language; the banner watcher goes to LocationBannerWatcher.h.
talk_to_npc() and the counted wall leg leave PlannedRoute.h for
PlannedTalk.h and CountedWallLeg.h. Includes follow nav-v4's split, and
ROUTE_LOG_TAG, now a string_view, is joined with std::format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine removed this pull request from stack #230 November 11, 2026 03:20
dayfine and others added 18 commits November 11, 2026 07:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Conflict in the unit test runner: kept this branch's PokemonBDSP::add_tests() and main's BDSP DialogDetector and MenuDetector suites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autostory AutoStory programs game:bdsp Brilliant Diamond/Shining Pearl navigation Maps, planner, walker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant