Repository navigation
feat(nav): renderoni/nav — tiled grid A*, expedition router, spatial hash - #41
Open
cmaycumber wants to merge 1 commit into
Open
cmaycumber wants to merge 1 commit into
cmaycumber wants to merge 1 commit into
Conversation
…atial hash
NavGrid is generic over a NavCostField the game supplies (size, cellCost,
optional coarseWalkable/passable). Tiles are sampled lazily and LRU-evicted
(evicted arrays are pooled), blockers are re-applied on rebuild, and A* runs
in a bounded window with generation-stamped scratch and a typed-array heap.
Cell size, tile size, tile cap, window, budget, easy-cost and blocker slack
are options; defaults reproduce the Sunder March grid exactly.
ExpeditionRouter joins complete local paths into long corridors against a
small RouterNav interface. SpatialHash<T> works over anything with a
position {x, z}.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
elemarin
requested changes
Oct 10, 2026
elemarin
left a comment
Owner
There was a problem hiding this comment.
Thanks, this is well built. The lazy tiles, re-applying blockers on rebuild, and the stamped typed-array A* all check out. Build, typecheck and tests (246/246) pass, and I found no correctness bugs in the A* itself.
Before merge:
- Router input validation: an out-of-bounds or unwalkable goal burns about 1,800 local searches before failing. Please check
inBounds/walkableinrequest()and returnblockedimmediately. minSpacing: halving can undershoot the floor (100 → 50 → 25). Please clamp withMath.max(minSpacing, spacing / 2).- Costs below 1: the octile heuristic is only admissible for costs ≥ 1, so "fast" cells such as roads give non-optimal paths. Please add a
minCostscale or document it. - Generalize: please rename
ExpeditionRouterto something likeRoutePlannerand drop the house/door/road wording. Use an enumreasoninstead of English UI strings, and plain{x, z}instead of three'sVector2. Router defaults would be better scaled fromnav.cellthan absolute metres. - Hardening: please add
invalidate(x, z, r)for runtime cost changes, guardSpatialHashagainst non-finite radius and out-of-range coordinates, and validaten <= 46340(Int32 index math). - Docs: please soften the "allocation-free" wording in AGENTS.md. The router allocates string keys and arrays per update.
- Tests: please add cases for router failure paths, costs below 1, and
SpatialHashwith negative and far coordinates.
Note: this will need a small AGENTS.md rebase after #39 and #40 land.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new
renderoni/naventry point: grid pathfinding for large worlds, extracted from a shipping game.NavGrid: generic over aNavCostFieldthe game supplies (size,cellCost(x, z), optionalcoarseWalkable/passablefor far-away queries that must not build tiles).nearestWalkable,lineClear,segmentWalkableandprewarm.ExpeditionRouter: joins complete local paths into long corridors across the map against a smallRouterNavinterface, with a ticketed request API.SpatialHash<T>: a neighbour-query grid over anything withposition: { x, z }.The game now supplies only its cost rules (water, cliffs, slope, roads) and uses these classes directly. Its 496-test suite passes on them, including long-range navigation tests.
Verification: typecheck, build, 246/246 tests.
🤖 Generated with Claude Code