Jump to content

Random Dungeon/Maze Generator


Recommended Posts

Does anyone out there have or know of a method/algorithm written in PHP or Javascript that is designed to create a random dungeon/map. I am not looking for a script that creates doors, staircases, treasure chests, etc but simply creates an area with open rooms, corridors, etc. An arena of sorts to battle in (throw-back to the online game Droidarena). I have seen some online versions which do exactly what I would like, but these are designed to be printed off for D&D, etc. I just simply need to generate a random dungeon and store the layout in an array for use in my game. Suggestions even as to how to go about coding one would be great. I currently have a few attempts going, but none of them work all that great.Thanks.

Link to post
Share on other sites

There's a whole bunch of algorithms available for that sort of thing - the depth-first search method is quite simple to implement. http://en.wikipedia.org/wiki/Maze_generation_algorithm.

Link to post
Share on other sites
I am not necessarily looking to make a rogue-like maze however. I would like there to be big rooms, small rooms and corridors connecting them.
After the algorithm is complete, you just remove a bunch of walls around randomly chosen cells until the space reaches a randomly selected size.
Link to post
Share on other sites

You can also randomly create rooms while the maze generates, or even before the maze generates, then just ignore them while the corridors are filled in. If you don't care about spatial accuracy (i.e., that everything actually "fits") you can also just pretend some of the corridor units are rooms :). "You enter a big room..."

Link to post
Share on other sites

Algoritm is just the (context independant) description of a process. You don't download it, you implement it in some language or fashion.On the Wikipedia page, you can see a Python implementation. You'd need to write a similar implementation in PHP that would fit with the rest of your code.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...