Bundle Classic AI algorithms: graph search, adversarial game search, optimization and tabular reinforcement learning (-lib ai)
AStar
A* single-pair shortest path: Dijkstra ordered by f = g + h using a per-node heuristic array. With an admissible heuristic (never overestimating the remaining cost) the result cost equals Dijkstra's while typically expanding fewer nodes.
Example
# heuristic[i] = straight-line estimate from node i to the goal
result := AStar->FindPath(graph, 0, 5, heuristic);Operations
FindPath # function
Finds the minimum-cost path between two nodes guided by a heuristic.
function : FindPath(graph:Graph, start:Int, goal:Int, heuristic:Float[]) ~ SearchResultParameters
| Name | Type | Description |
|---|---|---|
| graph | Graph | graph to search |
| start | Int | start node id |
| goal | Int | goal node id |
| heuristic | Float | estimated remaining cost per node id (length = node count) |
Return
| Type | Description |
|---|---|
| SearchResult | search result |