JPS+: Over 100x Faster than A* (2015) [video]
gdcvault.com
gdcvault.com
JPS by itself (not JPS+ in this video) is notable for not requiring any precomputation to achieve some speedup.
If you're willing to precompute some things, there are lots of other techniques available for unweighted grid maps. http://www.cs.du.edu/~sturtevant/papers/GPPC-2014.pdf has an overview of techniques and some benchmarks that use real-world game maps (Baldur's Gate, Dragon Age).
I believe the "goal bounding" from the video is called "arc flags" in the literature.
https://ad-wiki.informatik.uni-freiburg.de/teaching/Efficien...
And of course there's a serious down-side: if the graph changes at runtime (eg. player builds a new door, or blows away a bridge) the preprocessing has to be redone, and it's not cheap.
It pre-computes all the paths from all nodes to all nodes, and it's incredibly efficient.
Most awesome algorithm ever :D
https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorit...
Mostly used for drone/rover/robot navigation in open environments, with the graphs evolving as the robot discover the environment.
D* can be pathologically slower than repeated A* searches under such conditions.
Ideally speaking, you need to plan in higher dimensions to get an optimal path in dynamic environments
The pre-computation JPS(+) does is cheating because it's essentially providing a quicker-to-evaluate heuristic than A* gets to use.
So yes, I agree - the title is misleading! However, it's still a pretty cool efficiency for situations where it's applicable.
With respect to the techniques that require precomputation, however, I wonder how they perform with such moving obstacles. Potentially quite terribly, I imagine.
Previous HN thread: https://news.ycombinator.com/item?id=9714774
Jon Bentley had an article on two string reversal algorithms with the same algorithmic complexity. On a very large string, one would finish almost immediately; the other was pessimal for paged virtual memory and wouldn't finish for hours.
That being said there's an important gotcha, those techniques require a significant amount of precomputations (especially the bounding box one) so it might not be practical if you have very dynamic maps.
One option would be to look for strategies that "look intelligent", instead of being perfectly optimal paths at every simulation frame.
Run slow pathfinding for an enemy and store the path. Have them follow the path until they hit a player-created obstacle, and only then re-run pathfinding. Besides being faster, this could let the players use the enemy behaviour to their advantage by creating traps or such.
(Anyone who knows better, I'd be delighted to find out I'm wrong—for the sake of my own search runtimes.)
They may not solve all your problems or even any of them (hard to tell knowing nothing about your game, after all), but I was absolutely dumbfounded when I played around with them at how cheaply you can get some rather complex (seeming) behaviors (e.g. put the player and some enemies in a maze, give the players a scent that strongly attracts the enemies, but also give them a slight scent that makes them repulse each other, and they'll automagically split up and surround the player).
At the very least, if you're stuck with what you're doing at the moment, play around with those, and maybe you can at least find a use for them that frees up some processing resources for precise path finding where nothing short of it will do.
[0] Potential fields can't tell you a route is a dead end until you reach the dead end. Then they only tell you you're at a dead end, but don't tell you how to get out and find a viable route. Add-on exit-a-dead-end algorithms I've seen have very inefficient movement.
Algorithms to avoid the dead end in the first place have to look ahead so far that you might as well use Dijkstra/A*.
----
Some papers I've turned up:
Potential fields:
- http://www.gamedev.net/page/resources/_/technical/artificial...
- http://www.heikohoffmann.de/htmlthesis/node56.html
- http://www.researchgate.net/publication/222662144_Solving_th...
- https://randomaccessmaths.wordpress.com/2013/10/27/potential...
Harmonic Potential Functions (related to potential fields, they attempt to solve the local minima/maxima problem)
- http://repository.cmu.edu/cgi/viewcontent.cgi?article=1625&c...
- http://www.itst2007.eurecom.fr/site/var/html/h1053/file1221....
- http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=429591...
- http://ncsu.summon.serialssolutions.com/search?s.cmd=addFace...
I think the main power is that potential fields reduce the complexity of the calculation to the map and the number of goals, with an infinite number of agents being able to use that at little cost, but you pretty much always have to build additional pathfinding on top of it. For example, for some games it might be fine for agents to follow the potential field generally, but every tick one of them gets to use Dijkstra/A*, and if that points the other way it follows that path until coming close to another agent or something. Too much efficiency can be off-putting, but also be too predictable and easy to exploit as a player, that's also worth noting. But of course, I'm kind of rationalizing my lack of deeper knowledge here, I'd love to be able to do it perfectly, and then tone that down for realism/gameplay. Alas :)
All shortest paths are either a straight line, or consist of the straight line from the original location to an outside corner, a series of straight lines between outside corners, and a straight line from an outside corner to the destination. (An outside corner is any 2x2 square with three walkable and one wall tile.)
You can easily find all the outside corners. You can find which pairs of outside corners can be walked between using N^2 ray casts. Once you've done that, you can detect when an outside corner has been removed and drop it from the map, or detect when one has been created and perform N ray casts to add it to your pathing list.
Running A* on the resulting structure is really fast, because it's smaller and more connected than a tile list. The slowest remaining part is finding the corners immediately reachable from your start/end points, which I think could also be sped up but I'd benchmark it before worrying about that.
I would say that you have the causation reversed: we just don't bother doing large matrix multiplications, because they're so expensive (and yet still don't usually cross the intercepts into making the "better" algorithms worth it, due to those algorithms having ridiculous constant coefficients.)
I would love to run Floyd-Warshall on my 40-million point network graph—but it just ain't gonna happen.
Sure, I agree. I'm not a specialist in numerical lin.alg., but I've heard it said that if you're spending a lot of time on large dense matrix multiplications, you're probably approaching the problem in the wrong way.
The basic idea of landmarks is that you choose a small number of landmarks (e.g. four corners of a map) and for every landmark, you pre-compute the distances to every node. You can then use this information to get a lower-bound for the distance to the target via the triangle inequality: d(p,t) >= |d(p,LM) - d(t,LM)|.
This is obviously weaker than the goal bounding explained in the video, but the precomputing only takes O(n). We used it quite successfully in a global router (for EDA), where the heuristic lower-bound is often much better than a standard A-star heuristic based on geometric distances, because edges could have wildly different costs.
And yes, A* & landmarks is really nice :) !
Global routing is a high-level routing approach: routing millions of nets (= connections usually between 1 output pin of a gate and N input pins of other gates) on a grid graph with potentially billions of nodes is an extremely difficult Steiner tree problem.
To get good solutions, a common approach is to first solve the problem on a much coarser graph where edges have capacities. I.e. instead of having to place all connections disjointly, edges in the graph can accommodate a number of parallel connections.
A later detailed routing step will produce the actual disjoint routes while following the outline that was obtained during global routing.
There are certainly things you shouldn't delegate to an autorouter, but in the same way, the trend towards hair-shirt-wearing insistence that everything be done manually is a productivity cost.
It's no different to programmers who insist on hand-optimizing assembler: Rarely necessarily any more and usually done more out of ego.
The really competent engineers use the tools for the bulk of the problem, and fix up by hand where it makes sense.
1) This requires expensive precomputation. He mentioned it took 10 hours on one of the large starcraft maps. 2) (I may have misunderstood this point) This does not necessarily respond well to map changes - so in maps where you have the map changing structure (new walls, etc) you will have to run the precomputation again.
With that said, very interesting stuff coming out of Digipen.
Of course, with a specialized heuristics one could get a lot of pruning, but generally, if there is no way to come with a specialized heuristic when there is no way to have a jumping heuristic (one have to take one step at a time) and there is no way to look ahead for a specialized nodes, the A* is still the king.
But in AI almost everything is about finding a good-enough heuristic.
JPS is great. I remembered it from a former talk a while ago.
From the little experience i have with pathfinding, it seems to be an interesting topic with many little details to be explored. Like smoothing a path, smoothing/tuning a path in regards to loss of "speed" when turning, avoiding dynamic obstacles like other "agents", "flocking" of groups, various different ways of representing a "map", and probably many more.
If you want to have the best summary of routing algorithms currently available then read 'Route Planning in Transportation Networks' (2014) https://arxiv.org/abs/1504.05140
And if you want fast implementations for routing algorithms like Dijkstra, A*, CH and Landmarks check out GraphHopper: https://github.com/graphhopper/graphhopper (note: I'm one of the founders)
The boundary checking improvement would be simplified by dividing the map into islands divided by gates (per his closing remarks) limiting the damage to precalculated data from changes to the map (assuming they occur in one island at a time)
There was a paper by Microsoft Research where they find shortest path from one point to another in time equivalent to 5 memory reads + they sped up significantly the precomputation times and lowered memory requirements.