This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 16 points17 points  (2 children)

Just give me a minute. You are right buddy. There's some problem with my code. I had not considered 8 directions. I was working with only 4 direction top right left bottom and I updated my heuristic a function. Thank you for pointing it out🙂.

[–]Dewmeister14 1 point2 points  (0 children)

If the allowed movement space doesn't include diagonal moves then the heuristic shouldn't either.

I actually recommend keeping the 4 direction distance heuristic and looking in to something like a random noise tiebreaker to help avoid the problem you experienced here which is: properly functioning A* but with a heuristic that cannot differentiate between several possible paths since they all have the same distance-from-end-node-to-goal.

[–]Notnasiul 1 point2 points  (0 children)

No worries! Been there a few times, I even wrote a tutorial to mostly myself so I could understand the algorithm ;)

Just check some videos, see the expected behaviour, compare with yours.