pasobwriting.blogg.se

Maze generator algorithm
Maze generator algorithm








maze generator algorithm

On the positive side, this algorithm is extremely fast and very easy to implement. However, if the person solving the maze can't see the entire thing at one time, this algorithm is still useful. Generally, this makes solving the maze too easy to be fun. This algorithm produces mazes with a serious flaw: the North and West borders of the maze are completely open. Thus, it also determines the direction of the skew inherant in this algorithm.

  • Determines which corner of the maze to start looping from.
  • For every cell in the grid, knock down a wall either North or West.
  • Binary TreeĬlick to see the Binary Tree in Action The Algorithm This is perhaps the most common maze-generation algorithm because it is easy to understand and implement.
  • Stop when the algorithm has backed all the way up to the starting cell.
  • If all adjacent cells have been visited, back up to the previous and repeat step 2.
  • Randomly choose a wall at the current cell and open a passage through it to any random, unvisited, adjacent cell.
  • Backtracking GeneratorĬlick to see the Backtracking Generator in Action The Algorithm Like most tree-based maze algorithms, this one is a little slow. This algorithm treats the cells of a maze as a graph, and solves to find a Uniform Spanning Tree that covers that graph.
  • Repeat step 2 until all cells have been visited.
  • If the neighbor has not yet been visited, add the traveled edge to the spanning tree.
  • Choose a random neighbor of the current cell and visit it.
  • Maze-Generating Algorithms Go back to the main README Aldous-BroderĬlick to see Aldous Broder in Action The Algorithm










    Maze generator algorithm