Skip to content

test: check A* and Dijkstra paths on small grids - #286

Open
abedinm wants to merge 1 commit into
ShisatoYano:mainfrom
abedinm:test/grid-path-planners
Open

abedinm wants to merge 1 commit into
ShisatoYano:mainfrom
abedinm:test/grid-path-planners

Conversation

@abedinm

@abedinm abedinm commented Nov 24, 2026

Copy link
Copy Markdown

Summary

Adds unit tests for AStarPathPlanner and DijkstraPathPlanner on small grids written to pytest's tmp_path (gif_name=None, no drawing), reading the saved path back:

  • On an empty grid, a path along one row visits every cell from start to goal in order
  • Every step goes to a neighboring cell
  • Dijkstra's path to (6, 3) has the shortest length (3 diagonal + 3 straight steps)
  • With a wall that has one gap, the path crosses the wall only at the gap
  • The path never enters an obstacle cell

Tests only, no src/ change. Closes #272, part of #103.

How I checked it works

pytest test/test_grid_path_planners.py passes (9 tests). It fails when AStarPathPlanner.is_valid ignores obstacles (2 tests fail). . run_test_suites.sh passes (147 passed).

While writing these I found that paths of 20 points or fewer are saved as grid indices rather than world coordinates, so these tests use a map that starts at the origin with 1 m cells. That is reported separately in #283.

Images

Tests only, not needed.

Book

  • This PR doesn't change code that the book describes, or I updated those pages

AI disclosure: I wrote this with the help of Claude Code.

🤖 Generated with Claude Code

Part of ShisatoYano#103. Closes ShisatoYano#272.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Unit tests: A* and Dijkstra return a correct path on small grids

1 participant