Mud Walker

Problem #440

Tags: unlabeled

Who solved this?

No translations... yet

Once upon a time when computers were big and their resources were meek, first computer games included various text quests (like "Colossal Cave"), where player investigates an imaginary world, described by computer by and by. Other name for such kind of games is "interfactive fiction" - due to the game process likened to reading a book but with "non-linear" story. They evolved into multi-user versions, popularly called MUDs (multi-user dungeons, though they are not necessarily set in the dungeon of any kind).

One of the first of them is called British Legends and originates from the University of Essex. Thanks to computer enthusiast Viktor Toth, it is revived and could be still played online (here). Those who are familiar with more modern MUDs may notice the game is somewhat halfway between them and single-player quests.

But we want to talk about it for the special reason: the sources of the game are available in the opensource and the game is built in such a way that most of the world (and game behavior) is described via dedicated text file, rather than hard-coded - the file then being executed by game "engine" program. It was a great improvement in building such games. By the way our colleague Graeme Yeandle authored one of the early system combining "engine" and "game editor", The Quill for ZX Spectrum computer.

Programming of such games is an interesting practical task so our exercise will be to create small game engine, compatible with MUD1 game files. The goal is to initialize the world (rooms and objects) and make a number of moves, reporting for the answer the final "room" description and objects found on the way.

Problem Statement

Please have a look at this github repository: PDP-10/MUD1 - you can download these files by clicking green button code and choosing "Download ZIP" (then unpacking at your machine) - also you can clone them with git of course.

Here you'll find main game file MUD.TXT and some includes for it, generally with names like TXT***.GET. For them the main file has references starting with symbol @ at the lines where they are to be included.

The file itself consists of sections, e.g. *rooms, *objects, *travel. Please refer to the PDF file found among the others to understand the format of these sections. Here we touch it only quickly:

Roof format

roomid <attributes>
        short description in first line
        longer description...
        which may span several lines

Here we are mainly interested in making a list of room identifiers (as they are used in other sections) and also we want the short description of the last point of our path to be added to the answer.

Object format

objid [optional numbers for "live" objects] roomlist <more numbers> [flags]
0 state-0 description for this object
1 state-1 description fot this object
...etc

Here we mainly want object ids and places where they are put on the start (roomlist) - it is either a list of one or more room-ids (in which case object simply is added to every of those rooms) - or has form with "angular brackets", e.g. <bdrm02 bstand wabe> - in this second case let's utilize our Linear Congruential Generator according to description below, to decide into which one room the object is added. Typical example of the object present in many rooms is rain. Example of the object which randomly alters its initial position is axe.

Of course, objects should be processed in the order in which they are met in the file, so that "random" positions are not messed up.

Travel section

roomid cond dest dirlist
       cond2 dest2 dirlist2
       ...etc

This means that given room (roomid) could be left for another, named by dest if we walk in one of the directions in corresponding dirlist. However some lines have condition cond (e.g. player has some object in pocket or door is open etc) - and let us use for now only those which do not have a special condition (marked with n letter).

There are a couple of issues - in the swamp there is special format of dirlist enclosed in square brackets - let's not treat them in special way, e.g. just regard them as whimsical direction tags, like [ne; also there are rooms which do not have unconditional exits - but we'll try never put you in such places.

Randomizer

Let's use our usual parameters for LCG, A=445, C=700001 and M=2097169. When encountered, for example, a list of 3 rooms, generate next random value and take it by modulo 3 to select the 0-based index.

Input data: First line provides x0 - initial seed for randomizer. Next line contains roomid where we start our path. The third line contains several directions, describing your path.

Answer should give for each next room the number of objects found there and also, for the last room, its short description. All these elements should be space-ceparated.

Example:

82939
ostart
swamp swamp o s n sw nw sw

2 1 1 1 1 2 1 3 Flower garden.

Here swamp is the universally-recognized direction "to the swamp", but what is o - I honestly don't know.

P.S. One of the bewildering features of such games is that directions are not necessarily straight - if you went north, then way back could be not necessarily south, but south-west or even just west, or up (not speaking of situations when there is no way back at all. And the map of course is not pretty rectangular.

P.P.S. There could be some minor subtleties (or flaws) - e.g. roomid should be truncated to 6 symbols even if it is longer - but I don't think I spotted all of those, so please feel free either to figure them out when necessary - or simply re-generate input data.

P.P.P.S. If by chance you'll decide to try playing the game, try solving puzzles in Mausoleum. To get there you'll need some light source (investigate house a bit and search close at the forest - you'll be able to devise something). I found 4 of 6 keys (excluding Milne and Birthday).

You need to login to get test data and submit solution.