How to split up pathfinding? How to implement divide-and-conquer on pathfinding?

Started by
10 comments, last by Ashaman73 10 years, 2 months ago

I guess you can make sure that you're new algorithm isn't terrible at empty maps, but modifying your pathfinder so it does a check to see if it can do a direct walk from the start to the goal, and just returns that straight path would bypass that case entirely.

You're also not going to see any speedup compared to the standard A* algorithm, so you'd mostly just be doing a sanity test to make sure the more complicated algorithm isn't overdoing it.

The most lagging scenario would be when the paths are not straightforward, or when the goal cannot be reached at all. Though the latter, again is a scenario that's best optimized out entirely if possible.

Advertisement

You should consider several approaches. The hierachy is a really good solution for really large maps. If you just have issues with performance (stuttering due to long calculations), then you should consider to split up your A* calculation. This works quite fine, just explore maybe 100 nodes per frame to equally distribute the performance hit on severaly frames. I use this technique by calculating several paths over one or more frames distributed on multiple cores. This should work for small to medium sized maps.

If you want an immediate reaction of the entity start with an A* and take the result of the first frame (the A* heuristic should point into the right direction). This path is a good guess of where the final path will point to, and it should be good enough to let your entity start to move in the right direction, though it only works if you have one potential goal. After the final path has been calculated you can "connect" the entity to the final path (maybe a small A* is necessary to connect them).

This topic is closed to new replies.

Advertisement