Skip to content

Pokemon navigation core: tile positions and the leg planner - #66

Closed
dayfine wants to merge 15 commits into
mainfrom
nav/core
Closed

dayfine wants to merge 15 commits into
mainfrom
nav/core

Conversation

@dayfine

@dayfine dayfine commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

FRLG and BDSP each built a grid planner for AutoStory, and the two copies share the same ideas but can't serve each other, because each planner is tied to its own map type. This adds the part both games plan on: the grid types (tile positions and directions) and a leg planner that asks the game's step model what one press does and prefers legs that end at a wall, tested on a small made-up game. Everything else that was here moved to where its user lives: ScreenMachine/StepTrace to #108 (BDSP's new-game intro, no navigation dependency), the leg walker to FRLG's #67 (its LegMover is now a small abstract class, so this PR no longer depends on #72 and carries no copy of MoveOnlyFunction), and TileGrid/MapSet to #109 for BDSP's walker and maps, to come back into the core when FRLG adopts them. The plan is docs/design/AutoStory-Navigation-Stack.md on #42.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

dayfine and others added 3 commits October 29, 2026 17:45
…odel

The planner searches for the cheapest legs (hold one direction, then the
next) and prefers legs that end against a wall. Each game supplies what
one press of a direction does; the planner doesn't know any tile legend.
Tested on a small made-up game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Holds one leg while watching for what can stop it part-way. On an
interrupt, a leg to a wall is held again and an open leg walks what is
left, estimated from when the interrupt was seen. The bookkeeping is a
plain function, tested with scripted holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Routines that mash a button or hold a direction for a fixed time break when an
input drops or a stray press opens a menu, and nothing notices until much
later. run_screen_machine() is the closed-loop alternative: it reads the
screen (two frames must agree), takes the one step that state calls for, and
fails on a screen the previous state cannot lead to, a state seen too often or
too many times in a row, eight steps that change nothing, or the timeout. A
capture that drops out for up to 10s is waited out.

StepTrace logs each change of recognized screen with a numbered screenshot and
each input, and a failure lists the screens that led to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
std::function is copyable: copying it forks a stateful lambda's state,
and it cannot hold move-only captures. MoveOnlyFunction is an alias of
std::move_only_function where the standard library has it, and a
minimal R(Args...) fallback for Apple's libc++, which lacks it.

Tests: move-only capture, moving keeps one state, empty and nullptr
comparison, reassignment; copy is rejected at compile time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 6 commits October 29, 2026 22:03
The leg walker takes its mover as a MoveOnlyFunction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
LegMover had one method, so it is now a MoveOnlyFunction that holds a
direction for a duration. walk_leg() takes it by reference, since calling
a MoveOnlyFunction is non-const.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The search's maps and queue become a Search struct, and relaxing a node,
expanding a node, the goal search, tracing the moves back and the final
turn each get a function. The search visits nodes in the same order, so
the plans are unchanged.

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

The standard does not make std::move_only_function's move assignment
noexcept, and MSVC's STL does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Picks up the test fix for MSVC's std::move_only_function, whose move
assignment is not noexcept.

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
dayfine and others added 3 commits October 30, 2026 07:38
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
Move-only: Pokemon_TileGrid.{h,cpp} and Pokemon_MapSet.{h,cpp} are copied
unchanged from bdsp/floaroma-mvp, where the BDSP AutoStory MVP added them,
so the grid and map set sit with the planner and walker they build on.
Their tests stay with the BDSP map data they check.

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 Oct 31, 2026
…fset) and the MVP plan

Section 14 of the lessons: measured movement (D-pad taps are whole tiles,
stick holds drift), the clip-to-wall then D-pad offset route model, what
the screen tells, and the process mistakes. AutoStory-MVP-Plan.md: run 1
stays on fork #68; the compact series stacked on #66 follows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 2 commits October 31, 2026 20:49
…a search cap

Three planner changes the BDSP run made on its branch, ported to the core:
RobustPlanCosts::exact_open_tiles (open legs up to that length land exactly:
D-pad taps move whole tiles), per_open_tile (a long open leg costs more
than a short step after a wall), and max_searched (the set search gives up
after 20000 sets: all of Jubilife from six start tiles ran for minutes,
r224a; town costs or a cropped map are the answer, not a higher cap).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Both games plan on Grid and LegPlanner, so those stay here. The rest
served one game each and moves to its user: ScreenMachine/StepTrace to
common/screen-machine, LegWalker to frlg/brock-mvp (where LegMover is a
small abstract class, so MoveOnlyFunction is no longer needed here),
TileGrid and MapSet to bdsp/tilegrid-mapset. The MoveOnlyFunction copy
of #72 goes with them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine dayfine changed the title Pokemon navigation core: leg planner, leg walker, screen machine Pokemon navigation core: tile positions and the leg planner Nov 1, 2026
@dayfine

dayfine commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #114 (commit S2 3209523 of the shared-core collector). Branch kept.

@dayfine dayfine closed this Nov 1, 2026
dayfine added a commit that referenced this pull request Nov 2, 2026
* Design doc: shared AutoStory run flow, 2D movement, and an FRLG AutoStory

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

* Design doc: lead with problem, situation and proposal; FireRed, solo from a new game

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

* Design doc: full upstream reference for the SwSh draft

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

* Design doc: prior art (junari's FRLG script) and ComputerControl#259

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

* Design doc: PR plan with sizes for reviewers

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

* Design doc: FRLG pilot to Brock first, shared code later

Reorder the plan so the first PRs touch only FRLG files and end in a runnable
pilot (new game -> Boulder Badge in about 10 PRs, first runnable at PR 5),
with an F3 go/no-go gate on checkpoints and Switch hours. The SV/BDSP shared
run flow moves to a later phase. Add a one-page upstream-facing proposal,
standalone review comment drafts for PokemonAutomation#1717
(not posted), and the FRLG authors on main. Drop the agent process section.

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

* Design doc: reusable pieces in their final homes, no copy-then-move

The plan wrote FRLG's run flow and tile path inside the FRLG module and moved
them out in phase D (R0, T4): move-only PRs of our own code. Adding new files
to a shared module changes no one else's code, so they now start in
Pokemon/AutoStory and Pokemon/Navigation. New section 0.1 lists the
game-neutral pieces from SV, BDSP PokemonAutomation#1717, SwSh PokemonAutomation#1207, BBQ and the BDSP lab
work (screen machine, step trace, failure policy, list selection, system
keyboard, Lab Console, run flow, tile path, decision tests) with their
homes; D4 builds the FRLG intro on the screen machine. The proposal says
the same.

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

* Design doc: what broke on the console and the rule each break taught

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

* Design doc lessons: drop the Max Lair entry, it is not AutoStory

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

* AutoStory design notes: screen machine, walking, map, planner, executor

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

* AutoStory design: plan on routes, trust town grids only once verified

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

* AutoStory docs: what broke in Butters' 00.04 and 00.05, and what replaced it

Lessons: a table of his recorded route against what console B showed
(timed legs, slot-3 Ember, no healing, pixel-matched Potion, the Poke
Mart lady and Barry missed by a tile), our own mistakes in this round
(an optional step kept for hours, claims not checked on screen, map
errors, untiled movement, a fixed OCR cut), and stepping through new
ground before automating it. Design: the executor, move choice,
training and Potion healing as built, and the Lab Console stepping.

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

* AutoStory lessons: link our commit for each fix; the Pokétch president's talk

Each row of the Butters comparison and each of our own mistakes now
links the fork commit that fixed it, on bdsp/new-game-intro-v2. Adds
what stepping through Phase 23 showed: A re-opens the president's talk,
B advances it.

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

* AutoStory lessons: 00.05 stepped through to the PC; read positions from the ground; towns need grids too

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

* AutoStory: segment 01 plan (story, trainers, maps, work order); segment 00 leftovers scheduled

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

* AutoStory lessons: segment 01 runs r81 to r90, one rule per failure

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

* AutoStory lessons §10: Oreburgh Mine, Roark's gym, Route 204 to Floaroma; Butters' segment 01

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

* AutoStory: shared navigation core and the FRLG Brock / BDSP Floaroma MVP branches

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

* AutoStory: end the FRLG run with Mew, through the Sevii Ruby and Sapphire

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

* AutoStory navigation stack: fork PR numbers

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

* AutoStory: queue the BDSP MVP follow-ups (clock pin, shared walker, resources)

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

* AutoStory lessons §11: Floaroma MVP runs r107 to r109 and the lab around them

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

* AutoStory lessons: split into Part 1 for Butters (PokemonAutomation#1717) and Part 2 for us

Sections are renumbered; cross-references updated. Butters' segment 01
table and the two PokemonAutomation#1717 failures from r108 get their own sections in Part 1.

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

* AutoStory docs: mark the segment plans done or superseded, the PokemonAutomation#1717 drafts stale; pose status

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

* Design: AutoStory lessons from 01.03/01.04 (D-pad tiles, clip then offset) and the MVP plan

Section 14 of the lessons: measured movement (D-pad taps are whole tiles,
stick holds drift), the clip-to-wall then D-pad offset route model, what
the screen tells, and the process mistakes. AutoStory-MVP-Plan.md: run 1
stays on fork #68; the compact series stacked on #66 follows it.

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

* Design: AutoStory lessons 15 (Route 204, maps from the decomp) and the plan's next version

Lessons from 01.06 to 01.10 (r216 to r246): Bulbapedia DP images have 12 px
rows and cliffs painted taller than their tiles; the Platinum decomp gives
the real tiles and NPCs; a wandering NPC is not a wall; the planner's
cheapest legs are not a human's line; time-counted legs break when blocked;
a tap's screen change separates steps (21 to 50) from bumps (4 to 13); a
stale build ran twice. The MVP plan gets a "Maps from the game's data" track
(decoder, re-derivation, annotation, probes, PokemonNavigation) and the
planner/walker goals for the next version.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

* Design: take in the decomp review and the route-impact check

The review's points on events, scripts, interaction identities and warps
go into the plan; the critique: terrain first, pokediamond before
pokeplatinum (DP's own map and event data exist), the walker's observation
is a separate problem, and the start is the maps 01.06 to 01.10 walk on.
The offline route-impact check: wall legs absorb the row differences, two
open legs and all of Jubilife's walks change, and the short grids pass
because vertical timing compensates by the same 4/3.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

* Design: PR chain review, what moves to the core, what stays per game, FRLG and PokemonNavigation

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

* Design: a 160 ms D-pad tap turns and steps (r248a)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

* AutoStory lessons: Route 204 after r246 (turn taps, bumps, until-stopped, banner end, routes as data, Diamond decomp)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

* Design: AutoStory architecture after the FRLG proof of concept

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

* Architecture: the game simulator (encounters, Repel, battles, EXP, whiteout), parallel to the MVP

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

* Architecture: SwSh/LA, story engine under Pokemon/AutoStory, reuse of RNG and Elite Four programs, milestones after the MVPs

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

* Architecture: room for error - bounded safe inputs, then confirm the end state

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

* Architecture: fold in the event model (#78) and the FRLG demo plan (#56)

Section 8 keeps the step rules from the event model (anchors, talks,
dialogs that end on a screen, named recoveries, resume as a re-check)
and the RNG hand-off rules from the demo plan. Section 5 gets the
movement table and the SwSh target; section 7 the planner's missing
search limits; section 6c links the FRLG events after Brock (#130).

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

* Architecture: generated maps ship in Resources (Packages), test maps stay compiled in

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant