# The Reliques of Tolti-Aph— 47 of 57

## Graham Nelson

Release 1

Section E(r) - The encounters pack

[Here we populate the maze. When the player enters a new-found room which has open space, "cards" are drawn from the "encounters pack" to see what will be found there. The cards are actually the things (monsters, etc.) themselves and the pack is a container - though, like the Solid Rock and Terra Incognita rooms, it exists in a somewhat metaphysical way and is not actually to be found in the player's world.

We arrange these "cards" in a pack because dead monsters, used artefacts and played hazard cards need to be returned to the bottom of the pack. It would not do to simply draw randomly from the pool of out-of-world cards: then there would be a chance of immediately redrawing the Charmed Flute, say, only a turn after giving it up.

Although not much Inform code uses or notices this, the contents of a room or container are in fact organised as a list, and we sneakily use this as the ordering of the pack. Note that "return X to the pack", defined below, puts X at the bottom by removing all of the cards, putting X in, then putting all the cards back again - which sounds slow, but it's a trifling exercise for the computer, and in any case happens relatively seldom in play.]

The encounters pack is a container.

Definition: a thing is out-of-the-pack if it is in Terra Incognita.

When play begins:

let the pack size be the number of out-of-the-pack things;

let the total shuffled be 0;

while the total shuffled is less than the pack size

begin;

let the next card be a random out-of-the-pack thing;

move the next card to the encounters pack;

let the total shuffled be the total shuffled plus 1;

end while.

To return (this card - a thing) to the pack:

move this card to Terra Incognita;

now all things in the encounters pack are in Terra Incognita;

now all things in Terra Incognita are in the encounters pack.

The previous location is a room that varies. Before going, change the previous location to the location.

After going to an unvisited labyrinth room (called the locale): draw cards for the locale; continue the action.

To draw cards for (locale - a room):

if the open space part of the shape of the locale is 0, stop;

let the draw count be the open space part of the shape of the locale plus the maze level part of the grid position of the locale;

let the preferred artefact be the Enchanted Map;

if the current maze task is the mauve leaf, let the preferred artefact be the Charmed Flute;

if the current maze level is 1 and the preferred artefact is in the encounters pack:[1]

move the preferred artefact to the locale;

stop;

if the current maze task is the pea-green leaf and the Eye of God is in the encounters pack and the number of unvisited labyrinth rooms is less than 10:[2]

move the Eye of God to the locale;

decrease the draw count by 1;

while the draw count is greater than 1 and something (called the top card) is in the encounters pack:

move the top card to the locale;

if the current maze level is 1:[3]

if the top card is a hazard, return the top card to the pack;

if the top card is a monster and the defensive charm of the top card is exorcise undead, return the top card to the pack;

if the locale is the Dome of the White Bones and the top card is a hazard, return the top card to the pack;[4]

if the top card is an artefact and the current maze level is less than the minimum level of the top card, return the top card to the pack;[5]

if the top card is a monster, now the top card is surprised;

decrease the draw count by 1.

Notes

[1]. We rig the draw to make sure that the first thing the player encounters is a useful artefact: ordinarily the Map, but in the "rescue Eurydice" quest it's the Charmed Flute instead, since we picture the player as Orpheus.

[2]. In the quest to bring back the Eye of God, it would be a bit unfair for the Eye to remain at the bottom of the pack for the whole game: so once four-fifths of the maze is played out, the Eye of God is rigged to come up next.

[3]. The garden maze does not suffer from trap-doors, earthquakes or the baleful presence of the undead.

[4]. The Dome is a huge cave and likely to result in many cards being drawn, which means there is a good chance of a Trap or an Earthquake: when these did indeed happen in play-testing, the effect was unsatisfactory in the first case, unfair in the second. So the Dome has been made hazard-free.

[5]. For instance, you won't find the Ring by wandering around the hedge maze.