Dungeon/room generator for rpg/roguelike and such.

Monkey Forums/Monkey Code/Dungeon/room generator for rpg/roguelike and such.

Pakz(Posted 2015) [#1]


I tried another way of creating dungeons. I made a few already. Here I create one base room(rect) and then randomly place 10 rooms of random sizes on the map until they touch another room on the right spot. It seems to work allright. It is fast enough.

I read once that someone used makeroom and makecorridor functions and called these to make maps. I am going to spend more time experimenting with maps in the future.

The maps look nice enough to play in.

Here a video of more maps.

Here another video with more in it.

Here a video of a big map with monsters in it:


Here the flash applet on my blog : http://monkeygameprogramming.blogspot.nl/2015/08/monkey-x-random-room-placement-map.html

Here the code :



Here the same one but now with some monsters in it :




Pakz(Posted 2015) [#2]
Here something else that I tried. Here a* makes paths across a heightmap like map creating other kind of maps.






Gerry Quinn(Posted 2015) [#3]
Nice maps. Very similar to what you can get with a cellular automaton, but the straight lines look organically built in to yours, so it seems like they'd be good for ancient buried ruins etc.


Pakz(Posted 2015) [#4]
I put the code from one of my other rpg things and put them with a map generator.

press g to transport/warp to another level.
press m to show map
cursors move
collect coins
Collect health





(edit) I put some monsters in it. No collision yet. Made them scroll smoothly


Nobuyuki(Posted 2015) [#5]
Very awesome. I was actually planning on writing a map generator like this myself for the past few weeks, and I was surprised that I missed this thread! The strategy of using A* to "navigate" a heightmap may end up producing a lot of maps where a* enemy AI strategies are "normalized" quite a bit to a usual behavior. You may get more oomph out of your enemies' AI by "salting" the levels with a few obstacles which change this behavior.

I'd love to see versions of both of your generators which have more commenting inside them to explain what strategy it's currently taking, so that it may be easier to tweak/extend these generators more.

Also, since it seems relevant to the thread: The strategy used in Nuclear Throne for level generation is yet another interesting way to make a bit more semi-organic maps, one which carves out rooms by having a robot meander until it reaches a set tile limit (with a random chance of spawning identical robots with smaller TTLs) http://www.vlambeer.com/2013/04/02/random-level-generation-in-wasteland-kings/


tiresius(Posted 2015) [#6]
I love info on dungeon generation thank you for sharing. For my little rogue-like I eventually used a simple flood-fill algorithm because I needed to guarantee that there weren't any rooms off on their own and separate. The way you're building your maps this wouldn't be a problem for you, but I had corridors pushing out of rooms until it hit another open space, so it was possible for two rooms to join with each other and nobody else.

I want to eventually grow my code into doing different maze patterns, etc.

Fun stuff !!


Pakz(Posted 2015) [#7]
I wanted to make another map generator yesterday but got distracted. It would have shapes randomly placed on the map with a random+minimum distance from other objects on the map. I saw a map like that recently on rogue basin I thought.

I think map generation is fun to think about and make to btw (though difficult for some effects). I still want to try and make a map generator for a platformer so that I can play around in unlimited amounts of levels and have useable code. But I have not gotten to the point that I saw it clear enough to start coding.

One thing that I read once was to premake map parts that would all fit together or based on a pattern and them mix them into a new map. I still have not tried to make that yet.

I wish there were more tutorials and text online on map generation written so that a 5 year old can understand it.(reddit:explain it like i'm 5) I have not a clue most of the time what it is about. (like the text in ai books)


Nobuyuki(Posted 2015) [#8]
I wish there were more tutorials and text online on map generation written so that a 5 year old can understand it.(reddit:explain it like i'm 5) I have not a clue most of the time what it is about. (like the text in ai books)


The mystery is part of the fun, but also part of what makes it interesting. It's not one of those "trade secrets" that require some sorta math magician to reverse-engineer the most efficient way, it's more like an art, where you can have a ton of different styles, each producing something unique, interesting, and applicable to its own niche. That's also why I think this thread is interesting!

The generator I was writing down on paper before prototyping was going to be one based off large rectangles, connected together with a few "strands" of hallways. I was hoping that the large rooms would be more conducive to the type of gameplay I wanted, while "gating" a bit of the action so that the pace was more controllable. Simple concept, but by itself would probably make very boring looking dungeons. Each of these generators make very interesting things, and I look forward to seeing more of them, to see how they can be imagined as different types of dungeons, etc


impixi(Posted 2015) [#9]
Impressive results. Thanks for posting your code.


Nobuyuki(Posted 2015) [#10]

The other day I decided to try my own take on a generator based partly on the wandering floor generator used in Nuclear Throne, but spawning rects of variable size within a min/max specification not necessarily square nor directly adjacent to one another. Press spacebar to regen.

https://dl.dropboxusercontent.com/u/1417196/wandering_room/index.html

The technique starts with a center room, which has an "origin" / pivot point which is moved in a random direction towards the edge of the room. A second room is generated, and the edge of the new room is butted up against the edge of the previous room. It then slides the new room to a random point along the axis perpendicular to the direction the origin point moved. The origin is then moved to the center of the new room, and the direction is rotated 90, 180, or 270 degrees. The process then repeats until the specified dungeon size is reached. There is a threshold for where the pivot "winds"/rotates vs. tends to stay in a straight hallway. There are also variables for room overlap tendency as the origin moves, min/max room sizes, and min/max dungeon size.

Not yet implemented is recursive spawning of rooms to create more "tendril-like" and organic floor layouts.