Zen and the Art of Interactive Fiction

West of House
You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.

That famous white house.Zork was the first text adventure game I played back in the 1980s on my Commodore 64, and those games quickly defined my gaming life for several years.

Several years later I began tooling about with coding languages that made text adventures (or “Interactive Fiction” as they have become known.) At the time there was a very strong IF community that included competitions, and I put together a short game for something called the “Intro Comp” where the challenge was to write a short IF game that would form the introduction to a larger piece of work. My entry was called “Harlequin Girl” and you can still find the game and a review or two lurking on old IF databases.

That game was written ten years ago using the Inform 6 programming language. If you wanted to define a room and an object, the code might look like this:

 Object bedroom “Bedroom”
    with description “You are in the bedroom. It is dark here. You are likely to be eaten by a grue.”;

  Object -> “torch”
    with name ‘torch’,
          description “A red plastic torch with the words ‘EverLight’ printed on a peeling sticker.'”;

Since then, Inform has undergone a major version change. Inform 7 is largely built on Inform 6, but also uses natural language programming. Take our bedroom and torch example from before:

The bedroom is a room. “You are in the bedroom. It is dark here. You are likely to be eaten by a grue.”
The torch is in the bedroom. The description is “A red plastic torch with the words ‘EverLight’ printed on a peeling sticker.”

I remember discussing the concept of a “natural language” programming language when I studied Computer Science. A programming language in general is a way from a programmer to tell a computer what to do. That said, most languages need a complier that takes your source code and converts it to machine code for the computer to understand. A “natural language” programming language was a glassy-eyed ideal where you didn’t have to learn correct syntax and symbols to get the computer to understand you. In theory you could call a spade a spade rather than char a_spade[] = “a spade”;

Like to get started with Inform 7? Here’s your homework for tonight:

I have created a small demonstration called “Zen”. Begin by downloading Inform 7 for your platform.

Once you have it up and running, copy and paste the following code into your “Source” screen, and hit the green “Play” button.

As easy as that.

For further homework, you can use through iplayif.com to embed your game into a webpage. Here is my game Zen ready for everyone to play:

Try clicking after the “>” to get your cursor there, then enter in some commands like “look” or “open door.” The game is winnable; all you have to do is exit the cell through the stout wooden door.

At this stage, Zen hasn’t had a beta test with other players, so there is probably a few gameplay quirks that I haven’t considered. I’ll be updating the Zen code as these come to light. Future updates will be available through this blogpost and through my GitHub Zen repository.

Leave a Reply

Your email address will not be published.