Skip to content

feat: add astar_reach for steppable A* search - #787

Open
tachsin wants to merge 1 commit into
evenfurther:mainfrom
tachsin:feat/astar-reach
Open

feat: add astar_reach for steppable A* search#787
tachsin wants to merge 1 commit into
evenfurther:mainfrom
tachsin:feat/astar-reach

Conversation

@tachsin

Copy link
Copy Markdown

Summary

Implements astar_reach for #775.

A* currently runs to completion. There is no way to step it, inspect expansions, or stop early. dijkstra_reach, bfs_reach, and dfs_reach already provide that for the other searches.

astar_reach(start, successors, heuristic) yields one AstarReachableItem per expansion:

  • node, parent, total_cost (g) — same idea as DijkstraReachableItem
  • estimated_cost (f = g + h) — so a visualizer can show the A* priority

Nodes come out in the same order astar would expand them. Each node is yielded at most once. There is no goal predicate; stop from the outside with find, take_while, or by dropping the iterator.

idastar / iddfs are not in this PR. They restart the search at each bound, so a useful iterator is a different design.

Closes#775

Test plan

  • cargo test --test astar-reach
  • Zero heuristic matches dijkstra_reach on the same graph
  • Stopping at the goal reports the same cost as astar
  • A consistent heuristic expands fewer nodes than h = 0

Made with Cursor

A* could not be interrupted or inspected mid-search. astar_reach
yields each expansion so callers can step, visualize, or stop early.
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for freeto 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.

Steppable versions of A* (astar_reach) and of other algorithms

1 participant

@tachsin