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

3

u/babada Apr 24 '13

How can it know it is a valid path without at least checking each and every cell the path passes through?

I think the animation is just highlighting the path comparisons. It doesn't need to compare paths for each cell; all it needs to know is that the cell is "empty".

Or, in other words, the trick to JPS is that it splits things into two phases: (a) find the next jump point; (b) compare the path. (a) is a trivial algorithm that simply scans through cells looking for either a blocked cell or the end of a "rectangle".

How that relates to the animation is confusing and non-intuitive. It would have been handy to see it scanning the cells and which cells/paths are getting compared.