![]() |
MazeGenerator
1 Attachment(s)
I had an assignment for school to write a maze generator in Java, and decided to convert it to GS2. The purpose of the assignment was to apply a disjoint set data structure to something practical, like maze generating. It might not be the most efficient algorithm, and it might not generate the most difficult mazes, but it is fast and it works. The algorithm is essentially a randomized Kruskal's algorithm, and has an O(n) running time proportional to the number of spaces in your maze.
How it works:
See it in action: When generating a maze in the video, I'm actually generating 10 mazes with a .05 second sleep between each one to give it a cool "loading" effect. So it really is fast...seemingly instant when generating a full-level maze. Suggested Reading: Implementation: Simply put the code in a DBNPC and call this function: PHP Code:
The code: Attachment 51796 NOTE: I have not tested this on a gmap! |
Badass
Remind me why you arnt staff on Era/Manager? |
Quote:
|
Quote:
|
Dude.. my mind is blown... o_o
|
That's awesome... ._.
|
very cool- but there isn't an exit!! :(
|
Reminds me of this, nice job though.
|
Badass music. :cool:
But really cool Generator Sales. |
Very nice work Sales :).
|
Quote:
Quote:
Quote:
|
One maze server coming up.
|
Really cool, randomly generated dungeon levels anyone?
|
2 Attachment(s)
You inspired me to take a shot at the maze generator thing.
Uses.. Depth-first search algorithm The grid output is a fairly simple array. grid[y][x][wall direction (0 to 3)] == wall alive boolean My implementation does have it's limitations however I narrowed out the maximum size to be 35 by 35 but depending on your application (random dungeon level generator for example) that should be more than enough. PHP Code:
http://img40.imageshack.us/img40/7562/whitefill.png http://img259.imageshack.us/img259/9659/blackfill.png |
Very nice, I was actually planning on implementing a depth-first search version myself!
|
All times are GMT +2. The time now is 02:06 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.