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. (That’s no fun. The fun is in providing off-the-wall responses to crazy instructions.)
Instead, there are three engines I strongly recommend that you consider using. All are open-source, all permit you to redistribute and sell your creations freely and, while they are quite different in what they do and don’t offer, all have plenty of advanced features that would be a pain to reinvent, like graph-drawing IDEs, text parsers, accessibility for the visually impaired, etc.
I’ll go in the order I recommend that you consider using them:
Twine is a purely mouse-driven system (no text parser) with Choose Your Own Adventure-style gameplay as its primary focus. However, it does have macros and variables, it is extensible, and you will never find anything simpler or easier to create and share with.
Twine 1.x uses a native Windows or MacOS editor which graphically visualizes the structure of your story. Twine 2.0 (in beta as of this writing) moves the editor into the browser so installing your own copy is optional and Linux authors aren’t left out.
An exported Twine story is simply a TiddlyWiki 2.x HTML file that has been given an extreme makeover, which means that it requires no special hosting. Put it in your Dropbox, attach it to an e-mail, or put it on a thumbdrive. If the reader has a web browser, they can use it.
This also means that each page/passage/screen/location in your story is simply a series of pages, __written__
–in– ”TiddlyWiki” //markup//, and connected by [[wiki links]]. (Embedded images are supported)
A simple but comprehensive tutorial is available with plenty of screenshots for the 1.x series.
Given how low-friction Twine is, I’d suggest using it to prototype anything that can be implemented purely using mouse input, and then copying your text to TADS (which also supports HTML with hyperlinks) if you outgrow it.
Free hosting for your stories is available at Philomela, Adventure Cow, and any service which lets you share an HTML file without modifying its contents, such as Neocities, Dropbox, or your GitHub Pages blog.
Here are a few examples of what people have built with it:
- Text-only and with one of the default themes, but with links within the text
- Traditional Choose Your Own Adventure choice lists and illustrations
- How far can you push its hypertext capabilities in the name of art?
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.)
As they say on TV Tropes:
Examples of games with actual good parsers include The Hobbit and anything by Infocom or Legend. Ironically, that includes some of the oldest adventure games; many of the newer ones tried to reinvent the parser wheel. The TADS (Text Adventure Development System) runtime is particularly good at such reinvention — not only can you actually get ye flask, TADS allows to choose between multiple ye flasks, and will ask which one thou actually wantest.
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 a more impressive IDE than 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 with text parsers 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 Twine for mouse-driven stuff and TADS for stuff requiring a text parser. They’re both proven solutions that are only going to get better and you should never underestimate the benefits of having a solid, versatile foundation with plenty of room to grow.