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

-1

u/chironshands Apr 24 '13 edited Apr 25 '13

I managed to make a map that had different results for different heuristics. I think something is wrong with their bidirectional search strategy.

EDIT: punishment for pointing out bugs? I can take it.

EDIT2: see how to reproduce it here

3

u/mrbaggins Apr 24 '13

They're supposed to be different...

1

u/finix Apr 24 '13

Maybe he means the path, not the expansion of nodes?

1

u/chironshands Apr 24 '13

Indeed, the supposedly optimal path returned by the A* variants are supposed to have the same cost. For me, the bidirectional search returns sub-optimal paths.

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.