Repository navigation
Pokemon Navigation: connected maps, one world type for BDSP and FRLG - #408
Conversation
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
left a comment
There was a problem hiding this comment.
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
- (Medium)
ConnectedMapskeeps a pointer to aconst&argument, so it binds temporaries.ConnectedMaps view(load_maps());compiles and dangles at the end of the statement. AddConnectedMaps(std::vector<MapData>&&) = delete;(TotW #180, "don't keep references or views to arguments or temporaries"). - (Medium) No bounds check on
MapPlace::map.map(),across_edge()andneighbour()index(*m_maps)[index]unchecked, so a staleMapPlace(e.g. after #411's world grows, or from another world) is UB. Checkindex < size()inmap()and throwInternalProgramError(repo rule: explicit check, not.at()). - (Low)
MapPlace(andTilePos) have==but no order. #412's planner needs aStateLess, and FRLG is meant to plan withMapPlaceas its state; give bothauto operator<=>(const …&) const = default;here so every model can usestd::less<>instead of hand-written comparators (BDSP'sRobustWorldModeland the toy model in #412 already each write one). - (Low) Misplaced comment in the tests. "Why
actualis notexpected, if it is not." sits abovePlaceExpectationinstead ofmismatch(); move it down. - (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 onnav/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.
…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
…ealth) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
|
Review addressed at 213ceb7 (fixes: 371bd8d, 213ceb7;
|
dayfine
left a comment
There was a problem hiding this comment.
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
- Binding temporaries: resolved.
explicit ConnectedMaps(std::vector<MapData>&&) = delete;is in place, soConnectedMaps view(load_maps());no longer compiles. The tests build fromtest_maps(), which returns aconst&to a function-local static, so they are unaffected. - Index bounds: resolved.
map()is now out of line and throwsInternalProgramError(nullptr, PA_CURRENT_FUNCTION, ...)at or pastsize(), and the message gives the index and the count.neighbour(),across_edge()andwarp_arrival()all index throughmap(), andfind()stays inside the bounds of its own loop. No raw(*m_maps)[...]read is left unchecked. - Order: resolved.
MapPlaceandTilePoseach have a defaulted<=>next to their==, andTilePos's comes from its owning PR. - Misplaced comment: resolved. The comment now sits on
mismatch(). - 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::maphas 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
|
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 |
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), withsize(),find(),warp_arrival(),across_edge()andneighbour(); 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 aMapPlaceand step withneighbour(). Tested with the newPokemon::ConnectedMapssuite (12 cases) in the headless runner.🤖 Generated with Claude Code
https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss