From 9ac99cf488cb26b890e594d5a518f183ec005c5b Mon Sep 17 00:00:00 2001 From: wisplite Date: Thu, 14 May 2026 11:06:48 -0500 Subject: [PATCH] added square euclidean at the dismay of many theoretical mathematicians (it's inadmissible) (but it's really fast) --- astar.go | 4 ++++ main.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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