How to write interactive fiction games on Windows or Mac
My first computer was a Sinclair ZX80, followed rapidly by a ZX81, a Commodore PET and a BBC Micro, which I bought second-hand and that was missing the heatsink from its CPU. I got around the overheating problem by running it with the top off and a glass of cold water balanced on the chip. Ah, the innocence of youth.
Back then, computer games either had pathetically basic graphics or were entirely text-based. In the latter category were what we called “adventure” games, and which are nowadays more generally known as interactive fiction (IF).
I suffered a bout of nostalgia recently and wanted to revisit some of those old games but, of course, I no longer own that BBC Micro. It turns out that isn’t a problem, because there’s a thriving community of IF enthusiasts who’ve created interpreters capable of playing all these old games, and they’ve even created systems that enable you to author your own titles.
There’s a thriving community of interactive fiction enthusiasts who’ve created interpreters capable of playing all these old games
The standard way that IF games are written is by employing a virtual machine called a Z-machine, which was originally written back in the late 1970s by Infocom, the main company in the IF world at that time.
The Z in Z-machine in fact stands for Zork, which was the company’s first famous adventure game. Infocom took this virtual machine approach because there were so many different types of personal computer around at that time, so by writing a Z-code interpreter for each new platform the company could immediately make all its products available on that platform. That’s great news for us now, because it means that to play all of these old games, all you need do is implement a Z-code interpreter for your particular OS (or, perhaps more realistically, hope that someone else has already done so).
This, as it turns out, is very likely because there are Z-code interpreters for Windows, Mac OS X, Linux and pretty well any platform that you’re likely to be using. The key ones are, of course, open source. If you’re using a Mac the gold standard is Zoom, which supports not only plain-text games but also adventure games with graphics. For Windows folk, Frotz is probably your best option, and there’s even a port of Frotz for the iPhone and iPad, so you can play your games while you’re out and about.
The interpreter itself is of no use without games, of course, but you can find the old Infocom games online very easily, although the legality may be slightly questionable. You might also still be able to buy a compilation of the games that Activision released in the 1990s (Infocom was taken over by Activision in 1986, but it abandoned the Infocom trademark in the early 2000s).
Should you happen to download or buy one of these games, you’ll find that you need to rename the data file, whose name ends in DAT, so that it ends in Z8. Once you’ve done that, you’ll be able to open it in Zoom or Frotz and immediately start playing.
There are also many IF games that have been written by other people, and the best place to look for these is The Interactive Fiction Database, which is a searchable archive. From there you can download the games, and most of them work in Zoom or Frotz since they’re written in Z-code. If you want to create your own game, you can do that too, thanks to a program called Inform that runs on Windows, Macs and Linux.
Game development is interesting as you really don’t need to be a programmer at all: Inform’s “language” is very similar to standard English and the interpreter then translates that into Z-code (or into another similar bytecode called Glulx, which is more suitable for games that include multimedia content).
It takes a while to get the hang of writing games using Inform but you’ll be creating mysterious worlds to your heart’s content soon enough. An interesting application of Inform, as well as Zoom and Frotz, is letting teachers create games that their students can use, which can be used to improve reading and problem-solving skills – if you’re a teacher who’s done this, or who hadn’t considered it until now but is going to give it a try, I’d love to hear your experiences.