Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Jumping on the bandwagon with some dungeon building adventures of my own

9 views
Skip to first unread message

Gamer_2k4

unread,
Feb 5, 2007, 9:55:52 PM2/5/07
to
So I was puzzling over how to do some decent dungeon generation. How
can I make my random dungeons look as clean as those in ADOM or
Angband? Then I told myself, "Gamer, THINK. Your dungeons are formed
as a result of massive amounts of energy carving up the earth. Why on
earth (or under earth, as the case may be) would there be neat little
rooms and hallways? So I abandoned that idea in favor of something a
little rougher.

How does an explosion look? It's basically a bunch of rays coming from
a focal point (converted to 2D ASCII, anyway). So that's how I
designed my dungeon generator. <size> random points are selected, and
<density> rays are cast up to <openness> tiles long. Obviously this
looks incredibly rough, and the floor tiles probably aren't connected
very well. Time for some smoothing.

To smooth the dungeon and increase connectivity, I use what I think is
a cellular growth thing (maybe). If a tile is surrounded by 5 or more
floor tiles, it becomes a floor; otherwise it's a wall. Easy enough.
This takes away the explosion effect, but it still makes a fairly
rough level. Now it's time to place objects.

The down staircase will go on one of the focal points mentioned
earlier. Since not all of the floor tiles will be connected to each
other, we need to do a flood fill, starting from the stairs, to find
out which tiles are connected. If the area is large enough, we'll
place an up staircase randomly on one of the connected tiles. When
we're filling the area, we'll take note of every floor tile that is
adjacent to only one other floor tile. These will be the monster
spawn points. Any unconnected but fairly large areas will be
populated with some items and harder monsters (like a vault). Other
than that, there will be very few items on the ground. That's not
realistic. Most of the items the players will get will be from slain
monsters. This also helps balance the obtaining of artifacts.

I'll post some screenshots later of dungeons with different size,
density, and openness values.

Gamer_2k4

Krice

unread,
Feb 6, 2007, 2:39:06 AM2/6/07
to
On 6 helmi, 04:55, "Gamer_2k4" <gamer...@gmail.com> wrote:
> earlier. Since not all of the floor tiles will be connected to each
> other, we need to do a flood fill, starting from the stairs, to find
> out which tiles are connected.

For irregular shaped rooms I'm using a brute force routine which
carves some random blocks out of rectangular area, first
checking if the block is connected to some other floor. I just wanted
you to know that I didn't need over complex "explosion" (?) routine
or a flood fill:)

Gamer_2k4

unread,
Feb 6, 2007, 3:14:21 AM2/6/07
to

I don't want the rooms to be irregular; I want the dungeon to be
irregular. The entire routine is simple; basic generation (walls and
floor) takes less than 100 lines of code (other than libraries,
obviously). The flood fill (maybe the wrong terminology) has nothing
to do with creating the dungeon; it's for determining what tiles are
connected to each other.

Gamer_2k4

Krice

unread,
Feb 6, 2007, 7:30:12 AM2/6/07
to
On 6 helmi, 10:14, "Gamer_2k4" <gamer...@gmail.com> wrote:
> I don't want the rooms to be irregular; I want the dungeon to be
> irregular.

What was the exploding routine then?

> The entire routine is simple; basic generation (walls and
> floor) takes less than 100 lines of code

I think my irregular routine takes about 10 lines of code:)

tongHoAnh

unread,
Feb 6, 2007, 8:42:20 AM2/6/07
to
How about curved corridor (think electric cable)? :D

Gamer_2k4

unread,
Feb 6, 2007, 11:21:30 AM2/6/07
to
On Feb 6, 6:30 am, "Krice" <pau...@mbnet.fi> wrote:
> On 6 helmi, 10:14, "Gamer_2k4" <gamer...@gmail.com> wrote:
>
> > I don't want the rooms to be irregular; I want the dungeon to be
> > irregular.
>
> What was the exploding routine then?

That actually creates the dungeon. Not rooms, not modifications, but
the dungeon itself.

> > The entire routine is simple; basic generation (walls and
> > floor) takes less than 100 lines of code
>
> I think my irregular routine takes about 10 lines of code:)

Of making a dungeon, or modifying a premade one?

Anyway, I promised screenshots, and here they are:

[Size = 10 Openness = 30 Density = 25]
http://www.geocities.com/reptoran/images/dgen/10-30-25/01.PNG
http://www.geocities.com/reptoran/images/dgen/10-30-25/02.PNG
http://www.geocities.com/reptoran/images/dgen/10-30-25/03.PNG
http://www.geocities.com/reptoran/images/dgen/10-30-25/04.PNG
http://www.geocities.com/reptoran/images/dgen/10-30-25/05.PNG

[Size = 15 Openness = 20 Density = 25]
http://www.geocities.com/reptoran/images/dgen/15-20-25/01.PNG
http://www.geocities.com/reptoran/images/dgen/15-20-25/02.PNG
http://www.geocities.com/reptoran/images/dgen/15-20-25/03.PNG
http://www.geocities.com/reptoran/images/dgen/15-20-25/04.PNG
http://www.geocities.com/reptoran/images/dgen/15-20-25/05.PNG

[Size = 15 Openness = 25 Density = 25]
http://www.geocities.com/reptoran/images/dgen/15-25-25/01.PNG
http://www.geocities.com/reptoran/images/dgen/15-25-25/02.PNG
http://www.geocities.com/reptoran/images/dgen/15-25-25/03.PNG
http://www.geocities.com/reptoran/images/dgen/15-25-25/04.PNG
http://www.geocities.com/reptoran/images/dgen/15-25-25/05.PNG

Tarindel

unread,
Feb 6, 2007, 11:57:02 AM2/6/07
to
That is very cool, Gamer_2k4. I really like the way that turned out.

When you say:


"<size> random points are selected, and <density> rays are cast up to
<openness> tiles long."

So you're selecting a random point and then casting rays from it --
how many rays are you casting from each point? And how do you pick
which direction they go?

Alex
http://groups.google.com/group/subterrane

Gamer_2k4

unread,
Feb 6, 2007, 12:25:24 PM2/6/07
to

You cast a number of rays equal to the density. That's what I meant.
And direction is random too. I think I did

line(x, y, Randint((x - O), (x + O)), Randint((y - O), (y +
O))); //O is openness

If if the value of Openness is 5, the line might be (0, 0, -5, -5),
(0, 0, 5, 5), or anything in between. Then you just dig several
lines.

The source is here: http://www.geocities.com/reptoran/files/Dgen.zip

It includes the main program, a header file to generate random
numbers, and a header file I wrote that has several useful methods (it
supplies the line class for this program).

Gamer_2k4

Ido Yehieli

unread,
Feb 6, 2007, 12:35:10 PM2/6/07
to
On Feb 6, 6:25 pm, "Gamer_2k4" <gamer...@gmail.com> wrote:
> It includes the main program, a header file to generate random
> numbers, and a header file I wrote that has several useful methods (it
> supplies the line class for this program).

That looks like some pretty neat caves!

Say, why did you write all this code in the header file? AFAIK the
header is normally only used for declarations and function prototypes.

Ido.

Gamer_2k4

unread,
Feb 6, 2007, 12:37:50 PM2/6/07
to

It's just one of those things for me...I always use header files for
each part of my program (dungeon.h, items.h, etc.), because it feels
weird having more than one *.cpp file. Personal preference, I guess.

Gamer_2k4

Ido Yehieli

unread,
Feb 6, 2007, 12:49:17 PM2/6/07
to
On Feb 6, 6:37 pm, "Gamer_2k4" <gamer...@gmail.com> wrote:
> It's just one of those things for me...I always use header files for
> each part of my program (dungeon.h, items.h, etc.), because it feels
> weird having more than one *.cpp file. Personal preference, I guess.

OK, just keep in mind that the more you conform to standard practices
the more likely it is that people would use your code.

Ido.

Gamer_2k4

unread,
Feb 6, 2007, 2:00:18 PM2/6/07
to

Kornel Kisielewicz

unread,
Feb 6, 2007, 3:21:14 PM2/6/07
to
In a state of madness Gamer_2k4 wrote the following :

It's not just preference, it's not understanding the C/Cpp build
mechanism. If you have just one cpp file, then that means you have to
recompile the WHOLE program, no matter how small change you make no
matter where. Plain stupid if you ask me... Or maybe I don't know C/Cpp ;].
--
At your service,
Kornel Kisielewicz (adminATchaosforge.org) [http://chaosforge.org]
"Gott weiss, Ich will kein Engel sein..." -- Rammstein /Engel/

Corremn

unread,
Feb 6, 2007, 6:10:48 PM2/6/07
to
On Feb 7, 6:21 am, Kornel Kisielewicz <admin@nospam_chaosforge.org>
wrote:
> "Gott weiss, Ich will kein Engel sein..." -- Rammstein /Engel/- Hide quoted text -
>
> - Show quoted text -
If you have one cpp file you would have to compile everything every
time, this would only be good for small programmes. If you had a
massive program this would drive people crazy. The only benefit I can
see is less files, I generally only use inline functions in my header
files for a very slight speed increase in short funtions.


Gero Kunter

unread,
Feb 7, 2007, 5:20:57 PM2/7/07
to
Kornel Kisielewicz wrote:
[...]

> If you have just one cpp file, then that means you have to
> recompile the WHOLE program, no matter how small change you make no
> matter where.

I don't think that Gamer_2k4 meant it the way that he uses one massive file
for everything, but that he doesn't follow the C/CPP practice to have code
and declaration in separate files. Imagine having the interface of a Pascal
unit in one file (items.h), and the implementation in another (items.cpp).
That would be standard practice.

> Plain stupid if you ask me... Or maybe I don't know C/Cpp ;].

I never liked the header files myself, either. The whole build process of
C/CPP programs is just somewhat too awkward for my tastes. I do appreciate
the beauty of units or (Python) modules, though. :)

Cheers, Gero

--
Gero Kunter (kunter...@strandwall.de)

Martin Read

unread,
Feb 7, 2007, 9:21:26 PM2/7/07
to
kunter...@strandwall.de wrote:
>I never liked the header files myself, either. The whole build process of
>C/CPP programs is just somewhat too awkward for my tastes. I do appreciate
>the beauty of units or (Python) modules, though. :)

What's awkward about the *build* process? Compile all modules, link.
Done. make does the hard work of deciding what needs to be rebuilt; I
just need to specify the dependencies. Heck, I could even have make
do the hard work of deciding what the dependencies are.
--
Martin Read - my opinions are my own. share them if you wish.
\_\/_/ http://www.chiark.greenend.org.uk/~mpread/dungeonbash/
\ / impending, adj. - Fatal to small demons.
\/

Gamer_2k4

unread,
Feb 7, 2007, 9:30:56 PM2/7/07
to
On Feb 5, 8:55 pm, "Gamer_2k4" <gamer...@gmail.com> wrote:
> I'll post some screenshots later of dungeons with different size,
> density, and openness values.

For all intents and purposes, the dungeon generator is done. Here's
the executable and source: http://reptoran.rogueforge.net/dgen/
program.zip
The only thing you need to modify if you want a different look is the
dgen function call in main. Syntax: dgen(size, openness, density)

Screenshots:
http://reptoran.rogueforge.net/dgen/finished/01.PNG
http://reptoran.rogueforge.net/dgen/finished/02.PNG
http://reptoran.rogueforge.net/dgen/finished/03.PNG
http://reptoran.rogueforge.net/dgen/finished/04.PNG
http://reptoran.rogueforge.net/dgen/finished/05.PNG

Gamer_2k4

Gamer_2k4

unread,
Feb 8, 2007, 1:39:33 AM2/8/07
to
Trying this again...

Gero Kunter

unread,
Feb 8, 2007, 8:01:10 PM2/8/07
to
Martin Read wrote:
> What's awkward about the [C/C++] *build* process? Compile all modules,
> link. Done. make does the hard work of deciding what needs to be rebuilt;
> I just need to specify the dependencies. Heck, I could even have make
> do the hard work of deciding what the dependencies are.

I'm definitely *not* going to try to defend my (ill-formulated) expression
of personal dislike for the way how things are done in some programming
languages... :)

You are right about make, of course. It is, without doubt, a quite powerful
tool, and it's ability to keep track of changes to all sorts of resources
can't be overestimated. I don't use it often myself, though, but that's
probably because of the type of resources I'm dealing with.

Narf the Mouse

unread,
Feb 10, 2007, 2:15:54 AM2/10/07
to
On Feb 7, 10:39 pm, "Gamer_2k4" <gamer...@gmail.com> wrote:
> Trying this again...
>
> Here's the executable and source:http://reptoran.rogueforge.net/dgen/program.zip

Looks usefull. I think I'm going to ste...Borrow it for mine.

Gamer_2k4

unread,
Feb 11, 2007, 2:13:17 AM2/11/07
to

Sounds good. Just be sure to credit me if it makes it to your final
game.

What roguelike are you working on, anyway? I checked Roguebasin but
couldn't find you or your work anywhere.

Gamer_2k4

0 new messages