Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Maze Generator

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 22nd Jun 2009 02:56
Hello everyone!!

After seeing Valle's WIP thread for a small maze minigame, it sparked my fascination for mazes and prompted me to make a maze generator (and subsequently duplicating his program, but that isn't what this thread is about)

I decided to share my small maze generator program with the community. I don't think this is WIP quality or anything, so I've decided to put it in the code snippets.


Here's the source, it doesn't require much of anything to run.


There is a global value called "maxrecurse" at the top. It's there to prevent the generation function from nesting too deep and causing a crash. If you have more than 2GB of memory, you MAY be able to increase that value. It's set to what I found would be very close to the crashing point on my computer. If you are able to increase it, it should help to generate the mazes faster.

Unless you're making a ginormous maze, it shouldn't NEED to use any of the crash-prevention methods I've included.

If the cap is reached, it may APPEAR to have frozen, but it hasn't. It has simply been told to recurse allllll the way back to the beginning and start over from another location and continue the maze. This makes it so it won't crash, while still ensuring that the maze maintains it's "perfect" look. (To me anyway)

The largest maze I've generated with this was 3000x3000 (making a 6000x6000 px image). It took a very long time and I've since deleted it. I have found that unusually large images (like anything over 10000x10000 px) will eventually make the program freeze. I'm not sure what causes this, honestly, since it took many hours of generation time for it to freeze up like that.



Anyway, please enjoy and if time permits, I would enjoy some feedback.


The one and only,


fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 22nd Jun 2009 21:12
Is this a 2d maze, or is it a 3d maze model, Ive seen quite a few 2d maze generators, but not 3d ones.

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Jun 2009 04:25
3D isn't much different, really. You just have 2 extra directions for it to move it.


The one and only,


jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 3rd Jul 2009 18:59
Very nice Plystire!



You're the 'th to view this signature!
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 4th Jul 2009 23:45
As i said on MSN. This looks great mate. Really addicted now.

Login to post a reply

Server time is: 2024-11-22 00:56:23
Your offset time is: 2024-11-22 00:56:23