10 ms·
Procedural Dungeon Generation Algorithm
- smlacy 11y agoI've seen algorithms that produce results similar to this before, and I find them lacking in any sort of feeling of purposeful design. Dungeons are (in theory) built by intelligent people for a reason. There needs to be distinct working, eating, socializing, farming areas. There needs to be wider or thinner pathways between areas based on flow of people & goods. A good starting place to look for amazing looking dungeons is to look at people who play Dwarf Fortress, and how they build & organize their forts, which are essentially dungeons. Here are a few good links: http://discourse.stonehearth.net/t/slave-to-armok-god-of-blood-dwarf-fortress/2613 http://discourse.stonehearth.net/t/slave-to-armok-god-of-blo... https://leelubutterfly.wordpress.com/2013/01/01/dwarf-fortress-the-ultimate-story-creator/ https://leelubutterfly.wordpress.com/2013/01/01/dwarf-fortre... etc. just google image search for "dwarf fortress" and you'll see a lot. Good algorithmic dungeon design should take into account some of these factors, like good city design would.
- venomsnake 11y ago> There needs to be distinct working, eating, socializing, farming areas. There needs to be wider or thinner pathways between areas based on flow of people & goods. put those constraints as a starting point and use genetic algorithms?
- ajross 11y ago> Dungeons are (in theory) built by intelligent people for a reason. Well, in the make believe universes you frequent anyway. Others have different tastes. I mean, in the realm of software there's a whole genre of these things going back to the original Rogue which never pretended to have any purpose at all. And digging even farther back you'll find a dice-driven (and, relative to modern standards, really terrible) random dungeon generator in an appendix at the back of the 1e AD&D DMG. Likewise even earlier TSR products like "Dungeon Geomorphs" were clearly aimed at random-or-at-least-mostly-sensesless generation. That's not to say you can't do better, just that "not random" is probably not exactly the right aesthetic to chase.
- colechristensen 11y ago>not exactly the right aesthetic to chase I'd say not only. A procedural generator that took account of architecture and reason could probably make a more interesting game, not everything needs to point towards that goal, but it'd be neat if some did. I'm bothered more with many first person shooters more which design environments basically just as long kinked up hallways you have to walk through while pretending to be in a place supposably designed with a purpose in mind.
- angersock 11y agoDungeons are (in theory) built by intelligent people for a reason. That reason is typically to store something behind a lot of very dangerous traps, trick architecture, and maybe enemies. Unless you're concerned with maintenance, you don't worry about farms and all that other nonsense--that's gold you should've been spending on golems, pit traps, and other self-maintaining defenses!
- logfromblammo 11y agoI am concerned about your apparent disregard for smashable barrels. It is critical to ensure that payroll and minor health potions are located near at hand to the live defenders of the dungeon, to keep them from loitering around near the nice parts when they should be down patrolling the adventurer-murdering parts. I find the current theory circulating that suggests such placement of critical resources only serves to reinforce and resupply invaders is almost entirely without merit. Why wouldn't a guard take additional effort to defend his barrel? Are they all so incompetent that they would expire before breaking into the emergency medical supplies?
- douche 11y agoDungeons as portrayed in every video game ever are a fantastic concept. It's not like there are actually anything like real dungeons outside of our imaginations (digging through rock is hard). The closest real analogues would probably be cave systems, like Carlsbad Caverns or Mammoth Cave, which are formed by irregular natural processes.
- dllthomas 11y agoMines?
- jpreiland 11y agothe catacombs, perhaps? I've participated in and run more than a few dungeon crawls in catacomb settings
- riffraff 11y agocatacombs (at least those I have visited) have _really_ tiny living spaces, and connections between rooms are basically holes. This is somewhat far from the "the adventurers met a group of monsters in the corridor" or "moria's halls".
- twic 11y agoCentral Government War Headquarters: http://www.bbc.co.uk/wiltshire/content/articles/2005/11/22/underground_city_interactive_map_feature.shtml http://www.bbc.co.uk/wiltshire/content/articles/2005/11/22/u...
- goldfeld 11y agoThe Parisian underground system?
- fapjacks 11y agoHawaii has dungeons. Defensive positions (and related) built after Pearl Harbor right into the rock. Dungeons exist insofar as dungeons are underground structures built by X that are now left to ruin and hiding strange creatures and hidden treasure. Those places exist on Oahu, among others.
- adnzzzzZ 11y agoThis really depends on the game you're making. Some games don't call for super purposeful layouts because the fun comes from things other than your surroundings making a lot of sense. As long as they generally look believable it's mostly fine. And so in those cases as a designer you just really need some places to place enemies in and going for a random enough algorithm is a good idea.
- panic 11y agoThink less "town" and more "cave". Spaces created by natural processes also lack any feeling of purposeful design, but still have lots of interesting variation. The feeling of exploring an untamed natural space (which even the creator of the game hasn't seen before!) is part of what makes these games fun, I think.
- andrepd 11y ago"Dungeon" is a term in game design to refer to a self contained challenge space, which can be realized in many different ways. It does not necessarily mean "dungeon" as in a real life dungeon or catacomb. It can be an actual human built space, in which case you are right, or it can be a Zelda dungeon, in which there is an overarching theme but not necessarily a sense of verisimilitude, or it can be such a simple and abstracted dungeon such as in Nethack or whatever, in which case those concerns are meaningless.
- sago 11y agoI agree, though the issue, I think, is wider than 'purposeful' design. The dungeon could be a range of things, but this one doesn't look like anything except an 'algorithmic dungeon'. Is it: a) an underground city (your analysis is spot on, doesn't look like that) b) a cave system c) a mine d) a prison e) the lair of some non-intelligent species f) a fortress to protect something Another option is that they're supposed to be 'abstract challenge spaces' (as another commenter claims), but roguelikes aren't intentionally abstract: they attempt verisimilitude on lots of levels. Nethack in particular has a very detailed naive physics with all kinds of internal logic. Brogue does its natural caves pretty well, I think. Minecraft seems to, and places its seams of minerals reasonably (neither are perfect, but they're clearly trying). But this kind of dungeon generator? We're nearly 20 years after Crimes Against Mimesis [1] was written, and this feels like a big step backwards. --- [1] http://www.reocities.com/aetus_kane/writing/cam.html http://www.reocities.com/aetus_kane/writing/cam.html
- fenomas 11y agoCalling this a step backwards is patently unfair. The author is explaining a simple algorithm, simply enough for even beginners to implement, for building layouts of a given connectedness. They are not making any kind of argument that the results can be used as-is in any particular genre of game. Honestly, you might as well attack an A* pathfinding article on the grounds that game units shouldn't necessarily take the shortest path to their goal. Algorithms like this are tools in a toolbox - obviously tweaking them is what makes any given game unique, but beginners still need to start somewhere. (Also - Nethack? The game where you find potion shops eight levels underground that can only be reached via three rooms full of soldier ants, etc?)
- sago 11y agoGood points. Some quibbles: > game units shouldn't necessarily take the shortest path to their goal They shouldn't? This can in specific cases lead to weird looking behavior, but nobody is suggesting it is an 'abstract movement strategy' that isn't supposed to correspond to anything a person would do. The reason shortest paths are used is that they do correspond to the way people move, to a first approximation. > simply enough for even beginners to implement Really? Using delaunay triangulation, minimum spanning trees and relaxation? With no sample code? This isn't a beginner tutorial. > can be used as-is in any particular genre of game. Really? You don't think this is specifically for roguelikes/roguelites? > Nethack Nethack definitely has crimes against mimesis too, definitely. In fact it has that 'old adventure' feel. I was using it just to show that the challenge spaces aren't abstract.
- Balgair 11y agoHere and there. Suppose your dungeon is full of ant people or orcs, creatures that can swing picks but are essentially dumber than the rocks they are hitting. They are rule followers and have not care for design, much like an algo. You can imagine an adventurer having to infiltrate such a place to steal a mcguffin, be it an uber-bee hive, an intestinal system of the dragon that ate you, or the random water paths that carved out a cave. The creator has to give the player a good reason why the system is random.
- sedatk 11y agoNot every dungeon is built for logistics. Think of temples, tombs, or traps for invaders.
- cobalt 11y agothose are still purpose built however
- forrestthewoods 11y agoAre you shitting me? This is the worst and most worthless type of post HN has to offer. It serves no purpose other than for the commenter to try and make themselves sound smart. Given the context here that's delightfully ironic. These dungeons are indeed built by people for a reason. Those people are game developers and the reason is video games. Diablo, Dungeon Keeper, and TinyDungeon all have dungeons crafted quite meticulously for very specific gameplay purposes. Those purposes do not involve eating or socializing. Just like the castle in Mario or Quake doesn't have eating, socializing, or farming areas. So no. No good algorithmic design should not take those factors into account. Because they're not making a city builder or world sim. Ugh. Ugh ugh ugh ugh.
- LanceH 11y agoHe's got a point. Almost none of these algorithms produce a bathroom that's any usable distance from the front door. Imagine you're the resident ogre just back from pillaging and you've got nowhere to go. And the absurdity of a minimally connected dungeon shows itself the first time you have to run to answer the phone.
- PhasmaFelis 11y agoDungeons in games have to do two things: serve as spaces of play, and provide verisimilitude, suspension of disbelief. Most often, the first takes high priority, and the second shows up only as set dressing: cells in a prison, waterways in a sewer, altars in a temple, etc. If you look at classic tabletop dungeons, though--the games that gave us the modern meaning of "dungeon" as "enclosed space full of loot and danger" as opposed to the dictionary "underground prison"--you're more likely to see a balance between the two. Everything still serves the needs of play, but within that framework you'll find bunkrooms, kitchens, storage rooms, training areas, etc, etc, sometimes even with discussion of schedules and which characters are likely to be where when, which the players can attempt to learn and take advantage of. It's more work, but it does make the gameworld feel more immersive, more real. Either approach is perfectly valid. In a fast-paced hack-and-slash game, you're not likely to stand still long enough to notice the set dressing; you just need a space in which to kill monsters, and anything more is a waste. In a more thoughtful/exploratory RPG, the game can really benefit from a thoughtful layout. Now isn't it nice when we can disagree without getting all huffy and belligerent?
- SixSigma 11y agoFunny you should mention DF. You should look at the procedurally generated dungeons it makes!
- carlisle_ 11y agoI really like the idea to just use a physics engine as a means of randomizing the layout. Smart, succinct, and easy to implement.
- neolefty 11y agoI delighted in this article because of its opinions about what is easy and what is hard. Physics engine: easy; of course you have one; everyone has a physics engine. Graph data structure & algos: suggests a few places to find one. As an older programmer who is in the midst of retooling, I would assume the opposite: graphs easy, physics hard. But that's what retooling seems to be all about -- finding the new "easy" and learning it.
- yoklov 11y agoA physics system good enough to support this is probably ~200loc. Probably less if you cut out everything extraneous. All it is is AABB collision detection+resolution, and then some update code. I think the graph + graph algos would be trickier most of the time, but that could just be since I've written the above code many, many times.
- catpolice 11y agoI've been working on an algorithm to make more playable dungeons with included puzzles (e.g. locked door/key quests etc.). The math is there to ensure everything is solvable and relatively interesting (you're guaranteed to run into a puzzle before you find all the elements you need to solve it, for instance) but I got bored when it came time to make an example game to illustrate how it works. I'll pick that back up at some point...
- ashark 11y agoEver play Yoda Stories or Indiana Jones Desktop Adventures? They do something like that, but with self-contained tiles that are randomly arranged, with some variation in e.g. key/item placement.
- draggor 11y agoDo you have the source up somewhere?
- yoklov 11y agoBrogue does this, although none of its puzzles are strictly required to progress, they are guaranteed to be solvable. Highly recommend brogue for anybody even tangentially interested in traditional roguelikes. Most interesting RL game design in years and the game is absolutely gorgeous, despite being glyph-based (no tiles). I'm on mobile or else I'd link.
- mnem 11y agoHere's a link to the original dungeon generation demo that Phi Dinh posted using this algorithm: http://tinykeep.com/dungen/ http://tinykeep.com/dungen/ (Flash required). He kept an interesting blog about the development of Tiny Keep and added other posts about improvements to the generation mechanics for the dungeons, including this nifty one about generating locked areas that Ben Jones worked on: http://blog.tinykeep.com/2013/09/just-sneaky-quick-update-from-us-today.html http://blog.tinykeep.com/2013/09/just-sneaky-quick-update-fr...
- karl_gluck 11y agoIf anyone's interested, there is a Reddit post explaining this and an interactive demo from 2 years ago: https://www.reddit.com/r/gamedev/comments/1dlwc4/procedural_dungeon_generation_algorithm_explained/ https://www.reddit.com/r/gamedev/comments/1dlwc4/procedural_... http://tinykeep.com/dungen/ http://tinykeep.com/dungen/
- jere 11y agoMore generally I would also recommend: https://www.reddit.com/r/roguelikedev https://www.reddit.com/r/roguelikedev
- karl_gluck 11y agoThat's a great resource! Thanks :)
- archimedespi 11y agohttp://tinykeep.com/dungen/ http://tinykeep.com/dungen/ _was_ the source of the figures in the article, AFAIK.
- riffraff 11y agoto me they look slightly different, both in animation (because of underlying algorithmic differences) and graphics (space inside rooms is black in dungen, blue in TFA). But maybe it's just tweaks, I don't know.
- onion2k 11y agoOne of the best maze generators I've ever seen was in the ZX Spectrum (Timex in the US) game of Steve Jackson's Warlock of Firetop Mountain[1]. It's brilliant, coming up with a maze full of rooms and doors, with no islands, and relatively well placed monsters and items. And all in 48K of ram. Despite browsing the source code a couple of times I've never figured out how it actually worked. [1] https://en.wikipedia.org/wiki/The_Warlock_of_Firetop_Mountain_(video_game) https://en.wikipedia.org/wiki/The_Warlock_of_Firetop_Mountai...