Help the little robot find an exit to any given maze.
Take a look at the maze we are going to solve. To do so, just open up exercise1.html in a browser of your liking.
Try getting familiar with the robots controls. Open up the file solveMaze.js and edit the solveMaze
function to make the robot move.
The robot has access to the following methods:
turnLeft
-> turns the Robot to the leftturnRight
-> turns the Robot to the rightlookForward
-> looks in front of the robot returns:wall
-> if the robot is facing a wallfloor
-> if the space in front of the robot is freetarget
-> if the robot is facing the exit of the maze
moveForward
-> moves the robot one block forward
Try editing the solveMaze
function to make the robot move onto the exit.
Now Try modifying your solveMaze function so that it can solve any maze you get when opening exercise2.html in your browser. If you have any trouble thinking of a way to do that, take a look here.
Open up the file unsolvableMaze.js and return a maze that can not be solved by your algorithm from exercise 2. Tipp: The exit does not have to be on the outside of the maze.