Zork — 13 of 13

Infocom -- Ported by Dean Menezes

Release 4

Part 12 - The End Game

To decide what indexed text is the encryption of (x - an indexed text):

let keyw be {5, 3, 15, 22, 24, 18, 13, 19};

let outw be an indexed text;

let uinws be 0;

let usum be 0;

let inw be a list of numbers;

let i be 1;

let j be 1;

now outw is "[8 spaces]";

let len be the number of characters in x;

let a be character number 1 in x; [ to appease scoping rules ]

while i is at most 8 begin;

if j is greater than len, now j is 1;

let a be character number j in x;

if a matches the regular expression "<^A-Z>", now j is 1;

let a be character number j in x;

let b be the alphabet position of a;

add b to inw;

increase uinws by b;

increase i by 1;

increase j by 1;

end while;

now usum is (the remainder after dividing uinws by 8) + 56;

now i is 1;

while i is at most 8 begin;

let c be entry i of inw;

let b be entry i of keyw;

now j is the twiddle of c and b and usum;

now j is the remainder after dividing j by 32;

if j is greater than 26, now j is the remainder after dividing j by 26;

now a is character number j in the alphabet;

replace character number i in outw with a;

now usum is the remainder after dividing (usum + 1) by 32;

increase i by 1;

end while;

decide on outw.

To decide what number is the twiddle of (a - a number) and (b - a number) and (c - a number):

(- xor(xor({a},{b}),{c}) -).

To decide which number is the alphabet position of (n - an indexed text):

if n is "A", decide on 1;

if n is "B", decide on 2;

if n is "C", decide on 3;

if n is "D", decide on 4;

if n is "E", decide on 5;

if n is "F", decide on 6;

if n is "G", decide on 7;

if n is "H", decide on 8;

if n is "I", decide on 9;

if n is "J", decide on 10;

if n is "K", decide on 11;

if n is "L", decide on 12;

if n is "M", decide on 13;

if n is "N", decide on 14;

if n is "O", decide on 15;

if n is "P", decide on 16;

if n is "Q", decide on 17;

if n is "R", decide on 18;

if n is "S", decide on 19;

if n is "T", decide on 20;

if n is "U", decide on 21;

if n is "V", decide on 22;

if n is "W", decide on 23;

if n is "X", decide on 24;

if n is "Y", decide on 25;

if n is "Z", decide on 26.

The alphabet is an indexed text variable. The alphabet is [always] "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

Check exiting when the player is in a river:

say "You realize, just in time, that disembarking here would probably be fatal." instead.

Incanting is an action applying to one topic. Understand "incant [text]" as incanting.

Check incanting:

if endgame flag is true, say "[one of]Sorry, only one incantation to a customer.[or]Incantations are useless once you have gotten this far[at random]" instead.

Carry out incanting:

let i be the number of words in the topic understood;

let a be word number one in the topic understood;

now a is "[a in upper case]";

let b be word number two in the topic understood;

now b is "[b in upper case]";

if i is 1 begin;

if the player is not in Crypt of the Implementors, say "That spell has no obvious effect." instead;

if not in darkness, say "That spell has no obvious effect." instead;

if the player is carrying something lit, say "That spell has no obvious effect." instead;

let b be character number 1 in a;

if b matches the regular expression "<^A-Z>", say "Sorry, your secret word must begin with a letter." instead;

say "A hollow voice replies '[encryption of a]'";

now the score is 621;

now endgame flag is true;

move the battery-powered brass lantern to the player;

move the sword to the player;

move the player to Top of Stairs;

else if i is 2;

let c be character number one in a;

let d be character number one in b;

if c matches the regular expression "<^A-Z>", say "That spell has no obvious effect." instead;

if d matches the regular expression "<^A-Z>", say "That spell has no obvious effect.";

let ee be the encryption of a;

let f be the encryption of b;

if ee is b, skip to the endgame instead;

if f is a, skip to the endgame instead;

say "That spell has no obvious effect.";

else;

say "That spell has no obvious effect.";

end if.

To skip to the endgame:

say "As the last syllable of your spell fades into silence, darkness

envelops you, and the earth shakes briefly. Then all is quiet.";

now the score is 621;

now endgame flag is true;

now the sword is touched;

now the battery-powered brass lantern is touched;

move the battery-powered brass lantern to the player;

move the sword to the player;

move the player to Top of Stairs.

Endgame flag is a truth state that varies. Endgame flag is false.

Top of Stairs is a room. The description of Top of Stairs is "You are standing at the top of a flight of stairs that lead down to a passage below. Dim light, as from torches, can be seen in the passage. Behind you the stairs lead into untouched rock."

The rval of Top of Stairs is 10.

Check going south from Top of Stairs: say "The wall is solid rock." instead.

North of Top of Stairs is Stone Room. Down from Top of Stairs is Stone Room.

The description of Stone Room is "You are standing near one end of a long, dimly lit hall. At the south stone stairs ascend. To the north the corridor is illuminated

by torches set high in the walls, out of reach. On one wall is a red

button." A thing called a redbutton is in Stone Room. Understand "red" and "button" and "switch" as the redbutton. The redbutton is scenery. The printed name of the redbutton is "red button".

The redbutton has a truth state called depressed. The depressed of the redbutton is false.

Beam stopped is a truth state that varies. Beam stopped is false.

Mrint is a number that varies. Mrint is -1.

Check pushing the redbutton:

if the depressed of the redbutton is true begin;

say "The button is already depressed." instead;

else;

say "The button becomes depressed.";

if beam stopped is false begin;

say "The button pops back out." instead;

else;

now mirror open is true;

now mrint is 7 instead;

end if;

end if.

North of Stone Room is a room called Small Room 2. The description of Small Room 2 is "You are in a small room, with narrow passages exiting to the north

and south. A narrow red beam of light crosses the room at the north

end, inches above the floor.[if beam stopped is true]The beam is stopped halfway across the room by a sword lying on the floor.[end if]".

The printed name of Small Room 2 is "Small Room".

A red beam of light is in Small Room 2. The red beam of light is scenery.

Check destroying the beam of light with something:

try dropping the second noun instead.

After dropping the sword when beam stopped is false and the player can see the beam of light:

say "The beam is now blocked by a sword lying on the floor.";

now beam stopped is true.

After taking the sword when beam stopped is true and the player can see the beam of light:

now beam stopped is false.

Check taking the beam of light:

say "No doubt you have a bottle of moonbeams as well." instead.

Check saving the game when endgame flag is true: say "Saves are not permitted during the end game." instead.

North of Small Room 2 is a room called Hallway. The description of Hallway is "This is part of the long hallway. The east and west walls are dressed stone. In the center of the hall is a shallow stone channel. In the center of the room the channel widens into a large hole around which is engraved a compass rose. A passage enters from the south. A large mirror fills the north side of the hallway.[if mirror open is true] The mirror is mounted on a panel which has been opened outward.[end if]".

The miror is a thing in Hallway. The miror is scenery. Understand "mirror" and "panel" as the miror. Instead of entering the miror: try going inside instead.

Check going inside when the player is in Hallway and mirror open is true and Room Number is 1:

move the player to InsideMirror instead.

Mirror open is a truth state that varies. Mirror open is false.

Room Number is a number that varies. Room Number is 1. Mirror direction is a direction that varies. Mirror direction is usually west. Pole up is a truth state that varies. Pole up is usually false.

InsideMirror is a room with printed name "Inside Mirror". The description of InsideMirror is

"[5 spaces]You are inside a rectangular box of wood whose structure is rather

complicated. Four sides and the roof are filled in, and the floor is

open.[paragraph break]

[5 spaces]As you face the side opposite the entrance, two short sides of

carved and polished wood are to your left and right. The left panel

is mahogany, the right pine. The wall you face is red on its left

half and black on its right. On the entrance side, the wall is white

opposite the red part of the wall it faces, and yellow opposite the

black section. The painted walls are at least twice the length of

the unpainted ones. The ceiling is painted blue.[paragraph break]

[5 spaces]In the floor is a stone channel about six inches wide and a foot

deep. The channel is oriented in a north-south direction. In the

exact center of the room the channel widens into a circular

depression perhaps two feet wide. Incised in the stone around this

area is a compass rose.[paragraph break]

[5 spaces]Running from one short wall to the other at about waist height

is a wooden bar, carefully carved and drilled. This bar is pierced

in two places. The first hole is in the center of the bar (and thus

the center of the room). The second is at the left end of the room

(as you face opposite the entrance). Through each hole runs a wooden

pole.[paragraph break]

[5 spaces]The pole at the left end of the bar is short, extending about a foot

above the bar, and ends in a hand grip. The pole is [if pole up is true]up[otherwise]down[end if].[paragraph break]

[5 spaces]The long pole at the center of the bar extends from the ceiling

through the bar to the circular area in the stone channel. This

bottom end of the pole has a T-bar a bit less than two feet long

attached to it, and on the T-bar is carved an arrow. The arrow and

T-bar are pointing [Mirror direction]."

The yellow panel is scenery.

A short pole is a thing in InsideMirror. A long pole is a thing in InsideMirror. A mahogany panel is a thing in InsideMirror. A pine panel is a thing in InsideMirror. A red panel is a thing in InsideMirror. A yellow panel is a thing in InsideMirror. The short pole, the long pole, the mahogany panel, the pine panel, the red panel, and the white panel are scenery. Understand "wall" as the red panel. Understand "wall" as the pine panel.

Understand "wall" as the yellow panel. Understand "wall" as the mahogany panel.

Understand "yellow" as the red panel. Understand "black" as the white panel.

Check pushing the red panel:

if the pole up is true begin;

say "The structure rotates clockwise.";

if mirror direction is west begin;

now mirror direction is northwest;

else if mirror direction is northwest;

now mirror direction is north;

else if mirror direction is north;

now mirror direction is northeast;

else if mirror direction is northeast;

now mirror direction is east;

else if mirror direction is east;

now mirror direction is southeast;

else if mirror direction is southeast;

now mirror direction is south;

else if mirror direction is south;

now mirror direction is south;

else if mirror direction is south;

now mirror direction is west;

end if;

say "The arrow is now pointing [Mirror direction]." instead;

else;

say "The short pole stops the structure from rotating." instead;

end if.

Check pushing the white panel:

if the pole up is true begin;

say "The structure rotates counterclockwise.";

if mirror direction is west begin;

now mirror direction is south;

else if mirror direction is northwest;

now mirror direction is west;

else if mirror direction is north;

now mirror direction is northwest;

else if mirror direction is northeast;

now mirror direction is north;

else if mirror direction is east;

now mirror direction is northeast;

else if mirror direction is southeast;

now mirror direction is east;

else if mirror direction is south;

now mirror direction is southeast;

else if mirror direction is south;

now mirror direction is south;end if;

say "The arrow is now pointing [Mirror direction]." instead;

else;

say "The short pole stops the structure from rotating." instead;

end if.

Check lifting the short pole:

if pole up is true begin;

say "The pole cannot be raised further." instead;

else;

say "The pole is now slightly above the floor.";

now pole up is true instead;

end if.

Check lowering the short pole:

if pole up is true begin;

say "The pole is lowered into the channel.";

now pole up is false instead;

else;

say "The pole cannot be lowered further." instead;

end if.

Check pushing the mahogany panel:

if mirror direction is not north and mirror direction is not south begin;

say "The structure rocks back and forth slightly but doesn't move." instead;

else if mirror direction is north;

if room number is 2 and pole up is true begin;

say "The structure wobbles north and stops over another compass rose.[paragraph break]";

say "The structure wobbles as it moves, alerting the Guardians.[paragraph break]";

say "Suddenly, the Guardians realize that someone is trying to sneak by them in the structure. They awake and, in perfect unison, hammer the box and its contents (including you) to pulp. Satisfied, they then resume their posts.[paragraph break]";

end the game in death instead;

else if pole up is true;

if room number is 4 begin;

say "The structure has reached the end of the stone channel and won't budge." instead;

else if room number is 3;

say "The structure wobbles north and stops over another compass rose.";

now room number is 4 instead;

else if room number is 2;

say "The structure wobbles north and stops over another compass rose.";

now room number is 3 instead;

else if room number is 1;

say "The structure wobbles north and stops over another compass rose.";

now room number is 2 instead;

end if;

else;

if room number is 4 begin;

say "The structure has reached the end of the stone channel and won't budge." instead;

else if room number is 3;

say "The structure slides north and stops over another compass rose.";

now room number is 4 instead;

else if room number is 2;

say "The structure slides north and stops over another compass rose.";

now room number is 3 instead;

else if room number is 1;

say "The structure slides north and stops over another compass rose.";

now room number is 2 instead;

end if;

end if;

else if mirror direction is south;

if room number is 4 and pole up is true begin;

say "The structure wobbles south and stops over another compass rose.[paragraph break]";

say "The structure wobbles as it moves, alerting the Guardians.[paragraph break]";

say "Suddenly, the Guardians realize that someone is trying to sneak by them in the structure. They awake and, in perfect unison, hammer the box and its contents (including you) to pulp. Satisfied, they then resume their posts.[paragraph break]";

end the game in death instead;

else if pole up is true;

if room number is 1 begin;

say "The structure has reached the end of the stone channel and won't budge.";

else if room number is 2;

say "The structure wobbles south and stops over another compass rose.";

now room number is 1 instead;

else if room number is 3;

say "The structure wobbles south and stops over another compass rose.";

now room number is 2 instead;

end if;

else;

if room number is 1 begin;

say "The structure has reached the end of the stone channel and won't budge." instead;

else if room number is 2;

say "The structure slides south and stops over another compass rose.";

now room number is 1 instead;

else if room number is 3;

say "The structure slides south and stops over another compass rose.";

now room number is 2 instead;

else if room number is 4;

say "The structure slides south and stops over another compass rose.";

now room number is 3 instead;

end if;

end if;

end if.

Hallway2 is a room. The printed name of Hallway2 is "Narrow Hallway". The description of Hallway2 is "This is part of the long hallway. The east and west walls are

dressed stone. In the center of the hall is a shallow stone channel.

In the center of the room the channel widens into a large hole around

which is engraved a compass rose.The north side of the room is divided by a wooden wall into small hallways to the northeast and northwest."

Check pushing the pine panel:

if room number is 4 and mirror direction is north begin;

say "The pine door opens into the field of view of the Guardians.[paragraph break]";

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death instead;

else if room number is 2 and mirror direction is south;

say "The pine door opens into the field of view of the Guardians.[paragraph break]";

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death instead;

else if room number is 3;

say "The pine door opens into the field of view of the Guardians.[paragraph break]";

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death instead;

else if mirror direction is not north and mirror direction is not south;

say "The structure rocks back and forth slightly but doesn't move.";

else;

say "The pine wall swings open.";

now mirror open is true instead;

end if.

Check exiting while the location is InsideMirror:

if mirror open is false begin;

say "There is no way out." instead;

else if room number is 1;

move the player to Hallway instead;

else if room number is 2;

move the player to Hallway2 instead;

else;

move the player to Hallway4 instead;

end if.

Northwest of Hallway2 is a room called Narrow Room. The description of Narrow Room is "This is a narrow room whose east wall is a large mirror. Somewhat to the north, identical stone statues face each other from pedestals on opposite sides of the corridor. The statues represent Guardians of Zork, a military order of ancient lineage. They are portrayed as heavily armored warriors standing at ease, hands clasped around formidable bludgeons."

Northeast of Hallway2 is a room called NarrowRoom. The printed name of Narrow Room is "Narrow Room". The description of NarrowRoom is "This is a narrow room whose west wall is a large mirror. Somewhat to the north, identical stone statues face each other from

pedestals on opposite sides of the corridor. The statues represent Guardians of Zork, a military order of ancient lineage. They are portrayed as heavily armored warriors standing at ease, hands clasped around formidable bludgeons."

Instead of going north from Narrow Room:

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death.

Instead of going north from NarrowRoom:

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death.

The rval of InsideMirror is 15.

Hallway4 is a room. The printed name of Hallway4 is "Dungeon Entrance". The description of Hallway4 is "This is a north-south hallway which ends in a large wooden door. The south side of the room is divided by a wooden wall into small hallways to the southeast and southwest."

Instead of going southwest from Hallway4:

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death.

Instead of going southeast from Hallway4:

say "The Guardians awake and, in perfect unison, destroy you with

their stone bludgeons. Satisfied, they resume their posts.";

end the game in death.

The large wooden door is a door. The large wooden door is closed, openable, lockable, and locked. The large wooden door is north from Hallway4. The large wooden door is scenery. North of the large wooden door is Narrow Corridor.

Narrow Corridor is a room. The description of Narrow Corridor is "This is a narrow north-south corridor. At the south end is a door and at the north end is an east-west corridor. The door is [if the large wooden door is open]open.[otherwise]closed.[end if]".

The dungeon master is a man. Instead of attacking the dungeon master:

say "The dungeon master is taken momentarily by surprise. He dodges your

blow and then, with a disappointed expression on his face, he raises

his staff and traces a complicated pattern in the air. As it

completes you crumble into dust."; end the game in death. Instead of attacking the dungeon master with something:

say "The dungeon master is taken momentarily by surprise. He dodges your

blow and then, with a disappointed expression on his face, he raises

his staff and traces a complicated pattern in the air. As it

completes you crumble into dust.";

end the game in death.

Question number is a number that varies. Question number is usually 0.

Instead of answering the dungeon master that something:

if the topic understood matches the text "follow" begin;

now follow is true;

say "The dungeon master answers, 'I will follow.'";

else if the topic understood matches the text "stay";

say "The dungeon master says, 'I will stay.'";

now follow is false;

else;

try speaking "[the topic understood]";

end if.

Instead of speaking when question number is 1:

if the topic understood matches the text "temple" begin;

say "The dungeon master says, 'Excellent.'";

now question number is 2;

now tries left is 4;

award 5 points;

else if tries left is 0;

say "The dungeon master, obviously disappointed in your lack of knowledge, shakes his head and mumbles 'I guess they'll let anyone in the Dungeon these days'. With

that, he departs.";

remove the dungeon master from play;

else if tries left is 1;

say "The dungeon master says, 'You are wrong. You have one more chance.'";

now tries left are 0;

else;

say "The dungeon master says, 'You are wrong. You have [tries left in words] more chances.'";

decrease tries left by 1;

end if.

Instead of speaking when question number is 2:

if the topic understood matches the text "forest" begin;

say "The dungeon master says, 'Excellent.'";

now question number is 3;

now tries left are 4;

award 5 points;

else if tries left is 0;

say "The dungeon master, obviously disappointed in your lack of knowledge, shakes his head and mumbles 'I guess they'll let anyone in the Dungeon these days'. With

that, he departs.";

remove the dungeon master from play;

else if tries left is 1;

say "The dungeon master says, 'You are wrong. You have one more chance.'";

now tries left are 0;

else;

say "The dungeon master says, 'You are wrong. You have [tries left in words] more chances.'";

decrease tries left by 1;

end if.

Instead of speaking when question number is 3:

if the topic understood matches the text "touch" or the topic understood matches the text "rub" begin;

say "The dungeon master, obviously pleased, says 'You are indeed a

master of lore. I am proud to be at your service.' The massive

wooden door swings open, and the master motions for you to enter.";

award 5 points;

now the large wooden door is open;

now the large wooden door is unlocked;

now follow is true;

else if tries left is 0;

say "The dungeon master, obviously disappointed in your lack of knowledge, shakes his head and mumbles 'I guess they'll let anyone in the Dungeon these days'. With

that, he departs.";

remove the dungeon master from play;

else if tries left is 1;

say "The dungeon master says, 'You are wrong. You have one more chance.'";

now tries left are 0;

else;

say "The dungeon master says, 'You are wrong. You have [tries left in words] more chances.'";

decrease tries left by 1;

end if.

The later appearance of the master is "The dungeon master is quietly leaning on his staff here."

Follow is a truth state that varies. Follow is false.

Tries left is a number that varies. Tries left is usually 4.

Every turn:

let aaa be the rval of the location;

award aaa points;

now the rval of the location is 0;

if the thief has been unconsious for four turns and the player can see the thief, say "The thief returns to consiousness.";

if the engrossed of the thief has been true for two turn, now the engrossed of the thief is false;

if the player has been in Cage for the tenth turn begin;

say "Time passes...and you die from some obscure poisoning.";

end the game in death;

end if;

if the player is in InsideMirror and mirror open has been true for three turns begin;

say "The mirror quietly swings shut.";

now mirror open is false;

end if;

if question number is 1 and question number was not 1 begin;

say "The booming voice asks: From which room can one enter the robber's hideaway without passing through the cyclops room?";

else if question number is 2 and question number was not 2;

say "The booming voice asks: Besides the Temple, to which room is it possible to go from the Altar?";

else if question number is 3 and question number was not 3;

say "The booming voice asks: What can be done to the Mirror that is useful?";

end if;

if the thief carries the jewel-encrusted egg, now the jewel-encrusted egg is open;

if the player is in Treasure Room and the thief is not in Treasure Room and the thief is on-stage begin;

say "You hear a scream of anguish as you violate the robber's hideaway. Using passages unknown to you, he rushes to its defense.";

move the thief to Treasure Room;

end if;

if the thief is on-stage begin;

if the thief cannot see the player, try the thief escaping;

if the thief is not in Treasure Room and the player is in the holder of the thief begin;

if the thief can see a visible valuble thing which is not held by the thief begin;

say "A seedy-looking individual with a large bag just wandered through the room. On the way through, he quietly abstracted all valuables from the room and from your possession, mumbling something about 'Doing unto others before...'";

now every valuble thing had by the player is had by the thief;

now every visible valuble thing in the location is had by the thief;

try the thief escaping;

else;

say "A seedy-looking individual with a large bag just wandered through the room. Finding nothing of value, he left disgruntled.";

end if;

try the thief escaping;

end if;

end if;

if follow is true and the player is not in the holder of the dungeon master begin;

say "The dungeon master follows you.";

move the dungeon master to the holder of the player;

end if;

decrease mrint by 1;

if mrint is 0 begin;

now mirror open is true;

if the player can see the redbutton, say "The button pops back to its original position.";

now the depressed of the redbutton is false;

end if;

if the player has been in Vault for exactly 4 turns begin; say "A metallic voice says, 'Hello, Intruder! Your unauthorized presence in the vault area of the Bank of Zork has set off all sorts of nasty surprises, several of which seem to have been fatal. This message brought to you by the Frobozz Magic Alarm Company.'"; end the game in death; end if;

if gnome flag is true and the player has been in Small Room for exactly 4 turns begin; say "An epicene Gnome of Zurich, wearing a three-piece suit and carrying a

safety deposit box, materializes in the room. 'You seem to have

forgotten to deposit your valuables,' he says, tapping the lid of the

box impatiently. 'We don't usually allow customers to use the boxes

here, but we can make this ONE exception, I suppose...' He looks

askance at you over his wire-rimmed bifocals."; move the Gnome of Zurich to Small Room; now gnome flag is false; end if;

if the player is in Grating Room, now the grating is revealed;

if the location is the bad place and the brick is off-stage, foo;

if the number of moves from the location to the bad place is 1 and the brick is off-stage, foo;

if squish clock is 0 begin;

now the description of the bad place is "[pizza]";

if the player is in the bad place begin;

say "The room trembles and 50,000 pounds of rock fall on you, turning you into a pancake. [if the player is outdoors]Meteors, no doubt.[end if]";

end the game in death;

else;

say "You may recall your recent explosion. Well, probably as a result of

that, you hear an ominous rumbling, as if one of the rooms in the

dungeon has collapsed.";

[1]

end if;

end if;

decrease squish clock by 1;

decrease ledge clock by 1;

if ledge clock is 3, say "You may recall your recent explosion. Well, probably as a result of that, you hear an ominous rumbling, as if one of the rooms in the

dungeon has collapsed.";

if ledge clock is 0 begin;

if the player is in the basket and the basket is in Wide Ledge begin;

if the braided wire is attached to the tiny hook begin;

say "The ledge collapses, probably as a result of the explosion. A large

chunk of it, which is attached to the hook, drags you down to the

ground. Fatally.";

end the game in death;

else;

say "The ledge collapses, leaving you with no place to land.";

move the basket to Volcano Near WideLedge;

try looking;

end if;

else if the player is in Wide Ledge or the player is in Dusty Room;

say "The force of the explosion has caused the ledge to collapse

belatedly.";

end the game in death;

else;

say "The ledge collapses, giving you a narrow escape.";

end if;

end if;

if wire clock is 0 begin;

if the player can see the brick begin;

say "Now you've done it. It seems that the brick has other properties

than weight, namely the ability to blow you to smithereens.";

remove the brick from play;

end the game in death;

else;

say "There is an explosion nearby.";

if the brick is in the oblong hole begin;

now ledge clock is 5;

now the rusty box is open;

move the crown to Dusty Room;

move the note card to Dusty Room;

else if the brick is in Dusty Room;

now ledge clock is 5;

else;

now squish clock is 2;

now the bad place is the location of the brick;

end if;

remove the brick from play;

end if;

end if;

decrease wire clock by 1;

if burn interrupt is 0 begin;

if something visible is in the receptacle, say "You notice that the [list of flaming things in the receptacle] has burned out, and that the cloth bag starts to deflate.";

let the thingy be a random flaming thing in the receptacle;

now the thingy is not flaming;

remove the thingy from play;

end if;

decrease burn interrupt by 1;

now every thing which is flaming is lit;

if something inflammable (called the thingy) is non-flaming, now the thingy is unlit;

if the matchbook is non-flaming, now the matchbook is unlit;

if the pair of candles is non-flaming, now the pair of candles is unlit;

if match tick is greater than 0, decrease match tick by 1;

if match tick is 0 begin;

say "The match has gone out.";

now match tick is -1;

now the matchbook is non-flaming;

end if;

if the cure wait of the player is greater than 0, decrease the cure wait of the player by 1;

if the cure wait of the player is 0, now the wounds of the player are 0;

if the wounds of the player is greater than 4 begin;

say "It appears that blow was too much for you. I'm afraid you are dead.";

now the wounds of the player are 4;

end the game in death;

end if;

if the battery-powered brass lantern is switched on begin;

decrease lamp-power by 1;

if lamp-power is 50, say "The lamp appears to be getting dimmer.";

if lamp-power is 30, say "The lamp appears to be getting dimmer.";

if lamp-power is 20, say "The lamp appears to be getting dimmer.";

if lamp-power is 10, say "The lamp appears to be getting dimmer.";

if lamp-power is 4, say "The lamp is dying.";

if lamp-power is 0 begin;

say "I hope you have more light than from a lamp.";

now the battery-powered brass lantern is switched off;

now the battery-powered brass lantern is unlit;

end if;

end if;

if the player has been in Living Room for the second turn and brochure flag is 1 begin;

say "There is a knocking sound from the front of the house.";

now brochure flag is 2;

move the free brochure to the mailbox;

end if;

if the number of visible valuble things in the trophy case is 32 and the number of visible valuble things in the trophy case was not 32, say "Suddenly a sinister wraithlike figure, cloaked and hooded, appears

seeming to float in the air before you. In a low, almost inaudible

voice he says, 'I welcome you to the ranks of the chosen of Zork. You

have persisted through many trials and tests, and have overcome them

all, dispelling the darkness of ignorance and danger. One such as

yourself is fit to join even the Implementers!' He then raises his

oaken staff, and chuckling, drifts away like a wisp of smoke, his

laughter fading in the distance.".

The rval of Narrow Corridor is 20.

North of Narrow Corridor is a room called South Corridor. The description of South Corridor is "This is an east-west corridor which turns north at its eastern and western ends. The walls of the corridor are marble. An additional passage leads south at the center of the corridor."

West of South Corridor is south of a room called West Corridor. The description of West Corridor is "This is a corridor with polished marble walls. The corridor

widens into larger areas as it turns east at its northern and

southern ends."

East of South corridor is south of a room called East Corridor. The description of East Corridor is "This is a corridor with polished marble walls. The corridor widens into larger areas as it turns west at its northern and southern ends."

North of West Corridor is a room called North Corridor. The description of North Corridor is "This is a large east-west corridor which opens out to a northern

parapet at its center. You can see flames and smoke as you peer

towards the parapet. The corridor turns south at its east and west

ends, and due south is a massive wooden door. In the door is a small

window barred with iron. The door is [if the prison cell door is open]open[otherwise]closed.[end if]".

North of East Corridor is North Corridor.

North of North Corridor is a room called Parapet. The description of Parapet is "You are standing behind a stone retaining wall which rims a large parapet overlooking a fiery pit. It is difficult to see through the smoke and flame which fills the pit, but it seems to be more or less bottomless. It also extends upward out of sight. The pit itself is of roughly dressed stone and circular in shape. It is about two hundred feet in diameter. The flames generate considerable heat, so it is rather uncomfortable standing here.

There is an object here which looks like a sundial. On it are an indicator arrow and (in the center) a large button. On the face of the dial are numbers 'one' through 'eight'. The indicator points to the number [dial number in words]."

Dial number is a number that varies. Dial number is 1.

Persuasion rule for asking the dungeon master to try doing something: persuasion succeeds.

A large button is in Parapet. The large button is scenery.

Persuasion rule for asking the dungeon master to try going:

say "'I prefer to stay where I am, thank you.'".

A dial is in Parapet. The dial is scenery. Understand "sun dial" and "sundial" and "sun-dial" and "indicator" and "arrow" as the dial.

Check taking the dungeon master: say "'I'm willing to accompany you, but not ride in your pocket!'" instead.

Instead of asking the dungeon master to try doing something:

say "'If you wish,' he replies."; continue the action.

The prison cell door is a door. The prison cell door is closed and openable. The prison cell door is south of North Corridor. South of the prison cell door is a room called Prison Cell.

The description of Prison Cell is "You are in a featureless prison cell. You can see [if the prison cell door is open]the east-west corridor outside the open wooden door in front of you.[otherwise]only the flames and smoke of the pit out the small window in a closed door in front of you.[end if]."

PCell is a room. The description of PCell is "You are in a featureless prison cell. Its wooden door is securely fastened, and you can see only the flames and smoke of the pit out the small window." The printed name of PCell is "Prison Cell".

The prison cell door is scenery.

NCell is a room. The description of NCell is "You are in a featureless prison cell. Its wooden door is securely fastened, and you can see only the flames and smoke of the pit out its small window. On the other side of the cell is a bronze door which seems to be [if the bronze door is open]open[otherwise]closed[end if].". The printed name of NCell is "Prison Cell".

Check going inside while the location is NCell: try entering the bronze door instead.

The bronze door is a door. The bronze door is closed and openable.

The bronze door is scenery. The bronze door is south of NCell. South of the Bronze Door is a room called Treasury of Zork. The description of Treasury of Zork is

"[5 spaces]This is a room of large size, richly appointed and decorated

in a style that bespeaks exquisite taste. To judge from its

contents, it is the ultimate storehouse of the treasures of Zork.[paragraph break]

[5 spaces]There are chests here containing precious jewels, mountains of

zorkmids, rare paintings, ancient statuary, and beguiling curios.[paragraph break]

[5 spaces]In one corner of the room is a bookcase boasting such volumes as

'The History of the Great Underground Empire,' 'The Lives of the

Twelve Flatheads,' 'The Wisdom of the Implementors,' and other

informative and inspiring works.[paragraph break]

[5 spaces]On one wall is a completely annotated map of the Great Underground

Empire, showing points of interest, various troves of treasure, and

indicating the locations of several superior scenic views.[paragraph break]

[5 spaces]On a desk at the far end of the room may be found stock

certificates representing a controlling interest in FrobozzCo

International, the multinational conglomerate and parent company of

the Frobozz Magic Boat Co., etc.[paragraph break]".

Last every turn rule:

if the player is in Treasury of Zork begin;

award 35 points;

say "[5 spaces]As you gleefully examine your new-found riches, the Dungeon

Master himself materializes beside you, and says, 'Now that you have solved all the mysteries of the Dungeon, it is time for you to assume your rightly-earned place in the scheme of things. Long have I waited for one capable of releasing me from my burden!' He taps you lightly on the head with his staff, mumbling a few well-chosen spells,

and you feel yourself changing, growing older and more stooped. For a moment there are two identical mages staring at each other among the treasure, then you watch as your counterpart dissolves into a mist and disappears, a sardonic grin on his face.";

end the game in victory;

end if.

After deciding the scope of the player:

if the player is in Prison Cell, place the dungeon master in scope.

A thing has a number called cell number. The cell number of a thing is usually 0.

Every turn when something is in Prison Cell:

repeat with thingy running through things in Prison Cell begin;

now the cell number of the thingy is current cell;

end repeat.

Limbo is a room.

Current cell is a number that varies. Current cell is 1.

Instead of someone pushing the large button:

say "Click.";

now the current cell is dial number;

if dial number is 6 and the player is in Prison Cell, move the player to NCell;

if the player is in Prison Cell, move the player to PCell;

now every thing in Prison Cell is in Limbo;

if the cell number of the player is dial number and the player is in PCell or the player is in NCell, move the player to Prison Cell;

repeat with thingy running through things in Limbo begin;

if the cell number of the thingy is dial number, move the thingy to Prison Cell;

if the player is in PCell and the cell number of the thingy is the cell number of the player, move the thingy to PCell;

if the player is in NCell and the cell number of the thingy is the cell number of the player, move the thingy to NCell;

end repeat;

repeat with thingy running through things in NCell begin;

if cell number of the thingy is dial number, move the thingy to Prison Cell;

end repeat;

rule succeeds.

Check going inside while the location is Hallway4: try entering the large wooden door instead.

Include (- [ XOR a b; return (a | b) & (~(a & b)); ]; -). [2]

Notes

[1]. OK, this sort of doesn't make sense if the player is outside

[2]. Inform does not have a bitwise exclusive or built in, so we make one