Explore Euclidean vs Manhattan Distance in A* Search
Understanding how heuristics guide intelligent pathfindingA* uses the evaluation function f(n) = g(n) + h(n) where:
Uses straight-line distance (as the crow flies). Provides the most direct estimate but may not be admissible in grid worlds with only 4-directional movement.
Select a heuristic function above and click "Next Step" to begin A* search, or click "Show All Heuristics" to see values.
Current Status: Ready
No node selected
| Property | Euclidean | Manhattan |
|---|---|---|
| Movement | Diagonal allowed | 4-directional |
| Admissible? | Sometimes | Yes |
| Performance | Fewer explored | More explored |
| Optimality | Not guaranteed | Guaranteed |
Never overestimates the actual cost. Guarantees optimal solution in A*.
Satisfies triangle inequality: h(n) ≤ c(n,n') + h(n'). Ensures efficient search.
Closer to actual cost means fewer nodes explored. Balance accuracy vs computation.
h(n) = √((x₂-x₁)² + (y₂-y₁)²)
h(n) = |x₂-x₁| + |y₂-y₁|
Choose based on allowed movements in your problem domain.