Skip to content

Pokemon Navigation: connected maps, one world type for BDSP and FRLG - #408

Merged
dayfine merged 8 commits into
nav/grid-story-stepsfrom
nav/connected-maps
Nov 12, 2026
Merged

dayfine merged 8 commits into
nav/grid-story-stepsfrom
nav/connected-maps

Conversation

@dayfine

@dayfine dayfine commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Base: nav/grid-story-steps; no parent PRs; the diff shows only this change. Game PRs that read it: FRLG #409, BDSP #411.

AutoStory seam 2, the one world type (user's pick 2026-11-11: BDSP moves to FRLG-style connected maps). FRLG's planner and its sim each had their own map lookup, warp arrival and edge crossing, and BDSP had none, since its maps carry no connections and were stitched onto one grid instead. This adds Pokemon/Navigation/Pokemon_ConnectedMaps.h: a view of the loaded maps where the player's place is a map and a tile (MapPlace), with size(), find(), warp_arrival(), across_edge() and neighbour(); whether a step is allowed and what happens on arrival stays per game. connect_by_world() joins maps placed on one world grid (MapData::world) where their rectangles meet, which gives BDSP's maps their edges. Seam 3's SimBody is meant to hold a MapPlace and step with neighbour(). Tested with the new Pokemon::ConnectedMaps suite (12 cases) in the headless runner.

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

dayfine and others added 2 commits November 11, 2026 20:31
Maps joined by their warps and edges, with the player's place as a map
and a tile of it. Where a warp or an edge leads is computed once here;
whether a step is allowed stays per game. connect_by_world() joins maps
placed on one world grid, for BDSP's maps, which have no connections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…edge entry split out

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
Conflict in SourceFiles.cmake: kept both file lists.

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

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: e5e09c2

Reviewed against nav/grid-story-steps (own diff only). Shared infra, held to the infra bar.

Verdict

NEEDS_REWORK (changes needed)

Correctness of the geometry checks out: touching() sets offset = pb.x - pa.x (or .y), edge_entry() maps here - offset onto the far map's edge row/column, which is pret's connection-offset convention, and the strict overlap tests keep corner-only contacts out. connect_by_world() is idempotent, so calling it after each add() (#411) is safe. The 12 cases cover same-map, all four edges, off-span, off-grid and the warp misses. Code Health: 0 failures (advisory: ConnectedMaps 6 public methods).

Findings

  1. (Medium) ConnectedMaps keeps a pointer to a const& argument, so it binds temporaries. ConnectedMaps view(load_maps()); compiles and dangles at the end of the statement. Add ConnectedMaps(std::vector<MapData>&&) = delete; (TotW #180, "don't keep references or views to arguments or temporaries").
  2. (Medium) No bounds check on MapPlace::map. map(), across_edge() and neighbour() index (*m_maps)[index] unchecked, so a stale MapPlace (e.g. after #411's world grows, or from another world) is UB. Check index < size() in map() and throw InternalProgramError (repo rule: explicit check, not .at()).
  3. (Low) MapPlace (and TilePos) have == but no order. #412's planner needs a StateLess, and FRLG is meant to plan with MapPlace as its state; give both auto operator<=>(const …&) const = default; here so every model can use std::less<> instead of hand-written comparators (BDSP's RobustWorldModel and the toy model in #412 already each write one).
  4. (Low) Misplaced comment in the tests. "Why actual is not expected, if it is not." sits above PlaceExpectation instead of mismatch(); move it down.
  5. (Nit) The art in the test header draws Route over x -1..5; it spans -1..4 (6 wide), and Lake (4..5) also meets Route's south edge at x = 4, which connect_by_world() joins but no case checks. Either fix the drawing or add the Lake -> Route case.

Notes

  • Fork Draft CI is red from the base (Pokemon_StoryStepJson_Tests.cpp:150, GCC -Werror=dangling-pointer, same on nav/grid-story-steps), so the new suite has only run locally.
  • connect_by_world(std::vector<MapData>&) edits in place; fine as it is (an in-place join of a list), not asking for a change.

dayfine and others added 3 commits November 12, 2026 00:15
…exes, orders MapPlace (#408 review)

The rvalue constructor is deleted, map() throws InternalProgramError past
the last map, and MapPlace gets a defaulted <=> over TilePos's. The test
art matches the maps, the Lake to Route edge has two cases, and stale map
indexes have their own.

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

dayfine commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Review addressed at 213ceb7 (fixes: 371bd8d, 213ceb7; TilePos order in nav/shared d0c817b, merged down).

  1. ConnectedMaps(std::vector<MapData>&&) = delete;.
  2. map() is now out of line and throws InternalProgramError when the index is at or past size(). across_edge() and neighbour() go through it. A new table checks that the last index is read and that one past the last and far past it are rejected.
  3. MapPlace has auto operator<=>(...) const = default. TilePos gets the same in Pokemon_Grid.h, but in its owning PR (nav/shared), merged down AutoStory: story step types and engine (split from #122, layer 1 of 3) #312 → CommonTools: screen events for autonomous programs (what the screen is doing, since when) #313 → AutoStory: one story engine over a backend, save mode from checkpoint metadata #332 → AutoStory 2D core: tile navigation package #360 → AutoStory 2D core: scene judges, transitions and interrupts #361 → AutoStory 2D core: story actions and interrupts between steps #362 and down the BDSP base chain.
  4. The comment now sits on mismatch().
  5. The drawing now matches the maps (Route spans -1..4). Two new rows: north out of the Lake onto Route (5, 2), and past Route's span to nowhere.

connected_maps(StoryWorld&&) = delete is in #411. Code health: 0. The ConnectedMaps suite passed in the local headless run. The three-row stale-index table was added after that run and has only been compiled, so CI covers it.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: 213ceb7

Re-review after e5e09c2. I read the fix commits 371bd8d and 213ceb7 and the TilePos order from nav/shared (d0c817b). The other commits since the last review are base merges and are not reviewed here.

Verdict

APPROVED

Earlier findings

  1. Binding temporaries: resolved. explicit ConnectedMaps(std::vector<MapData>&&) = delete; is in place, so ConnectedMaps view(load_maps()); no longer compiles. The tests build from test_maps(), which returns a const& to a function-local static, so they are unaffected.
  2. Index bounds: resolved. map() is now out of line and throws InternalProgramError(nullptr, PA_CURRENT_FUNCTION, ...) at or past size(), and the message gives the index and the count. neighbour(), across_edge() and warp_arrival() all index through map(), and find() stays inside the bounds of its own loop. No raw (*m_maps)[...] read is left unchecked.
  3. Order: resolved. MapPlace and TilePos each have a defaulted <=> next to their ==, and TilePos's comes from its owning PR.
  4. Misplaced comment: resolved. The comment now sits on mismatch().
  5. Test art: resolved. Route now spans -1..4 in the drawing. I checked the two new Lake cases by hand: Lake (0,0) is world (4,3), so north lands at world (4,2), which is Route (5,2). Lake (1,0) is world (5,3), and north of it lies past Route's span, so it goes nowhere.

Fix diff

I found no correctness problems. In the stale-index table, the "last map index is read" row uses House (index 3), which has no connections. North of (0,0) leaves its grid, so neighbour() returns nothing without throwing, and the row checks the boundary as intended. The table follows the input/expectation case shape, and the failure message gives both the expected and the actual outcome. Style is fine: CRLF, }catch (...){, includes in order, and a comment on each new symbol. Code Health: 0 failures (advisory: ConnectedMaps has 6 public methods, against the advisory 5 and the limit of 7). Fork Draft CI's Ubuntu build passes at this SHA. The native-schema failures come from the base and are not part of this diff.

Nits (non-blocking)

  • StalePlaceInput::map has no initializer (size_t map = 0;), which matches the "initialize every scalar" rule.

Conflict in ComputerPrograms_UnitTestRunner.cpp: kept both
add_tests_ConnectedMaps and add_tests_MoveMechanics.

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

dayfine commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Merged base nav/grid-story-steps at 0ac724b (merge commit 29841ed); conflict only in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp: kept both registrations.

     Pokemon::add_tests_MapData(ret);
     Pokemon::add_tests_ConnectedMaps(ret);
+    Pokemon::add_tests_MoveMechanics(ret);
     Pokemon::add_tests_RuntimeMap(ret);

(the #include lines for both test headers auto-merged; SourceFiles.cmake auto-merged with each file listed once). Code health: 0 failures.

@dayfine
dayfine merged commit 8be521c into nav/grid-story-steps Nov 12, 2026
13 of 16 checks passed
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