Pick a direction (helps if it's the rough direction of the exit) and "pledge" to always go in that direction when possible.
When you hit a wall hug it and follow it round but disconnect when you're facing in your pledged direction(and the sum of angles turned is a multiple of 360).
It stops you getting trapped in a disconnected segment in the middle of the maze.
View all comments
Show parent comment
19
u/other_usernames_gone Jun 10 '23
Pledge algorithm also works.
Pick a direction (helps if it's the rough direction of the exit) and "pledge" to always go in that direction when possible.
When you hit a wall hug it and follow it round but disconnect when you're facing in your pledged direction(and the sum of angles turned is a multiple of 360).
It stops you getting trapped in a disconnected segment in the middle of the maze.
A Wikipedia article full of maze solving algorithms