Is there a way to keep direction priorities in A*? (ie. Generating the same path as breadth-first)

Viewed 572

I have an application that would benefit from using A*; however, for legacy reasons, I need it to continue generating exactly the same paths it did before when there are multiple best-paths to choose from.

For example, consider this maze

...X
FX.S
....

S = start
F = finish
X = wall
. = empty space

with direction-priorities Up; Right; Down; Left. Using breadth-first, we will find the path DLLLU; however, using A* we immediately go left, and end up finding the path LULLD.

I've tried making sure to always expand in the correct direction when breaking ties; and overwriting the PreviousNode pointers when moving from a more important direction, but neither works in that example. Is there a way to do this?

4 Answers
Related