Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 04:17:37 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Dungeon generation?
Pages: [1] 2
Print
Author Topic: Dungeon generation?  (Read 28166 times)
Hayden Scott-Baron
Level 10
*****


also known as 'Dock'


View Profile WWW
« on: December 11, 2008, 04:55:23 PM »

I've been playing around with this online dungeon generator:
http://direpress.bin.sh/tools/dungeon.cgi

Is there some existing rulesets in order to generate this sort of thing?

The maps that are generated often seem quite well laid out, and I was interested in whether these sorts of layour are widely known, or whether people tend to develop their own techniques for building maps procedually.

Also, is it something where you start off simple, and work your way up to a more complex generation system?
Logged

twitter: @docky
Decipher
Guest
« Reply #1 on: December 11, 2008, 05:44:33 PM »

That seems like a quite cute maze generator to me. And maze generators are widely known. In fact it's not even hard to code one. I have coded one for Krysp (my submission for the CodeBlocks Challenge). Although the one Krysp implements is not as mature as the one you posted, the two share a lot in common.

As for the existing rulesets, it all depends on you, and how you want your content to be generated. This is what is good about procedural generation you're simply unbounded.

Finally, it simply is up to you how will you code it. If the generator I'm coding is something really complex I'd start off simple and build on, otherwise I'd code straightforward.
Logged
Hajo
Level 5
*****

Dream Mechanic


View Profile
« Reply #2 on: December 12, 2008, 01:14:57 AM »

Is there some existing rulesets in order to generate this sort of thing?

I've once been collecting dungeon generation algorithm description for my library. You can find a few of them here:

http://www.simugraph.com/h-world/pmwiki/pmwiki.php?n=Library.Maps

Logged

Per aspera ad astra
Hayden Scott-Baron
Level 10
*****


also known as 'Dock'


View Profile WWW
« Reply #3 on: December 12, 2008, 01:33:58 AM »

I wonder whether the map making algorithm in the example I linked to is available. I love the wiggly labyrinth corridors between the rooms.

I've once been collecting dungeon generation algorithm description for my library. You can find a few of them here:

http://www.simugraph.com/h-world/pmwiki/pmwiki.php?n=Library.Maps

This helps a lot, it's good to get an idea as to how these maps are figured out. I guess the best way to learn is to make a 2D array and start poking through it.

Does anyone know of any guides or tutorials for random map programming?
Logged

twitter: @docky
george
Level 7
**



View Profile
« Reply #4 on: December 12, 2008, 07:43:27 AM »

Maybe start here at the PCG wiki, more specifically here with the dungeon generation link.
Logged
nihilocrat
Level 10
*****


Full of stars.


View Profile WWW
« Reply #5 on: December 13, 2008, 11:37:07 AM »

The generator you link to looks like a pimped-out version of a roguelike dungeon generator. If you set some of the options to more conservative values (rectangle rooms, straight/bent corridors, no deadends) you'll notice that you've got what looks like a roguelike dungeon.

The algorithm for those dungeons is pretty simple. Basically you choose a number of rooms, a min room size and max room size, and maybe some other variables, and generate a bunch of non-overlapping rooms. Then, you randomly create doorways to each room based on some other variables. Proceed to generate corridors between these doorways, making sure that all the rooms are connected (there are no disconnected rooms, or sets of rooms disconnected from all the others). If you can't connect rooms with a straight corridor, just make one or more bends in it. From here, you can make more complicated algorithms to generate rooms and corridors to get labyrinth corridors or non-rectangular rooms.

If you need more help with the algorithm, there are plenty of open source roguelikes out there. Hopefully the dungeon generation code is well-written and well-commented.

edit: whoa, thanks for the PCG wiki link! I never knew such a thing existed!
Logged

Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #6 on: December 13, 2008, 11:48:24 AM »

I made a little roguelike awhile back and I just bruteforced my dungeon generation. Just generated a few random rectangle rooms in the overall space and then connected them with corridors. Unless you're doing mazes and stuff, it's not a bad way of doing things imho.
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
Hayden Scott-Baron
Level 10
*****


also known as 'Dock'


View Profile WWW
« Reply #7 on: December 14, 2008, 06:03:01 AM »

http://dirkkok.wordpress.com/2007/11/21/generating-random-dungeons-part-1/

I found a tutorial that, from first impressions, seems to know what it is talking about.

I'm starting to think that the best approach will be to try to do it myself. Solving the problems is probably the most important part of understanding the process in the first place. Also, I'd like to do something with diagonals and other shapes, which complicates things much more than the average roguelike map. 

Toastie, by brute force are you referring to your method of checking whether or not there was a route from one room to the next? This is one part that confuses me, how you choose paths between each room without overlapping or tangling... but I suppose it's a matter of rules, and waiting for those rules to cease to be invalid.
Logged

twitter: @docky
Loren Schmidt
Level 10
*****



View Profile WWW
« Reply #8 on: December 14, 2008, 06:20:41 PM »

Wow, that's a great generator, Dock.

I've always been fascinated by dungeon generation. I was working on a hex grid roguelike a while ago, but I never got my dungeon generation to work very well. I started with one room, specified door points, and then crawled outward randomly from there, creating rooms (or dead ends) at the end of each corridor. The wall cells bordering the passages and rooms weren't even marked, so the corridor diggers would inadvertently connect to non-door spaces all the time.

The main points I was missing were room packing and nice path finding for the corridors.

Despite how poor my results were, it was a lot of fun to code. I wish you better luck than I in your endeavors, and I look forward to seeing your results.
Logged
Natso
Level 0
**



View Profile WWW
« Reply #9 on: December 15, 2008, 05:25:55 AM »

The dungeon generator linked in the first post seems to draw all of its room content from D&D (I confirm this).  Also, in dungeon generation, you're going to feel like you're cutting some corners to get things to work right.  It always ends up feeling like that.

Cheers
 - Natso
Logged

Home is where my power chord is.
Hayden Scott-Baron
Level 10
*****


also known as 'Dock'


View Profile WWW
« Reply #10 on: December 15, 2008, 06:34:37 AM »

The dungeon generator linked in the first post seems to draw all of its room content from D&D (I confirm this).
Is there a documented set of rules for constructing dungeons in this manner in D&D?
Logged

twitter: @docky
Natso
Level 0
**



View Profile WWW
« Reply #11 on: December 15, 2008, 09:57:53 AM »

Naw, the map layout is whatever the DM wants it to be (D&D in itself can be played without a physical grid/map at all, but it helps a lot to use them)  As for the monsters & room contents themselves, they look to be from D&D 3.0 or 3.5 edition.  If you're interested in the D&D-related generation, you should check out http://www.d20srd.org/ for more info.  As for the map-generator, that is entirely unrelated to D&D, other then that the map can be used for it.  The DM's Guide has a few pointers for dungeon decor & layout, etc, but their layout is really at the DM's own discretion. (Sorry if my original reply was misleading)

Cheers
 - Natso
Logged

Home is where my power chord is.
Titch
Level 3
***


Cautiously Pragmatic


View Profile WWW
« Reply #12 on: December 15, 2008, 11:39:13 AM »

I have been wondering about psuedo-random generation, but for a performer rather than a dungeon crawling game. I always get hammered by having to ensure that the metrics of the content function properly without having to pre-fabricate blocks of content and stick them together.
Logged

increpare
Guest
« Reply #13 on: December 15, 2008, 11:55:35 AM »

I have been wondering about psuedo-random generation, but for a performer rather than a dungeon crawling game. I always get hammered by having to ensure that the metrics of the content function properly without having to pre-fabricate blocks of content and stick them together.
Well one way is usually to generate a sure-fire path first (this isn't necessarily the same as having pre-fabricated content), then to elaborate it as much as possible.
Logged
Natso
Level 0
**



View Profile WWW
« Reply #14 on: December 15, 2008, 12:51:04 PM »

I have been wondering about psuedo-random generation, but for a performer rather than a dungeon crawling game. I always get hammered by having to ensure that the metrics of the content function properly without having to pre-fabricate blocks of content and stick them together.
I hate to make a suggestion with little explanation, but you should look into dynamic programming, if you structure your generation similarly it may become quite a bit easier.  Also, consider the generation function recursively, if you haven't done that yet... (just throwing out some ideas)

Cheers
 - Natso
Logged

Home is where my power chord is.
Hayden Scott-Baron
Level 10
*****


also known as 'Dock'


View Profile WWW
« Reply #15 on: December 15, 2008, 01:01:21 PM »

If you map out the pattern of satisfying platform movement you can, theoretically, reverse generate a map to fill out those patterns. 

On the other hand, I believe Derek Yu's Spelunky game is procedurally generated using pre-made chunks of level (right?), which for a cave environment is very well suited.
Logged

twitter: @docky
Natso
Level 0
**



View Profile WWW
« Reply #16 on: December 15, 2008, 01:52:15 PM »

nethack (an awesome roguelike) takes an approach as follows:

1. Generate some rectangles amongst the entire floor, make sure the rectangles don't collide.
2. Make sure there are at least 2 rooms of suitable sizes for the up/downstairs (and check for other neccessary rooms for particular floors), otherwise return to step 1.
3. Connect the rooms with passages (and generate doors at this point)
4. Go through every room and generate content for it, from several templates (including a standard dungeon room with monsters/treasures, shops, beehives, swamps, throne rooms, etc)

Each of the templates is generic, but has its own requirements.  The the shop, for instance, adjusts inventory based on the size of the room.

(/nethack)

There was a maze-generation algorithm where the entrance and exit are placed on the outer edge.  The rectangle is then split into a 2x2 grid, where the cells are random-sized.  Each of the cells is then split again, and again, until the cell reaches the minimum possible size.  When there is a split, sized leave spaces open (so as to respect the paths entering and leaving them).  A similar approach could be used, splitting a platform-game's room into various areas, then filling them with content based on how much cell space is provided.

Cheers
 - Natso
Logged

Home is where my power chord is.
Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #17 on: December 15, 2008, 02:04:22 PM »


http://code.google.com/p/gridhack/source/browse/trunk/grid_level.c

This was my crappy dungeon code that's kind of similar to what nethack does I guess, but is a lot more brutish.
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #18 on: December 15, 2008, 03:25:32 PM »

Natsuo: I have always wanted to know how did the gnomish mines levels work? For those who haven't played nethack, these levels were more organic cavelike structures. Repeat bisection again?
Logged
Natso
Level 0
**



View Profile WWW
« Reply #19 on: December 15, 2008, 04:13:37 PM »

I want to say (don't take my word for this though) that it places an absurd number of small rooms around (like usual, but more & smaller, so as to leave less gaps.  also, the check requiring at least 1 cell between each room isn't used).  Then, when it would usually construct paths between rooms, it uses a modified form of the maze algorithm (the same maze generator used in Gehennom, and in some other levels).

Alternatively, it creates a maze-level, covers it in small rooms, then trims off the remaining dead-ends.

(The above are semi-guesses, the nethack source code isn't too well documented)

I attempted to do this actually, the demo: http://darknovagames.com/nathack/nathack.html
classic roguelike controls: hjklyubn, you know the drill I'm sure
If you type a capitol O and then move in some direction, it will make the entire map visible (so you can see the wood & cave elements as I describe below)

Algorithm:
1. Construct a maze that covers the entire room.
2. Place the three big rooms (one on left, one enclosed room in the middle, and one room on the right)
3. Snapshot this room, will use it later
4. Now, "erode" the entire room 4-6 times.  Erosion consists of changing a wall-type into floor-type based on surrounding elements (when entirely surrounded, no erosion, but if there are only 2-5 surrounding wall elements, there is a good chance of erosion)
5. The current map becomes the cave area. (grey)  The snapshot's bordered areas become the wooden tunnels & flooring (as seen in the demo).

This created a suitable atmosphere for me.  Since wood was going to be destructable, a suitable environment was needed behind it.

Hope this helps...
 - Natso
Logged

Home is where my power chord is.
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic