1 / 14

Algorithms: Maze Craze

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:

howell
Download Presentation

Algorithms: Maze Craze

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Algorithms: Maze Craze

  2. 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?

  3. 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.

  4. Depth-First Search Algorithm

  5. Depth-First Search Algorithm …and so on to get:

  6. 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).

  7. Example

  8. 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.

  9. 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

  10. 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

  11. 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.

  12. 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!)

  13. 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

  14. 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?

More Related