Sign in to follow this  

XNA Maze Generating

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.
I'd like to ask you for an advice about generating random maze in XNA (C#).

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.
Thanks for every answer.

Share this post


Link to post
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this