While trying to use a wavefront algorithm, I came across a scenario that I haven’t been able to easily solve. I populate an array with a wavefront algorithm and using a Moore neighborhood, how do I decide which way to travel given that several of the neighbors are the exact same.
My local neighborhood has the values of 4,4,5,5,5,4,5,6. The local minima is 4, but I have 3 of them in this case. How do I make a decision based if there are several local minima to move to. Right now I am making a random decision if there are equal values, but I feel there’s a better way to decide.
All paths to the destination have the same number of steps (5 steps), but each path taken is different. I am also assuming that the local minima is chosen for the pathway.
My question is, given an equal number of steps (in wavefront) is there a way other than randomization or order of the comparators are written in to make a decision on which way to move from one block to another?
Just a notation, 99 indicates a barrier.
The problem with just pure local minima or comparator order is a failure case pictured below.
I’m not looking for an Astar solution to this question, but I feel in this case, I would be faced with the exact same decision problems as all paths are equal.
Thanks
EDIT: I had incorrectly generated the numbers, embarrassing.
Here's a correct generation of the wavefront
When correctly generated, it shows there is only 1 path
Even when the barrier is a little more complex
Note: in all the images (corrected) the pathway is generated using Van Neumann neighborhood, while the movement is via Moore neighborhood.
However, if using Van Neumann neighborhood generation and Van Neumann navigation, the problem pops up again.