Skip to main content
GameDev.net gamedev.net
🔒 Locked

Precomputing pathfinding: Which algorithm?

Started by rmmc Feb 4, 2005 at 6:00 AM 3 replies 1.7k views
Original Post
rmmc
rmmc
Hello I'm implementing a pathfinding system that generates a navigation mesh based on the collision data for the objects in the world, precomputes the shortest path between any 2 cells and, at runtime, simply polls the tables for the path to follow. The problem is that I'm not sure if using an A* approach to compute the path from any cell to any other cell is good enough compared to a Floyd-Warshall or a Johnson's sparse graphs algorithms. Does anyone have any experience with this kind of computation? If so, what do you think is the best approach? Keep in mind that we are talking about potentially very complex navigation meshes. Thanks in advance, Rui Casais
Rui Casais
Trap
Trap
What is very complex? What number of nodes and edges?

Is the resulting mesh gridlike? Then you should take a look at: http://www.avglab.com/andrew/pub/msr-tr-2004-24.ps, it describes a pathfinding algorithm which is very fast on gridlike graphs (20 times faster than A*). Maybe fast enough for pathfinding without precomputation of all paths.

Floyd-Warshall is O(n^3), A* for all pairs is O(n^3) too if implemented without heaps. So which one is faster is implementation dependend.
How are you going to store your precomputed paths?
rmmc
rmmc
Very complex as in large and complex scenes, not many almost straight line paths.

As for storage, I will keep it in an hierarchical set of tables, to have a compromise between memory consuptiom and time to resolve the path.

As for the gridlike approach, I'm afraid that I can't use it, as my navigation meshes won't be gridlike at all.

I do not have much detailed information about the mesh itself, though, as the collision meshes from where I construct the navigation meshes are still being done, and I won't have access to that data for a while.

From what I've been seeing it seems like the best option is to go for A* using priority queues, but I still have to do some more research...
Rui Casais
superpig
superpig
Personally, last time I was working with this stuff I based things on Dijkstra's algorithm. Because it's a labelling algorithm, you can use it to generate shortest-path data from a given start node to all other nodes in the network in a single pass (instead of searching for node/node pairs).

However, I've never learnt about things like Floyd-Warshall or Johnson's sparse graphs so it's very likely that I'm just ignorant of better solutions [grin]
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Trap
Trap
Bidirectional dijkstra/A* is another option. There is also a basic description of it in the .ps i linked above...

Straight lines aren't important for the landmark based search, it works on roadmaps too.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.