# XNA Maze Generating

This topic is 2854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi.

My maze is generated from an array of ints [15,12], it looks like this:
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,0,0,0,0,0,0,0,0,1,0,1,1,0,1
1,0,1,1,1,1,1,0,1,1,0,1,1,0,1
5,0,1,1,0,0,0,0,0,1,0,0,0,0,1
1,1,1,1,0,1,1,1,1,1,0,1,1,0,1
1,1,1,1,0,1,1,0,0,0,0,1,1,0,1
1,1,1,1,0,1,1,0,1,1,0,1,1,0,1
1,0,1,1,0,0,1,0,1,1,0,0,0,0,1
1,0,1,0,1,0,1,0,1,1,1,1,1,0,1
1,0,1,1,1,0,1,0,1,1,0,1,1,0,1
1,0,0,0,0,0,0,0,0,0,0,1,1,2,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

1 is wall, 0 is empty space, 2 is start and 5 is finish.

Now everything works, but I'd like to create some function that will generate random maze. I read some tutorials, but it didn't help - every algorithm works only for mazes where cells are empty spaces and borders between cells are walls.

I don't want you to write whole code for me, just an advice how could I make it.

##### Share on other sites
One way would be to start your grid out something like:

11111
10101
11111
10101
11111

The initial 0's would be your "cells" and the 1's between them would be your "walls".

##### Share on other sites
This might be useful to you.

Quote:
 every algorithm works only for mazes where cells are empty spaces and borders between cells are walls.

Sorry if this is obvious, but why is that a problem?

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631775
• Total Posts
3002277
×