Write Your Game Story as Facts the Game Can Check

The demo is playing itself. Press a key or a button to take over.
One memory for the whole world: the bridge, the greeting and the door all ask the board. A name that is not on the board's list, like the rusty lever's misspelled one, is refused and changes nothing. Keys count up to 3 and stop there. Greeting twice adds nothing new.
Try it: Greet the older beekeeper twice: the second time no new line appears in the list at the top. Pull the rusty lever: a red question mark, no lamp, no line. Pick up the fourth key: the pips stay at 3. Pull the good lever again: the bridge rises and the door shuts too.
←→ walk Space greet, pick up, pull
In the game above, the whole story is three facts on a board: the bridge is down, the older beekeeper was greeted, and how many keys are found. Every place in that small world either changes one of them or asks about them, and the door of the hive house asks about all three. That is what a story is to a game: facts that are true or not, set by some scenes and asked about by others. This lesson has you write those facts down before any prose, so that your AI builds a story the game itself can check.
Also in this lesson 4 things to read up on 3 questions to check yourself
The idea
A story in a book lives in the reader's head. A story in a game has to live in the game, and what the game keeps of it comes down to facts. A fact is a yes or no, or a number, and that is what a game can ask about. "The bridge is down" is a fact. "The old bridge has carried the valley's beekeepers for generations" is lore. It may be lovely, and nothing in the game can ever ask whether it is true.
Every scene in a game story does two things with facts. Before it can happen, it asks about some: may the door open now? After it has happened, it sets some: from now on, the elder has been greeted. If you cannot say for a scene what it asks and what it sets, the game cannot know whether it happened, and neither can a check.
A writer in the reading list describes a unit of game story in three parts that match this: a piece of content, what must be true for it to play, and what it changes in the world once it has played. She sometimes writes such units on index cards before anything is built. That is this lesson's step: facts first, the words for the player after.
How it works
Play the game above once, all the way through the door, and keep an eye on the board at the top. It has a lamp for the bridge and one for the greeting, three pips for keys, and a row of the latest changes, newest on the right. The blueprint keeps the last 20 changes like this, so that when a door stays shut you can see what set what.
Now take a sheet of paper and make a table with three columns: the fact, what sets it, and what asks about it. Fill it in from what you just saw.
- The bridge is down. The good lever sets it and, pulled again, clears it. The river asks about it: without it, she cannot walk across. The door asks about it too.
- The older beekeeper was greeted. Greeting her sets it. Her own bubble asks about it: a question mark before, a heart after. The door asks about it as well.
- Keys found. Each key you pick up adds one, up to three. Only the door asks about it.
Look at the front of the hive house. Three small pictures there, a bridge, a hat and a key, light up one by one as each part of the door's question holds. The door keeps no notes of its own. It asks the board.
Now check your table in both directions. Every fact that something asks about needs something that sets it, or the question can never be answered yes. Every fact that is set needs something that asks about it, or it is lore wearing a name. In the game above, both directions hold for all three facts.
Then play it in another order: the keys and the bridge first, the greeting last. The door opens just the same, because it asks about the facts and not about the order in which they became true. A story written as facts holds in orders you never wrote down.
Last, pull the rusty lever. It is wired to the name bridge-dwon, a typing mistake for the real one. The board refuses it: a red question mark, no lamp, no new entry in the row. It can refuse because the list of names was written before anything else. Without that list, the lever would have made a second fact that nothing asks about, and a player who pulled only that lever would wait at the river for a bridge that never comes down.
What goes wrong
The shortcut is to ask an AI for "the story of my beekeeper game" and take what comes: pages of lore about the elder's past, how the bridge came to be, the old legend of the hive house. It is often well written, and there is not one line in it the game can ask about.
Then the AI builds the scenes and has to invent the facts on the spot. It puts talkedToElder into the greeting's code. A week later, in a new chat, it builds the door and has it ask for elderMet. Nothing complains: the game runs, every scene works on its own, and the door stays shut for a player who did everything right. This is the rusty lever again, only this time nothing refuses it.
You notice it when you ask your AI for a list of every fact the game remembers, with what sets and what asks about each one. If it has to search the code to answer, there is no list. If one fact turns up under two names, or something asks about a fact that nothing sets, the shortcut was taken. And if "has the player met the elder yet?" gets a sentence of lore instead of a name from a list, the story lives in prose, where the game cannot check it.
Tell your AI
Before you write any story text for my game, write the story down as facts. No dialogue and no descriptions yet.
My game: [two sentences about it]. The story so far: [paste it, or say "read it from the project"].
1. Make one list of every fact the game has to remember: a name, whether it is a yes or no or a number, and for a number its lowest and highest value. From now on, use only names from this list.
2. Make a table with one row per scene, place or object: what it asks about before it can happen, and what it sets or changes after it has happened. Use only names from the list.
3. Mark every piece of story we already have that is not a fact on the list as "lore". The game cannot ask about lore.
4. Write a small check in code that reads the list and the table and prints three things: every name in the table that is not on the list, every fact something asks about that nothing sets, and every fact that is set and nothing asks about. Run it and show me what it printed, word for word.
5. Write one test for every row: start from a fresh game, make true what the row asks for, run the scene, and check that exactly the facts in the row changed and nothing else. Run the tests and show me their output.
Only when the check prints nothing I have not decided, write the scenes, each one true to its row. If we need a new fact later, add it to the list first and run the check again.
Try it
- In the game above, greet the older beekeeper twice. The first time a green plus rises and a new entry appears in the row at the top. The second time only a grey zero rises: the fact was already true, so nothing changed, and the game says so instead of acting as if something new had happened.
- Pull the rusty lever, then the good one. The same press both times, but only one of them uses a name from the list: one brings up a red question mark, the other lights a lamp and lowers the bridge.
- Take one scene of your own game and write its row: what it asks about, and what it sets. If you cannot fill a column with plain names, you have found the fact to write down next.
Read up
Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.
What Is a Story Bible, and How Does Your AI Use It?
The whole file your AI works from, from characters to a scene map of what each scene needs and changes, with a real TLC run that finds two scenes contradicting each other on one path.
The board of this lesson as a blueprint: why every name comes from a fixed list, what to do with an old save after a fact was renamed, and the tested code your AI can build on.
A short definition of a unit of story with content, prerequisites and effects on the world state, and how the common branching shapes can be rebuilt from such units.
Beyond Branching: Quality-Based, Salience-Based, and Waypoint Narrative Structures
Three ways to choose the next piece of a story from the state of the world instead of a fixed branch, with clues that can be found in any order, and the bookkeeping this costs the author.
Check yourself: three questions
Each answer is checked and explained at once. The questions are part of the quiz, so they count for your Game Coder IQ like any other.
Your notes for the story of a game hold four lines. Which one is a fact the game itself can ask about?
Next lesson Meaningful Choices in Games: Something Has to Read Them
How useful was this page?
Nobody has rated this page yet.