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...
- subdivide maze 3 sets: start (intially holding start cell), goal (initially holding goal cell), , undiscovered (all rest).
- randomly remove walls between cells in start or goal set , cells in undiscovered set, , move newly discovered cell respective set.
- repeat until each cell either in start or goal set.
- remove many walls between 2 regions want paths start goal.
alternatively, if have maze single path form start goal, use variant:
- do breadth first search both start , goal, , each cell in maze record number of steps cell away both start , goal.
- subdivide maze putting cells closer start start set , cells closer goal goal set.
- 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:
Comments
Post a Comment