140 likes | 425 Vues
Algorithms: Maze Craze. Starter. Can you think of any games you have played which involve a maze? Here is an example of a numerical maze: http:// www.roundgames.com/game/Maze+And+Math How do you think these mazes were created?. Depth-First Search Algorithm. Algorithm:
E N D
Starter Can you think of any games you have played which involve a maze? Here is an example of a numerical maze: http://www.roundgames.com/game/Maze+And+Math How do you think these mazes were created?
Depth-First Search Algorithm Algorithm: • Choose a random cell. • Choose a neighbour which has not been visited. • Remove the wall between the chosen cell and its neighbour. • Continue with each neighbour until all cells have been visited.
Depth-First Search Algorithm …and so on to get:
Binary Tree Algorithm Algorithm: • Look at each cell in turn. • Choose randomly whether to create a passage travelling north or west. • Continue until all cells have been visited. Note: You are not allowed to exceed the boundaries of the grid (i.e. a solid line must remain around the grid).
Making the Maze Numerical Now that the maze has been created, we must add in a start point, end point and some numbers around the maze. The challenge is for the user to travel from the start to the end, “picking up numbers” along the way, in order to total exactly 20 in the least number of steps possible.
Example Using our maze from the previous example, we have: 4 6 As we can see from this maze, there are four possible routes we could take in order to travel from the start to the end point and total 20. 6 10 5 5
Please note: The faint grey lines represent the grid lines (to aid understanding of method). Example 4 6 4 6 6 10 6 10 5 5 Method 1: 23 steps Method 2: 23 steps 5 5 4 6 4 6 6 10 6 10 5 5 Method 4: 17 steps Method 3: 19 steps 5 5
Your Task (Part 1) Create your own maze, using the binary tree algorithm! Decide on whether or not each cell should create a passageway travelling north or west by rolling your die: • If you get an even number, travel north; • If you get an off number, travel west Note: Some cells may not allow you to travel north/west due to the constraints of the algorithm, therefore you do not need to roll the die for these cells.
Your Task (Part 2) Once you have created your maze, make it numerical by adding in a start point, end point and some numbers so that the user has to find a route of numbers which add up to exactly 20 in the least amount of steps possible. (Try to create your maze so that there is more than one possible route which totals up to 20!)
Relation to Real Life • Operational Research • Algorithms • Cooking • Instruction manuals • Travelling Salesman Problem • Choosing the best direction to go to get to a specific place quickly • Satellite Navigation • Company delivery
Evaluation • How do you think the difficulty of your maze could be improved? (Consider the algorithm used, as well as the design) • What did you learn from today’s lesson? • What skills do you think you have gained through this lesson?