Use cell hueristic for tentative g

This commit is contained in:
Ketchetwahmeegwun T. Southall 2024-02-03 00:51:41 -08:00
parent a9fba17943
commit 182214c6d0

View File

@ -64,7 +64,7 @@ func FindPath(w *World, fromX, fromY int, toX, toY int) ([]Node, bool) {
// Iterate over neighbors. // Iterate over neighbors.
for _, neighbor := range 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))) distance := int(math.Abs(float64(neighbor.X)-float64(toX)) + math.Abs(float64(neighbor.Y)-float64(toY)))
tentativeF := tentativeG + distance tentativeF := tentativeG + distance