Thread:TwinArmageddonz/@comment-9531161-20140414010649/@comment-9531161-20140414012749

OK, first you'll want to set every cell in the maze to a wall. Next, you want to go through and place open cells in every other spot, like a tablecloth. This will look like:

1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1

Where 1's are walls and 0's are open areas.

The basic idea of this algorithm is:

1: Start with a grid (like the above) 2: Choose a starting location (has to be an empty area) 3: Add the wall information for the starting area to an array. Loop start: 4: Choose a random wall 5: If the cell on the opposite side of the wall hasn't been visited, destroy the wall, mark that cell as visited, and add the walls for the new cell to the wall array. 6: Do not add walls which are on the edge of the map 7: Repeat loop until wall array is empty

Remember, we have 3 arrays. One is the maze, another one (which is the same size and dimensions) will hold whether or not we've visited a block, and the final one-dimensional array will hold information necessary to generate the maze. Choose a place to start (it can't be in a wall of course), and mark it as visited in the parallel array (I'll call it the "visited" array from now on). Next, add the walls to the one-dimensional array. What do I mean by add the walls? I mean that the one-dimensional array needs to be able to store information that will point you to a wall. I would store the X and Y position of the wall,

..Crap, I have to finish this later, because I have to go! I'll be back in a while.