Brian Slesinsky's Weblog
 
   

Saturday, 06 May 2006

Fun with Inform 7

"Hello, Hobbit" by Brian Slesinsky
 
Part 1 - Definitions
 
A hole is a kind of room.
A Hole in the Ground, a nasty dirty wet hole, and a dry bare sandy hole
  are holes.
A hobbit is a person.
A hobbit-hole is a kind of hole.
 
Part 2 - Introduction
 
In a hole in the ground is a hobbit.
A nasty, dirty, wet hole contains ends of worms and an oozy smell.
A dry, bare, sandy hole contains nothing to sit down on or eat.
A hole in the ground is a hobbit-hole.
"That means comfort."

The above text is the (somewhat contrived) source code for a simple text game written in a new programming language, Inform 7, whose public beta was just announced last week. Here's a transcript from running the game:

Hello, Hobbit
An Interactive Fiction by Brian Slesinsky
Release 1 / Serial number 060506 / Inform 7 build 3K56 (I6/v6.30 lib 6/10N) SD
 
Hole in the Ground
That means comfort.
 
You can see a hobbit here.
 
>take hobbit
I don't suppose the hobbit would care for that.
 
>

As you can probably tell, Inform 7 is a radical departure from conventional programming languages. It's meant to allow people to write games in a language that's a subset of English. It's too soon to say how useful it will be for real games, but the signs are good. Several games were written as part of designing the new language, and its test suite was written by one of best writers in the small but dedicated interactive fiction community, Emily Short.

Text games are a strange niche where the usual rules of programming languages don't apply. Text and logic are intimately connected, making them very difficult to write in a conventional programming language without losing sight of the story you're trying to tell. Almost all text games are already written in domain-specific languages.

The IDE (available for Mac and Windows, Linux programmer wanted) is pretty innovative too:

Screenshot of Inform 7 IDE

It automatically records a transcript every time you run the game, and you can re-run the game to any point in any transcript by double-clicking. It also lets you "bless" a transcript and highlights any difference from it, so you can easily see if you have a bug. You can even write the transcript first and then implement the game to match it. The only thing that seems to be missing is a way to re-run all your blessed transcripts. Even so, it's an amazing development environment.

I've occasionally tried to write a text game ever since my brother and I got a Commodore Vic-20 when we were kids, but I never finished one worth playing. I don't know how far I'll get this time, and with a language this fun, who cares? But I'm betting the interactive fiction competition will get a lot more entries this year.

More about Inform 7: