top expert

i am my own ghost

action count is a number that varies.

story mode: an idea.

I first encountered the idea of an automated playthrough in a discussion thread started by John Ziegler. John’s initial motivation was making his game “playable” to audiences that did not understand the idiom of parser gameplay. I thought that there were many such people, and that it would be nice if someone made a comparable tool for Inform 7 (John works with TADS, a different language). However, this was days before the Spring Thing deadline, and I was in full panic mode trying to get Repeat the Ending to work as a website. I forgot about it as a good idea that I just didn’t have time to think about.

During Disability Pride Month, I began to think about it again, but once more I was crunching a project. I made a thread about accessibility efforts in IF, which sadly died out too soon. However, while it still lived, Wade Clarke and I had a brief discussion about the IFTF Accessibility Testing Report. We both were very interested in honoring its suggestions, yet we also acknowledged the challenges in doing so. I left that exchange wishing or hoping that I could do more than I was currently doing with my work, though I wasn’t sure how to proceed.

In a Discord, the author of one of the year’s IF Comp games mentioned that they had devised a mode of play in which a player could “read” the story. I thought it was a nice idea, but it seemed focused on disguising commands to make a game read like a short story. That didn’t really interest me, though I was curious about their approach, which involved writing world state information state to a table(s?). However, that method would not work for the kind of complexity in Repeat the Ending (especially not as a retrofit!), with tons of conditional text that would be impossible (or at least miserable) to track. RTE has tons of conditional everything, really. Even the options in the menu-based *GUIDE* are displayed conditionally. Assuming it could be done, I’d rather be writing new games with the time required.

Besides, suddenly remembering John’s efforts, I wanted to help people experience parser games. Nothing was stopping me from writing a short story, if that’s what interested me as an artist. At that moment, a moment spent writing Inform 7 games, I ultimately wasn’t looking to turn a dynamic game into static prose. I also recalled my exchange with Wade, and wondered if there was an opportunity to make my game more accessible. I put some code in my work in progress that created a “walkthrough” based on entries in a table. It made heavy use of an Inform 7 extension, “Undo Output Control,” to enable the player to pause and resume the walkthrough at will.

A handful of players who don’t usually enjoy parser gameplay tested it and gave positive feedback. I thought this code could provide a great accessibility feature and possibly be a tutorial-builder as well. I decided to I should build an extension for it. What is an extension? It’s a bit of portable code that an author can incorporate into their project, adding new functionality without having to reinvent the wheel.

Then, a problem. In my circles parser IF playtesting usually is done with a local application (called an “interpreter”) rather than with a web client like Parchment. Why? Gathering game transcripts makes better intuitive sense, and authors would like to receive transcripts. Because of this convention, I was caught flat-footed when I discovered that Parchment’s auto-save feature does not support undo. At all. I worried that working around the absence of undo would amount to taking ownership of parser/interpreter functions in my game. I wasn’t technically proficient to the extent of supporting baked-in parser operations. As I was making this discovery, Wade Clarke announced his own extension, which probably works better than mine. It’s definitely worth a look.

Parchment wasn’t going to change, so I could move forward, leaving the undo problem as-is, fix it, or bin the project altogether. Since I did not want to abandon an accessibility feature, I decided to fix the problem and move on.

Fixing it involved a near-complete teardown, as the then-current functionality was built around undo.

how does it work.

The essential operation of story mode is not complex. There is a number:

action count is a number that varies.
action count is one.

There is a table. Story mode checks a row number (based on action count) in a database (called the table of story steps) to find an “input” entry. The “input” entry is the current step of the walkthrough. A game using story mode will execute the current step, then increment the action count. In the next turn, the game will execute the new walkthrough step, and so on in a loop.

When in the course of an Inform 7 turn do these events happen? The bulk of story mode is concerned with the input of the player. Before accepting the player’s input, a story mode game will retrieve the input, then preload it. Command Preloading is an extension by Daniel Stelzer that enables the author to automatically populate a command prompt. In story mode, the command prompt is preloaded with the current action.

	choose row action count from the table of story steps;
	preload the command input entry;

If the player presses the *ENTER* key, the command will be executed and the next command will be preloaded. This execution “check” happens immediately after the input is received. If the player’s input (normally the preloaded command) matches the input entry, the walkthrough proceeds.

			if "[the player's command]" in lower case is input entry in lower case:
				increment the action count;
				continue the action;

If the player presses *ENTER* at every prompt, then this loop is enough to walk through the entire table of story steps, potentially progressing from beginning to end. This is a very simple loop. The skill floor here involves reading from tables, which beginners may not yet have experience with.

The bulk of story mode’s code is handling exceptions: leaving, pausing, and resuming the mode. Pausing and resuming were the operations previously dealt with via Undo Output Control and were incompatible with the Parchment interpreter. This burden was shifted to an autosave functionality provided by Daniel Stelzer’s appropriately-named Autosave extension. To do this, I needed the game to save every turn before the player’s command is processed. For this reason, I added it to the “before reading a command” loop that is already preloading commands for us. With the Autosave extension, it’s as simple as this:

autosave the game;

Since this happens before the player’s input is processed, that makes it possible for us to “start fresh” whenever the player resumes story mode after a pause. That is straightforward, too:

	if we restored an autosave:
		say "[lb][bk][it]Resuming story mode and restoring previous world state[dot][rt][cb][lb]";
		now the player is guided;
		choose row action count from the table of story steps;
		preload the command input entry;
		try looking;

If you’re wondering what all of the small texts in brackets are: they’re abbreviations I’ve made for symbols and formatting in text. “[lb]” is short for “[line break]” and “[bk]” is short for “[bracket],” for instance. You can find a comprehensive list of my text substitutions in the source code for Repeat the Ending (Volume 1, Book 2, Part 2, Section 2: “Definitions and Substitutions”).

Pausing story mode is straightforward. The check that keeps the loop going while the player is “guided” will redirect things if the player’s command does not match the anticipated entry in the table.

			otherwise if "[the player's command]" in lower case is not input entry in lower case:
				now the player is in-scene;

While in-scene, autosave is disabled, so the player will snap back to the world state immediately preceding the pause. If the player presses the ENTER key or else types “resume” at the prompt, the game will restore the save.

Besides dealing with strange cases (undoing after out of world actions, for instance), I also needed a way to handle options for when the game ends. If story mode is paused, Inform 7 should offer a “resume” option. If story mode is active, or if story mode is disabled, an “undo” option should be available instead. This required the most elaborate code in the extension! There’s a lot of table-related stuff going on in the background, but here’s the basic logic. I like how readable this is:

last when play ends (this is the finalized questions rule):
	if the player is not in-scene: [applies to both autonomous and guided modes]
		if undo is available:
			rule succeeds;
		otherwise if resume is available:
			instate undo;
	otherwise if the player is in-scene: [only applies when story mode is paused]
		if resume is available:
			rule succeeds;
		otherwise if undo is available:
			instate resume.

more on accessibility.

You may wonder: what does story mode have to do with accessibility? It targets the following recommendations from IFTF:

  • Parser IF should offer a separate “training ground” for new players: Story mode is a separate training mode that players can leave whenever they feel comfortable. Rather than separate geographies, story mode incorporates separate timelines. Players can experiment indefinitely, without limit, without ever affecting the game’s story. A detailed, organized manual is available at all times.
  • Offer Hints and Walkthroughs: Story mode is a complete walkthrough that offers interaction and learning possibilities beyond any static walkthrough document (RTE already has comprehensive in-game hints). Players can step off the path at any time without disrupting the walkthrough or risking the state of the game world.
  • Offer an Undo Command: Story mode’s undo functionality goes above and beyond built-in* parser capabilies for undo. There is no practical limit to how many turns can be undone. Playing in story mode offers sandbox-like capabilities in which any and all actions are free of negative consequences.

how do I get it.

Story mode is available at the community’s repository of extensions, Friends of Inform. It’s in the “Drew Cook” directory, appropriately enough. I also maintain a copy at itch.io. If you need assistance configuring your Inform 7 game with story mode, or just want to talk about it, get in touch! You can see it in action by playing my game Repeat the Ending.