2 ms·
FTA: “This is especially useful for mazes where the goal is to get to the centre: if the centre isn’t connected to the outside, wall-following won’t work, and y
by Someone 3y ago
FTA: “This is especially useful for mazes where the goal is to get to the centre: if the centre isn’t connected to the outside, wall-following won’t work, and you will need to switch walls to get onto the centre component. But as long as there are a finite number of pieces to the maze, and you keep trying different ones, you will eventually find a piece that is connected to your goal”
I think that’s not entirely correct. Consider this maze:
#######
# #
# # # #
# #G# #
# ### #
# #
# ### #
E #A# #
# ### #
# #
# ### #
# #B# #
# ### #
# #
#######
E = entry point, G = goal.
You start by walking around the inside of the outside perimeter.
Detecting a loop, you switch sides and walk around the square marked ‘A’.
Detecting another loop, you have two options for switching sides. Let’s say you pick the square marked ‘B’.
Detecting another loop, there’s no way to switch to the other side that gets you to a loop that you didn’t finish before.
So, what you have to do is keep track of the fact that, after circling the ‘A’ square, you had another option, go back there, and pick that other option. In other words: you have to backtrack.