r/programming • • Apr 23 '13

PathFinding algorithm, visually explained

http://qiao.github.io/PathFinding.js/visual/
2.2k Upvotes

230 comments sorted by

View all comments

Show parent comment

1

u/chironshands Apr 24 '13

No, A* with valid heuristics is meant to always return an optimal path.

1

u/mrbaggins Apr 24 '13

I figured he meant different search patterns.

A* will return not optimal paths if the heuristic returns values that over (I think) estimate the distance remaining. I cant recall the article and am in mobile but theres a good one about sacrificing admissibility in order to speed it up.

1

u/chironshands Apr 25 '13

right, it won't be optimal if the heuristic is invalid. Admissible heuristics cannot overestimate the distance see Admissible Heuristic. In my test cases, the big issue was that the bidirectional search was getting worse final path costs for each heuristic, except with the Chebyshev distance.

1

u/mrbaggins Apr 25 '13

It won't be optimal for length but it's likely to be found faster with a heuristic that drops admissibility.

this is the thing I was thinking of before.

The only reason I can see bidrectional being different is the order of checking finding a different path of equal length. Is it actually worse? Or just different?

1

u/chironshands Apr 25 '13

the cost was about one unit of length higher for the bidirectional search than for the standard forward search.