by date
An Approach to Making Random Dungeons
An Approach to Making Random Dungeons
| Name: | Gary Haussmann | ![]() |
|---|---|---|
| Date Posted: | Jan 02, 2006 | |
| Rating: | 5.0 out of 5 | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Gary Haussmann |
Blog post
I'm a big fan of the old dungeon crawl games (like Nethack) that auto-generated random dungeons and populated them with monsters. So over the holiday break I attempted to make a reasonable generator that would take torque interiors and assemble them in a mission file to approximate the old-school dungeon setup. The initial results were surprisingly easy to produce, but there are many little details to iron out.
Step 1: Make a bunch of modular interiors representing parts of the dungeon. This includes things like hallways, small rooms, and stairs/ramps. Each part will correspond to a single tile in my autogenerated maze, and has to be a standard size and have openings/doors at the right spot. This way all the parts will fit together so that, for instance, the west door of room #323 will match up with the hallway opening of hallway part #193. The screenshot shows a simple part representing a hallway turn.

Step 2: Generate the maze. Here I just have a python script generate a simple maze, like the kind you would have done in an undergraduate algorithms class. The script then tries to match up interiors to appropriate tiles. For instance, a tile with openings to the west and east would correspond to a straight hallway, or perhaps a room with two doors on opposing walls.
The screenshot shows a text dump of the results: The walls of the maze are the "#" characters and tiles are filled with different letters to indicate which DIF structure was placed there. It's only for debugging, so it doesn't really have to make a lot of sense...

Step 3: Generate a mission file containing all the interiors at the proper position and orientation. Load mission. Profit! Here is an example dungeon made up of a 5 x 5 x 2 region of tiles. Yeah, it's three-dimensional, so there are two floors; the ramps are kind of a problem. You can also see some "missing" parts, since I haven't made enough interiors to cover all the possible tile configurations. If the script can't find an interior that matches up to a given tile in the maze, that tile is just left as empty space.

And here is a debugging shot that clearly shows the parts that make up the "Dungeon"

It's not really that easy, though. Slapping dozens of interiors all in one spot is a good way to drag down your FPS, so I'm thinking heavy use of LOD will be needed here. The other main problem is lighting, which stems from my use of portals. The portals block off sunlight from reaching the inside of each part, but since I can't stick the portal at the very edge of each interior, the edges of each part will get lit up. Here you can clearly see the joints between dungeon parts since they are lit up by the sunlight leaking in. Also, lights placed in one DIF won't illuminate other DIF, so the light in a specific room won't bleed out into the adjacent hallways.

Luckily, Universal Static Lights (USL) from the lighting pack can help a lot. The main advantage here is that USL's will illuminate multiple interiors seamlessly, so it's much less obvious where the joints go. In the previous shot, the green illumination is from a USL. Currently I've just turned off the sun altogether and rely on USL's, although if anyone can suggest better methods I could use here I would greatly appreciate it. Here's the same mission file with only USL's in it.

Finally, note that you can make bigger and more complex structures as long as they fit into the tile system. Here is a bigger room which occupies a 2x2 tile region on the map.

Anyway, a nice little diversion over the holidays. I still need to make some more structures (and better ones) but the siren's call of Real Work is wafting to my ears...
Step 1: Make a bunch of modular interiors representing parts of the dungeon. This includes things like hallways, small rooms, and stairs/ramps. Each part will correspond to a single tile in my autogenerated maze, and has to be a standard size and have openings/doors at the right spot. This way all the parts will fit together so that, for instance, the west door of room #323 will match up with the hallway opening of hallway part #193. The screenshot shows a simple part representing a hallway turn.

Step 2: Generate the maze. Here I just have a python script generate a simple maze, like the kind you would have done in an undergraduate algorithms class. The script then tries to match up interiors to appropriate tiles. For instance, a tile with openings to the west and east would correspond to a straight hallway, or perhaps a room with two doors on opposing walls.
The screenshot shows a text dump of the results: The walls of the maze are the "#" characters and tiles are filled with different letters to indicate which DIF structure was placed there. It's only for debugging, so it doesn't really have to make a lot of sense...

Step 3: Generate a mission file containing all the interiors at the proper position and orientation. Load mission. Profit! Here is an example dungeon made up of a 5 x 5 x 2 region of tiles. Yeah, it's three-dimensional, so there are two floors; the ramps are kind of a problem. You can also see some "missing" parts, since I haven't made enough interiors to cover all the possible tile configurations. If the script can't find an interior that matches up to a given tile in the maze, that tile is just left as empty space.

And here is a debugging shot that clearly shows the parts that make up the "Dungeon"

It's not really that easy, though. Slapping dozens of interiors all in one spot is a good way to drag down your FPS, so I'm thinking heavy use of LOD will be needed here. The other main problem is lighting, which stems from my use of portals. The portals block off sunlight from reaching the inside of each part, but since I can't stick the portal at the very edge of each interior, the edges of each part will get lit up. Here you can clearly see the joints between dungeon parts since they are lit up by the sunlight leaking in. Also, lights placed in one DIF won't illuminate other DIF, so the light in a specific room won't bleed out into the adjacent hallways.

Luckily, Universal Static Lights (USL) from the lighting pack can help a lot. The main advantage here is that USL's will illuminate multiple interiors seamlessly, so it's much less obvious where the joints go. In the previous shot, the green illumination is from a USL. Currently I've just turned off the sun altogether and rely on USL's, although if anyone can suggest better methods I could use here I would greatly appreciate it. Here's the same mission file with only USL's in it.

Finally, note that you can make bigger and more complex structures as long as they fit into the tile system. Here is a bigger room which occupies a 2x2 tile region on the map.

Anyway, a nice little diversion over the holidays. I still need to make some more structures (and better ones) but the siren's call of Real Work is wafting to my ears...
Recent Blog Posts
| List: | 03/24/06 - More AI Pack Trigger Examples 02/10/06 - A real simple AI pack example 01/02/06 - An Approach to Making Random Dungeons 10/31/05 - Plan for Gary Haussmann 09/26/05 - Plan for Gary Haussmann 03/07/05 - Plan for Gary Haussmann 01/30/05 - Plan for Gary Haussmann 01/04/05 - Plan for Gary Haussmann |
|---|
Submit your own resources!| Brett Fattori (Jan 02, 2006 at 22:00 GMT) |
- Brett
| Hans (Jan 02, 2006 at 22:21 GMT) |
When will it be released ?
| Jesse (Midhir) Liles (Jan 02, 2006 at 22:31 GMT) |
| Treb Connell (formerlyMasterTreb (Jan 02, 2006 at 23:07 GMT) |
| Brian "Ayavaron" Ross II (Jan 02, 2006 at 23:57 GMT) |
| Chip Lambert (Jan 03, 2006 at 00:48 GMT) |
| Gary Haussmann (Jan 03, 2006 at 03:27 GMT) |
This is just proof-of-concept stuff. A setup appropriate for release would need to allow you to hit some "play random dungeon now!" button from the main menu which would then drop you into a fully functioning random dungeon. That would require a LOT more coding work. Not to mention that I'd have to make a buttload more interiors and make them nice-looking :P
| David Montgomery-Blake (Jan 03, 2006 at 03:29 GMT) |
| James Urquhart (Jan 03, 2006 at 10:22 GMT) |
Perhaps you could directly generate a .map file consisting of all the brushes of the segments stuck together to solve your "too many interiors in one spot" problem...
Then again, that might also bog down your system, and you'd have to remove duplicate portal brushes from the exits.
Of course, you could still go for combined .map's and .mis' - stick A x A segments into a .map, with B x B segments total as .dif's in the .mis.
| Ville Helin (Apr 06, 2006 at 21:24 GMT) |
http://users.tkk.fi/~vhelin/dippa.ps
http://users.tkk.fi/~vhelin/lg.html
:D
You must be a member and be logged in to either append comments or rate this resource.



5.0 out of 5


