algorithm - How to generate a maze with more than one success full path? -


which algorithm can used generate maze more 1 success full path , if algorithm modified version of known algorithm explain or add link .

i using 2d array store configuration of maze .

assume if size of maze n * n more 1 path should there a[0][0] a[n-1][n-1] .

this algorithms should able generate mazes distinct loop-free paths start goal:

starting empty maze (or solid block of rock), start , goal...

  1. subdivide maze 3 sets: start (intially holding start cell), goal (initially holding goal cell), , undiscovered (all rest).
  2. randomly remove walls between cells in start or goal set , cells in undiscovered set, , move newly discovered cell respective set.
  3. repeat until each cell either in start or goal set.
  4. remove many walls between 2 regions want paths start goal.

alternatively, if have maze single path form start goal, use variant:

  1. do breadth first search both start , goal, , each cell in maze record number of steps cell away both start , goal.
  2. subdivide maze putting cells closer start start set , cells closer goal goal set.
  3. remove wall between 2 regions add additional path start goal.

the generated paths might have (maybe substantial) parts in common, should unique loop-free paths start goal. here's illustration of first case:

enter image description here


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -