# A* and quick invalid path determination.

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

## Recommended Posts

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. Edited by slicer4ever

##### Share on other sites
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.

##### Share on other sites

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.

##### Share on other sites
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.

##### Share on other sites

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. Edited by slicer4ever

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

##### Share on other sites

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.

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 35
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631701
• Total Posts
3001811
×