Page 1 of 8

[WIP] Randomly Generated Dungeon! [Revived]

Posted: Mon Apr 12, 2010 3:15 pm
by Nash
Image

Original post from 2010:

A few days ago, I rediscovered the old game Dungeon Hack and suddenly had the urge to attempt to create a random dungeon generator in ZDoom.

This is an experimental, work-in-progress random dungeon generator system for GZDoom. It will always be WIP as I am constantly adding and adding stuff onto it.

At this point, I can't say if it'll be a proper, full game - I'm just having fun experimenting with this. It might turn into a first-person Roguelike, maybe even a full-scale RPG like Diablo. Who knows?

Features:

Dungeon is randomly generated everytime you start the map.
Fully-working MODELDEF doors.
Random monster placement.

Planned features:

Improvements to the dungeon generating algorithm
Room prefabs (randomly places prefabbed rooms)
Decoration
Items
Locked doors, requiring keys that are randomly spawned
Starts and exits

Stay tuned...

Re: [WIP] Randomly Generated Dungeon!

Posted: Mon Apr 12, 2010 9:39 pm
by qwerqsar
Nice to see the first result :D !
The map it creates look often good, although I don't know why I spawned 3 of 3 times on the outside of the dungeon... Guess it's real bad luck!

Re: [WIP] Randomly Generated Dungeon!

Posted: Mon Apr 12, 2010 11:35 pm
by Jinal
A Diablo themed Doom wad would be possible perhaps?

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 3:26 am
by Cutmanmike
Groovy. I look forward to a project that actually uses this. Maybe an endless multiplayer survival adventure? :P

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 3:39 am
by Nash
Yeah it could possibly have Diablo-like gameplay.

Anyway, after a quality night's sleep, I looked over again at the code and saw how crappy it was. I have a clearer mind now so I'm gonna rewrite it a bit...

What I tried to do last nite was basically:

1) Build first room
2) Pick random wall
3) Build random length corridor in that direction
4) Place a room at the end of the corridor and randomly offset it a bit
5) Repeat step 2 ROOM_LIMIT times

It generates a bunch of mess. :P

I went ahead and totally rewrote DigCorridor() so it actually works correctly now. I'm also scrapping the idea above and will probably go for my original approach:

1) Build ROOM_LIMIT amount of rooms randomly (random position and dimensions)
2) Step through each and every created room in the list - for each room, pick random wall
3) Dig corridor of random length in that direction
4) Once corridor has reached the end, pick another random direction and length, and dig again (must not go back in previous direction)
5) Repeat step 4 until corridor digger collides with open space (should I check if the open space is a room, or should I let it not care whether it collides with a room or corridor?)
6) Go back to step 2 and repeat until all rooms in the list has been gone though

Once I have that working, I'll start working on doors. I think I have an idea on how to actually implement it but I'm trying not to overload my poor unintelligent brain too much right now. :P

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 9:03 am
by Chex Warrior
This is a great idea, good luck.

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 9:20 am
by Armaetus
Very WIPy, as it definitely needs variety in it.

The first level generated had no exit.

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 9:26 am
by Nash
I know. It's not even building the dungeon properly yet. :P

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 10:24 am
by Nash
Found an interesting article on using BSP trees to subdivide and build the dungeon:

http://doryen.eptalys.net/articles/bsp- ... eneration/

I might try this...

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 6:48 pm
by qwerqsar
Nash wrote:I think I have an idea on how to actually implement it but I'm trying not to overload my poor unintelligent brain too much right now. :P
You're kidding, right?
I like how it is going, plus it would look cool with some typical fantasy monsters roaming :D
Great idea!

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 7:07 pm
by Nash
The BSP technique looks cool but IMO the dungeons look too organized and orderly... it's not random enough for my tastes.

So it's back to my idea for now. :P

I spent the last 5 hours fixing DigCorridor(). I'm so tired.

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 7:07 pm
by NeuralStunner
Nash wrote:... my poor unintelligent brain ...
Oh pfuh. You're an unsung genius. Wait, you do sing... Nevermind. ;)

Personally I'm impressed with how "lite" the code is! I bet the map itself is an absolute hulk though.

... "HULK MAP!" :P

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 7:12 pm
by Nash
Well if there was some way to generate UDMF maps through scripting (if anyone remembers a thread I created a while back - this was exactly the reason) then preparing the map could be totally easy.

I almost settled for WadC but I couldn't bothere figuring out the runtimes it needed, plus it didn't do UDMF.

In the end, I just created the sectors in DB2 manually. It's not that difficult: Create first sector, sequentially paste copies to the right until I reach DUNGEON_WIDTH copies (the selection box in DB2 is handy as it copies and pastes sectors in the correct order). Then repeat vertically for DUNGEON_HEIGHT copies.

Generating sector tags for all the sectors was made easy by a QBasic program LilWhiteMouse wrote.

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 7:44 pm
by NeuralStunner
Nash wrote:Well if there was some way to generate UDMF maps through scripting (if anyone remembers a thread I created a while back - this was exactly the reason) then preparing the map could be totally easy.
Of course, they'd have to be run beforehand by an external program, then loaded up into ZDoom.

If you wanted to be weird, you could generate an ACS script to do the stuff sector-by-sector, then call ACC on it and pack it up. (Is there a good command-line based wad packer?)

Re: [WIP] Randomly Generated Dungeon!

Posted: Tue Apr 13, 2010 7:52 pm
by carlcyber
@ NeuralStunner:
You mean something works like Block of Doom 2 editor?