Inform 7 -- Create Text Adventures via Natural Language
When I bought my first computer, text adventures like Colossal Cave and Zork were my favorite games. While "interactive fiction," as modern text adventures are called, are no longer commercially viable in this age of games with film-like graphics (and budgets), a large number of free text adventures are published by fans every year -- hundreds are available at The Interactive Fiction Archive. Most are forgettable, but there are a number of good games and a few true gems such as Curses!, So Far, Anchorhead, Photopia, Varicella, Galatea, and Slouching Towards Bedlam. There are quite a few specialized programming languages developed just for writing text adventures. Unfortunately, they all require a lot of programming (and programming knowledge) to produce even a short mini-adventure. Until now. Until Inform 7.
Earlier versions of Inform were standard, complex programming languages that produced games that run on the "Z-Machine" -- a modern version of the virtual machine that Infocom used for their games (Zork, Deadline, etc.) Inform 7 branches out into a new direction: natural language programming. Here's how the Inform 7 web site describes this new version:
Three years in the making, Inform 7 is a radical reinvention of the way interactive fiction is designed, guided both by contemporary work in semantics and by the practical experience of some of the world's best-known writers of IF.
In place of traditional computer programming, the design is built by writing natural English-language sentences:
‣ Martha is a woman in the Vineyard.
‣ The cask is either customs sealed, liable to tax or stolen goods.
‣ The prevailing wind is a direction that varies.
‣ The Old Ice House overlooks the Garden.
‣ A container is bursting if the total weight of things in it is greater than its breaking strain.
Inform's power lie in its ability to describe: to lay down general rules about "closed doors", or "bursting containers", or "unmarried men liked by Martha". At its best, expressing IF in natural language results in source text which is not only quick to write, but very often works first time, and is exceptionally readable.
An easily learned but flexible one-window user interface makes the cycle of writing and testing rapid and painless. Inform creates, manages, edits, indexes, tests, and even helps to publish works of IF without fuss or screen clutter.
Inform 7 actually translates a very limited and somewhat stylized version of English to the Inform 6 programming language and compiles that, but it all happens behind the scenes. While the language reads like English and is very clear to read, it has many limitations which make some aspects of writing interactive fiction in Inform 7 still more akin to programming than to writing prose, but Inform 7's natural language is much easier to learn and to use than any other interactive fiction language I've tried in the last ten years. You have to think like a programmer much of the time, but you no longer have to deal with all the complex details of a standard programming language.
To be honest, Inform 7 has allowed me to actually write a complete, working mini-adventure for the first time. It handles all the boring scut work behind the scenes, so instead of writing classes and coding everything step-by-step, I could just write the adventure. Here is the Inform 7 code for my simple adventure:
"Clean Up" by Randall S
When play begins: Say "Your spouse has sent you out to the back lawn to put the garden tools back in the tool crate. The gardener has disappeared -- probably ran off with that odd-looking, but beautiful woman he had been seeing -- and you have yet to hire a new gardener. As there is no one to care for the ganden at the moment, obviously, according to your spouse, it is your job to clean the mess the missing gardener left. You'd just leave it for whoever you hire, but your spouse is fussy. Let's see. It looks like three tools are missing. It's time to..."
The Tool Shed is a room. "You are at the Tool Shed, a small plastic building about the size of a small closet. The back lawn surrounds the shed to the north, south, east, and west."
The wood-slatted tool crate is in the Tool Shed. The crate is a closed openable container. Instead of taking the crate, say "It's far too heavy to lift." The description of the tool crate is "A large crate-like wooden box with a sign that reads 'Garden Tools.'"
The East Lawn is a room. The East Lawn is east of the Tool Shed. "A large expanse of well-maintained green grass. You notice the Tool Shed to the west."
The West Lawn is a room. The West Lawn is west of the Tool Shed. "A large expanse of green grass with a few ugly weeds spouting here and there. You notice the Tool Shed to the east."
The hand rake is in the West Lawn. The description of the hand rake is "A small green hand rake best used for weeding gardens."
The North Lawn is a room. The North Lawn is north of the Tool Shed. "A large expanse of well-maintained green grass. You notice the Tool Shed to the south and more lawn and a large pile of dirt to the north."
The Far North Lawn is a room. The Far North Lawn is north of the North Lawn. "A large expanse of mostly healthy green grass. The grass around a pile of dirt is sickly looking. A hole has been dug in the lawn by the pile of dirt. You notice a strange odor coming from the dark pit, it reminds you of rotten eggs or perhaps burning sulphur. Looking in the pit, you can't see anything that could be causing the stench, but with the pile of dirt blocking the light, you can't even see the bottom. You can still see the Tool Shed far to the south."
The Smelly Pit is a room. The Smelly Pit is down from the Far North Lawn.
Instead of going from the Far North Lawn to the Smelly Pit: say "Jumping into a dark pit is a bad idea. Especially when you can't see the bottom, or even that it has a bottom. You fall for a long time. Eventually you land in Hell."; end the game in death.
The small shovel is in the Far North Lawn. The description of the small shovel is "A very small shovel that looks like it is better suited for backpacking than for gardening, let alone for digging an apparently deep pit."
The South Lawn is a room. The South Lawn is south of the Tool Shed. "A large expanse of weeds. It looks like there once was a nice lawn here, but that was apparently some time ago. You notice the Tool Shed to the north."
The weed eater is in the South Lawn. The description of the weed eater is "A nice looking new electric powered weed eater."
Before inserting the hand rake into the wood-slatted tool crate, award one point.
Before removing the hand rake from the wood-slatted tool crate, award -1 point.
Before inserting the weed eater into the wood-slatted tool crate, award one point.
Before removing the weed eater from the wood-slatted tool crate, award -1 point.
Before inserting the small shovel into the wood-slatted tool crate, award one point.
Before removing the small shovel from the wood-slatted tool crate, award -1 point.
if the score is greater than 2, end the game in victory.
Note: To use this code in Inform 7, you'd probably need to replace the fancy quotes with plain ascii quotes.
Yes, "Clean Up" is an extremely simple text adventure -- even for a mini-adventure. However, it only took me 60 to 90 minutes to write and test. And that was with have to look up how to do things in the manual and examples as I wrote it. Since the early 1990s, I've spent days at a time playing with Inform 6, Alan, TADS, and other interactive fiction programming languages and never produced a complete, playable adventure -- even one as limited and simplistic as this one. Ever since I played Colossal Cave back in the late 1970s, I've always wanted to write my own text adventure. Thanks to Inform 7, I finally have.
If you have any interest in interactive fiction or natural language programming, you will want to take a look at Inform 7. Here are some reviews and articles on Inform 7:
- Introducing Inform 7
- Natural Language Game Programming with Inform 7
- Beginner's Guide to Interactive Fiction with Inform 7
- Some Observations on Using Inform 7
Operating System: Windows 95 or later, Mac OS X, Linux
Version: 7 release 4F59
Web Site: http://www.inform-fiction.org/I7/Inform 7.html
[tags]Inform 7, interactive fiction, text adventure, programming, writing interactive fiction[/tags]