Chapters

On this page

All lessons

A* Algorithm
Anytime Weighted A*current
Dijkstra's Algorithm
soon
Breadth-First Search
soon
Back to A*
Chapter 1

Understanding AWA* (Anytime Weighted A*)

AWA* finds a valid path almost immediately, then keeps improving it. It multiplies the heuristic by a weight w > 1 to search aggressively — then continues to improve the solution over time until the lower and upper bounds cross, proving we have discovered an optimal solution.

Open set
Closed set
Current node
Water (cost ×10)
Incumbent path
Tool:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
A
B
C
D
E
F
G
H
I
J

Statistics

Upper Bound (UB)
Lower Bound (LB)
Open Set Size0
Nodes Expanded0
Nodes Re-expanded0
Nodes Pruned0
Weight0

Draw your map above, then click Run A* to generate the step trace.

How AWA* works

Weighted heuristic. Standard A* uses f(n) = g(n) + h(n). AWA* uses f(n) = g(n) + w·h(n) where w > 1. This inflates the heuristic, making nodes closer to the goal look artificially cheaper — so search is faster but the result may cost up to the optimal.

Anytime guarantee. As search continues, you iteratively look to improve upon the existing best-solution.

Pruning. Once a solution of cost C exists, any OPEN node whose f-value ≥ C, enabling us to prune them from the search space.

In this demo: The water band (cost ×10) sits in the direct path. AWA* initially charges through it; but later discovers the cheap route around it — cutting the path cost dramatically.
Chapter 2

Comparing AWA* to A*

Same grid, same start, same goal — two different strategies. AWA* (left) charges through expensive water using its inflated heuristic, finds a quick path, then keeps refining. A* (right) carefully weighs every option and routes around the water to find the optimal path in a single pass. Edit either grid to modify both simultaneously.

Open set
Closed set
Current node
Water (cost ×10)
Path
Tool:
AWA*f = g(n) + w · h(n), w = 108-connected

AWA* Statistics

Upper Bound (UB)
Lower Bound (LB)
Open Set Size0
Nodes Expanded0
Nodes Re-expanded0
Nodes Pruned0
A*g(n) + h(n)8-connected

A* Statistics

Path Cost
Open Set Size0
Nodes Expanded0

Modify the grids above, then click Run animation to compare both algorithms side by side.

Continue your Learning

Watch the full AWA* video for a deeper walkthrough of the algorithm and the intuition behind anytime search.

Read the original Anytime Weighted A* paper:

https://doi.org/10.1613/jair.2096
A* Algorithm
Dijkstra's Soon

Found this helpful?

These resources are free — if they saved you time, a coffee keeps them going.

Buy me a coffee