Sign in to follow this  

Vehicle pathfinding in large height map with obstacles

This topic is 2118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to generate useful data for pathfinding purposes, and store it, when the input is a height map. The map itself is 2048^2 in dimensions, so I would need to store the data in a quadtree, and I also need to store data about which cells contain obstacles (large and small buildings, other vehicles, etc).

As for the pathfinding itself, can I get away with old fashioned A*? I'm using C# here if that makes a difference. I've looked for pathfinding libraries but the ones I've found are fairly useless.

Share this post


Link to post
Share on other sites
I'll try to be a help here as much as I can. A* is just an algorithm that finds the best route from its given heuristics (terrain type and etc...) It can be used in grid-based maps as well as graph-based (think nav-meshes).

Given your quadtree (depending how it stores data), you can tell your A* algorithm how many obstacles it may have and include that in the heuristic equation.

So, regarding your question, A* can definitely work but the you'll have to determine what's the "worst type of terrain" as well as the "best".

Since you're using a height-map, you could probably get away with some sort of [b]funnel algorithm [/b]applied to your path-finding system of choice. To avoid obstacles, you can (as stated before), include those in your algorithm-determining system or use dynamic avoidance to apply forces to "push" your agent away from them.

Share this post


Link to post
Share on other sites
My concern about using A* for a vehicle is that it doesn't naturally consider vehicle handling, momentum etc. According to A* you'd turn on a dime to take the shortest path rather than take a longer gentle curve. Of course you could build a non-grid-based graph for A* in a way that takes that into consideration, e.g. choose choke points and bends as your nodes, treat straight flat areas as "low cost" edges, treat hilly or windy areas as "high cost" edges, then apply path smoothing after.

Share this post


Link to post
Share on other sites
[quote name='jefferytitan' timestamp='1329948027' post='4915686']
My concern about using A* for a vehicle is that it doesn't naturally consider vehicle handling, momentum etc. According to A* you'd turn on a dime to take the shortest path rather than take a longer gentle curve. Of course you could build a non-grid-based graph for A* in a way that takes that into consideration, e.g. choose choke points and bends as your nodes, treat straight flat areas as "low cost" edges, treat hilly or windy areas as "high cost" edges, then apply path smoothing after.
[/quote]

From what I usually see, A* finds the best path and the agent (or vehicle) seeks the next path-node. So A* shouldn't be responsible for the vehicle portion, the vehicle should.

Share this post


Link to post
Share on other sites
I think that's being simplistic. If you're looking for the [i]shortest[/i] path, fine. A* will find it. If you're looking for a [i]realistic[/i] path, A* is not it unless your game world is mostly open space. On a day with light traffic, a highway that is 20% longer than taking local streets could easily take 50% less time to travel because vehicles like wide straight roads. And let's not forget performance handling characteristics of a vehicle. A semi-trailer might technically be able to travel narrow windy lanes, but some corners might require 20 point turns, and if it needs to be re-routed for any reason it would be unable to turn around. A* assumes that all paths to a point are equal as long as the cost of the paths are equal. Apart from the costs and the open list, A* is stateless. For a vehicle, facing the right way when it reaches that point is of huge value.

Share this post


Link to post
Share on other sites
When pathfinding with A* you could make nodes that require sharp turns cost more. Like you would compute how long it takes to go from the previous node to the current node given the approximated direction and speed at the previous node. Take more nodes into account for better paths.

Might not be the best way to do it though.

Share this post


Link to post
Share on other sites
The problem is that people use A* because it's efficient, and that efficiency depends upon only exploring a node once. If you investigate a node multiple ways depending upon how they got there, you potentially get a combinatorial explosion in the amount of work you have to do.

I see two possible approaches:
1. Each node is only expanded once, but each node stores a "direction of travel" (how it was first reached) and it gets to explore neighbours in the direction of travel before anyone else that has the same cost to get to that neighbour.
2. You categorise the terrain itself based on it's straightness or bendiness. This would likely mean a coarser A* graph with many assumptions built into the edge costs. Maybe even use a hierarchical system, because coarser levels have a better idea where you're going, and therefore what constitutes "bendy".

As you can imagine, they both have flaws. ;)

Share this post


Link to post
Share on other sites

This topic is 2118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this