Advertisement

A* and quick invalid path determination.

Started by July 07, 2012 03:07 AM
5 comments, last by slicer4ever 12 years, 4 months ago
hello everyone, i'm working with a large tile map, and need to determine if a path is simply unreachable without exhausting alot of time.

i've come up with a few ideas on this, and would like some opinions:

A. for large area culling, i can do geometric id's for determining if the target tile is in the same area as the start tile, i expect i'll automate this process, but i suspect it'll give me a great boost when i select a target that is another land mass away.

B. for local area culling(i.e. several static objects are in a circle around my target(or even dynamic), making it unreachable), I was toying with the idea of taking the distance of the currently closest tile to the destination, after a certain point, i'll go in a circle around all the tiles at this radius, as such, if all tiles are in the closed list, then i can determine that the destination is unreachable, without having to do an exhaustive search.

my problem is implementing B quickly, my pathfinding system is already configured that it'll only take several tick's before breaking out, and allowing other things to be processed, but i'm simply not certain how and when i should trigger the radius search for unreachable determination.

any tips on the subject, or even better, better methods of pathing determination are very much welcome.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Is your map static or dynamic? For a static map you could just segment the map using floodfills. You'd end up with x different areas. Then at runtime just check if the destination in the same area as the source. Another approach which may be more amenable for dynamic maps is recursive pathfinding. You could do it quickly (with crappy paths, just for connectivity checking). For a grid cell determine which of the 4 edges can be pathed between. Then treat each cell as a black box, and make bigger cells out of them, repeat. For connectivity checking then just path up to the next biggest level that doesn't overlap the destination, then back down levels until the destination is reached. For a dynamic map a limited subset of the pathing info could be recalculated as required.
Advertisement

Is your map static or dynamic?

both, their's alot of static objects, but also a number of dynamic objects, so i'd ideally want to make sure any pathing system that's developed can handle dynamic objects.


For a static map you could just segment the map using floodfills.
You'd end up with x different areas. Then at runtime just check if the destination in the same area as the source.


this sounds like essentially what i was going to do with part A of path detection.


Another approach which may be more amenable for dynamic maps is recursive pathfinding. You could do it quickly (with crappy paths, just for connectivity checking). For a grid cell determine which of the 4 edges can be pathed between. Then treat each cell as a black box, and make bigger cells out of them, repeat. For connectivity checking then just path up to the next biggest level that doesn't overlap the destination, then back down levels until the destination is reached. For a dynamic map a limited subset of the pathing info could be recalculated as required.


this kindof sounds like network programming and routing tables, but essentially it's be a routing table between a number of grouped nodes. It's an idea i had seldomly toyed with before, it's an interesting idea to approaching pathing, but the shear amount of memory required is way too much for my liking.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Hierarchical pathfinding is probably the best straight-out-of-the-tin solution, and done right isn't particularly memory intensive. Generally you would want to be a bit more granular than jeffereytitan described. Group perhaps 10x10 grid cells at a time, and make probably a total of 3 layers at most, and you should be good.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


Hierarchical pathfinding is probably the best straight-out-of-the-tin solution, and done right isn't particularly memory intensive. Generally you would want to be a bit more granular than jeffereytitan described. Group perhaps 10x10 grid cells at a time, and make probably a total of 3 layers at most, and you should be good.

hmm, a 3 layer map might be interesting, i think i'll try to implement it.

also, i've come up with potetionally another approach to quickly determine if a tile is not reachable, essentially, instead of marching in a circle at a certain point, i'll keep track of the closest tile, if i have tested, say another 100 tiles, and none of them get me closer, than i probably can't reach the destination tile, it's not full proof, but my maps shouldn't really require going around something 100 tiles in diameter. i might also be able to dynamically determine the number of tiles i need to test before i can break, by calculating the number of tiles which would be in a circle to the destination.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Try Bi-Directional, and find the intersection between paths, If the goal is unreachable one of the sides will stop.
Advertisement

Try Bi-Directional, and find the intersection between paths, If the goal is unreachable one of the sides will stop.


their are key flaws in that design, in theory it can potentially be == to normal pathfinding, at best, it does correctly identify blocked paths quickly, however, the worse(and in my opinion most potentially possible), is that the two path's bening searched in both directions well take radically diffrent paths, for example if we have:

[_][_][_]
[_][X][_]
[_][_][_]

where X is blocked, and we start/end in both corners like so:

[S][_][_]
[_][X][_]
[_][_][D]

then what's to stop something like so from occuring:

[S][_][_]
[S][X][D]
[_][_][D]

[S][_][D]
[S][X][D]
[S][_][D]

[S][D][D]
[S][X][D]
[S][S][D]


such that we've done twice the work.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This topic is closed to new replies.

Advertisement