aseboheavy.blogg.se

Maze generator algorithm
Maze generator algorithm









maze generator algorithm
  1. MAZE GENERATOR ALGORITHM VERIFICATION
  2. MAZE GENERATOR ALGORITHM CODE

Test: Will removing this wall merge two empty spaces of different label? Remove the index form the list ( never test a wall twice).Randomly choose a wall from the index list.Label all empty spaces with a unique label.The current maze is a grid with isolated empty spaces. So, the start for a 17x16 looks like this (Start is red, goal is green): (if at least one dimension is even-sized, this will be the case.) If the destination voxel is a wall, remove the wall.Set the voxel of index (n,m.) to be the goal destination.Set the voxel of index (0,0.) to be the starting location.remove the according index from the listĮssentially set the two opposing "corners" to be start and end.Store the wall-voxel index in the list.

maze generator algorithm

  • Set every voxel with at least one even index to 1 (wall).
  • Create a list for voxel-indices of walls (empty).
  • Create the maze-data as Boolean array of needed dimensionality.
  • Indexing starts with 0 for the first voxel.
  • The data dimensions sizes are called n,m,k,l.
  • My solution is based on the idea that each pixel/voxel/n-dim-element ( called voxel from now on) can either be a path (0) or a wall (1).

    MAZE GENERATOR ALGORITHM VERIFICATION

    Hence there is no 100% verification it is correct.

    MAZE GENERATOR ALGORITHM CODE

    I do not post code here, but the algorithm concept. This algorithm works for n-dimensional mazes and arbitrary maze dimensions. (With or without hole close to the "exit" and "entry" points depending on your liking.) If you require the maze to be "enwalled" you need to use a 14x15 dimension in my algorithm and then draw a border of wall around it. Note that you ask for a 16 x 17 maze requiring each point either wall or empty.

    maze generator algorithm

    This is an adapted version of the algorithm posted at this question.











    Maze generator algorithm