added square euclidean at the dismay of many theoretical mathematicians (it's inadmissible) (but it's really fast)

This commit is contained in:
2026-05-14 11:06:48 -05:00
parent 754ea5bd18
commit 9ac99cf488
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -109,6 +109,10 @@ func (a *AStar) SetHeuristic(heuristic int32) {
a.heuristic = func(x int, y int, endX int, endY int) float32 {
return float32(math.Max(float64(x-endX), float64(y-endY))) // Chebyshev distance
}
case 3:
a.heuristic = func(x int, y int, endX int, endY int) float32 {
return float32(math.Pow(float64(x-endX), 2) + math.Pow(float64(y-endY), 2)) // Squared Euclidean (extremely fast but not optimal/inadmissible)
}
}
}