|
if (openSet[i].fCost < node.fCost || openSet[i].fCost == node.fCost) { |
|
if (openSet[i].hCost < node.hCost) |
|
node = openSet[i]; |
|
} |
This does only set another node as current if the h-cost is also lower not just the f-cost - also the first if does not make much sens since it can be rewritten as a single <=. In the respective video you use another version (https://youtu.be/mZfyt03LDH4?t=331) that might actually work because of associativity rules of || and && essentially leading to something like "lower f OR (equal f AND lower h)".
I was implementing a-star in plain C for fun after watching your videos and that bit confused me because I of course though I made an error somewhere else. Thanks for the inspiration - your videos are great.
Pathfinding/Episode 03 - astar/Assets/Scripts/Pathfinding.cs
Lines 29 to 32 in b938872
This does only set another node as current if the h-cost is also lower not just the f-cost - also the first
ifdoes not make much sens since it can be rewritten as a single<=. In the respective video you use another version (https://youtu.be/mZfyt03LDH4?t=331) that might actually work because of associativity rules of||and&&essentially leading to something like "lower f OR (equal f AND lower h)".I was implementing a-star in plain C for fun after watching your videos and that bit confused me because I of course though I made an error somewhere else. Thanks for the inspiration - your videos are great.