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.

11 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 l0ungeb0y · · 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

    2. Re:Are you freaking serious? by PPH · · Score: 4, Funny

      C#/.NET makes great dungeons. Resources go in but can't get out.

      --
      Have gnu, will travel.
    3. Re:Are you freaking serious? by Anonymous Coward · · Score: 5, Interesting

      I have been running C# ASP.NET on Raspbian Apache/ModMono for a solid 3 years. No problems.

    4. Re: Are you freaking serious? by DigitAl56K · · Score: 4, 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#?

    5. 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.
    6. Re:Are you freaking serious? by colenski · · Score: 4, Informative

      I don't get this submission. I wrote the same thing in 1982 on a TI-99/4A with 16kb RAM and a 3MHz 16 bit chip. It loaded from a cassette deck using an analog stream from the tape. It displayed on my TV. It was written in BASIC. It sucked.

      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.

  2. Alternate Link by Anonymous Coward · · Score: 5, Funny
  3. 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.
  4. 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.

  5. What? by gabereiser · · Score: 4, Informative

    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.