Computer games have been around about as long as computers have. And though it may be hard to believe, Zork, a text-based adventure game, was the Fortnite of its time. But Zork is more than that. For portability and size reasons, Zork itself is written in Zork Implementation Language (ZIL), makes heavy use of the brand-new concept of object-oriented programming, and runs on a virtual machine. All this back in 1979. They used every trick in the book to pack as much of the Underground Empire into computers that had only 32 kB of RAM. But more even more than a technological tour de force, Zork is an unmissable milestone in the history of computer gaming. But it didn’t spring up out of nowhere.

The computer revolution had just taken a fierce hold during the second World War, and showed no sign of subsiding during the 1950s and 1960s. More affordable computer systems were becoming available for purchase by businesses as well as universities. MIT’s Laboratory for Computer Science (LCS) was fortunate to have ties to ARPA, which gave MIT’s LCS and AI labs (formerly part of Project MAC) access to considerable computing resources, mostly in the form of DEC PDP systems.

The result: students at the MIT Dynamic Modeling Group (part of LCS) having access to a PDP-10 KA10 mainframe — heavy iron at the time. Though this PDP-10 was the original 1968 model with discrete transistor Flip Chip modules and wire-wrapping, it had been heavily modified, adding virtual memory and paging support to expand the original 1,152 kB of core memory. Running the MIT-developed Incompatible Timesharing System (ITS) OS, it was a highly capable multi-user system.

Naturally, it got mostly used for playing games.



Are you ready for an adventure?

In the Spring of 1977, a game arrived at MIT called Colossal Cave Adventure (or ‘Adventure’ for short). This game was the first interactive fiction computer game, providing the player with a text adventure involving a big cave system that’s rumored to be filled with treasures. Reminiscent of ‘choose your own adventure’ books, the player would make choices that would lead them through the cave’s rooms, either succeeding at recovering treasure and escaping alive, or meeting an untimely demise.

Inspired by this game, a group of students at LCS figured that they could do better than this Stanford-developed project. The main weakness they spotted was that Adventure was implemented in FORTRAN, a language not exactly know for its strong dynamic text-handling features, let alone the needs of an interactive fiction game. Because of this, Adventure essentially hard-coded the entire game, limiting flexibility and complicating extending and maintaining the game.

In Adventure, each room has a numeric ID, with an associated description in a table. Another table defines its short description. Another table lists which rooms lie relative to other rooms using their numeric IDs. This means that in order to add a room, one has to modify all of these tables, taking care not to cause any issues with those changes.

Hacker rivalry

Using the natural language experience that existed at LCS and the AI departments back then, it was Dave Lebling who first put together a simple parser and beginnings of a game engine akin to that of Adventure, using the LISP-derived MDL programming language. Using the strong natural language processing capability of MDL, Marc Blank, Bruce Daniels and Tim Anderson then built upon Lebling’s efforts to create the first prototype game that would ultimately turn into the game we know as ‘Zork’ today.

The revolution of Zork was that it could grasp entire sentences due to the strong natural language features of MDL, in contrast to the simple commands of Adventure, where ‘LAMP GET’ and ‘GET LAMP’ were equivalent. It could grasp full sentences, and even multiple sentences (commands) strung together into a single sentence. The strong parser, coupled with the ease of modelling new rooms in an object-oriented style using MDL, meant that after the parser and game engine had been written the world could be expanded practically at will.

A room in Zork could be defined using a simple bit of code like this:

<ROOM "WHOUS"

"This is an open field west of a white house, with a boarded front door."

"West of House"

<EXIT "NORTH" "NHOUS" "SOUTH" "SHOUS" "WEST" "FORE1" "EAST" #NEXIT "The door is locked, and there is evidently no key.">

(<GET-OBJ "FDOOR"> <GET-OBJ "MAILB"> <GET-OBJ "MAT">)

<>

<+ ,RLANDBIT ,RLIGHTBIT ,RNWALLBIT ,RSACREDBIT>

(RGLOBAL ,HOUSEBIT)>

This defines the ‘white house’ from the beginning of the game, along with exits from this room, special properties of exits (e.g. a locked door) and the objects in the room. This ensures that all properties of a room, including its description, short description, properties and tags are in one location. The game engine can then toggle individual tags (bits) on rooms, keeping a central database of all rooms and their current status. Managing which rooms are connected during game design is done using proper names, not numeric IDs in a table.

Smash hit

Suffice it to say, Zork was absolutely fantastic on mainframes. It was ported to the far more widespread DEC TOPS-20 OS for the PDP-10 by popular demand from other interested gamers. Though the Zork developers were generous enough to give the game away for free, they did distribute it as a read-only, encrypted version. They even stored the source code for Zork in a secure folder on the ITS mainframe, for which they had to patch the otherwise fully open and unsecured ITS mainframe OS.

At this time in computer history, there were still relatively few computers in the world. The concept of a home computer was only beginning to take hold, with the introduction of computers like TRS-80 and the Apple II in 1977, though even that system was incredibly limited compared to the mainframes that were being used for text adventures at the time by students around the US. The thought of porting a game like Zork, a 1 MB executable, to home computers seemed rather far-fetched.

While home computers were still scarce, the concept of selling software to regular consumers was also new. This was the time when the Atari 2600 had just gone on sale, starting the second generation game consoles that were expandable to play more that one game through the use of plug-in cartridges. It was a new market, with many questions among MIT, Stanford and other students regarding the open hacker culture versus the world of commercial software. Some, like Richard Stallman, not changing their stance on this much since their student days at MIT.

As the Zork developers were graduating, they realized that with the success of Zork on their hands, they had this one chance to commercialize it, taking their lives and careers into an entirely different direction from their original goals. With little standing in their way, Infocom was founded on June 22nd, 1979.

Now we just have to port it

This only left the tiny little detail of getting Zork from the PDP-10 mainframe systems onto those dinky little home computers; at this point Infocom didn’t actually have anything to sell yet. They mulled various game ideas that could be adapted to work on home computers, but porting Zork just made too much sense. They just had to crack the problem of getting 1 MB of MDL-based game code onto microcomputers with 32 kB of RAM (or less) and relatively anemic amounts of storage.

They also didn’t want to have to port the game separately to the TRS-80, Apple II, or any upcoming new systems. What if one could use the existing MDL source code? This was the start of the design of the Z-Machine, as it came to be known.

Of course, the initial approach to making Zork fit on a microcomputer was to make the game smaller by removing content. After lots of cutting they had something close to the size of Adventure. They then did something similar with MDL, removing all features that weren’t needed for Zork. This created the Zork Implementation Language (ZIL) which they could cleanly port Zork to from MDL. The ZIL compiler was then able to produce much smaller binaries than the MDL compiler.

Looking at the description of Zork’s brass lantern in ZIL we can see that it’s easier to read than MDL:

<OBJECT LANTERN

(LOC LIVING-ROOM)

(SYNONYM LAMP LANTERN LIGHT)

(ADJECTIVE BRASS)

(DESC "brass lantern")

(FLAGS TAKEBIT LIGHTBIT)

(ACTION LANTERN-F)

(FDESC "A battery-powered lantern is on the trophy

case.")

(LDESC "There is a brass lantern (battery-powered)

here.")

(SIZE 15)>

This was great, of course, but this still didn’t make Zork run on a TRS-80. They could at this point of course have written a ZIL compiler for each platform, along with a ZIL runtime, to then spend a lot of time tweaking each game on every target platform. Instead they opted to write this virtual machine: the Z-Machine. Essentially an ideal platform for text adventure games, directly supporting ZIL binaries and also implementing a number of optimizations, most important of which was the packing of characters into 5 bits, reminiscent of Baudot code.

With all of those optimizations, a virtual machine, and a custom programming language, they managed to squeeze the trimmed-down world of Zork I into a mere 77 kB ‘story file’, along with the interpreter (the VM). Since this was still too much to fit into the 32 kB of a mainstream microcomputer of the time, the VM implements a virtual memory system, with just the dynamic data (variables) loaded into RAM and any static data (text) only got read from the floppy disk when needed.

Towards the future

The Apple II had floppy disks with 140 kB capacity, and the TRS-80 had 180 kB, which meant that the space problem had been solved. Only the interpreter needed to be optimized for the target platform, which meant that for all future Infocom games the same interpreter could be used for each and every game that got released, without having to port it to individual platforms.They had more content waiting in the wings from the mainframe version of Zork. They were set for a sequel.

After the commercial success of Zork I, they’d continue to release the parts that were cut from the original mainframe version in the form of Zork II, as well as Zork III. Year over year, the sale of Zork I would keep rising, and it became a must-have game often provided with new systems. New Z-Machine versions were developed that added additional features for even more advanced games.Today we can still enjoy Infocom games without having to worry about compatibility issues: the MDL source to Zork as well as the source for other classic Infocom games have been released. If you haven’t played Zork in a while, or ever, give it a spin and then have a look under the hood. It’s not a stretch to say that a group of hackers at US universities during the 1970s have very likely defined the world of video gaming and interactive story telling.