Skip to content
Techniques & Technology

Z-Machine

The portable text adventure engine

The virtual computer Infocom's text adventures ran on: a game compiled once, an interpreter per machine. Lebling described it in BYTE in 1980 with four interpreters; Infocom advertised twenty formats by 1984.

cross-platformvirtual-machineinfocomadventureinterpreter

The Z-machine is the virtual computer that Infocom’s text adventures ran on. A game was compiled once into code for an imaginary machine; each real computer got an interpreter that pretended to be that machine. Dave Lebling described the arrangement in BYTE in December 1980, when interpreters existed for four machines; by 1984 Infocom’s advertisements listed twenty formats. The name “Z-machine” is a later one — period sources say “Zork-language virtual machine” and ZIL.

Fast facts

  • Designed: 1979-80, by Marc Blank and Joel Berez (later accounts); the design article is Blank and S. W. Galley, “How to Fit a Large Program into a Small Machine”, Creative Computing, July 1980.
  • Company: Infocom, founded 22 June 1979 by ten members of MIT’s Laboratory for Computer Science.
  • Source language: ZIL, “Zork Implementation Language” (Michael Berlyn, 1984); compiler ZILCH.
  • Interpreter: one per machine. Apple II, PDP-11, PDP-10 and TRS-80 in December 1980; twenty formats by June 1984.
  • Why: mainframe Zork needed about a megabyte; home machines had 32K and a 100K floppy.

The problem it solved

Zork was written on MIT’s PDP-10 and, in Lebling’s words, “eventually grew to strain even the megabyte address space of that machine.” Roy Wagner put the same figure to Computer Gaming World readers in 1984: “nearly a megabyte (1 million bytes) of memory on the mainframe computer”, against a three-part micro version that “uses only about one quarter of a megabyte.” Graham Nelson, writing in 1996, added the commercial half of the problem: “until the late ’80s, there were never less than a dozen home computer models in use, housing four or five different microprocessors: 6502, Z80, 68000 and so on. The individual markets were small and the challenge was to find a product to sell to all of them.”

How it worked

Lebling’s 1980 account is the earliest and the clearest:

Zork is shrunk to fit into the micro-world by running on a Zork-language virtual machine. This means that the code that is running while you are playing Zork is much more compact than the same program would be if written in machine language (on a Radio Shack TRS-80, for example). This is because the instruction set of the virtual machine is tailored to CFS games. For example, the Zork-language instruction to move an object from one room to another takes just 3 bytes of storage. The other advantage is that the Zork code is machine independent; all it takes to move Zork to another machine is to write the Zork-language interpreter for that machine.

The game did not have to fit in memory either: “Zork games swap data (programs and text) into memory from the disk as needed and therefore aren’t limited by the size of the system’s user memory.” A standard 100K floppy held “about 10,000 words of English prose and a similar amount (about 40 K bytes) of code” — enough, Lebling said, for a short story, so the mainframe game was cut into two and then three parts. Retro Gamer’s 2004 history adds the text compression (5.5 bits per character rather than 8) and Infocom’s name for the interpreter, ZIP, “Z-Machine Interpretive Program”.

ZIL

Infocom’s writers did not program the virtual machine directly. Michael Berlyn, author of Suspended and Infidel, told a CompuServe conference in 1984 that the development language, “called ZIL for Zork Implementation Language”, was “remarkably smart”: “The language doesn’t make you do tiring programming tasks like declaring variables, it does that for you. It’s also fairly intelligent about the background universe. For example, when I wrote Infidel, I didn’t have to ‘program’ what it meant to look around a room. The game system automatically knew what ‘look’ meant, and how to do it. It also knew that if there was no light there, that you couldn’t see.” The world model — rooms, objects, light, the parser — lived in the language and the machine, so an author wrote the story on top of it. Nelson’s 1996 column records that the ZIL compiler, ZILCH, was by then “missing, believed deleted.”

Platforms

BYTE’s December 1980 box gives the first two formats on sale, Apple II and TRS-80, distributed by Personal Software; Personal Software’s own advertisement that month specifies “32K Apple II and II Plus and 32K TRS-80 Model I Level II disk systems.” By June 1984 Infocom’s “Incomplete Works” advertisement listed Apple II, Atari, Commodore 64, CP/M 8“, DECmate, DEC Rainbow, DEC RT-11, IBM PC and PCjr, Kaypro II, MS-DOS 2.0, NEC APC, NEC PC-8000, Osborne, Tandy 2000, TI Professional, TI 99/4A, and TRS-80 Models I and III, with the IBM version also serving the Compaq and the MS-DOS one the Wang and Mindset. Compute! summarised it that October as “available in versions for most personal computers”, and reported the Zork series past a quarter of a million disks.

Afterwards

Nelson, who wrote Inform to compile a new language to Infocom’s machine, made the comparison the technique is usually remembered by: Berez and Blank “were far ahead of their time - 17 years later and the Java bytecode machine may soon be in every phone and television set.” In 1996 he counted three living design systems — TADS, Inform and Hugo — and noted that Inform “was so called because it forms Infocom files”. Retro Gamer’s 2013 survey of adventure engines placed ZIL and the Z-machine before SCUMM; Ron Gilbert, in the same feature, remembered Infocom’s “Z-engine” as one of the engines LucasFilm had in view. The version numbering (Z1 to Z8), file extensions and the later interpreters are outside the sources held here.

See also

Not yet fact-checked. This entry was drafted by an AI and nobody has verified it. The dates, figures and technical details may be wrong. Use it to find your bearings, then confirm anything that matters against a primary source.