Creating interactive fiction with Inform 7

closeHey, just so you know ... this post is now about 12 years and 11 months old. Please keep that in mind as it very well may contain broken links and/or outdated information.

If you owned a personal computer in the 80s and played computer games, you probably played at least one Infocom text-based adventure game like Zork or (my personal favorite) The Hitchhiker’s Guide to the Galaxy. Known as interactive fiction, or IF, these games used the most powerful computers on the planet for their processing engines … your imagination. Instead of fancy color graphics and digital sound effects, Infocom games were just white text on a black screen controlled by you typing in commands like “go north” or “examine the small box” and usually involved solving complicated puzzles to win.

I’m actually a little surprised I haven’t written about IF before on this blog considering how fond I was of playing Wishbringer or Moonmist on my Atari 800XL back in the day. Even my daughter had even gotten into playing IF games on my iPad with Frotz. She’s an avid reader and also loves playing games, so IF games are a natural fit for her. Back in late August I decided I wanted to try my hand at writing her a personalized game which eventually evolved into the idea of making the game a scavenger hunt of sorts for her birthday in December. That gave me about four months to plan, design, write, and test the game.

The first thing I did was to download Inform 7 and start reading the documentation. Inform is a natural language design system for IF games which makes it pretty easy to learn. In almost no time at all, I was creating the rooms of our house, writing (a LOT of!) descriptions, linking rooms with exits, and creating objects.

The screenshot above shows the basic Inform interface. On the left-hand side is my source code and the right-hand pane is showing the running game for testing. Tabs along the top of each pane allow you to quickly switch between different views, like the skein (a flowchart of in-game commands you’ve run, showing the branches), the map, compilation errors, etc.

Inform’s syntax is extremely flexible, allowing for the simplest definition of objects and rooms to more complex actions like wandering NPCs, conversation tables, almost anything you can think of. The Inform web site contains an impressive library of user-contributed extensions: re-usable modules of code you can include in your own to add features like locking doors (with keys), vehicles, or even writing games in different languages (like Spanish) which let you avoid writing all of that code from scratch.

Over the next few months while I worked on developing the game, I made extensive use of Inform’s built-in help system, code examples, and also participated in the Interactive Fiction Community Forum whose members were very helpful when I got stuck on a particular coding problem or needed advice on how to approach something. At last, I was ready for testing so I “released” my game and published it on my Dropbox account using Quixe, a javascript-based IF interpreter. This made it easy for my play-testers (my brother, sister, and sister-in-law) to play the game without needing to install their own Z-interpreter like Frotz plus I was able to quickly re-publish new builds as I made corrections or changes to the code.

Finally, it was December and time for the game to be released for real. I put the final game into Frotz on my iPad told her I found a new IF game I thought she’d enjoy. Her reaction, once she realized she was playing a game as herself in her own house, was priceless, and well-worth the months of effort it took to write. Unlike my play-testers who had a hard time with some of  my puzzles (since a) they were new to IF games and b) the game was tailored for a young girl), my daughter blew through the game in just under a day and completed the scavenger hunt, laughing almost the entire time. Lucky for me she missed some of the non-critical puzzles so the game still has replay value. She has even expressed interest in writing her own IF game, which is pretty cool.

Of course, my new coding challenge is now … how do I top this for next year? 😀

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *