Everything2
Near Matches
Ignore Exact
Full Text
Everything2

How interactive fiction works

created by ferrouslepidoptera

(idea) by ferrouslepidoptera (3.9 y) (print)   ?   (I like it!) 2 C!s Mon Oct 02 2000 at 4:46:33

Next


This series of nodes describes how those interactive fiction, adventure games like Zork and the original Colossal Cave adventure game work. I chose C as the programming language for all the examples because it seems to be the most widely used, and the most likely to still be around in 20 years.

The first time I encountered a text adventure game was not on a computer at all. It was in a book called The Soul of a New Machine, by Tracy Kidder, a book about the engineers at Data General who were working to build the Eagle, a computer meant to compete with DEC's VAX.

The book contained a description of the original Colossal Cave adventure by Crowther and Woods, and gave tantalizing little excerpts of the program's output. This output amazed me at the time. I would read these little excerpts over and over wondering if it was genuine. I didn't know too much about computers then, and I strained my brain wondering how it was possible for the computer to seemingly understand input in English, and generate meaningful responses, seemingly understanding what it was directed to do. I wondered if this program were for real, or if the author had taken some artistic license to make it seem better than it really was. I soon found out that it was for real though, and this fact got me going.

I immediately set out to build one of these games myself, but I was very naive. I began with a section of BASIC code dedicated to describing each "room" in the game, and a series of gotos and gosubs depending on the player's typed input in each of these "rooms". This was a very very wrong way to go about it as I soon discovered.

I looked around in various books, and could find nothing that even began to tell how such a game worked. Eventually, I found an advertisement in (the now defunct) Compute! magazine for a little pamphlet describing how such games were made, and included a BASIC program for an example game. So I sent away for it. The name of the sample game was, appropriately enough, Deathship. It was some of the most horrible code I have ever seen. It performed as advertised, but it was made to run on a machine with 16k RAM, and it squeezed out every byte possible. Spaces in the source were dispensed with, an unnecessary luxury, no spaces. The names of verbs and nouns were significant only to the first two characters..., and the longer version of these words were contained nowhere in the program. I never did figure out what some of those words were supposed to be. Anyway, as bad as it was, it did teach me the concepts behind adventure games well enough that I could write my own code.

What I needed, it turned out, was the concept of arrays. Clever use of arrays is what makes these games tick, and Deathship was my bewildering and fascinating introduction to them.

But, I'm getting ahead of myself.

Eventually, I did manage to write a passable adventure game in Turbo Pascal with a parser that could do everything that the Infocom parser in Zork could do, plus a bunch more stuff. (I really need to resurrect that computer and save that code.)

But this node is not about building a sophisticated parser like that. This node is about the basics, and will describe just enough to get you started. Enough to get you started that is, if you're goal is to write such a game from scratch in C, or to learn about C while having a fun programming project to tinker with. If your goal is to write a serious adventure game, you'd probably be better off starting in a different place, standing on the shoulders of giants, using any of the many adventure writing toolkits out there, such as TADS, to name one.

So, If this sounds like your kind of thing, keep reading.

Next


printable version
chaos

How interactive fiction works (part 2) I Have No Mouth, and I Must Scream Interactive Fiction Archive TADS
Pick up the Phone Booth and Die Zork How interactive fiction works (part 5) Choose Your Own Adventure
The Soul of a New Machine Heinlein's Rules for Writing Friendster Inform
Adventure Games Interactive Fiction How interactive fiction works (part 4) How interactive fiction works (part 3)
March 15, 2005 February 12, 2005 How to make electroclash Hugo's House of Horrors
Commandos : Behind Enemy Lines parser adventure The Flathead Calendar
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help


cooled by sensei

Cool Staff Picks
Nodes your cousin would have liked:
This freaking obsession with really abysmal porn
Anger, shaped like a man
Earth
U-2 Incident
Rosa Parks
catcher
West Side Story
Camel
steganography
Anna
ice cream and psilocybin
Butter
Cambrian Explosion
New Writeups
gate
Anarchy is Order(idea)
ushdfgakjasgh
Scribeling(thing)
XWiz
Trism(review)
artman2003
Briefcase Full of Souls - Part I(fiction)
Dreamvirus
Alan Ladd(person)
waverider37
Harold Holt(person)
The Debutante
Until death do us part(fiction)
Ysardo
a brother to a sister(personal)
antigravpussy
your warm whispers(personal)
Clarke
Multiculturalism(idea)
aneurin
Earl of Landaff(person)
Heitah
Pseudocide(idea)
XWiz
Google Knol(lede)
Mythi
July 24, 2008(personal)
locke baron
The fall of Earth(fiction)
E2 is a by-product of the existence of The Everything Development Company