Building a Procedural Dungeon Generator In C# 83
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.
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
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
Re: (Score:2)
Re: (Score:3)
Karma has been kapped at 50 for years now, unless it was uncapped along the way someplace
Re: (Score:2)
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.
Are you freaking serious? (Score:5, Insightful)
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.
Re:Are you freaking serious? (Score:5, Funny)
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*.
It's C# -- so it's likely that's the minimum requirements for a compiled .NET App to run
Re: (Score:1)
Re: (Score:2)
From the looks on their faces, I'd say some of them actually liked it.
Re: (Score:2)
Re: (Score:2)
oh_my_080980980 wins.
Re: Are you freaking serious? (Score:1)
Probably used to run in half the time on an 8080 with 4kb of ram
I swear c# is a conspiracy between Microsoft and the ram and cpu vendors....
Re: (Score:1)
Microsoft? I've been running C# in my Linux for years.
Re: Are you freaking serious? (Score:5, Funny)
How's the systemd C# port coming?
You'll need to be more specific, are we talking about systemd running in C#, systemd running C# code, or the port of systemd in C# that runs C#?
Re: Are you freaking serious? (Score:4, Insightful)
He's talking about the systemd module that *compiles C#.
Re: (Score:3)
Re: (Score:3)
Jumping on this thread, if you want a dungeon generatore, check out the Libtcod library, it's been ported to Python, C++, C#, and very recently TypeScript (i.e. Javascript#)
http://roguecentral.org/doryen/ [roguecentral.org]
https://github.com/jice-nospam/yendor.ts [github.com]
Here's an example from 2011: https://www.youtube.com/watch?v=DZkDOx4W3zs [youtube.com]
Re: (Score:2)
In fact, C# is a conspiracy *against* CPU vendors: the plan was to say bye bye Intel x86 because Windows 32 bits was aging, and be more open to transition to other CPU such x86_64 while keeping the developer base. Just for this reason they succeed.
Re: (Score:3)
There are still plenty of people interested in getting stuff to run in 256-512 MB with a 700 MHz ARM. I think about half the tendency for code bloat in the past 15 years has been the decline of cheap hobby PCs - a vacuum that has now been filled. Still seems like a lot to me, but it does at least impose a little restraint and interest in optimization.
(The other half is of course managed languages, but really slimming down C# to work on a RP doesn't seem impractical - just something that MS hasn't had a re
Re:Are you freaking serious? (Score:5, Interesting)
I have been running C# ASP.NET on Raspbian Apache/ModMono for a solid 3 years. No problems.
Re: (Score:2)
I have been running C# ASP.NET on Raspbian Apache/ModMono for a solid 3 years. No problems.
Worth making this AC more visible. That's pretty cool.
Re:Are you freaking serious? (Score:5, Informative)
But it *worked* fine, I mean it drew the map in well under 10 seconds, printed it, then used the edge dots of one side as the seed for the next section of the dungeon. Isn't that what this is, and why do we even need an ARM for this, you should be able to get decent performance from a 4004!
This was my first real piece of software, and it worked on the first try (by that I mean I wrote it and bugfixed it, and...it worked). I was 13. You millennials or whatever you call yourselves should be running rings around me - who needs multiple cores or C# for this?? Do it in Minecraft, then I'll be impressed.
Re: (Score:2)
Hmm, This would make an interesting Minecraft mod for the dungeons.
Re: (Score:2)
Hmm, This would make an interesting Minecraft mod for the dungeons.
There are already lots of minecraft mods which insert dungeons into the game.
Re: Are you freaking serious? (Score:1)
Re: (Score:2)
I also wrote this, but I wrote it in Pascal in 1987, beating the author by 3 years unless his rounding function is broken.
Mine also sucked.
Still, procedural generation remains the next big thing, and applying it to something as simple as a text-based map, limited to two dimensions and "wall" or "not a wall" is nostalgic for many, and interesting for those who did not do the same project in some fashion.
The need for multiple cores did not exist - it just happened to be the hardware available, I assume. It w
Re: (Score:1)
Re: (Score:2)
https://www.ghielectronics.com... [ghielectronics.com]
C# running on a 168MHz Cortex-M4 with 1MB of flash and 192KB of RAM. This particular "module" replaces the older one that used a 72MHz ARM7 with 512KB of flash and 64KB of RAM.
Think smaller.
Re: (Score:2)
Now someone just needs to port it to the C64!
Re: (Score:2)
The other half is of course managed languages, but really slimming down C# to work on a RP doesn't seem impractical - just something that MS hasn't had a reason to focus on.
Or if you're impatient, you could just use D - the syntax is virtually identical to C#, but you get the performance of native code. I actually wrote some patches for buildroot a while back that added support for gdc, which make it pretty easy to compile a suitable toolchain for using D on a Raspberry Pi.
Re:Are you freaking serious? (Score:5, Funny)
C#/.NET makes great dungeons. Resources go in but can't get out.
Re: (Score:2)
Re: (Score:2)
Anything? Call up your professor, then, and tell him you broke theoretical computer science with your proof that you can, in fact, solve the halting problem. [/needlessly pedantic]
Re: (Score:1)
Re: (Score:2)
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.
You're genuinely curious? Well, OK. The recommended specs for a dungeon generator are what exactly?
I get your point, this is akin to measuring graphics cards by how fast they can render a Solitaire win, but it was more a comment reflecting how fast ancient programs run on today's hardware.
Or in other words, targeted at us old farts who do remember when computers used to actually strain themselves.
Re: (Score:2)
And exactly one month ago, we had:
http://games.slashdot.org/stor... [slashdot.org]
Re: (Score:3)
It is a big dungeon, mate! A really big dungeon! You know, with torture chambers, torture mistresses and such. Lots of moldy bread and stinking water. Imagine the whimpering and sobbing. Water drops down from the ceiling and flows down at the walls. The stink of excrements and rotting corpses. Then all the guards with warts on their faces, sometimes on the nose, sometimes on the cheek, sometimes on the forehead. All that needs computing power! Especially the stink and the warts, obviously.
However I'm surpri
Re: (Score:2)
It is a big dungeon, mate! A really big dungeon! You know, with torture chambers, torture mistresses and such.
No. Dungeon Keeper could do it all without the massive system requirements!
What an awesome game it was... Ironic that it was EA that published it.
Re: (Score:2)
Yeah, dungeon keeper!
That was awesome!!! Especially if you played late at night: 02:00 at night, the background voice: "your monsters demand cable TV!" 04:00 at night: "Your monsters are tired running around at your command, please go to sleep!" (Well, roughly translated from german).
The very best game intro ever is the start up cinematic of Dungeon Keeper I. A shiny hero in the shiny armor with a friend or two is entering the dungeon ... panicking monsters run deeper into the dungeon luring him after them.
Re: (Score:2)
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.
Ah yes, but it's running VMWare running FreeBSD emulating Linux running Qemu running Windows XP running AppleWin running the dungeon generator written in Applesoft Basic for a 1MHz 6502 in 1979, and that's worthy of the front page of Slashspot.
(Oh year, "Apple II forever!").
Re: (Score:1)
I wrote one last week in a single line of BASIC running on a 4MHz Z80 system. Admittedly the level size is only 80x24, and it is more random than procedural (i.e., rooms can be left isolated), but that's the nature of trying to fit that into a single line of code (monster placement and gold placement take up another line).
It takes a few seconds to complete - mainly due to it being interpreted BASIC on a 4MHz Amstrad CPC.
I figure that most "dungeon generating algorithms" are quite unrealistic anyway. If you
Re: Are you freaking serious? (Score:1)
Alternate Link (Score:5, Funny)
Alternate link [dice.com]
Amazing performance ! (Score:4, Insightful)
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.
Re: (Score:2)
Re: (Score:2)
From the screenshot it looks like the work could be done in less than a second on an 8-bit 20 MHz MCU.
So someone else invented NetHack, goodie. (Score:4, Insightful)
NetHack [wikia.com] has had procedural dungeon generation with available source for .... gosh a long time.
Re: (Score:3)
And the original Rogue is even older than that, so yeah, why is this news?
Re: (Score:3)
Nethack confirms it.
Fortune-teller mode on... (Score:2)
I foresee a sudden rush of crappily made dungeon crawlers, all sporting the Unity3D free/indy badge clogging up kongregate for months to come.
Oh Goodie (Score:2, Insightful)
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 tacti
Re: (Score:2)
As an old school DM, I make the "trap" category fit the premise. As stated by the parent I'd have "traps" be a magic mouth that calls the guards. I also might have a "puzzle" that would be solvable for XP. For example, trying to "liberate" a magic sword from a statue. Sometimes I'd bring in a real life puzzle for the players to solve, just as a change of pace.
Of course, traps do come in handy. Grimtooth's books were fun, and I'd have something there so the players can think they outsmarted the DM, espe
Re: (Score:1)
Original AC, Torchlight had amazing maps, especially the non-random ones that you accessed by killing a Phase Beast. I'd love to run some in a PnP RPG setting.
I actually think there's pretty good commercial software out there for dungeon generation. And there's definitely lots better resources for learning about procedural generation.
http://pcg.wikidot.com/pcg-alg... [wikidot.com]
http://journal.stuffwithstuff.... [stuffwithstuff.com]
http://games.soe.ucsc.edu/site... [ucsc.edu]
https://news.ycombinator.com/i... [ycombinator.com]
Random google results. Because they're still
Re: (Score:2)
The funny thing is that the random kicking of doors, breaking of clay pots, and killing anything that moved, was not the standard trope when I started. I am showing my age, but if PCs tried that in a town, the local watch would be on them in no time. If the PCs dispatched the watch, then they would be marked as bandits, and everyone and their brother would be going for them for the reward (and I'd have the "escape from the royal gaol" campaign at the ready.)
There also wasn't the element of opening a box a
Amazing indeed (Score:3)
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 [cpubenchmark.net]. High TDP of course.
Re: (Score:3)
I thought the same thing.
Computers has been very fast for a while now. Only things like transcoding and some gaming really push CPUs for the "average home user".
What? (Score:5, Informative)
Re: (Score:2)
Why do these so-called 'editors' keep posting shit articles?
Okay... (Score:2)
Call me when he re-writes Dwarf Fortress [bay12games.com], 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.
Re: (Score:3)
Re: (Score:2)
Random Map Generation (Score:1)
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
How about a procedural programming language genera (Score:1)