Generating dungeons....

Posted by death on Aug. 2, 2012, 9:30 p.m.

is killing me. I can't seem to do it. I've looked up so much info on this, played with examples and it seems my low math skills and lack of programming experience cause me to fail every time. The only thing i need to do to finish my rpg is finish the dungeon generating code. I've tried different methods multiple times and i can't get the results i need. i can hardly understand most examples i found on the GMC. The BSP method made the most sense to me but i suck at using data structures such as grids which are needed. i can only write the most basic of code with them.

I don't think i can even ask for help at this point… again another project of mine comes crashing down completely due to my lack of skill… i really don't know what to do. i REALLY wanna finish this game but i just don't know what i can do. it's one of the most frustrating experiences i've forced myself into.

Everything else is done for the game too. Town generating, all the graphics, items, weapons, classes, etc. All i need is to generate dungeons, it can't be a full game without it and at this point, i can't hand make the dungeons - that would contradict every thing else in the game.

Does anyone have any good advice for randomly generating dungeons, or no of tutorials or examples for idiots like me?

Comments

death 12 years, 4 months ago

Quote:
This is exactly why I don't understand why you didn't start your CS courses in the first semester…
i explained this =P courses have requirements you know, and i have to meet the requirements first before i can get to the later courses.

I started random generation so i could avoid: tiling an enormous amount of space/rooms. I was also generally curious about it. I wanted to see if i could do it and i can in some ways but it all depends on what results i want and it's hard to do exactly what i want.

Rob 12 years, 4 months ago

Quote:
i explained this =P courses have requirements you know, and i have to meet the requirements first before i can get to the later courses.

I don't remember that. What kind of prereqs are there? Math? Where I'm at there are no non-CS pereqs for first year CS courses (besides taking all the highschool math courses, of course). Although second year ones have math courses as prereqs too. But even then, you said you were at it for more than a year, do they have like 3 math prereqs or something for the very first CS class…?

ludamad 12 years, 4 months ago

The method I'm using in my game 'lanarts' is pretty simple in concept. I place random rooms as rectangles, and then connect them with tunnels that attempt to dig until a certain depth, and then backtrack completely and try again. The dungeons turn out looking fairly decent, although I am looking into expanding this approach.

Juju 12 years, 4 months ago

I'll dig out my old 3 hour Halloween entry.

Edit: Here we go.

Few notes:

1) Don't judge me on my code. This was done in 3 hours (actually, this was only 2 hours). The generation code is in Alarm[0] in controller_obj. I left in some bugs by accident before uploading here. You can go track them down by yourself, I guess, it's not a complex game by any means.

2) The simplest solutions are often the best. Consider this: Do you need to have a complex branching structure? You can create artificial branching paths by using multiple locked doors/stairwells that move between levels rather than having them within the levels themselves. This often better as it more easily delineates areas from each other.

3) A big issue with procedural generation is the AI. Most AI systems work on nodes and set-pieces, neither of which are easy to implement in proc gen. Nodes can be used but it demands pre-programmed rooms of some sort which damages the illusion you're trying to create.

4) Try to get the setting to fit the limitations in your coding - at least until you become a better programmer.

5) Dress your rooms well. Pretty rooms can be rectangular and no one notices that they're easy to generate and kinda dull by themselves.

6) Create enough random content that's believable so that repetition is infrequent. Make a list of events and situations that have been generated within the last few dungeons so that the player sees the full breadth of your design. To that end, consider theming your dungeons.

7) Play test, play test, play test. Create a debugging system that can force certain things to generation. Output debug reports with the seed of each dungeon so you can recreate bugs easily to track them down.

8) Make your challenges scalable; be it in the traps that are used, the frequency of friendly encounters or the strength of opposition within the dungeon. The length of the quest is also an important factor.

And kinda general notes on making dungeons:

9) Don't be afraid of using words. If the player finds nothing in a chest, don't just have an empty chest. Put something useless in it and/or have some text. Examples: "This chest holds nothing but antique dirt."; "The musty smell suggests this chest has long been disused."; "A sudden puff of bitter dust falls from the wardrobe. These used to be garments long ago." Immersion is cheaper than you'd think.

10) Make sure the player doesn't get lost. Giving them a map isn't enough. Try to make each room notable, maybe even have a little discrete title for the room pop up when the player enters a room. Every location must have flavour.

11) Make the player feel emotion by modifying game play as much as possible. If the player is a mighty warrior and you want him to feel powerful, send many weak enemies. If you want to humble him, send a single vile beast. The player is determining his worth based on his strength - another challenger with sufficient strength to test the player is going to evoke an emotional response. Sending a mage to kill the player is never going to be as emotional because there's always the feeling of "that was bound to happen." Being out-muscled will be more pertinent. Procedural generation, incidentally, gives designers a rare opportunity to exploit this.

12) The excitement in combat games comes from a simulated "Flight or Flight" response. Most games emphasise the fighting but rarely, if ever, allow you to run away in relative safety. Always let the player make mistakes and get away with it if he decides to run. On the flip-side, make sure your AI isn't so stupid that it doesn't react sensibly to hit-and-run attacks.

13) Dungeons and Dragons is the best RPG system ever created because it has very flexible rules. Strive to create a similar feeling. Play DnD to understand the importance of description and intrigue without being explicit. Let the player assume things but correct him when he's wrong.

14) Don't be afraid to have a sense of humour. A character sneezing because of harmless pepper-fungus is funny, the Hobgoblins attracted by the noise isn't. Together, it makes for a fantastic story. Remember: the essence of drama is the combination of mirth and misery.

Astryl 12 years, 4 months ago

In the 64Fools comp entry I made, I worked with rectangles. Basically, I stored an array of rectangles, and each of those became a 'room'. Then, in order from the first rectangle in the array, I drew passageways from one to the next.

I didn't mind if two rectangles overlapped, because it made rooms with unusual (L-type) shapes.

Castypher 12 years, 4 months ago

Juju has some excellent points up there, even for people who aren't interested in procedural generation. Great stuff.

death 12 years, 4 months ago

@ Juju: wow that's one long post. You could have made a whole blog with that one xD i do agree with it though, it's very good advice. Luckily i know more about game design than i do with game programming but there were still some things you mentioned that i didn't think about. Thanks for taking the time to post it.

Juju 12 years, 4 months ago

I could have done but I didn't want it to sit out of context with regards to the RPG contest.

Yaru 12 years, 4 months ago

I've got some nice algorithm you could use… it's called "Artificial Dungeon Generation" since you don't actually create tiles, so it's actually more useful for text-based dungeons. But it's of course possible to make a dungeon made of Zelda I-style rooms and just have one in memory at a time.

Anyway, here goes:

Hmm… Again, speed vs space.

I'd personally, if I were you, make a story-driven RPG with a clear goal, a bunch of named characters, but lots of freedom. First of all, using random generation you can make lots of bonus dungeons the player can go to if he wants to, either for grinding, for treasure, or just because he's wondering what's on the bottom. Secondly, if you make a Disgaea-like system where the player can make his own Player Mooks who will basically be 90% of his party at any given time, the game will also last longer because there's loads of room for strategy.

Also, if the game generates all dungeons for you, you can spend all the time you gain from that on making plot, monsters, skills and items to put into the game. As I said a bit up, to make a dungeon you just tell the game where it begins, where it ends, what tileset and monster set will appear in it, and how deep it should be.

Question: do you want the dungeon to be the same all the time, or to be different each time?

If you want visited areas to always be the same, here's one idea on how to make bosses appear in the first-person dungeons:

When you generate the first room, set "Bossdistance" to the dungeon parameter. The first room has at least two paths: exit and onwards. Pick any path not leading backwards and set this path to the boss path; I'd generate a bunch of nodes with "backwards" doors to this node and a parameter "this room is generated" set to false. Each time you enter a node that's not "generated", you generate its contents, size, skin (throne room? hallway? prison cell?) and number of paths.

Anyway, generate some rooms, and pick one of them and set it to be the "Boss Baton" and set its "Boss Distance" to this room's Boss Distance minus one. This process is repeated each time the player enters the Boss Baton room; the rooms are basically passing the baton onwards. Since the rooms are given their individual random_set_seed() seed upon generation based on the previous room's seed, no matter what order you visit rooms the boss path will always be the same.

Also, the Boss Baton room may never be a dead end, unlike any other generated room it has to have at least one new path when it is generated. (obviously, all rooms gotta have a door back to where you came from)

Finally, obviously, when Boss Distance reaches zero, you make this room an ominous hallway with a single door forward; that door leads to a throne room with the dungeon boss.

Oh, by the way; the current algorithm ignores the fact that paths may intersect; each node just lead to other nodes via doors that work just like teleporters and you don't actually create tiles or anything. You could end up with a dungeon where you may turn right 40 times in a row without walking in circles!

To solve this:

- Give every single node a value DISTANCE. This is equal to 0 for the entrance/exit node, 1 for all nodes you reach from it, 2 for all nodes they lead to, and so on. Basically, when the player enters a node for the first time and you generate its paths and contents, you create "non-generated" nodes for all the paths, and just set the Distance of all those nodes to this node's distance plus one.

- When you go trough a path that does not lead to the Boss Baton, somehow select a random node from the list. If this node

a) has at least one non-visited path

b) has roughly the same distance as the current node (e.g you're at a node with Distance 5 and the random node has distance 6)

you might (say a one-in-three chance or something) make this path lead to THAT node instead, and also make the unthreaded path in that node lead to the current node.

Got it? That's one way to introduce loops. Oh, and don't forget to remove any non-generated nodes that get unaccessible when you connect a loop this way to avoid small memory leaks.

Link: http://gmc.yoyogames.com/index.php?showtopic=528315&st=13

We discussed that system a while more in that GMC topic, so you could read on fore more suggestions and ideas about it.

death 12 years, 4 months ago

Quote:
Question: do you want the dungeon to be the same all the time, or to be different each time?
well the game would save the room once it's been created so it'll always remain the same for that players world.

All of that confused me… a bit xD

is this from a game your making or is it just an idea? also "nodes"? [-_-]