Dungeon Generation (#80)


#1

The three rules of Ruby Q.:

  1. Please do not post any solutions or spoiler discussion for this quiz
    until
    48 hours have passed from the time on this message.

  2. Support Ruby Q. by submitting ideas as often as you can:

http://www.rubyquiz.com/

  1. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem helps
everyone
on Ruby T. follow the discussion. Please reply to the original quiz
message,
if you can.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

by Kev J.

This week’s task is a dark and dangerous one. Since the late 1970’s, a
particular type of game has appealed to a particular type of person.
Games?
From the 70’s? Yep, there can only be one type of (computer) game with
that
lineage that’s still going strong (ish) after all these years - the
Rogue-like
game!

For those not in the know, a typical Rogue-like game uses ascii
characters (and
sometimes extra/non-ascii characters) to represent the (Tolkienish) game
world.
The object of each of the games is subtly different, some require you to
retrieve the Amulet of Yendor, some require you to kill the Serpent of
Chaos.
In common, they all require you to descend into a (randomly generated)
dungeon.

Here’s the task for this week. To write a dungeon creation program that
will
generate and display a typical Rogue-like dungeon

A sample of which could look something like:

depth 50ft (lvl 1) (pretty much the most trivial dungeon possible)
stairs back to surface ( < ) and stairs down to 100 ft/lvl 2 ( > )

##########
#   <   >#
##########

depth 100ft (lvl2)
stairs back up to 50ft and stairs down to 150 ft

             ###
########     #>#
#      #     # #
#####  ##    # #
   # <####### #
   #          #
   ##+#+#######

depth 150ft (lvl3) (example of an 'arena' style level, includes a
                    'vault' style room)
stairs back up to 100 ft and down to 200ft

#################################
#                               #
#                               #
#   #####         #######       #
#   #   +         # # #>#       #
#########         ## # ##       #
#       #         # # # #       #
#       #         ###+###       #
#       #                       #
# <     +                       #
#################################

Each ascii character represents terrain, an object (dungeon furniture)
or a
monster.

Each dungeon must have an < (up stairs) and one > (down stairs) and they
must be
connected in some way (ie the player must be able to move from the <
(start) to
the > (down to the next level). The simplest dungeon is simply a single
room
with both an up stairs and a down stairs.

~ = liquid (water => blue, lava => red, acid => green)
# = wall
+ = door
< = up stairs (back to the town)
> = down stairs (deeper into the dungeon)

To actually create an entire game would take far far too long (some of
these
games have been in development for years), but feel free to add as much
or as
little of the Rogue-like attributes as you feel like, for instance:

% = vegetation
[a-zA-Z0-9] = monsters (ie => o = Orc, U = Demon, d = little dragon,
                        D = Greater Hell Wyrm)
@ = player
, = slime mold (yummy)
^ = trap
* = gold (found in walls, ie ##*##)

For those that can parse C source, the source files from Zangband (my
personal
favourite Rogue-like) are freely available (you have to extract them
from a
tar.gz bundle):

http://www.zangband.org

#2

Oh, hell yes.

I hereby preemptively declare this, Best. Quiz. EVER.

…aaaand my weekend now appears to be full. :slight_smile:

-dB


#3

On May 26, 2006, at 3:07 PM, David B. wrote:

Oh, hell yes.

I hereby preemptively declare this, Best. Quiz. EVER.

I’m glad to see some interest. I thought if was a great problem too,
but got worried when no one was talking about it. :wink:

James Edward G. II


#4

On 5/26/06, James Edward G. II removed_email_address@domain.invalid wrote:

On May 26, 2006, at 3:07 PM, David B. wrote:

Oh, hell yes.

I hereby preemptively declare this, Best. Quiz. EVER.

I’m glad to see some interest. I thought if was a great problem too,
but got worried when no one was talking about it. :wink:

I’m pretty booked this weekend, but I hope I can fit this in. I love
Angband, and I love Greater Hell Wyrms.


#5

Wait wait… where’s the archives? I just joined the list and can pwn
you at
angband :slight_smile:


#6

On May 26, 2006, at 3:47 PM, Jason M. wrote:

Wait wait… where’s the archives? I just joined the list and can
pwn you at
angband :slight_smile:

Mailing list archives:

http://ruby-talk.org/ruby/ruby-talk/index.shtml

Ruby Q. archives:

http://rubyquiz.com/

James Edward G. II


#7

On 26 May 2006, at 13:28, Ruby Q. wrote:

The three rules of Ruby Q.:

  1. Please do not post any solutions or spoiler discussion for this
    quiz until
    48 hours have passed from the time on this message.

48 whole hours!??!??! How’s a man supposed to last so long, damn it?!

sigh

Come on, already. Tick-tock, tick-tock.


#8

Tip (not a spoiler):

If you, like me, were about to ask why those dungeons seem a bit

messy, and there’s no route from the start to the end in a lot of
cases, you might want to check that you’re viewing with a fixed width
font before you post :slight_smile:

whistles

(Just about got away with that, I think).


#9

This is a fantastic quiz. I find it very interesting that ASCII art
is so effective for quickly generating basic graphics. I think the
great thing about it is its supreme ubiquity. There can’t be too many
languages where you can’t print out some monospace text with a
handful of lines of code.

However, it seems a little sad that in today’s world of stupendous
graphical processing power, and lovely displays, we can’t trivially
go a little bit further. I’d really like to see a library that is:

1) Completely ubiquitous. ASCII's degree here will be hard to match,

but for a given set of platforms (say Ruby on Unix, Win, OS X, common
hand-helds) it should be possible.
2) Works out of the box. It must come as part of a standard
instal, and before that, be well packaged. It must not need lots of
extra installation of components. It’s got to be pure ease in a glass.
3) Makes the easy things easy.
4) Make hard things quite easy.

  1. Making the easy things easy.

ASCII does this wonderfully. You can’t get much easier than “puts
‘:)’”. BBC BASIC did it too with: “MOVE 100,100; DRAW 200,100”. Logo
also did it well with “fd 100”.

Right from the outset, you can start to draw things. You don’t need
to create contexts, add them to windows, create an event loop, blah
blah blah. You just begin. Brilliant.

  1. Make the Harder things quite easy.

Ok, so full on GUI packages have useful things in them. Widgets that
know how to behave and render themselves. We’ve got 3d, and
scrollable surfaces and particle systems… All sort of great stuff.
I think these things shouldn’t be so much harder though, and their
presence should not stop the easy things being easy. It’s important
to have a gentle progression from simple stuff to harder stuff.

Anyone got any thoughts in this area? :slight_smile:

Cheers,
Benjohn


#10

On 28 May 2006, at 11:30, Ross B. wrote:

to do
it again :slight_smile: It’s all well and good until you have a thousand lines (or
more) of ‘move here, draw this, select this pen, move here…’ and
find
an errant green pixel in the middle of the screen…

Hmm, this may be why I still have a strong aversion to all forms of
graphical programming (including GUI)…

:slight_smile: Ah. I love graphics programming, although I do agree that it could
get hairy back then. I think that’s before I learnt about
“abstraction” though. I’ve noticed that I’ve been doing less and less
graphics though, and I think it’s down to the barrier to entry that
currently exists. That’s what I want from this hypothetical library.
The smallest barrier to entry possible, and the smoothest learning
curve possible… I think those two properties are the reason that I
like Ruby too.


#11

On Sun, 2006-05-28 at 19:05 +0900, Benjohn B. wrote:

ASCII does this wonderfully. You can’t get much easier than “puts
‘:)’”. BBC BASIC did it too with: “MOVE 100,100; DRAW 200,100”. Logo
also did it well with “fd 100”.

Ouch. My earliest programming experiences were with basic and logo on
the Amstrad CPC, and later the Spectrum. They did this kind of thing and
I have to say, in the twenty years since then, I’ve never yearned to do
it again :slight_smile: It’s all well and good until you have a thousand lines (or
more) of ‘move here, draw this, select this pen, move here…’ and find
an errant green pixel in the middle of the screen…

Hmm, this may be why I still have a strong aversion to all forms of
graphical programming (including GUI)…


#12

This probably fits more into “coordination languages” than with “ASCII
art”, but what I’ve always wanted was a programming language that
would let me draw arbitrary shapes and connectors on a canvas, like
XFig, Dia or Visio, and then let me assign more or less arbitrary
behaviors to them. One such behavior would be animation – objects need
to move about.

There are specialized tools that sort of do this: Max/MSP and its open
source clones Jmax and PureData will let you design basic digital signal
processing systems this way, but the shapes aren’t necessarily
customizable, and the behavior of the objects is mostly limited to
things that make sense in computer music and digital signal processing.

QTDesigner, Korundum and Kommander will let you design GUIs with
“standard” things like list boxes, buttons, etc., but again, the shapes
are given. And there are plenty of graphical languages, UML-based tools,
etc. Hypercard was close, actually, except for its metaphor of a stack
of cards.

What I’d like is a single graphical language that would let me build,
for example, Petri nets, queuing networks, Mind Maps, dialog maps,
entity-relationship diagrams, clouds of tags – about any kind of
graphical tool you could think of – and have the elements all be active
objects/actors, with methods, etc. And, of course, it needs to be open
source.

I’m probably going to revisit Kommander to see if it can do what I want,
because it’s compatible with QTRuby. I also think Blender might be able
to do it, although I’m not all that interested in “physical realism” –
I don’t want cars or people, but abstract symbolic diagrams. Anybody
here have any ideas on tools I might be overlooking?

Benjohn B. wrote:

1) Completely ubiquitous. ASCII's degree here will be hard to

ASCII does this wonderfully. You can’t get much easier than "puts
know how to behave and render themselves. We’ve got 3d, and scrollable


M. Edward (Ed) Borasky

http://linuxcapacityplanning.com


#13

<very_unsubtle_attempt_to_get_people_on_the_quiz>
So no one else knows how to go about building up a random dungeon, huh?
I Guess I’ll have to put that on my resume: “only memeber of the Ruby
community able to automatically build random mazes”. I didn’t know I was
that good. In fact, as we’ve got appraisals here at work, I think
it’ll be good material to try out for a pay rise.
</very_unsubtle_attempt_to_get_people_on_the_quiz>

:slight_smile:

Regards,
Benjohn


#14

M. Edward (Ed) Borasky wrote:

What I’d like is a single graphical language that would let me build,
for example, Petri nets, queuing networks, Mind Maps, dialog maps,
entity-relationship diagrams, clouds of tags – about any kind of
graphical tool you could think of – and have the elements all be active
objects/actors, with methods, etc. And, of course, it needs to be open
source.

IIRC TkCanvas lets you put general Tk widgets on a canvas, connect them
with stretchy lines and arrows, move them about, scroll them, etc.


#15

On 31 May 2006, at 13:42, Gregory S. wrote:

} </very_unsubtle_attempt_to_get_people_on_the_quiz>
two of the sinks are clogged, the dishes need doing, and we’re on a
production push at work. The Ruby Q. is lower priority than any
of those,
I’m afraid, so…

:slight_smile: Yeah yeah, a fine excuse.

At least you have one. - feeling like a school master here.

Ah well, shame, it’s a really cool quiz too.

Cheers,
Benjohn


#16

On Wed, May 31, 2006 at 05:05:58PM +0900, removed_email_address@domain.invalid wrote:
} <very_unsubtle_attempt_to_get_people_on_the_quiz>
} So no one else knows how to go about building up a random dungeon,
huh?
} I Guess I’ll have to put that on my resume: “only memeber of the Ruby
} community able to automatically build random mazes”. I didn’t know I
was
} that good. In fact, as we’ve got appraisals here at work, I think
} it’ll be good material to try out for a pay rise.
} </very_unsubtle_attempt_to_get_people_on_the_quiz>
}
} :slight_smile:

Heh. Well, the thing about the Ruby Q. is that unless your day job is
not
terribly demanding or your weekend is not thoroughly allocated, there
just
isn’t time. I’d love to dedicate a few hours to generating random
dungeons,
but I was away for the weekend, the house is a mess, the AC is broken,
two of the sinks are clogged, the dishes need doing, and we’re on a
production push at work. The Ruby Q. is lower priority than any of
those,
I’m afraid, so…

} Regards,
} Benjohn
–Greg


#17

This quiz in particular is a painful one because it’s so darned cool,
but
takes a little more brainpower than I can possibly apply right now :frowning:


#18

On Thu, 1 Jun 2006 04:43:42 +0900, Benjohn B. removed_email_address@domain.invalid
wrote:

The Ruby Q. is lower priority than any of those, I’m afraid, so…

I’m in pretty much the same boat, really. I might have something by the
weekend, but I don’t feel very motivated if I’m just going to miss the
summary.

-mental


#19

Agreed with all of the above…
I may try it this coming weekend, even if the quiz has moved onto
greener pastures.


#20

On May 31, 2006, at 4:51 PM, Elliot T. wrote:

Hi all,

I did the quiz :slight_smile: I am new to Ruby so any tips are appreciated.

Let me be one of the first to welcome you then. Your code looks
nice. Definitely ahead of my early attempts. :wink:

Don’t take it personal, but I had the summary completed before this
made it in. It’s just a function of my schedule, no favoritism. I
really wish I could have talked about both solutions. :frowning:

James Edward G. II