Simple Maze Generator

Community Forums/Showcase/Simple Maze Generator

Ryan Burnside(Posted 2008) [#1]


This is a simple maze generator.

I've got it making mazes decently fast.

blitzmax language


.exe for those without blitzmax

http://myfreefilehosting.com/f/d604cf3874_0.1MB


PGF(Posted 2008) [#2]
Nice result.


Doggie(Posted 2008) [#3]
That's amazing


Yahfree(Posted 2008) [#4]
holy crap, try solving that


Retimer(Posted 2008) [#5]
Man that is fast.

Thank you for sharing.


LineOf7s(Posted 2008) [#6]
Okay, I'm being picky here - it's very nice and all - but shouldn't a maze have some sorta entry and exit?

Plop someone in the middle of that and just sit and watch them go criminally insane. :o)


Rob Farley(Posted 2008) [#7]
Can I countinue the picky theme and suggest most mazes have some kind of symertry about them also.

Not sure they usually have an exit, Mazes generally have an entrance and you're supposed to get to the middle and back out again.

I appreciate this is a 'simple maze generator' so really these are suggested improvements!


Digital Anime(Posted 2008) [#8]

Okay, I'm being picky here - it's very nice and all - but shouldn't a maze have some sorta entry and exit?



Better not, else people might try to solve the maze using a waterproof marker....
;-)

But it's a nice small generator...


Ryan Burnside(Posted 2008) [#9]
Glad to see some interest. ;)

If you want an exit, just knock down two outside wall segments in a simple paint program. Since this maze is perfect you can start in any location and get to any other. This is why you can cut an exit and beginning at any location.


Ryan Burnside(Posted 2008) [#10]
Now that you have a simple maze generator you could make levels for dungeon crawlers. I'll be working on a level generating engine soon.

Here is a page to do so:
http://www.aarg.net/~minam/dungeon.cgi


impixi(Posted 2008) [#11]
I don't want to hijack your thread, but you might be able to use / get some ideas from this entry in the code archives: TDungeon


Ryan Burnside(Posted 2008) [#12]
I had a look at that some time ago. The "dungeons" have odd walls for use in my project, but I do appreciate your code.


rebootbug(Posted 2008) [#13]
Thank you for this Ryan, very useful indeed

Thanks
Brendan


plash(Posted 2008) [#14]
Nice.
I would be interested in a solver.


xlsior(Posted 2008) [#15]
This is my favorite maze generator: http://homepages.cwi.nl/~tromp/maze.html

char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
--            E;             J[              E]             =T
[E   ]=  E)   printf("._");  for(;(A-=Z=!Z)  ||  (printf("\n|"
)    ,   A    =              39              ,C             --
)    ;   Z    ||    printf   (M   ))M[Z]=Z[A-(E   =A[J-Z])&&!C
&    A   ==             T[                                  A]
|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}


Obfuscated C... It generates mazes, it is a maze, it spells 'maze', and it uses m,a,z, and e for variables.


Defoc8(Posted 2008) [#16]
now all you need to do is add rooms..then you will hvae
a neato dungeon generator - handy if you feel like making
some kinda endless dungeon crawler..very cool ;)


taumel(Posted 2008) [#17]
Nice, now if you could add some room like structures it would be great!

I haven't found time to continue a lot on this one ( http://www.blitzbasic.com/Community/posts.php?topic=77524 ).

Just made a test with a 24x24 maze and even that is so hard to get through without a map. Try to get from the yellow to the red coloured area.

Steering:
wasd/lmb&rmb: movement
mouse: viewing direction
m: map
t: string of the minotaurus

-> http://spielwiese.marune.de/_uni/testarea/maze/maze.html


Jesse(Posted 2008) [#18]
I downloaded this code a while back when I was trying to figure out how to solve mazes it uses the Depth-First Search(DFS) algorithm, I got it from here:
http://mazes.50megs.com/
and converted it to Bmax:


you can get executable from here:
http://hosted.filefront.com/ChuyP/


Ryan Burnside(Posted 2008) [#19]
Updated a bit.

It now makes binary mazes and dungeons for games. You can ofcourse edit the binary dungeon genertion code. See the first post. I *DO* plan to clean up my code and commentary. Just a small update.


impixi(Posted 2008) [#20]
Impressive dungeon.


Retimer(Posted 2008) [#21]
Updated a bit.


Damnit, and I spent some time setting it up to generate mazes for a tilemap when it seems you just did the same.

Nice @ the dungeon generation. You are unknowingly working for me and saving me time =P

Thanks for the update.

Edit:

Could you maybe add some more constants for things such as min/max hall width, room min/max size, density, etc?

Another thought came to me about multiple level dungeons/mazes. I'm not entirely sure how it would generate, but to have up/down values for going up or down from a floor into another dungeon maze in random locations in the maze. The only difference with this would be having different start/finish values (instead of the corners)

If you're short for time or anything I could put forth some effort into making these edits and posting. But I don't want to go ahead and start updating your work if you are going to anyways hehe.

Time


Ryan Burnside(Posted 2008) [#22]
The binary maze is really easy to work with. If you clear out whole square sections of space then take off all of the dead ends you get an even better result. This dungeon is still pretty uguly. I'm working on a better algorithm. Perhaps I'll make a module for adding random dungeon data arrays to your games.


taumel(Posted 2008) [#23]
Cool, although it doesn't look really right yet as it's missing those real rooms. I guess the mix of a) simple corridors, b) more natural random like areas like they are now in maze3 and c) precise rooms would do it. You should also be able to define the colours easily and it would be heloful if you also could exclude certain areas from beeing used for the maze.


impixi(Posted 2008) [#24]
I think it would be best to have multiple dungeon styles, some ‘realistic’, some odd / unusual, some a combination. There probably is no one-dungeon-style-fits-all-games algorithm. Anyway, good job so far...