An Introduction to Gnome Inform7, Part 1
What is interactive fiction?
It all started in 1975 with a man named Will Crowther who wanted to create something for his daughters that tied together two of his loves: role playing games and cave exploration. The result was a game called "Adventure" (also sometimes called "Colossal Cave"). He wrote the game on the mainframe he used at work and while his daughters loved it, others who discovered the game did to, and they shared it far and wide. Stanford student Don Woods discovered the program on one of the university computers in 1976 and with Crowther's permission extended the Fortran original, adding more rooms and treasure. This expanded version was later ported to C and from there to countless platforms and languages. You can still download various versions of it today.
To make it easier for novice users to use, Crowther programmed the game to understand and parse natural language commands like "unlock grate", "get key", and "go north".
Adventure was a landmark in computing history. It gave us the term "xyzzy" and the phrase "you are in a twisty maze of passageways, all alike" among other things. It proved that stuffy mainframes could be fun and exciting. It also inspired Dave Lebling, Marc Blank, and Tim Anderson, who all worked together at MIT to create their own adventure game in 1977, which they called "Zork". They then worked with some of their colleagues at MIT to create a company called Infocom, which became the undisputed king of the style of game that came to be called "text adventures" or "interactive fiction".
At first, both Adventure and Zork were designed to work on mainframes. Infocom wanted to find a way to port Zork to the new personal computers, such as the AppleII and the TRS-80 that were arriving on the scene. The method they came up with was to create a sort of virtual machine that all of their games were written for. They called it the Zork Machine (Z-Machine for short). They then wrote a "Z-Machine Interpreter Program" or ZIP for each computer platform they wanted to support. With the ZIP built for several different platforms, Infocom was able to release their games simultaneously on dozens of different platforms. For example, the box for Zork III lists the following system requirements:
For your: Apple II, Macintosh, Atari, Commodore 64, DECmate, DEC Rainbow, DEC RT-11, HP 150 & 110, IBM PC* & PCjr, KAYPRO II, MS-DOS 2.0*, Osborne, TI Professional, TI 99/4A, Tandy 2000, TRS-80 Color Computer, TRS-80 Models I & III.
* Use the IBM PC version for your Compaq and the MS-DOS 2.0 version for your Wang, Mindset, Data General System 10, GRiD and may others.
This wide availability gave Infocom tremendous advantages in the marketplace and during the early days of the 1980's, Infocom was the darling of the PC games industry. They released hit after hit and it seemed as if they could do no wrong. But during the late 1980's, two problems arose that proved their undoing. The first was that computer graphics started coming into their own. Characters in computer games actually started to become recognizable instead of just being little square blocks on the screen. Even worse than the transition from textual to graphical games was that some of the people managing the company didn't want to be in the "games" business at all. They wanted to be taken "seriously", and so they funnelled large amounts of money and manpower into a business database program called "Cornerstone". The database flopped, spectacularly, and it wasn't long before Infocom was bought, and subsequently killed.
As Infocom was dying, several different groups of text adventure enthusiasts were hard at work building a community around interactive fiction by creating text adventures of their own and by reverse-engineering the Z-Machine. The InfoTaskForce managed to decode the format of Z-Code files and succeeded in creating a public domain version of ZIP, making it possible to play Infocom titles on any computer system you wished. A couple of news groups were also created on usenet during this time that provided a community for people to belong to, whether they just wanted to play the games (rec.games.int-fiction) or to write them (rec.arts.int-fiction).
These enthusiasts created their own environments to create and play interactive fiction. But then, in 1993, Graham Nelson released the first version of the Inform programing language and its associated compiler. The benefit that Inform had, and still has, over competing text-adventure systems such as TADS and AGT, is that games written in Inform and then compiled come out as standard Z-Code files, and are compatible with Z-Machine interpreters that exist on just about every computer platform on the planet from mainframes, to desktop computers, to Gameboys, to cell-phones and iPods.
Like many programing languages, since its initial release Inform has gone through several different versions to the point now where the games you can create with it can be much more advanced than the best of Infocom's work, and at the same time, much easier to create.
The latest version of Inform is version 7. It was originally released along with a custom-built integrated development environment (IDE) specifically designed for creating interactive fiction. This new IDE orginally ran only on the MacOS X platform, but it has since been ported to both Windows and Linux. The Linux version is called Gnome-Inform7.
Getting and installing Inform7
You can download Gnome-Inform7 from the SourceForge download page (see the links section). There are packages for several different distributions, and the source code, if you want to compile from scratch.
I use Ubuntu, so I downloaded the Ubuntu specific version.
Once downloaded I installed it from the command line like so:
sudo dpkg -i gnome-inform7_5T18-ubuntu1_i386.deb
The Ubuntu specific version is built for Ubuntu 8.04 "Gutsy". If you are using an older version of Ubuntu, the Debian is what you want. Also, when installing the Debian packages with dpkg, if the install fails with missing dependencies, just issue the following to resolve the missing dependencies and finish the install:
sudo apt-get -f install
The above command tells apt to fix (-f) the missing dependencies and complete the install.
On my Ubuntu machine, Inform7 put a launcher into my Applications > Programming menu. Alternatively, you can launch the program from a terminal with "gnome-inform7".
Creating a simple game using Gnome-Inform7
In order to give you the flavor of what creating a text adventure is like, I'm going to step through the creation of a simple game. Ok, "game" is probably too strong a word, but it is a functioning example. To get the most out of it, install Gnome-Inform7 and follow along.
When you first start Gnome-Inform7 it prompts you to either open up an existing project, open the last project you had open, or to create a new project.
There is a bug in the program that prevents you from quitting Gnome-Inform7 from this splash screen (if, for example, you launched the program by mistake). The only way around the bug is to kill the program (via the kill or xkill commands) or to select one of the options and follow through until the main interface opens, whereupon you can quit normally. It's an annoying bug, but it is the worst one I have encountered when using Gnome-Inform7, and it is fairly easy to work around.
When creating a new project there are options for four different project types: an Inform7 project, an Inform7 extension, an empty Inform6.3 project, or an Inform6.3 project with one room. The two Inform6.3 project types are just placeholders for now, so the only real options are the two Inform7 project types.
For my example project, we'll go with an Inform7 project and click the "Forward" button. In the Inform 7 Project window you then select where you want to save the project, what to call the project, and the name of the author. I'm calling the project "The Server Room". Feel free to call it whatever you wish.
After clicking on the "Apply" button, the Inform 7 integrated development environment will appear.
When a new project is initially saved, Gnome-Inform7 creates a project directory named the same as the name for your project with a .inform extension. Inside this directory is the actual source for your game (the story.ni file in the "Source" subdirectory) and the other various files that Gnome-Inform7 uses.
The Gnome-Inform7 IDE is organized into two panes. The tabs for each pane are: Source, Errors, Index, Skein, Game, Documentation, and Settings. By default, Source is displayed in the left pane, and Documentation in the right. You can also vary the relative width of each pane.
To find out the purpose of each of the tabs, consult the Inform7 documentation. The documentation built into Gnome-Inform7 is excellent --- there a lots of examples and tutorials that cover every aspect of creating interactive fiction.
In the source pane, if you're following along, you'll see that the first line of code has been inserted for you. It should say"
"The Server Room" by "your name"
A "Name of Game" by "Author Name" line starts every Inform 7 game and under this line we will set a few options for ours.
The first is to include an extension to allow us to easily license this game and any future games under the GPL. Extensions are a big part of Inform7 and there are several built into Gnome-Inform7. To see which extensions are installed, click on the "Installed Extensions" link in the Documentation tab. Unfortunately, the GPL extension is not included in Gnome-Inform7 by default. To install it we first have to download the extension from the Extensions page of the Inform website:
The GPL extension is in the "Publishing" section. Click on the little graphic next to the name of the extension and the source of the extension will be displayed in your browser. Save the file to your Desktop, or another location of your choosing. The file should be named "GNU General Public License v3" and be saved as a plain text document. Then, from Gnome-Inform7 choose "Install Extension..." from the file menu, navigate to the file you saved earlier and open it. The extension will then be installed and will show up in the "Natural Inform Extensions" section of the Extensions tab in the Inform 7 preferences window (which can be accessed from the Edit menu). Any other extensions you manually install will also show up here.
Unfortunately there is a small typo in the version of the extension that I downloaded. The fix is easy though. First we need to open the extension by choosing "Open Extension" from the File menu and choosing the extension. With it open, search for the following line:
GNU General Public License v3 by Free Software Foundation ends here.
Take out the "by Free Software Foundation" part of the line so that it reads:
GNU General Public License v3 ends here.
Save the file, and the extension will now compile properly.
To include the extension in our example game, put in the following line:
Include GNU General Public License v3 by Free Software Foundation.
Next we will make a couple of modifications to our world:
The maximum score is 6.
Understand "lift [something]" as taking. Understand "steal [something]" as taking.
The first sets the maximum score possible to six and the next defines a couple of synonyms for the "take" action.
Now let's put in some flavor text to print out when the game begins:
When play begins, say "It's Saturday, a nice one at that, and you've been called in to fix a server that's on the blink. [bold type]Again.[roman type]
You've had it. This server is going to run Linux from this day forward! The process will be easy - just put the disc into the server and away we go. Now where is that custom Ubuntu disc?"
Basically, the above code prints out a little bit of text to "set the stage" for the game. In some games these sections are long, in others not very long, or non-existent. Don't worry about the [bold type] and [roman type] tags now, we'll go over them later.
We are now ready to create our first room. In interactive fiction the game world is defined in terms of "rooms" and how they connect together. In this example game there are five rooms:
The green rooms are the ones that the player will actually be able to enter, and the gray rooms are rooms that technically exist, but which we won't allow the player to enter. It is a good idea to always sketch out how your rooms connect together so that you can refer to it when writing.
Here is the room the player will start in:
The Break Room is a room. The description is "Your standard break room. A fridge, and a long counter take up one wall. East is the outside world and west is the hallway to the server room."
As you have probably noticed from the code we have entered so far, Inform 7 code is entered as natural sentences. This is to help make writing interactive fiction as similar as possible to writing plain old non-interactive fiction. It can't always succeed, but once you get the basic rules under your belt writing in Inform 7 becomes very natural. In fact, when I want to do something in Inform 7 that I haven't done before, I often guess at what the "code" should be, and often the guess will work and if not, the error messages are informative, and the documentation is just a click away.
We are now at a point in writing this example where we can test what we have so far. To do this, click on the "Go" button. Assuming there aren't any typos, the code should compile and you the Documentation pane should automatically switch to the "Game" pane.
Since there is only one room, you can't go anywhere. To test this, type "go north" at the prompt (or just "north" or "n"). The game should reply with "You can't go that way." You can also try all of the other compass directions (east, west, south, northeast, and so on) and try going up and down. You'll fail in every attempt, but it does illustrate how Inform makes things easier --- there are a lot of built-in behaviors and actions (all of which you can change) that are ready to go before you do anything.
I hate to leave the game in an unfinished state like this, but we're out of time. Don't worry, next time we'll flesh out the world a bit, add some objects and some more rooms, and make this game winnable.
History of 'Adventure'
History of Infocom
Wikipedia Entry on Interactive Fiction
The Inform Website
Limited Time Offer
Take Linux Journal for a test drive. Download our September issue for FREE.
Topic of the Week
The cloud has become synonymous with all things data storage. It additionally equates to the many web-centric services accessing that same back-end data storage, but the term also has evolved to mean so much more.