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 { a.heuristic = func(x int, y int, endX int, endY int) float32 {
return float32(math.Max(float64(x-endX), float64(y-endY))) // Chebyshev distance 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)
}
} }
} }
+1 -1
View File
@@ -299,7 +299,7 @@ func main() {
toolDropdownOpen := false toolDropdownOpen := false
var tex texSync // GPU uploads: partial rects while painting; full after path resets 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, ";") heuristicOptionsText := strings.Join(heuristicOptions, ";")
activeHeuristic := int32(0) activeHeuristic := int32(0)
heuristicDropdownOpen := false heuristicDropdownOpen := false