email@example.com (Michael Michalchik) wrote in message news:<firstname.lastname@example.org>... > I was wondering if anyone knows if all possible topologies of finite > 2d mazes can be solved by a finite algorithm.
Yes, they can.
> For example, we know > that all fully connected mazes can be solved by picking a wall and > exhaustively following it. Can a general solution work for all mazes > including the ones that are piecewise disconnected? If this is > possible, is the general solution a solved problem?
Yes it is. Look for the "Pledge Algorithm". It is well-described in the book "Turtle Geometry", including a proof for how it solves every finite maze.
The algorithm works by keeping track of the total amount of turning you do as you move throughout the maze. Using this purely local information (you don't need breadcrumbs, or to mark walls etc.) it is possible to escape.
It is rather simple:
1. Initialize a counter to zero, and define an arbitrary direction to be 'north'.
2. Move straight north until an obstacle is met.
3. Turn left and follow the obstacle. Keep track of 'total turning' and increment the counter by +1 for every full 360 degree turn clockwise, and -1 for every full 360 turn anti-clockwise.
4. Leave the obstacle when it is possible to move straight north and the counter reads zero. Goto step 2.