3 ms·
The simplest algorithm for solving a maze is to pick between 'left' or 'right'; I'll pick 'left'. Then the algorithm is: Whenever you are presented with a choic
by yes_or_gnome 10y ago
The simplest algorithm for solving a maze is to pick between 'left' or 'right'; I'll pick 'left'. Then the algorithm is: Whenever you are presented with a choice on which direction to go, then follow the 'left' wall. In the worst case, you'll hit every square and there will be a lot of retracing, but it'll get the job done. It's the equivalent of bubble sort for solving mazes.
(My apologies, to zappo2938, I didn't dive into your code, though I did skim it. I didn't want to create a new top-level comment about the maze problem.)