Natural Language Game Programming with Inform 7

Programming games is an activity. A programming language is a kind of thing. Inform 7 is a kind of programming language. It is either the single-most important advance in interactive fiction in a decade, or an interesting idea doomed to fail. —Liza DailyNatural Language Game Programming with Inform 7 (OnLamp.com)

I’ve been teaching myself Inform 7 by translating, room by room, object by object, conversation tree by conversation tree, a work-in-progress that I started in Inform 6 in 1998 (when my CD-ROM drive died and I had to go retro in order to have any fun).



I’ve been taking a break from my Half-Life 2 modding, having first played with The Games Factory and Game Maker (point-and-click tools for creating arcade games).



One of the early benefits of interactive fiction (during the 80s) was that a company’s back catalog of text adventure games didn’t go stale as quickly as the arcade/graphics-heavy games, because the new year’s text adventure games looked pretty much like last year’s, at least to the customers in the store.



That was also part of commercial IF’s downfall, since improved parsers and a more realistic world model didn’t necessarily always translate into an obviously better product (or better sales). Infocom and Adventure International streamlined the production process, so that their designers could churn out decent products more efficiently (reusing code and architecture). But a brilliantly-executed NPC, a greater number of in-game objects, more complex behavior — these developments in the IF medium weren’t immediately visible.



By the mid 80s, text-adventure games were regularly incorporating images, but the point-and-click graphical adventure made the hybrid obsolete.



In the best history of Infocom I’ve seen, a student project from MIT, the authors note that Infocom’s developments were evolutionary, rather than revolutionary. Consumers simply didn’t notice improvements in IF as quickly as they noticed improvements in graphics and sound.



TADS is an adventure programming language that includes support for hyperlinks and a robust world model, an Inform game and a TADS game and a Hugo game and an Alan game all pretty much look the same.



While I haven’t seen what kind of an IDE these other folks might have come up with recently, Graham Nelson’s Inform 7 is a beautiful piece of work.



Recent developments in interactive fiction — more complex NPCs, self-conscious tension that works against the conventions of the medium (and explores new ones), and literary aspirations — still depend on textual transactions that occur in a world in which the game can say “there is a bunkbed here” but refuse a command such as “examine bed” because the author didn’t think of “bed” as a synonym for “bunkbed.”



Computer users today are used to textual chat sessions with real people who understand typos and emoticons. They’re not as willing to work hard to make the computer understand them. Short of dumbing down IF games though the inclusion of a “Clippy” character who tells you exactly what you should do (Nick Montfort beautifully spoofs that idea in his game “Book and Volume”), there is little an IF author can do to get around that barrier.



Novels are long, heavy metal is loud, operatic performance is bombastic, and text adventure games force you to think. Of course, some novels would be better if they were shorter; but IF games that include random puzzles (such as the obligatory maze) can be downright annoying. I like dialogue trees and long NPC conversations, but only when the “He doesn’t have anything to say about that” messages, or other features within the game, give you some hint as to what you’re supposed to be doing. Other IF players prefer puzzlefests, and dismiss the more literary works as pretentious. One-room mind-benders that call for numerous replays, rich landscapes, and the quality of the error messages are among the other criteria IF players consider.



Will Inform 7 inspire a rush of great new IF games? I don’t know.



IF design requires both writing talent and programming ability. An extremely well-written game that didn’t ask the player to do something interesting and unusual would be very boring. And, while it should be very easy for non-programmers to create rooms and scenery to explore, you sill have to think like a programmer in order to add any complexity to a world built with Inform 7. Further, I7 is in beta right now, so there’s a real possibility that code I’m writing now will be broken by the time the final release comes out. (I’m more than willing to risk that.)



On the surface, contemporary IF looks exactly like the classical stuff (from the 1980s). And a significant handful of amateur authors is today producing IF works that easily outshine those created by professionals working during the medium’s commercial heyday.



Those professionals didn’t have Inform 7.



We do.



I’m still only beginning to understand all the features of the new system.



Daily puts her finger on a problem I’ve been facing: “Note also that there are no procedure names; there is no reason to name a function when you can instead describe the conditions under which to call it.”



So much of the code I wrote for I6 is simply there to produce pretty paragraphs of prose that describe events in the real world. But in Inform 7, you can make complex decisions right in the output text, like this:

After dropping the priceless fragile vase:



say “The vase shatters into a zillion worthless pieces. Scattered amidst the shards are [is/are list of things in the vase].”

Of course, you’d still have to create the code that handled destroying the vase itself, and moving its contents to whatever place the vase occupied before it was destroyed, but that’s easy. What takes so much time in IF is presenting, in human-readable prose, a representation of the changing status of the game world. Here, the “is/are” automatically chooses the right verb based on whether the “list” results in one or more items. (Though here, Daily’s example is incomplete. First, there’s an “are” that’s hard coded in text, so you might get “is are” or “are are,” and further… what if the vase was empty?)



I can’t wait until I’ve finished translating my existing code, so that I can get away from thinking in terms of the functions and procedures that make up my I6 code, and start really exploring the close connections between the output text and the code in I7.