Heuristic-driven shortest path search balancing speed and optimality.
Easy Explanation
A* uses distance-so-far plus a heuristic guess to focus search toward the goal while still finding optimal paths.
Renderer Mode
`Simple` uses abstract, short-form-friendly visuals. `Advanced` keeps the current detailed view.
Grid
n/a
Expanded
0
Distance
n/a
Result
Searching
Safe mode: choose a tool to edit the grid.
Press Play or Step to start execution.
function a_star(graph, start, target, heuristic):
open_set <- { start }
g[start] <- 0
f[start] <- heuristic(start, target)
parent <- empty
while open_set is not empty:
node <- open_set node with lowest f
remove node from open_set
if node == target:
return g[target], reconstruct_path(parent, target)
for each (neighbor, weight) in edges(node):
candidate_g <- g[node] + weight
if candidate_g < g[neighbor]:
parent[neighbor] <- node
g[neighbor] <- candidate_g
f[neighbor] <- candidate_g + heuristic(neighbor, target)
add neighbor to open_set
return not found