The three rules of Ruby Quiz:
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 Quiz by submitting ideas as often as you can:
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion. Please reply to the original quiz message,
if you can.
···
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
by Kev Jackson
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):