Incremental improvement from A* to Dijkstra's

Started by
9 comments, last by wodinoneeye 12 years, 3 months ago
I'm looking for a way to smoothly present path improvement, starting from A* to a regular Dijkstra. I'm operating under an assumption that A* with its heuristics will find a path fast, while Dijkstra's will find the best path ever, though it might take significantly longer. Basically, I need my pathfinder to find (some) path immediately, with an option to improve it over the next second or two.

Obviously gradual reducing the heuristic towards-the-target bias should do the trick, but at the unacceptable cost of recalculating every-damn-thing at each pass.

I tried making A* not stop at a first found end node edge, and not putting the end node on the closed nodes list, but that resulted in the algorithm frantically hopping around the end node, trying to get at it from different angles. Also, nodes once visited in a seemingly good, but ultimately sub-optimal path (costly in terrain, but good in heuristics) were never visited again (closed list prevented that, naturally) even if backing away a bit from the proper direction resulted in finding a perfect shortcut path (very cheap terrain-wise, but not promising as far as heuristics go).

So, here's my puzzle: is there a known combination of these algorithms, capable of somehow gradually reducing the use of heuristics? Perhaps by some clever "reviving" of closed nodes if they prove to be reachable faster (though when I tried it, it kept reviving all nodes around the goal, for some reason)..?
Advertisement
Dijkstra's and A* will both give you the optimal path. A*, if it has a viable heuristic, has the potential to use the information that the heuristic gives to make the search faster.

I think what you're looking for is something along the lines of http://137.215.9.22/bitstream/handle/2263/10822/Botha_Shortest(2008).pdf?sequence=1
ROFLMAO-GG-HF-GL-LOL-TTYL-BRB-GTG
What you're looking for is something along the lines of: http://137.215.9.22/bitstream/handle/2263/10822/Botha_Shortest(2008).pdf
ROFLMAO-GG-HF-GL-LOL-TTYL-BRB-GTG
I'm operating under an assumption that A* with its heuristics will find a path fast, while Dijkstra's will find the best path ever, though it might take significantly longer.
A* will find the shortest path, assuming your heuristic is "admissible" (it never overestimates the minimal cost of reaching the goal).

Another algorithm you might be interested in is 'iterative deepening A*'.

A* will find the shortest path, assuming your heuristic is "admissible" (it never overestimates the minimal cost of reaching the goal).

Actually, I don't think it will: in a complex map where a direct portal (leading right next to the target point) lies just behind the starting point, no A* variant that I know of will ever knowingly move away from the target, unless it's stuck. So when there's a (mediocre) beeline from start to end, A* will never think of moving in the completely opposite direction, in hopes of finding a perfect shortcut from there. And this IS the kind of map that I'm working on - shortcuts and teleports and wormholes all over. Hence, no heuristic (that I know of) can be good enough.

Iterative deepening, though, looks like a series of A* runs, just with a narrowing acceptable cost - however, how exactly do I prevent the accepting of a too-costly solution? By never closing nodes whose total cost has already exceeded the allowed cost, perhaps, and just dropping them?

Also, how does that prevent the problem I described, where a heuristically "more interesting" node has already been seen (and thus, closed), and later somehow a shortcut leading directly to that node is found, exceeding the heuristic expectations? In my experience, the shortcut is ignored, since that node is in the closed list. Or, should nodes be taken out of the closed list, if cheaper paths to them are found? But, wouldn't that massively increase calculation time, with each interesting shortcut forcing the recalculation of a significant part of the map?
A* will search the "whole solution space" like Dijkstra. It will just always try the "most obvious" path first which may allow it to terminate early.

It will just always try the "most obvious" path first which may allow it to terminate early.

"May" allow? If I don't allow and just proceed, my ending node ends up on the closed list, and the search never again completes. If I leave it on the open list, though, it's constantly "licked at" from neighboring nodes, which are trying to find a better solution (but if the heuristic was good, these are worse than the first found beeline path). Do you mean that I should allow it anyway, thus wasting a lot of time for the nodes to "lick" at the end node, so that finally the move "backing away" from the end direction, and into the "portal", is considered? But even then, the portal will only lead to an already checked (and, thus, closed) node...
i am not very familiar with A* but I think the key here is in determining the correct heuristic to make sure portals are accounted for when executing the search. I dont know what your current heuristic is, but if you are using Manhattan Distance to goal, you could try using Manhattan Distance to the nearest of goal or any portal. In that way you are sure you are never overestimating your heuristic.

I hope this will help!

My personal blog on game development!

Black Wolf Game Development

Hum. Minimum of goals or portals, you say... Now that's a thought.

That actually answers a different question - "how to get a perfect path even when portals are involved". However, maybe this renders my dilemma moot.

Interesting, will give it a spin. Thank you.
The portals themselves could have a child node to the exit point as well so that nodes expansion would include a node a lot closer. Sorry I am a bit rusty on A*, but I need to implement it here very shortly, so I may come back with my concept solidified.

This topic is closed to new replies.

Advertisement