

PathFinding.js - kamaal
http://qiao.github.io/PathFinding.js/visual/

======
kevan
Some friends and I made pathfinding visualizations that use real map data from
the OpenStreetMap project, it gets messy pretty fast.

[http://kevanahlquist.com/osm_pathfinding/](http://kevanahlquist.com/osm_pathfinding/)

~~~
aqrashik
That's really good. Is it open source? I couldn't find any licensing info

~~~
fit2rule
Github link is in the lower-right .. uses MapBox, which in itself is a
beautiful mapping service, but .. its not open source.

------
nacs
Pretty much the definitive guide for pathfinding how-to/visualization (the
author used D3.js for the examples):

[http://www.redblobgames.com/pathfinding/a-star/introduction....](http://www.redblobgames.com/pathfinding/a-star/introduction.html)

~~~
gamekathu
amazing resource to learn! thanks for sharing :)

~~~
seivan
Amit also writes on [http://aigamedev.com](http://aigamedev.com)

You sorta need to use other tools with A* in order to fully utilise it.
Steering forces, behaviour trees an etc :)

------
hitekker
I found myself trying to place paths in front of the algorithm, trying to
delay it from reaching its end goal.

With a bit of tweaking, I imagine this could be turned into a little game.

------
tlrobinson
It would be cool if it ran all the algorithms and showed you how many steps it
took and the final path length for each one.

Also, a "random maze" button would be nice.

------
TazeTSchnitzel
It never checks the target is actually reachable, meaning it just keeps going
if you make reaching it impossible.

~~~
Buttons840
How can you tell if the target is reachable other than finding a path?

~~~
TheLoneWolfling
You preprocess the grid into connected components, marking every grid cell
with the CC it is in. Then before pathfinding check that the start and end are
in the same component. This is an O(1) check, albeit with a potential of O(n
log n) space required for storing the array of CC lookups.

~~~
TheLoneWolfling
Whoops, make that an O(log n) check, technically speaking, as the index of
which CC a cell belongs to may take O(log n) space worst-case.

Though you can treat it as effectively O(1) time and O(n) space.

------
sytelus
I wonder if there are patterns that makes A* take unruly amount of time when
there is an "obvious" solution from human point of view.

~~~
rcfox
Something like this performs pretty poorly for all of the algorithms:

    
    
        ===========          ================
                 s=          =e
        ===========          ================
    

I think if you searched from both ends, it would perform much better.

~~~
hayksaakian
try the "bi-directional" checkbox on the website

~~~
rcfox
Nice, I didn't notice that. Waaay better.

------
z3t4
I use this in one of my games. The API could be slightly simpler/better
though. But having abstractions like this available makes me so much more
productive.

Now I'm just waiting for a library/API for hexagon map's ;)

~~~
nacs
> Now I'm just waiting for a library/API for hexagon map's ;)

You can use A* and co with hex maps too. There's more info on hex maps and an
illustration of pathing here:

[http://www.redblobgames.com/grids/hexagons/#pathfinding](http://www.redblobgames.com/grids/hexagons/#pathfinding)

------
zyxley
So... with a screen sized to about 1280x580 (a comfortable size on my 13-inch
BMA), the "Start Search" button starts completely off the screen. Any smaller
than that, and the "Select Algorithm" box is partially clipped off the screen.
In any case, there's no scroll bar, which really confused me.

That aside, this is really neat, and it's interesting to see a visual
representation of the different algorithms.

------
koopuluri
This is really cool! Reminds me of the Berkeley PACMAN Ai project:
([http://ai.berkeley.edu/project_overview.html](http://ai.berkeley.edu/project_overview.html)),
but seems easier to customize, try out different edge cases and compare
algorithms.

------
seshakiran
On Mac 15 inch, visualization is very neat. very good implementation of the
algorithms. Regarding Zyxley's comments; this can be made responsive so that
it works on all screen sizes.

------
sagivo
I love A*, used it in all of the games i developed.

------
jaunkst
I have had to roll my own. I have been meaning to release a library for a
graph based datastructure and path fining for games

------
Grue3
IDA* almost hanged my browser. It didn't seem to be able to find the path,
just bumping into a wall constantly.

------
rcfox
Could anyone recommend a Javascript pathfinding library that doesn't assume a
grid-based graph?

~~~
iamdave
It's not a javascript library, but MapBox recently released the Directions API
for pathfinding within the context of mapping:
[https://www.mapbox.com/developers/api/directions/](https://www.mapbox.com/developers/api/directions/)

So... _somewhat_ relevant to what you're asking.

~~~
imaginenore
Directions algorithms on real life maps are quite different from what they
teach you in CS classes. Just think of the amount of computation to get the
best directions between SF and NYC, taking traffic into consideration. I'm
pretty sure none of the services actually give you the best solution, but
something that's pretty close to it.

Full USA map graph contains around 24 million nodes, 58 million edges. Your
regular A* just doesn't cut it.

~~~
rcfox
I'm sure you're right, but it seems like traffic would be easy enough to
consider by simply increasing specific edges' costs.

As for the scale issue: most of these nodes and edges will never change, so it
might be possible to calculate a Dijkstra map.

~~~
imaginenore
The point is, if you add traffic into consideration, you can't have almost
anything precalculated.

~~~
amitp
A* runs faster if you have better path cost estimates. To get the shortest
paths, you want an estimate that's as close to the true cost, but not greater
than it. You can precalculate to generate good estimates. Traffic makes the
costs higher than normal, so those precalculated estimates are still useable
(if you raise the costs because of traffic, the estimates continue to be lower
than the true cost), and still much better than what you get without
precalculation.

------
ww520
OT: How does potential field perform vs A* path finding?

