r/programming • u/hazadess • Apr 23 '13
PathFinding algorithm, visually explained
http://qiao.github.io/PathFinding.js/visual/
2.2k
Upvotes
r/programming • u/hazadess • Apr 23 '13
72
u/diego_tomato Apr 24 '13
Glad I found a good use for this.
269
u/smallstepforman Apr 23 '13
I've never heard of Jump Point Search before, and I'm amazed with its performance. I've done A* for a Civ like game using hexes (it only takes 4 hours to implement from scratch), but now that I've seen Jump Point Search, it's time to rework the path finding algorithm.
93
u/willvarfar Apr 23 '13
Here's the go-to article for jump-point-search: http://harablog.wordpress.com/2011/09/07/jump-point-search/
Its been exciting to track A*JPS in 0ad and MegaGlest last year.
57
u/Ronnie_G Apr 23 '13
Very nice site!
I like the wikipedia illustartion of the A* Search
44
u/Iambillion Apr 24 '13
I had way too much fun with this. http://i.imgur.com/rgU9cRd.png
84
u/rspeed Apr 24 '13
*tries jump point algorithm for the first time*
Holy shit!
43
u/[deleted] Apr 23 '13 edited Apr 24 '13
Mind blown...
This visual simulation makes a heavy point in using Jump Point Search for Path Finding in RTS games... Several orders of magnitude faster than even the best A* !
13
u/doodle77 Apr 24 '13
Jump point search seems to not count many of the points it visits. It doesn't count them as backtrack points, but it does check to see if they contain obstacles.
36
u/abomb999 Apr 23 '13
These javascripts demos that are showing up in /r/programming lately are so fluid and impressive. What should I type into google to learn javascript visual programming like these demos?
9
u/TerminalPlantain Apr 23 '13
So, as I understand it, the "Best-First-Search" demonstrated here is just A* with a really strongly-weighted heuristic function?
I'll definitely have to check out Jump Point Search — that looks neat.
7
u/Uberhipster Apr 24 '13
For complex ambiguous problems it appears Best-first takes less time (9ms) to find a longer path (128.28) than Jump point (11ms, 109.46)
http://imgur.com/a/oXIZi
In this example, using Best-first saves ~20% in computation time but adds ~17% to the length...
So if the computation time cost vs. path travel cost ratio is heavily in favor of path travel cost, Best-first produces a "better" solution.
To take a clear cut albeit banal example: if there are a million nodes (1000x1000 grid) and the cost of traveling node to node is a nanosecond than Best-first produces a better time saving solution because the travel time will be only 0.2ms higher but the computation time will be 2ms lower.
56
u/ablatner Apr 23 '13
This explains almost nothing about how they work.
5
u/ithika Apr 23 '13
I suck at finding interesting maps for it to hunt through.
22
u/tylo Apr 23 '13
Is this what love feels like?
3
u/[deleted] Apr 24 '13
I played with that for far too long...
3
u/[deleted] Apr 24 '13
Not a programmer. I still spent 20 min playing with all the buttons.
5
u/T-rex_with_a_gun Apr 24 '13
A* Search for beginners : http://www.policyalmanac.org/games/aStarTutorial.htm
5
u/chris2point0 Apr 24 '13
Reminds me of this slideshow about Left 4 Dead: http://www.valvesoftware.com/publications/2009/ai_systems_of_l4d_mike_booth.pdf
2
u/JohnDoe365 Apr 24 '13
In reality you would start from both points and meet at the intersection. That reduces runtime overhead a lot (for a lot to google what it means in O(n) notation)
2
u/ackerlight Apr 24 '13
This is an amazing site. Saving it for later.
2
u/Kissaki0 Apr 24 '13
“explained”? Not really.
There’s no step by step, and not even a legend of the colors it uses.
2
u/frankster Apr 24 '13
TIL about Jump Point Search, sounds fairly cool
9
u/Guinness Apr 23 '13
Clearly someone should send this to the Simcity team.
3
u/iarcfsil Apr 24 '13
Is this how GPS devices work?
3
u/dimmy Apr 24 '13
It's an excellent representation. Unfortunately there is a bug in the path finding algorithm: http://i.imgur.com/kPxr4cO.png
It seems to be prioritizing nodes solely based on the heuristic, i.e. the manhattan distance from the node to the goal. It should heuristic + walk distance from start.
2
u/[deleted] Apr 24 '13
Nifty, 'cept for this bug.
http://imgur.com/UDrfYNP
2
u/Wee2mo Apr 24 '13
This is pretty cool, but pretty old.
1
u/GWigWam Apr 23 '13
Like some of you, I have indeed used A*
Gota do some research on 'jump' now!
1
u/TooKool4This Apr 23 '13
Anyone know if an uninformed version of jump point search is possible? If it is, how does it compare to D* or D* Lite, which are pretty popular, more efficient, variants of A* for uninformed search ( by uniformed I of course mean graph data is not known before path finding). I just implemented D* lite for a project and wanted to know if jump point search is a better alternative.
1
u/ClickerMonkey Apr 24 '13
Nice visualization! Bookmarked!
1
u/PlNG Apr 24 '13
This would be vastly improved with some randomized walls.
1
u/damonkashu Apr 24 '13
Very nice work!
1
u/NotWorthy101 Apr 24 '13
Fascinating - right in my 'coding' bookmark it goes - Thanks!
1
u/socialite-buttons Apr 24 '13
I would love to watch a video of these pathfinders in the same style as Sorting out Sorting...
http://www.youtube.com/watch?v=SJwEwA5gOkM
1
u/Philipp Apr 24 '13
Which of those if any incorporate line of sight knowledge, like the searcher able to see the target once it turned around a wall?
1
u/JeffMo Apr 24 '13
Try putting 4 walls "surrounding" the red node, in the non-diagonal positions. This appears to stump even the algorithms that allegedly allow diagonal.
Then remove the "east" wall. Now, a path is found that was available (but apparently undetectable) before.
1
u/[deleted] Apr 24 '13
JPS is amazing
1
u/princeton_cuppa Apr 24 '13
So beautiful!
1
u/[deleted] Apr 24 '13
I love this, but can you add some walls ?
1
u/dreamkota_com Apr 23 '13
Just beautiful. This is really a work of art.
0
u/nickbenn Apr 24 '13
Cool illustration - though the corner of my eye kept twitching each time I saw Manhattan, Euclidean, and Chebyshev listed as heuristics (rather than distance metrics).
-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
0
u/[deleted] Apr 24 '13
[deleted] — view deleted comment