Slashdot Mirror


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.

5 of 83 comments (clear)

  1. Are you freaking serious? by DigitAl56K · · 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.

    1. Re: Are you freaking serious? by sconeu · · Score: 3, Insightful

      He's talking about the systemd module that *compiles C#.

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
  2. Amazing performance ! by alexhs · · Score: 3, 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.

    --
    I have discovered a truly marvelous proof of killer sig, which this margin is too narrow to contain.
  3. So someone else invented NetHack, goodie. by Anonymous Coward · · Score: 4, Insightful

    NetHack has had procedural dungeon generation with available source for .... gosh a long time.

  4. Oh Goodie by Anonymous Coward · · 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 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.