2D Maze Algorithm

I hate freak'in 2D mazes. You know the ones. The little mazes that appear on the place mats of kiddie meals. They have so many twists and turns and make your eyes hurt. Well here is a full proof solution.

Requirements
2D
The maze is abstractly two dimensional. That is you can only go left, right, forward, and back; no up or down. The maze physically go up or down, like slopes, but there is no direct change, like up or down floors.
static
That means the maze doesn't move or change, no repeating loops (think of the "warp" in Pac-Man), or "teleports", i.e. moving from one point in the maze to another spontaneously.

Solutions
Method A Pick one wall and touch it. Now keep moving forward while never letting your arm off. If you return to the beginning pick another wall and repeat. If you return to the beginning again then the maze either doesn't have a solution or doesn't meet the requirements.
Method B Pick a direction, e.g. right, and always take that choice if a junction arises. If you get back to where you started choose the the other direction and repeat. If you return to the beginning again then the maze either doesn't have a solution or doesn't meet the requirements.

Simple eh? But this solution is very plug-and-chug. You have to be really stubborn to follow it all the way through.

Prev -- Back to Console -- Next