Episode ZS′
This is the second and final episode of Zork source code exploration. Again we are using The Visible Zorker to see the source code alongside the game.
We spent the majority of the time looking at the thief: how he moves, stealing things, and combat. We also browsed the properties of various rooms and items, including weights and container capacities. (And finally settled the mystery of the set of teeth.) We uncovered a few deep secrets, like a magical connection between the treasure room and the temple, a different solution for the loud room puzzle, and the fact that death by grue is not an absolute certainty when you take a step in the dark.
- 0:02:48
-
We looked up the "set of teeth" that had bedeviled us since episode Z3. The
TEETHobject is a global object (accessible from any room) that exists only so that the parser has something called "teeth" to refer to when you try to BRUSH TEETH WITH GUNK. (Otherwise it would say "I don't know the word 'teeth'.") The strange phrase "set of teeth" is an artifact of how objects are defined, like "quantity of water" or "pair of hands". - 0:09:10
-
We looked at the function
JIGS-UP, which is called whenever the player does something to gets them killed. (Like brushing their teeth with the gunk, say.) The condition that decides whether you respawn alive in the forest or as a ghost at the Gates of Hades is whether you've been to the south temple or not. TheRANDOMIZE-OBJECTSfunction is what scatters your inventory when you die. There's a failsafe inJIGS-UPfor when you die when you're already a ghost. (Which takes some doing, but it can happen!) - 0:14:34
- 0:16:19
-
The songbird and the clockwork canary. The songbird is not a live, moving object like the dwarves and pirate in Adventure; but rather one of those that you can refer to from many rooms that doesn't really exist in any of them. While you're in a forest room, there's a uniform probability that you'll hear the chirping of the songbird. (In that way, the songbird is like the first dwarf encounter in Adventure, but not the subsequent ones.)
- 0:19:54
-
The thief and thief movement. The thief doesn't follow the same room connections that are available to the player. Instead, he starts in the Round Room and then warps from room to room on a predefined circuit. The thief's
STRENGTHis 5, which is why he is so strong in battle. (Compare to the troll'sSTRENGTHof 2.) There are some random interactions in combat with the thief that we did not see. If you throw the knife at him while not engaged in combat, there is a small chance that he will flee and leave his items behind. The point at which the jeweled egg is opened is when the thief deposits the egg in his lair (either in his wanderings or after he dies).It seems like you could take the thief's chalice without killing him, if he is unconscious in the treasure room. That, combined with the random chance of making him drop items, might make possible a run where you do not kill the thief.
- 0:50:31
- 0:52:31
-
I-THIEF, the thief "demon" routine that runs on every turn. The order in which the thief visits rooms is defined by theROOMSlist. But he doesn't enter rooms that haveSACREDBITset, nor rooms that are not solid land (RLANDBITbit).The thief may pick up and drop items as he moves around. He'll never take something from a room you haven't been to yet (
TOUCHBITis not set). Otherwise he has a chance of stealing any treasures that are present (ROBfunction). He may take non-treasures as well, but how this works differs depending on whether he and the player are in the maze. If the thief and the player are inside the maze (MAZEBITis set), he callsROB-MAZE, in which he has a chance to remark "My, I wonder what this fine item is doing here" and possibly to pick up the item. Otherwise, he callsSTEAL-JUNK, where he has a chance of picking up each non-treasure in the room.Correction to what was stated at 1:04:08: it looks like the thief can steal the rope in
STEAL-JUNK, and in so doing also setsDOME-FLAGto false. - 1:11:06
-
V-LEAP. You will die if you try jumping in the kitchen, because there's a (never usable) down exit from there. But you can jump down from the tree safely. - 1:17:08
-
Perusing the rooms in
ROOMS. Seeing which ones are considered sacred. The "Granite Wall" mystery: the strange engraving in the slide room that had baffled us is an oblique hint that there is a connection between the granite wall on the east side of the treasure room and the the granite wall on the west side of north temple. We had dimly guessed that some kind of connection existed, but were unable to make use of it. What it means is that you can say TREASURE or TEMPLE to warp between the two rooms. - 1:31:48
-
Looking at the commentary on various items and rooms. The broken timber in the timber room was used for a puzzle in the original MDL version of Zork. It has no use in Zork I.
RAISED-BASKETandLOWERED-BASKET.BAT,DAM-ROOM,GARLIC,BONES,BUBBLE,COFFIN. - 1:37:59
-
Object size/weight and the capacity of containers. The
WEIGHTfunction.The
ALTAR, too, acts like a container, albeit one you cannot pick up.The magic boat is a container as well, having capacity 100. We talked about the "boat of holding" glitch, where you fill the boat with items and then deflate it. The deflated boat is considered a different item, with a lower weight than the inflated boat and the items it contains. Re-inflating the boat brings the items back.
- 1:46:33
-
More items and their properties.
MATCH,PAINTING,CANDLES,GUNK,LEAVES. The buttons in the dam maintenance room. - 1:49:58
-
An alternative solution for the loud room.
I-RFILL.The rushing sound in the loud room is the sound of flowing water. If you turn the bolt once to drain the reservoir, then turn the bolt again to start to refill it, and hurry to the loud room before it completely refills, the loud room will be quiet and you will be able to take the platinum bar.
The implementation of the loud room is really elaborate. Just like the sneaky extra-loop input that secretly accepts "yes" when you fight the dragon in Adventure, the loud room outputs a fake command prompt, reads input outside the main input loop, and handles the input itself without giving it to the main game engine for processing. This is how the echoing effect is achieved.
- 1:59:23
-
Syntax definitions. The $VERIFY command. BLAST.
- 2:00:15
-
There is only about an 80% probability that you will be eaten by a grue when taking a step from a dark place.
We had the impression that in the case you are not eaten by a grue, you stay in place and cannot actually make progress in the dark, but the part we were looking at is for when you take a step in the dark in a direction where there is no exit. There is another code path (with a separate about 80% chance) for when you follow a valid exit from one dark room to another. (There's a difference in the death message in each case: the former is "You have walked into the slavering fangs" and the latter is "A lurking grue slithered into the room".)
- 2:03:59
-
Combat. The
THIEF-VS-ADVENTURERfunction.HERO-BLOWandVILLAIN-BLOW. The player's combat strength (FIGHT-STRENGTH) goes from 2 (STRENGTH-MIN) to 7 (STRENGTH-MAX), increasing by 1 point for every 70 points of score. The player's strength can be adjusted by theirSTRENGTHproperty, which is normally 0, except when injured.The result of any given blow in combat is a random variable that depends mainly on the absolute strength of the defender, and the difference in strength between the defender and the attacker. These numbers are used to index tables of combat results. There are 9 possible outcomes of any attack. Not all of them are encoded directly in the tables, but use special-case logic, such as the defender having a random chance of losing their weapon when staggered.
Topics mentioned:
- Zork
- Zork III
- The Visible Zorker
- ZIL
- acrostic
- Grim Fandango
- speedrunning
- Lisp
- Heart of Darkness
- Lua
- Colossal Cave Adventure
- Zork Playground
- mainframe Zork
- Sorcerer
- Hunt the Wumpus
- Trinity
- New York City Subway
- Massachusetts Institute of Technology
- MDL