From 182214c6d07f9989a34b93e67a78d2e8898c3ecc Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Sat, 3 Feb 2024 00:51:41 -0800 Subject: [PATCH] Use cell hueristic for tentative g --- sauce/astar.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sauce/astar.go b/sauce/astar.go index 2654fc8..5e6755c 100644 --- a/sauce/astar.go +++ b/sauce/astar.go @@ -64,7 +64,7 @@ func FindPath(w *World, fromX, fromY int, toX, toY int) ([]Node, bool) { // Iterate over neighbors. for _, neighbor := range neighbors { - tentativeG := current.g + 1 + tentativeG := current.g + 1 + int(w.At(int(neighbor.X), int(neighbor.Y)).Hueristic) distance := int(math.Abs(float64(neighbor.X)-float64(toX)) + math.Abs(float64(neighbor.Y)-float64(toY))) tentativeF := tentativeG + distance