11.4.16

Maze Solving Algorithm

1. What is computer programming?
https://www.brainpop.com/technology/computerscience/computerprogramming/

What is an algorithm?
Algorithm is a set of steps to accomplish a task. For example, Tim would like Moby to sit on the most CLOSE and FREE seat.
(Situation to avoid: Seat is not free)


The algorithm to accomplish this task is as follows:
Step 1. Go to the next seat, check if it's free.
Step 2. Free: sit (TASK ACCOMPLISHED). Not Free: Go to 1.
Step1
Step2


Step1
Step2


Step1
Step2 (Task accomplished)


2. Use algorithm to solve maze



I: Random mouse algorithm

This algorithm is for a very unintelligent mouse or stupid robots. Being put on the start position of the maze, it simply proceeds following the current passage until a junction is reached, and then it makes a random decision about the next direction to follow. By reaching a dead end, it turns back and keep on trying randomly. If it's lucky, it can arrive the exit quickly, otherwise, it needs to keep on trying....

II: Wall follower algorithm (left wall or right wall)

There is a precondition for the maze. All the walls need to be connected together or to the maze's outer boundary. By keeping on hand in contact with one wall of the maze the solver is guaranteed not to get lose and will reach the exit.

Left hand/Right hand rule simulator:
Press green flag, then drag and put the mouse inside the maze (anywhere) and use arrow keys to adjust its orientation, please make sure either green or blue part should cover around 70%-90% of the black wall (not crossing the wall). Press "s" to run the mouse. (If the mouse got stuck somewhere, please rearrange the position of the mouse)
Project direct link: https://scratch.mit.edu/projects/107309809/#player



 3. Activity -- Maze solver programming
https://www.brainpop.com/games/blocklymaze/