3 ms·
https://imgur.com/VBsht https://imgur.com/VBsht while (true) do if not (wall to the left) then (turn left) while (wall ahead) do (turn ri
by agf 14y ago
https://imgur.com/VBsht https://imgur.com/VBsht
while (true) do
if not (wall to the left) then
(turn left)
while (wall ahead) do
(turn right)
(move forward)
This uses the general maze-solving logic of following the outer wall in one direction until you find the exit. It never turns then turns back or runs into a wall.
- jbrechtel 14y agoNice. I didn't realize you could parameterize the conditionals so I did this (bumps into walls): while (true) do if(wall ahead) then turn left else move forward turn left if(wall ahead) turn right
- saurik 14y agoThis will not solve general mazes. S=Start, G=Goal, O=Empty O-O-O | | O S-O-G | | O-O-O
- agf 14y agoI should have been more clear. That's the general logic for mazes where both the entrance and exit are on the outer edge.