diff --git a/astar.go b/astar.go index 3e6b4bd..5f1df82 100644 --- a/astar.go +++ b/astar.go @@ -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) + } } } diff --git a/main.go b/main.go index 5e607f6..1c3ad36 100644 --- a/main.go +++ b/main.go @@ -299,7 +299,7 @@ func main() { toolDropdownOpen := false var tex texSync // GPU uploads: partial rects while painting; full after path resets - heuristicOptions := []string{"Manhattan", "Euclidean", "Chebyshev"} + heuristicOptions := []string{"Manhattan", "Euclidean", "Chebyshev", "Squared Euclidean"} heuristicOptionsText := strings.Join(heuristicOptions, ";") activeHeuristic := int32(0) heuristicDropdownOpen := false