Skip to content

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

Draft
dayfine wants to merge 86 commits into
bdsp/nav-v4from
bdsp/walk-v4
Draft

dayfine wants to merge 86 commits into
bdsp/nav-v4from
bdsp/walk-v4

Conversation

@dayfine

@dayfine dayfine commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Depends on #127 (base bdsp/nav-v4); the diff shows only this PR's change.

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.

🤖 Generated with Claude Code

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 added a commit that referenced this pull request Nov 1, 2026
dayfine and others added 4 commits November 1, 2026 13:38
…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
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:41
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
namespace X{ with no space, and if bodies on their own lines. No code
changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Code health rejects the non-const extern g_story_language. The program
sets the language once before the story runs, so it now calls
set_story_language(), and readers call story_language().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Code health: walk_until() took 8 parameters, walk_until_dpad() 9 with a
defaulted bool, walk_expecting() 9, and walk_until_impl() 12 with four
bools over 126 lines. Every walk now takes the stick as one
JoystickPosition. walk_until_dpad() takes DpadWalkOptions (arrived, and a
DpadPace for B held) and walk_expecting() a WalkExpectation (the stop,
and arrived). The walk loop is a WalkUntil class in the .cpp, with
what it presses and how battles end it as enums. Behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
RouteWalk.cpp was 926 lines, and splitting walk_route() into functions
would take it past the 1000-line limit. walk_route(), walk_waypoints(),
talk_to_npc(), RouteTrainerFight and the route-log helpers they use move
unchanged to PokemonBDSP_AutoStory_PlannedRoute.{h,cpp}. RouteWalk exposes
route_ms_per_tile() and route_stick() for them.

Review with: git diff --color-moved HEAD~1

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

Code health: walk_route() was 475 lines nested 7 deep with 11
parameters, walk_waypoints() and talk_to_npc() had 10. walk_route() is now
a RouteWalker class: planning, a leg to a wall, an open leg, the banner
check, the trainers after a leg and each replan are their own functions,
with the same steps in the same order. The trainers and their fight go
together in RouteTrainers; where a walk goes is a RouteWalkPlan,
WaypointWalkPlan or NpcTalk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Code health: WhiteScreenWatcher and BlackScreenFlashWatcher had 8
parameters. Every caller used the default thresholds and durations, so
WhiteScreenWatcher takes the colour, box, finder type and duration, and
WhiteScreenOverWatcher the colour and box; the values are the old
defaults. BlackScreenFlashWatcher had no callers and is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Code health asks for public data without methods: the banner checks and
the run options are free functions of a LegWalk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 4 commits November 1, 2026 15:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…m it

The transition watchers, the overworld detector and Walk.cpp's
BattleDialogWatcher come from PokemonAutomation#1717 by
Developer-Butters; their headers now say so. The transition watchers get
the repo's header block, include guard and one namespace per line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
#129's new .cpp and .h files were LF; they are CRLF like the rest of
the repo. Line endings only: git diff --ignore-cr-at-eol shows nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
r14 walked into Barry's Route 201 warning, which no map records, took it
for an unknown trainer, replanned into it again and looped for minutes.
A route now fails on the third such stop instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 5 commits November 9, 2026 00:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Moves #226's versions of these files into the PR that owns them. #226 commits:

0d35443 AutoStory: shared screen events and judges; BDSP and FRLG adapters (#268) (#290)
0192d6b BDSP AutoStory: a warp is a fade or a banner; walks report warps (#268 slices 1-3) (#284)
5493a9e BDSP AutoStory: routes never run along a wander zone; short wall legs walk every tile (#277)
71c3ed1 BDSP AutoStory: a wall leg that never moved waits, then plans from its start (#271)
0738cd5 BDSP AutoStory: 01.03 runs straight north up column 46 to the Center
f2567a2 BDSP AutoStory: a battle on a counted leg's first tap re-plans to the step's end
65e145a BDSP AutoStory: a battle on a route leg's first input re-plans too
a0d2204 BDSP walk: do not mark origin as preceding leg when movement moved chunks
f9d253b BDSP AutoStory: tag late encounter origin unknown only when chunks moved <= 1
5a16268 BDSP AutoStory: soft cost penalty for wandering hazards and wall check safeguard
9a2eb0a BDSP AutoStory: avoid wandering NPC hazards and simulate wandering NPCs
ac1ef0b BDSP AutoStory: align Oreburgh Mine maps, corridor legs, and Floaroma pathing

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
…nsitionTracker

A warp's fade is judged frame by frame on BDSP_FADE_PROFILE: its dark or
white held as the step's rule says, or, when the hold fell between two
frames, the first frame of another scene after the fall. The walk's fade
watchers read their thresholds from the same profile (same numbers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 15 commits November 9, 2026 03:04
A walk's watchers (the encounter flash, black, the battle menu and text
box, a dialogue box) and the late watch after the hold now record what
they saw into WalkResult::events, the shared timed ScreenEventLog, from
the walk's first input (WalkResult::started). WalkResult also counts the
chunks that moved after the last battle was run from. Nothing reads them
yet; the walker places an open leg's battle with them next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
place_leg_battle() reads a walk's timed events with the shared
classifier: for one wild encounter it takes the tap its first timed
event's step fell in, adds the taps that moved after the battle was run
from, and bounds the player to a tile either side. An UNSETTLED verdict
(a fade too recent to tell a battle from a warp), two battles, or no
events leave it unplaced, and leg_battle_line() says why.

BDSP's lags are not measured on the console yet (flash 500 ms, battle
box 4500 ms after the tap); they are data in LegBattleTiming and flagged
there. record_tap_battle() records the same events for the sim. Unit
test on synthetic walks; the walker does not use it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…or is explicit)

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

The sim's encounters name their tap from 1, and a battle seen on a leg's
first tap may have begun before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
interrupted_open_leg() logs place_leg_battle()'s verdict and, for a wild
battle it places, plans again from the tiles a tile or so from where the
taps left the player rather than from every tile of the leg. A battle
on the taps after a block (a second walk), two battles, an UNSETTLED
fade or no events keep the whole leg, as before.

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
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
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