Skip to content

fix: cached paths skip the start cell and are no longer shared between maps (2.1.1) - #334

Merged
erwan-joly merged 1 commit into
masterfrom
fix/cached-path-excludes-start
Oct 13, 2026
Merged

erwan-joly merged 1 commit into
masterfrom
fix/cached-path-excludes-start

Conversation

@erwan-joly

Copy link
Copy Markdown
Contributor

Summary

  • Cached paths included the start cell. A fresh JumpPointSearchPathfinder.FindPath path starts at the first step, but FindPath cached path.Skip(i) under (path[i], end), which starts at the cell itself. On a cache hit the walker spent a step standing on its own cell. Now path.Skip(i + 1).
  • Caches were shared across maps. Cache (JPS) and BrushFirecache (goal-based) are static and were keyed only by coordinates. NosCore creates one pathfinder per map, so a path or brushfire from one map could be served on another. Both keys now include the grid. The static fields are kept, so this is a patch release.

Needed by NosCoreIO/NosCore#2445, which drops the server's .Skip(1) now that fresh paths are known to exclude the start.

Test plan

  • dotnet test test/NosCore.PathFinder.Tests: 9/9
  • New tests fail on the old code and pass now: a cached path equals the fresh path minus its first cell, and a blocked map doesn't reuse an open map's cached path through its wall

🤖 Generated with Claude Code

…n maps (2.1.1)

A fresh JPS path starts at the first step, but the entries cached along it
started at the cell itself, so a cache hit made the walker spend a step on
its own cell. The path caches were also static and keyed only by
coordinates, so one map's path could be served on another map. Both caches
are now keyed by grid too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: NosCoreIO/NosCore.PathFinder/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f58c935c-5720-4ae1-b0d8-6faa7ce8527e
📥 Commits

Reviewing files that changed from the base of the PR and between 45de42c and 22b6cb8.

📒 Files selected for processing (4)
  • src/NosCore.PathFinder/NosCore.PathFinder.csproj
  • src/NosCore.PathFinder/Pathfinder/GoalBasedPathfinder.cs
  • src/NosCore.PathFinder/Pathfinder/JumpPointSearchPathfinder.cs
  • test/NosCore.PathFinder.Tests/JumpPointSearchPathfinderTests.cs
 ________________________________________
< Where we're going, we don't need bugs. >
 ----------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@erwan-joly
erwan-joly merged commit 8b3b37f into master Oct 13, 2026
2 of 4 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