If you’re writing a piece of interactive fiction (A.K.A. a text adventure game),writing your own engine is the last thing you want to do.
Instead, there are two engines I strongly recommend that you consider using. Both are open-source, both permit you to redistribute and sell your creations freely and, while they are quite different in what they do and don’t offer, both have plenty of advanced features that would be a pain to reinvent, like the text parser, accessibility for the visually impaired, etc.
I’ll start with the one I recommend more:
TADS (short for Text Adventure Design System) is an advanced programming language, engine, and development environment for text adventure games. They also provide a site named the Interactive Fiction Database (IFDB for short) which provides free hosting for non-pornographic games and allows people to play them in the browser if you export them in the right form.
Writing your game in TADS has the following big advantages:
- A ready-made engine with a highly advanced text parser, a bundled library of 150+ predefined verbs, and a world model that allows it to infer things like “the room should go dark if you put the only light source in a box and close it”.
- “HTML TADS” multimedia support so you can include headings, illustrations, text formatting, horizontal rulings, block quotes, ambient sounds, etc.It also allows you to hyperlink words like “bottle” to commands like “take bottle” to enable a certain degree of mouse interaction.
- A simple C++/ActionScript-like language with declarative extensions that make it easy to rely on the engine to understand concepts like picking up objects and moving from place to place.To quote the TADS website,
- A Flash-like “portable bytecode and platform-specific runtimes” approach to distributing games with at least one open-source runtime per platform for Windows, MacOS, Linux, DOS, AmigaOS on PPC, BeOS, and jailbroken Kindles, plus an in-browser solution.(Though it does require you to set up some server-side componentry if you are self-hosting rather than relying on IFDB.)
- Fully open-source with command-line compilers for all major platforms and an IDE for Windows which can generate both EXE installers and the TADS equivalent of Java JAR files for you with one or two clicks. (And it includes offline copies of the quickstart guide, tutorial, and various reference manuals)
- As of TADS 3, you can override just about any default behaviour to make as complex and fancy a UI as you want. For example:
- One screenshot shows an arcade game where text mimics graphics.
- The documentation for the advanced windowing features discusses an example with a fixed status line, fixed “picture of the location” pane, fixed compass, and scrolling text pane.
- They’re working toward network multiplayer support. (The in-browser option has network primitives but “just ask for it and you’ve got a MUD” isn’t an option quite yet.)
Here’s the “starter game” from the quick start guide so you can get an idea for how much it does for you.
#include #include <en_us.h> gameMain: GameMainDef initialPlayerChar = me ; versionInfo: GameID name = 'My First Game' byline = 'by Bob Author' authorEmail = 'Bob Author <email@example.com>' desc = 'This is an example of how to start a new game project. ' version = '1' IFID = 'b8563851-6257-77c3-04ee-278ceaeb48ac' ; firstRoom: Room 'Starting Room' "This is the boring starting room." ; +me: Actor ;
Connecting rooms together is as simple as writing
west = firstRoom in one and
east = secondRoom in another.
The main downside is that, because IFDB doesn’t allow pornographic content, a pornographic text adventure like Corruption of Champions must be self-hosted. (And, as I mentioned, self-hosting the “play in browser” option is a bit involved.)
Now for the other option:
Like its predecessors, Inform 7 compiles to bytecode for Inform’s venerable Z-machine runtime but can also produce bytecode for the Glulx engine, a modern successor which removes many of the system’s limitations.
Like TADS, multiple open-source runtimes are available and the IDE is open-source as well. However, unlike TADS, Inform 7 games generally have minimal text parsers and no support for anything beyond what you’d see in
However, there are four reasons I recommend Inform 7 to people who don’t want to use TADS:
- It has the best development environment. Unlike TADS, the Inform 7 IDE is available on Windows, MacOS X, and Linux platforms and has various visualizations that help you to better understand the structure of your game.
- Thanks to playfic.com, you can write, share, and play Inform 7 games completely in your browser.
- It has a “plain english” syntax. (I think this is a downside, but some people apparently prefer it.)
For comparison with TADS, here’s Inform 7′s answer to “Hello World”:
"Hello Deductible" by "I.F. Author" The story headline is "An Interactive Example". The Living Room is a room. "A comfortably furnished living room." The Kitchen is north of the Living Room. The Front Door is south of the Living Room. The Front Door is a door. The Front Door is closed and locked. The insurance salesman is a man in the Living Room. "An insurance salesman in a tacky polyester suit. He seems eager to speak to you." Understand "man" as the insurance salesman. A briefcase is carried by the insurance salesman. The description is "A slightly worn, black briefcase." Understand "case" as the briefcase. The insurance paperwork is in the briefcase. The description is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork. Instead of listening to the insurance salesman for the first time: say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you."; move the insurance paperwork to the player.
In essence, both TADS and Inform 7 are specialized programming systems with first-class tooling but TADS developers focused on giving you more freedom to create rich experiences while Inform 7 focused on trying to make the existing spartan experience accessible to a wider, less technical population of authors.
Personally, I think Inform 7′s plain English syntax is counter-productive because no programming language can understand the full breadth of English grammar and that conflation makes it harder to fully learn what the language will and won’t allow when compared to a purely artificial syntax like the ones used in TADS and older Inform versions.
Other engines do exist, but TADS, Inform, and ADRIFT are the most popular by a huge margin (very important for ensuring plenty of good documentation and community support) and ADRIFT costs money.
All in all, my advice is to use TADS if at all possible. It’s a proven solution that’s only going to get better and you should never underestimate the benefits of having a really smart text parser and a renderer that allows you to enhance your text with custom typesetting, illustrations, fixed UI elements, and the like if you so choose.