The pledge algorithm is useful for the mazes you are talking about. It consists of:
The choice of direction, if you know the general direction to the goal, but an arbitrary direction. Say you choose North.
Go in this direction until you hit an obstacle.
Follow the obstacle, watching how hard you turn. For example, going north, you encounter an East-West wall. You turn east (90d) and follow the wall, turning south (180d), west (270d) and north again (360d). You do not stop following the wall until the amount you have converted becomes 0. So, you continue to follow, turning West (270d turned in the opposite direction), South (180d), East (90d) and finally North (0d), Now you can stop following.
Do this anytime you hit an obstacle. In the end, you will reach the northernmost part of the maze. If you still haven’t found the target because you have chosen the wrong direction, try again with the East or South or any other direction closest to the target.
source share