SebLague / Pathfinding

MIT License
668 stars 251 forks source link

Issue with a-star algrithom #4

Closed zhaobenx closed 6 years ago

zhaobenx commented 6 years ago

https://github.com/SebLague/Pathfinding/blob/b938872d12bbf9a78cda1e88cbb6a5acff25ccbf/Episode%2004%20-%20heap/Assets/Scripts/Pathfinding.cs#L45

Referring to Wikipedia, there, hCost( Wiki call it fScore) should be the sum of distance and gCost.

I didn't compile your script, but I implemented it in Python, and in the beginning, I always find something wrong. After I changed it in the Wiki's way, it worked.

SebLague commented 6 years ago

The hCost IS the distance (in this case using manhattan dst instead of euclidean). If you look in the Node class you'll see there is an 'fCost' property which returns hCost + gCost. My implementation is in line with the wiki.

zhaobenx commented 6 years ago

Oh thanks!