The Reliques of Tolti-Aph — 34 of 57

Graham Nelson

Release 3

Section E(e) - Labyrinth rooms

A labyrinth room is a kind of room. A labyrinth room has a labyrinth shape called shape. A labyrinth room has a text called map legend. A labyrinth room usually has map legend "-+-". A labyrinth room has a number called minimum level. A labyrinth room usually has minimum level 1. A labyrinth room can be grovelike or ungrovelike. A labyrinth room is usually ungrovelike.

Definition: A labyrinth room is unplaced if its grid position is <0,0,0>.

Definition: A labyrinth room is unshaped if its shape is L0/0-0-0-0-0-0.

Definition: A labyrinth room is ascending rather than non-ascending if the U part of its shape is 1 and the maze level part of its grid position is not 1.

Definition: A labyrinth room is descending rather than non-descending if the D part of its shape is 1 and the maze level part of its grid position is not 9.

[1]

After printing the name of an ascending labyrinth room, say " with Staircase Up".

After printing the name of an descending labyrinth room, say " with Staircase Down".

[At the start of play, the game contains a large stock of labyrinth rooms which are not committed to any shape or position, but are waiting to be joined to the maze. The previous section's table is used to assign shapes to the rooms, but respecting their relative frequencies.]

To calculate how many labyrinth rooms should have each shape:

let total space be the number of unshaped labyrinth rooms;

let total allocated be 0;

let total frequency be 0%;

if the total space is 0, stop;

repeat through the Table of Shape Frequencies:

now the shape count entry is 0;

repeat through the Table of Shape Frequencies:

let N be the parts per hundred part of the frequency entry;

let N be N multiplied by the total space;

now the shape count entry is N divided by 100;

now the total allocated is the total allocated plus the shape count entry;

let total frequency be total frequency plus the frequency entry;

unless the total frequency is 100%,

say "Oops: the frequency table totals up to [total frequency].";

[Nevertheless, if the cave extent is not a multiple of 50 we have probably under-allocated due to rounding errors. We make random draws to put this right.]

while the total allocated is less than the total space:

let total frequency be 0%;

let R be a random number from 1 to 100;

let the weighted percentage be the percentage with parts per hundred part R;

repeat through the Table of Shape Frequencies:

let total frequency be total frequency plus the frequency entry;

if the weighted percentage > 0% and the weighted percentage <= the total frequency:

now the shape count entry is the shape count entry plus 1;

now the total allocated is the total allocated plus 1;

now the weighted percentage is 0%.

To give shape to the shapeless labyrinth rooms:

[Now we change the count entries so that a count entry of X means that the Xth room is the first to have the characteristics of the present row. In particular, there is guaranteed to be a row with a count entry of 1.]

let total allocated be 0;

repeat through the Table of Shape Frequencies:

unless the shape count entry is 0:

let new value be the total allocated plus 1;

let total allocated be total allocated plus shape count entry;

now the shape count entry is the new value;

[Now we go through the rooms, using the current row to set each one, and moving to the appropriate row whenever one of the start counts is hit. Since there is guaranteed to be a count entry of 1 somewhere, the changes can only be reached when a row has been chosen.]

let total allocated be 0;

repeat with blank room running through unshaped labyrinth rooms:

let total allocated be total allocated plus 1;

if there is a shape count of total allocated in the Table of Shape Frequencies, choose row with a shape count of total allocated in the Table of Shape Frequencies;

now the shape of the blank room is the shape entry;

now the map legend of the blank room is the legend entry;

now the printed name of the blank room is the shape name entry.

Before casting make sanctuary at: if the location is a labyrinth room or the location is the Budless Grove, say "You hear the laughter of the never-children in your mind, and know that you might as well save your strength." instead.

Before listing nondescript items when the location is a labyrinth room:

now all hazards are unmarked for listing;

if a hostile monster is marked for listing, say "The [if the current maze level is 1]lawn[otherwise]cave[end if] is guarded by [a list of hostile monsters which are marked for listing].";

now all hostile monsters are unmarked for listing.

Note

[1]. The point here is that if a cave with an up staircase is found on the top level, the staircase must be ignored: similarly a down staircase on the bottom level.