Did you know ... Search Documentation:
Pack canny_tudor -- prolog/canny/a.pl
PublicShow source
 a_star(+Heuristics0, -Heuristics, +Options) is det
Offers a static non-Constraint Handling Rules interface to a_star/4. Performs a simplified A* search using CHR where the input is a list of all the possible arcs along with their cost. Each element in Heuristics0 is a h/3 term specifying source of the heuristic arc, the arc's destination node and the cost of traversing in-between. Nodes specify distinct but arbitrary terms. Only terms initial and final have semantic significance. You can override these using Options for initially and finally. For Options see below.

Simplifies the CHR implementation by accepting h/3 terms as a list rather than using predicates to expand nodes. We match heuristic terms using member/2 from the list of heuristics. This interface does not replace a_star/4 since having a pre-loaded list of heuristics is not always possible or feasible, for example when the number of arcs is very large such as when traversing a grid of arcs.

Here is a simple example.

?- a_star([h(a, b, 1)], A, [initially(a), finally(b)]).
A = [h(a, b, 1)].

Options include:

  • initially(Initial) defines the initial node, defaults to atom initial.
  • finally(Final) defines the final node, atom final by default.
  • reverse(Boolean) reverses the outgoing selected Heuristics so that the order reflects the forward order of traverse. The underlying expansion pushes path nodes to the head of the list resulting in a final-to-initial traversal by default.
See also
- https://rosettacode.org/wiki/A*_search_algorithm