Jump to Navigation

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.

Every turn:
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:

Rating: 5.0
Operating System: Windows 95 or later, Mac OS X, Linux
License: Freeware
Price: Free
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]


Please contact me at chicken_bicken9147@hotmail.com

The 'before jumping out at soldiers and 'to jump out at soldiers' have things wrong with them and i dont know jow to fix them, because when i had it as 'Instead of going from south forests to far southern forests: Say "blah blah blah"; end the game in death and if you enterd this area you no matter what died, how do i fix this?

"Green" by ~Fubb

When play begins: Say "In the land of Aesriel, far to the south of the Great Forests, there is a farm, where a boy lives alone in. This boy is one of two people that holds the power to unlocking a secret crypt that could either save the world, or destroy it..."

The Farm House is a room. "Your bed is at the far end of the farm house and the kitchen is in the middle of the room. A Fire place lays in the corner comfortabily, and rays of warm sunlight shine in through the windows and roofs."

The Yard is south of the Farm House. "Your greeted by warm wind as your enter your yard, eyeing the surrounding forests and fields of yours. Something could be heard in the bushes to the far south."

The Forest Edge is south of the Yard. "Trees are scattered about here as they get thicker farther south into the forests, sounds can be heard here. The Yard and Farm House are north of here."

The South Forests is south of the Forest Edge. "Trees are thicker here, and your farm house has almost dissapeared from site. Noise can be heard from the south and the forest edge, the yard, and your farm house are north from here."

the Far Southern Forests is south of the South Forests. "A Band of soldiers is here, trudging through the bushes on there way north, you hide behind a tree carefull not to get caught. It appears they are going to your home. If you run back now you could easily pack up all your bags and make an escape, though if you jump out to surprise them, you will surely die."

The Soldiers is a person. "The soldiers are heavily armed, in silver armour, and there is a hooded men leading them."

If jump out at soldiers: Say "You jump out at the pack of soldiers and yell at them, only to be cut down by a well-aimed arrow to the heart."; end the game in death.

before going to the Farm House, award one point.

before jump out at soldiers, remove one point.

Every turn:
if the score is greater than 0, end the game in victory.

The best place to get help with Inform 7 is rec.arts.int-fiction. The creator and many far more knowledgable people than myself hang out there.

Main menu 2

Blog | by Dr. Radut