Brass Lantern
the adventure game web site


Introducing Inform 7

by Stephen Granade

The Language

There are three parts of the I7 language that deserve highlighting: the natural language, rules, and relations. I'll also mention the library and how I7 allows you to group things together, though those are, to my mind, of lesser import.

Natural Language

I7's language is a subset of English. Graham Nelson's guiding principle in designing I7 was that "the natural language in which to write interactive fiction is natural language." Despite this, I7 does not use natural language, but a subset of it. It's very similar to IF's in-game parser in that way: there is the promise of the system understanding anything you type, when in reality it understands only certain phrases and constructions.

One of the major benefits to the natural-language approach is that, if you're familiar with IF conventions, you can look at I7 code and make a guess about what's going on with a good chance of being right. Consider this example from the I7 manual:

Instead of doing something other than looking, examining or waiting in the presence of the Queen: say "I'm afraid they take what you might call a zero tolerance approach to court etiquette here."; end the game saying "You have been summarily beheaded".

You might not be able to come up with that code on your own, but you can easily tell what it's doing. Note also that the code is a perfectly acceptable English sentence, semicolon and all. Defining rooms, connections between rooms, and simple objects is straightforward.

The Tombs Outside Ostia is a room. "Walls, or the remains of them, box you in on all sides. Wind whistles through the head-height niches in some of the structures. Underneath your feet loose stones crunch. In the southwest corner the walls are low enough and the dirt piled high enough that you could scramble out."

Southwest is the Capitolium.

In the Tombs Outside Ostia is a container called the burial niches. The description of the burial niches is "Burial niches, according to the poorly-photocopied sheet you read back in the Welcome Center. They are just deeper than you can reach."

This short example sets up a room, gives it a description, connects it to another room, and adds the niches as a container.

If you examine the above code examples, you can begin to see how I7 uses parts of speech. To use the terminology of other IF languages, nouns are objects or classes (depending on whether they're proper nouns or not), verbs are functions, adjectives are functions which return true or false, and prepositional phrases perform tests.

In service to the natural language approach, I7 minimizes the explicit names you need to give. So, for example, you don't give functions or rules names unless you need later to refer to one explicitly. This is similar to how TADS 3 allows you to define anonymous objects and callback functions.


Most everything I've talked about so far define the stuff that makes up the game world, things like rooms and chairs and burial niches. To define what happens in the game, we turn to rules. A rule is defined by the situations in which it applies and the actions that occur when it does apply. For instance,

When play begins: change the right hand status line to "Score: [score]".

The above rule applies only when the game first starts, and changes how the status line works. Many rules are attached to actions—verbs in the source code, such as take or look. These rules often take the form of Instead, Before, and After rules. Instead rules replace the action that would normally happen. Before rules are triggered before an action takes place, and After rules unsurprisingly happen after an action occurs.

Instead of picking up the can of sterno, say "It is too hot to touch."

Before reading the newspaper for the first time, say "(first unfolding the newspaper)".

After taking the diamonds: say "Your score has gone up five points!"; award 5 points

Having all of these rules is well and good, but if rules are in conflict, which one is followed? Precedence is defined first by specificity. A rule that applies only to a single object, like the rocking chair, takes precedence over a rule that applies to a broader set of objects, like all chairs. If two contradictory rules are equally broad or equally narrow, then the rule that was defined later in the source code takes precedence.

You can get an idea of the power of rules by looking at the I7 Standard Library, which contains the rules for reachability, for darkness, for printing the names of rooms, and more. After you've looked at the library you can lie down and take deep breaths until you've regained your equilibrium.


I7 allows you to define relations: a question about two objects that can be answered "yes" or "no." Relations are a framework for defining how two items in the game world can be related. It's a generalization of standard two-item interactions such as containment. Relations are binary in nature, since they're yes-or-no questions; the relation is either true or false. Relations can be physical in nature:

The pigeon is on top of Admiral Lord Nelson.
The Lone Ranger is riding Silver.

They can represent emotional states:

The Sheriff of Nottingham hates Robin Hood.

You define new relations as verbs, which you can then test for in rules:

If the metal detector can detect a metal object which is carried by the player...

Relations could be used to implement a simplified form of a TADS 3-like simulation of senses, where sounds can be heard down hallways and a storm lantern can be seen inside a glass box.

Next | 1 | 2 | 3 | 4

About Us | Contact Us | Technical Info | History
Copyright © 1997-2010, Stephen Granade.