Selacius Posted December 7, 2010 Share Posted December 7, 2010 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 comment Share on other sites More sharing options...
Synook Posted December 7, 2010 Share Posted December 7, 2010 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 comment Share on other sites More sharing options...
Selacius Posted December 7, 2010 Author Share Posted December 7, 2010 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. Link to comment Share on other sites More sharing options...
ShadowMage Posted December 7, 2010 Share Posted December 7, 2010 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 comment Share on other sites More sharing options...
Synook Posted December 8, 2010 Share Posted December 8, 2010 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 comment Share on other sites More sharing options...
ilyakar Posted December 9, 2010 Share Posted December 9, 2010 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.i checked the link out, but where can you actually download these algorithms? Link to comment Share on other sites More sharing options...
boen_robot Posted December 9, 2010 Share Posted December 9, 2010 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 comment Share on other sites More sharing options...
ilyakar Posted December 11, 2010 Share Posted December 11, 2010 ooohh. alright thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.