Zork I: The Great Underground Empire runs on the Z-machine, which is famously portable and runs on many different operating systems and consoles. Some of the topics on this page are particular to the Apple II implementation, while others apply to any version.
The forum topic is in the MS-DOS Games subforum.

Revisions

Zork I appeared in many revisions over several years. Revision 88 (1983) is the most common and widely distributed revision; it's the "canonical" revision to play unless you have a particular reason to choose a different revision.
Graeme Cree's bug list has a table of which bugs affect which revisions.

Game settings

The game by default runs in "brief" mode, which means the long description of a room is shown only the first time you enter it, and the short description is shown thereafter. There is also "verbose" mode, which always shows the long description, and "superbrief" mode, which always shows the short description. Superbrief mode (which can be entered using the command super) is about 20% faster than brief mode in the Apple II version.
The Apple II version can run in 40-column mode or 80-column mode. 80-column mode is visually nicer, because it has uppercase and lowercase letters, but it is estimated to be about 6% slower.

Glitches

Of particular interest for a TAS is the "raft of holding" bug:
27. THE RAFT OF HOLDING: When you put objects in the raft and then deflate it, they effectively cease to exist, allowing you to carry as much weight and as many objects as the raft will hold (it won't hold the gold coffin, unfortunately, and of course sharp objects are out). This is because the game handles the pile of plastic and the raft as two separate objects, and there's no provision for handling any objects inside the raft when the switch is made. -- Stu Galley in The New Zork Times

Stacking commands

It's possible to enter multiple consecutive commands on one line by separating the commands with dots. (The queue of commands gets stored in a variable called P-CONT.) For example, at the start of the game, you can enter n.n.u.get egg.d to get to the tree, climb the tree, get the egg, and climb down again. Doing this is generally slightly faster than entering the commands on separate lines. There are limitations: many game events, such as entering the Loud Room or initiating combat, will clear P-CONT. If you queue up commands that produce more than a screen's worth of output, you still have to enter inputs to clear the "[MORE]" prompts that appear.

RNG

The RNG in the Apple II version uses the time delay while waiting for input to be typed, as well as the ASCII codes of the typed characters. You can manipulate RNG by altering the case of entered commands, e.g. get egg versus get egG versus Get EGG.
The Apple II Z-Machine interpreter (ZIP) uses the KEYIN random number generator built into the Apple II firmware, which rapidly increments a 16-bit counter at addresses 0x4e and 0x4f (which the ZIP calls RNUM1 and RNUM2) while waiting for a key to be pressed. The ZIP's GETKEY subroutine calls the Apple II RDKEY subroutine, which in turn calls KEYIN. KEYIN returns an ASCII code in the A register and leaves RNUM1 and RNUM2 in some hard-to-predict state. At the end of GETKEY, the ZIP further tweaks the random number state by adding the ASCII code into RNUM1 and xoring it into RNUM2:
	ADC RNUM1		;FUTZ WITH RANDOM
	STA RNUM1
	EOR RNUM2
	STA RNUM2
Random events to worry about:

Inventory limits

Object have a SIZE property that represents their weight. The most weight you can carry is 95 units. (The nominal limit of LOAD-MAX is 100 units, but the game's WEIGHT calculation includes the SIZE of the WINNER container, which is the default 5 units.) The limit is lowered when you are injured (LOAD-ALLOWED).
The weight limit is a hard limit that may not be crossed. There is also a soft limit on the number of items you are carrying. Beyond 8 items, there is a random chance that you will fumble when trying to pick up an additional item.

Combat

Combat is affected by what weapon you are using, what enemy you are attacking, and how many points of score you have. The troll's base strength is 2 and the thief's base strength is 5. The troll is weak to the sword and the thief is weak to the nasty knife; using an enemy's weakness reduces the enemy's strength by 1. The player's fighting strength starts at 2 and increases by 1 for every 70 points of score (it's supposed to be like gaining XP in a role-playing game). A strength of 0 means death, and a negative strength means unconsciousness. An unconscious or unarmed enemy can always be killed in one hit.
The strength of the attacker and defender are used to index tables of combat results in the VILLAIN-BLOW and HERO-BLOW functions. For each blow result (KILLED, LIGHT-WOUND, etc.) there is a table of flavor remarks which is indexed randomly.
There is supposed to be a mechanic (THIEF-ENGROSSED) whereby you can give the thief a treasure to temporarily reduce his strength to 2. But it doesn't seem to actually work: his strength is restored to normal before the player's next turn.

Thief movement

The movement of the thief is not random. He warps from room to room in a set and predictable schedule. Basically, he iterates over ROOMS in reverse order, starting in ROUND-ROOM and skipping any room that has SACREDBIT set, or RLANDBIT unset. He is invisible while doing so. When in the same room as the player, there is a random chance that he will become visible and encounter the player.
During his circuit, the thief has a 74% chance of stealing treasures (items whose TVALUE is greater than 0) from rooms you've already seen (rooms whose TOUCHBIT is set). This can work to your advantage, as the thief has no carrying limit and treasures stolen by him will be left in the treasure room after the final showdown.
There are some limits on what the thief can steal. The thief also does not look inside containers for treasures—he only takes things that are at the "top level" in the room. The thief doesn't enter SACREDBIT rooms, so a treasure in such a room will not be stolen. This notably includes BAT-ROOM which initially contains the jade figurine. Some treasures also have SACREDBIT set, and the thief is prohibited from stealing those (because it could bypass a puzzle the player is meant to solve). The SACREDBIT treasures are COFFIN and BAR. SACREDBIT is cleared from BAR after you echo in the loud room; this makes it eligible for stealing again.
The other flag that affects the thief's movement is RLANDBIT, which means something like "there is dry land in this room". The thief cannot enter a room unless RLANDBIT is set. Almost all the rooms that RLANDBIT unset are also sacred, so it doesn't matter much; the only exception is the RESERVOIR room, which is not sacred, and initially does not have RLANDBIT set. Draining the reservoir at the dam sets RLANDBIT and lets the thief go there (to pick up the trunk of jewels, possibly).
In the maze (rooms with MAZEBIT set), there is special code to unset TOUCHBIT on rooms you've entered. This is to avoid revealing side information through whether the long or short room description is shown. As a side effect, it prevents the thief from picking up items in the maze. This does not apply in the coal mine, whose rooms do not have MAZEBIT set, even though they form a small maze.

Resources

Manual for the Apple II version.
The Visible Zorker is a playable online version that shows an execution call stack and has easy cross-references to the source code. It uses revision 88. If you click "Show addresses" under the hamburger menu, you'll find decimal addresses that correspond to the disassembly. See also: The Visible Zorker (2025).
https://github.com/historicalsource/zork1 is the ZIL Lisp source code of the game itself. Commit 34cc828c4f represents revision 88. See also: All of Infocom's game source code (2019).
zork1-disassembly.txt is disassembly of the compiled Z-machine code. The hexadecimal addresses in the left column correspond to the decimal addresses in The Visible Zorker.
https://github.com/erkyrath/infocom-zcode-terps is the source code of original Infocom Z-machine interpreters ("ZIPs" or "terps") for many platforms. apple/zip is the Apple II version. See also: All that Infocom interpreter code (2023).
Speedrun.com guides. A TAS of the Gym Slow route can be found at Forum/Posts/538557. It uses the "raft of holding" bug.
Internal Secrets of Infocom Games. Structure of story files, memory layout, game loop logic.

GameResources/AppleII/ZorkI last edited by Sand 2 days ago
Page History Latest diff List referrers View Source