Unless you’re a software developer or scientist, you probably only see mazes in newspaper puzzles. Although it is an ordinary brain exercise for us, mazes are of great importance for the occupational groups we mentioned, because mazes are mathematical problems.
Every math problem also has one or more solutions. So are labyrinths, and if you ever find yourself in a labyrinth, you should use math to get out of it in the safest way possible.
There are 3 popular ways to get out of a maze:
The first of these is the “Wall Follower”, where you can move forward by setting direction.
The wall follower method is also known as the ‘left hand rule’ or the ‘right hand rule’. Although this method takes a bit of time, it is an effective method for finding the exit of the maze. All you have to do is choose one hand.
Leaning your hand against the wall on the side of your chosen hand and following the wall without taking your hand away from the wall until you find the exit. If you continue without stopping, you can reach all kinds of exits.
The wall follower method always works in interconnected labyrinths with closed outer boundaries, but it can take a very long time depending on the size of the maze.
The other method is the more advanced “Pledge algorithm”.
Discrete labyrinths (where the walls are not connected to the outer boundary/the boundary is not closed) can be solved by the wall follower method, provided that the entrances and exits to the labyrinth are on the outer walls of the labyrinth. However, if this method is used in situations where you start from inside the labyrinth and there is an open end, you will always return to where you started.
The Pledge algorithm, named after John Pledge, solves this problem. According to Pledge, all you have to do is set a direction (any of north, south, west, or east) and then drive in that direction until you encounter an obstacle.
After you hit the obstacle, take the obstacle to your left and keep moving by placing your left hand on the wall, counting your turns as you move forward. When you turn back in the direction you originally went, keep moving forward. Repeat this process for each obstacle. If it is difficult to understand from the text, you can understand it more easily from the diagram.
The last and most guaranteed method is the “Trémaux algorithm”.
This method is the longest, although guaranteed. According to the Trémaux algorithm, when you start moving in the labyrinth, you have to move forward by leaving a trace on the road. That way you never get lost. When you reach a dead end, you can follow the trail back and put a sign at the beginning of the dead end and you will not enter there again.
Of course, there are other ways to get out of the mazes, but these three are the ones that can get you out of the maze for sure. These algorithms we mentioned are also the most frequently used and successful ones in software and experiments.