Building a Procedural Dungeon Generator In C#
Nerval's Lobster writes Procedural dungeon generation is a fun exercise for programmers. Despite the crude interface, such games continue to spark interest. A quarter century ago, David Bolton wrote a dungeon generator in procedural Pascal; now he's taken that old code and converted it to C#. It's amazing just how fast it runs on a five-year-old i7 950 PC with 16GB of RAM. If you want to follow along, you can find his code for the project on SourceForge. The first part of the program generates the rooms in a multilevel dungeon. Each level is based on a 150 x 150 grid and can have up to 40 rooms. Rather than just render boring old rectangular rooms, there are also circular rooms. "There are a couple of places where corridor placement could have been optimized better," Bolton wrote about his experiment. "However, the dungeon generation is still very fast, and could provide a good programming example for anyone exploring what C# can do." For C# beginners, this could represent a solid exercise.
Have we slipped so far down the performance-orientated slide that we are impressed by *how well a dungeon generator runs on an i7 with 16GB of RAM*.
I am genuinely curious. That is an outrageously high spec for a dungeon generator.
Alternate link
It's amazing just how fast it runs on a five-year-old i7 950 PC with 16GB of RAM.
Yep, almost as fast as the original's code on a i386 with 4MB of RAM. Impressive.
I have discovered a truly marvelous proof of killer sig, which this margin is too narrow to contain.
NetHack has had procedural dungeon generation with available source for .... gosh a long time.
These kids nowadays, with their fancy processors.
I foresee a sudden rush of crappily made dungeon crawlers, all sporting the Unity3D free/indy badge clogging up kongregate for months to come.
kartune85 : Incapable of reason, observation or learning. A kind of dim, drab, flightless parrot.
Another shitty dungeon generator.
Why not post this in /r/cartographersguild or something?
There are already lots of shitty dungeon generators, you're probably not doing anything useful like using features that are in sourcebooks, and dungeon building is almost certainly something you should be doing by hand anyway. Even if your party is a bunch of mindless murderhobos. Good dungeons make enough of a difference that people will actually pay real money for them. If you want story on top of an interesting tactical scenario then you have to do it yourself, and this is not likely to be a good place to start. You should start with a line diagram connecting *encounters* with each other (straight lines, branches, loops), and then come up with the layout. Doing it the other way around makes for shitty dungeons. There are books and papers on this topic that would be much more useful.
And another thing, as long as I'm ranting: don't use traps. They slow the game down and decrease player resources without actually giving them agency. They serve no narrative purpose. If you must have traps, have them [a] sound alarms or otherwise summon foes, or [b] make it a risk / reward situation: make their choices interesting. If, given complete knowledge of a situation, you would always want to choose one action, you're not being given a real choice. Choosing to avoid a trap isn't an interesting choice. Choosing to walk into a trap because the danger is worth the shiny thing you might get out of it is far more interesting. See also FPS map design, good example would be Unreal Tournament's DM-Pressure, where there's a powerup inside a room, and a button other players can hit to kill anyone in there. Risk vs reward. There's actually quite a bit about FPS map design that's applicable to PnP RPGs.
tl;dr
This is not a way to generate maps that people will want to play. If you have to use a generator, there are better options. If you want to learn about how to make good maps, there are better resources. If you want to pretend that something you wrote decades ago is full of important lessons for other people, fuck off.
I remember when getting first post was a major acheivement.
Yep, you'd fire up BitchX, brag to all your friends on freenode, and get your mom to bring down a celebratory hotpocket and coke.
Those were the days! I haven't even used BitchX this decade.
*bites hotpocket, sips coke*
It's amazing just how fast it runs on a five-year-old i7 950 PC with 16GB of RAM.
Yeah, it's five year old, but even today a very fast CPU. Has a CPUMark of 5600. High TDP of course.
*high-fives mom*
It's actually harder nowadays because slashdot is down for $RANDOM_HOURS pretty much every day now.
"Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
Yeah baby. I remember the joy of getting a story accepted. In fact, it was once a major achievement to be in the first 500 comments on a story.
Oh, it's just some Dice Slashvertisement, just to remind us that they own this shithole.
I've noticed that too.
Even in the bad old days, stuff would occasionally break, but the whole site usually stayed up, and in either case things were fixed very quickly. Outright outages up until Dice took over were pretty damn rare, but now as you said, they've become rather frequent, and when they do happen, it's for hours. Also the alignment of various elements occasionally goes wonkey and comment boxes only fill up half the screen.
I almost wonder if they are trying to degrade the performance of the site on purpose in a really desperate attempt to push us into their beta disaster.
Why is it "amazing" that a piece of code, written 25 years ago, on a processor 100,000 times slower, runs quickly? o.O
I really don't understand why this article is a thing. For 1, it's a really shitty way to generate dungeons as there are vastly superior ways of doing it: cellular automata http://www.futuredatalab.com/p... for example can product cave like dungeons, regular rectangular dungeons, etc and not just something made with ASCII that needs to then be converted. I've even seen KDtree's drawn out to represent rooms and such for muds. This article fails on a multitude of fronts. First being the DICE ad tracker embedded in the link to the article. Second, being the fact that he is "impressed" with how fast it runs on a Core-i7. Third, the use of SourceForge, where projects go to die. And finally, the fact that the article says it's geared towards beginners, teaching them bad coding practices and the like with the shitty code that's on sourceforge.
Call me when he re-writes Dwarf Fortress, which doesn't just build the dungeon but also the countryside around it along with a few more continents and oceans as well as a thousand years of history for each of the major civilizations living there.
Is this similar to what the RPG Diablo from Blizzard was doing with its dungeon random generation (with a few exceptions) back in 1996?
http://en.wikipedia.org/wiki/Diablo_(video_game)
Wow there's even people left on Slashdot to mod offtopic. Check out my user number, I could be modded offtopic for months without my karma taking a dent.
Karma has been kapped at 50 for years now, unless it was uncapped along the way someplace
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
No worries.
"They" do that to me right now. Every second post modded "offtopic".
File a complaint as soon as you can not post anymore with the automatic +1 modifier, and they get revoked their modding ability for life time.
Needed to do that already twice. Not sue how long it takes that Karma vanishes. Last time it took over a year.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Its Dead Jim but not as we know it, not as we know it, not as we know it
Its Dead Jim but not as we know it, not as we know it Jim.
Its alive Jim but not as we know it, not as we know it
Its alive Jim but not as we know it, not as we know it
Not as we know it JIM.
#had to compress the fucker as the compression filter sucks balls
So I had a crack at this a while back, but assuming that it would be too sane in C#, I thought I'd do it in Excel for a laugh. ;)
http://www.frayn.net/games/ddxl/index.html
It builds roguelike dungeons and cellular-automata-based cave systems. With a procedural terrain generator too. And all wrapped in a fully-featured RPG with skill systems, equipment, inventories, randomly generated towns, merchants, mercenaries, magic, crafting...
It doesn't seem to work properly on Win8.1/Excel 2013, but YMMV. I really must get back to fixing that at some point.
Don't look too closely at the code, as it might make your eyes bleed. Sorry - I hadn't written any VBA before. I have no intention of quitting my day job. :)
I've had some fun with this..
;)
Cave Generation
http://i.imgur.com/grPvlNp.jpg
Classic with random room shapes.
http://i.imgur.com/Hjh1dSw.jpg
Maze generation.
http://i.imgur.com/36p9jR0.jpg
I can do a 640x640 map under 2 minutes on an i5 1.2ghz with 4 gigs ram. My dungeon rooms are all done with procedures and my rogue maps do boxes, circles, triangles, diamonds, H's, doughnuts. I wrote this in Java for fun and here are some of the references I used.
Rogue
http://www.roguebasin.com/index.php?title=Simple_Rogue_levels
Maze
http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
http://www.math.cornell.edu/~lipa/mec/lesson6.html
http://www.ibiblio.org/lifepatterns/
Cave
http://www.roguebasin.com/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels
Lots of room for improvement obviously, but I don't think I did too bad for my first dive in to map generation. I did start with recursion to generate these maps but they took way too long and ate up a lot of memory. I changed to a different method and avoided recursion. Still it was fun to dabble in recursion for a short time.
~~ Behold the flying cow with a rail gun! ~~
For each project you could generate a parser for a new programming language with procedurally generated characteristics, and use that to write your program. For example, it could make up a object oriented language where all variable names are required to be nonalphanumeric, and all of the operators are letters. Or a language where every variable is really just a FIFO queue. Or a language where you have to use sockets instead of function calls, with recursion being performed via the loopback interface. Maybe there is a builtin language keyword for reading from a database connection and posting the result to a twitter feed. The possibilities are endless.