Repository navigation
Pokemon Navigation: robust leg planner shared by the tile games - #412
Conversation
BDSP's search over the sets of tiles a player may stand on after an uncertain open leg, lifted as a template over a step model so it can plan on any state (a world tile, or a map and a tile). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…put and expectation cases 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
dayfine
left a comment
There was a problem hiding this comment.
Reviewed SHA: 4206f33
Reviewed against nav/connected-maps (own diff only). Shared infra, held to the infra bar.
Verdict
NEEDS_REWORK (changes needed)
Correctness: I compared the template with the BDSP code it replaces (RobustSearch, step_tiles, slide_to_wall, to_wall_leg, open_leg, robust_route_cost in PokemonBDSP_AutoStory_RoutePlanner.cpp on bdsp/connected-maps). It is the same algorithm line for line: the same error formula, the same costs, the same per-leg discount for a continued open leg, the same max_spread/max_searched limits, consolidation moved from legs_to() to consolidate() with the same rule, and relax() copies the leg into the node before moving after into the queue. So BDSP plans cannot change. Code Health: 0 failures (advisory: to_wall_leg and robust_legs_cost 32 lines).
Findings
- (Medium) The tests are not data-driven. Each row holds a function pointer plus an
expectation.descriptionstring that nothing reads, and the map, start, goal, costs and expected legs live inside five hand-written functions with compoundifchecks. That is the shape the repo's test rule exists to prevent (input and expectation structs, inputs visible in the row, oneUnitTestover a table). Make the row{rows, from, goal, costs overrides}->{expected legs as text, or "no plan"}and comparedescribe()output, so a failure prints expected and actual plans. - (Medium)
open_error_per = 0divides by zero.costs.open_error + tiles / costs.open_error_perruns whenevertiles > exact_open_tiles. FRLG's planned setup is "open_error 0" for timed holds, and zeroing the growth term is the obvious way to write that. Either treat 0 as "no growth", or reject it withInternalProgramErrorat the top ofplan_robust_legs()/robust_legs_cost(), and document that exact legs areexact_open_tiles = max_open_tiles. - (Medium) Coverage gaps in what is claimed game-neutral. No case has
step_tiles() > 1(the ledge hop that the header calls out), the wild cost,max_spreadrejecting a wide spread,max_searchedgiving up, or two open legs the same way being joined. The toy model'sstep_tiles()is always 1. These are the parts FRLG will lean on (FRLG ledges); one row each. - (Low, FRLG fit) The API is neutral in its state type, so
MapPlaceworks, with three gaps worth deciding before FRLG builds on it:- It is a second step-model concept beside
Pokemon_LegPlanner.h(press()/Step<State>/StateHashthere;step()/step_tiles()/wild()/wander()/StateLesshere). Each game now writes two adapters over the same rules (BDSP'sStoryWorldModelandRobustWorldModelin #413). At least share the names (held_atalready matches) and say in the header how the two relate. - It has no warps or game actions (Surf, doors, spin tiles): a stop that isn't held is never used, so a plan cannot cross a warp. That is fine if FRLG plans each warp-to-warp segment separately; say so in the header as the caller's job.
StateLessmust be hand-written becauseMapPlace/TilePoshave no order (see #408 finding 3); with<=>there, the concept could default tostd::less<State>.
- It is a second step-model concept beside
- (Low)
slide_to_wall()loops untilstep()returns nothing. On one stitched BDSP grid that always ends; on connected maps a loop of edge connections (or a model bug) hangs the planner. Bound it (e.g. bymax_searchedor a tile cap) and treat the cap as "not held". - (Note for #413 and the lab line)
RobustLegCosts::per_wander_tile = 3duplicates BDSP'sTilePlanCostsdefault. BDSP never uses the shared default (it copies its own), so this is harmless now; see #413 about the lab's 15.
Notes
- Fork Draft CI is red from the base (
Pokemon_StoryStepJson_Tests.cpp:150GCC dangling-pointer, inherited), so the suite ran only locally. const std::function<…>& goalmatchesPokemon_LegPlanner.h; fine.
…0; capped slide (#412 review) Each row now holds the map, starts, goal and costs, and the expected plan as text; one runner compares describe() output. New rows cover a ledge hop, tall grass, max_spread, max_searched, joined open legs and a walk that never stops. open_error_per 0 adds no growth instead of dividing by zero, and slide_to_wall() gives up as not held after 1024 steps. The header says how this step model relates to LegPlanner's and that warps are the caller's job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
|
Review addressed at ffdf9ae (fix: 1ca9ec4, plus #408 merged in).
Local headless run: 20/20 RobustLegPlanner rows pass, and the BDSP golden is unchanged. Code health: 0. |
|
Merged base nav/connected-maps at 29841ed (merge commit 138d27f), which brings in nav/grid-story-steps 0ac724b. This merge was clean; the only conflict upstream of it was in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp, resolved in #408 by keeping both registrations: Pokemon::add_tests_MapData(ret);
Pokemon::add_tests_ConnectedMaps(ret);
+ Pokemon::add_tests_MoveMechanics(ret);
Pokemon::add_tests_RuntimeMap(ret);(the |
dayfine
left a comment
There was a problem hiding this comment.
Reviewed SHA: 138d27f
Re-review of the fix (1ca9ec4) against my review at 4206f33; the later merges (ffdf9ae, 138d27f) bring only base changes: git diff origin/nav/connected-maps...138d27fab is still just the planner header, its tests, the test registration and SourceFiles.cmake.
Verdict
APPROVED
Earlier points:
- Data-driven tests: resolved.
PlanCaserows hold rows, wrap flag, starts, goal and costs, and expectdescribe()text or "none";CostCaserows hold legs and the expected cost. A failure prints the planned and expected text. open_error_per = 0: resolved. The formula now lives only inopen_leg_error(), which returnsopen_errorwhenopen_error_per <= 0. It is documented on the struct and covered by two plan rows and one cost row.- Coverage: resolved. There are rows for a ledge hop (
step_tiles2), a ledge that can't be climbed, cheap and costly tall grass,max_spread,max_searched, two open legs joined, and a walk that never stops. - FRLG fit: addressed in the header. It says how this step model relates to LegPlanner's, that warps are the caller's job, and that
std::less<State>works forTilePos/MapPlace. Keeping two adapters is a design choice I'm leaving open. - Unbounded slide: resolved.
slide_to_wall()stops afterMAX_STEPS_TO_WALL(1024) steps withheld = false, and its only caller checksheldbefore it usesstop/tiles. The wrapping-row test exercises this. - Note only; nothing needed here.
Checks: Fork Draft CI on 138d27f is green, and all 20 Pokemon::RobustLegPlanner cases pass in its log (16 plan, 4 cost). Code Health passes. Both files are CRLF throughout. The red "Runtime map reader" (native-schema) job fails on the base too and is not from this PR.
No new findings.
Base
nav/connected-maps(#408); the diff shows only this change.BDSP's robust route search, lifted into Pokemon/Navigation as a template over a step model, so FRLG can plan on it too (AutoStory unification seam 2).
Pokemon::plan_robust_legs()searches over the sets of places the player may stand on after each leg: open legs may endopen_errortiles off, walls bring the set back together.robust_legs_cost()prices given legs the same way.==and an order, so a world tile (BDSP) or a map and a tile (FRLG) both fit.RobustSearch/to_wall_leg/open_legfromPokemonBDSP_AutoStory_RoutePlanner.cpp, moved with the world calls replaced by model calls; nothing in it is new.Pokemon_LegPlanner.h's (press()/Step<State>), so each game writes two adapters over the same rules. Warps and game actions (doors, Surf, spin tiles) are not legs, so FRLG has to plan each stretch between warps on its own.Testing
Pokemon::RobustLegPlannersuite (table rows on a toy grid: walls, open-leg spread, doors, ledge hops, tall grass, wander zones, search limits,open_error_per0, a walk that never stops, costs) passes in the headless runner, built together with the BDSP child, which also passes itsPokemonBDSP::AutoStorysuites including the plan golden.🤖 Generated with Claude Code
https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss