Game Characters Who Remember: One Number Every Line Reads

The demo is playing itself. Press a key or a button to take over.
One pixel of the bar is one point, from -100 to 100. She turns friendly at 30 and stays friendly down to 20, the dotted line; the same mirrored below zero. Gains stop at 15 a day, losses never stop, and a night without contact pulls the bar 2 back toward the middle, never past it.
Try it: Throw three flowers on one day: the first gives 8, the second only 7, the third 0, and the small bar under the meter is empty. One wasp takes 20 at once, no limit. Turn her away at -30, then throw two flowers: at -22 she still shows her back, and only at -15 does she face you again.
Space throw a flower X send a wasp ↓ sleep a night
A character remembers what the player did only when the game keeps it as a number or a fact, and every line she says reads it. Without that, each scene is written alone, and she is warm in one and a stranger in the next. The neighbour in the game above has one number, and her whole face is read from it. This lesson plays it, and then you write down what your own characters remember and which line reads what.
Also in this lesson 4 things to read up on 3 questions to check yourself
The idea
A game does not remember by itself. You remember your story, and an AI that writes a scene knows what was in the message that asked for it. What a character knows about the player has to sit in the game as something it can ask.
There are two kinds, and they do different jobs:
- A number for many small deeds that add up: gifts, favours, insults. It says how much she likes the player. It does not say why.
- A fact for one deed that matters on its own, true or false: the player saved her hive, the player sent wasps at her. A line that names a deed needs the fact, because a number cannot tell wasps from a forgotten favour.
The other half is the reading. Every line she says reads one of them: her greeting, her price, whether she opens the door. A line that reads nothing was written for one moment, and it will be wrong in another.
How it works
- Make her a friend. Throw flowers over the fence. The first two move the bar to the right, and the third falls to the ground: she takes 15 a day and no more, and the small bar under the meter is empty. Sleep a night and throw two more. When the bar reaches 30, the solid line, she waves, with a heart over her head.
- Send one wasp. The bar falls back near the middle at once, and she is plain again, not hostile. Two days of flowers are still in the number. Send two more, and when the bar reaches the solid line on the left, she turns her back, with a bolt over her head.
- Sleep a night, then throw a flower. It is the same flower as on the first day. The bar moves right, back over the solid line, and she still shows her back. Only the second flower turns her round. A mood is left only when the bar passes the dotted line, 20 from the middle, so one kind deed does not undo three wasps, and her face does not flip on every small deed.
- See what reads what. Her stance, her bubble, the heart and the bolt all come from one place. They read the level, friendly, neutral or unfriendly, and not the raw number. That is why a flower can change the number and leave her face as it was.
- Write it down for your game. For each character who matters: the number, what moves it and by how much, where each level begins and where it ends; and each fact she knows, with what makes it true. Then list every scene she is in, and next to each of her lines write what it reads. A line with nothing next to it is where she will forget.
What goes wrong
The shortcut looks harmless. You ask your AI for a scene: the neighbour brings the player a jar of honey, make it warm. The AI writes a warm scene, and it reads well. A week later you ask for a scene at the market, and she meets the player there. The AI writes that one too, and she is polite and distant, because the message said nothing about what came before.
Each scene was written alone, from the message that asked for it. On the path where the player sent three wasps the day before, she now smiles and hands over honey. On the path where the player brought her flowers for a week, she greets them at the market like somebody she has never met. Neither scene is wrong on its own. They are wrong together, on some paths, in some orders, and you only see it if you play those paths in that order.
A better message for each scene does not fix this. The fix is a memory that every scene has to read, kept in one file, and a check that plays orders of deeds and prints what she would say after each.
You notice the shortcut in two ways. Point at any line of hers and ask your AI what it reads. If the answer is "nothing" or "the scene", it was written alone. Or play the warm scene right after an unkind deed, and see whether she noticed.
Tell your AI
In my game, [character] should remember what the player did. Before you write or change any of her lines, write down what she remembers and check that every line reads it.
1. Write memory.md for [character]:
- One number for how she feels about the player: its range, every deed that moves it and by how much, the most it may gain in a day, how it fades while the player stays away, and its levels, each with the line where it is entered and the line, a little closer to the middle, where it is left.
- Every fact she knows about the player's deeds, true or false: what makes it true, and whether she saw it or was told.
2. List every scene with [character] and every line she says. Next to each line, write the level or the fact it reads. Mark every line that reads nothing, and give each marked line a version for every level, or the fact it should read.
3. Draw her levels as states and moves, and write one test for every move.
4. Write a test that plays these orders of deeds: [for example: two gifts, then an insult; an insult, then three gifts; a gift, then a week away]. After each deed, print her number, her level and the line each of her scenes would choose.
5. Run the tests and show me their output, not your summary of it. Do not change any scene until I have read it.
Try it
- In the game above, make her friendly, then sleep night after night without a flower. The night after a visit changes nothing. After that each night pulls the bar 2 back toward the middle, and she stays friendly until it falls below the dotted line. She forgets slowly, and the number decides how slowly, not the scene.
- Turn her away with wasps, then only sleep. After enough nights she faces you again without a single flower: in this game, she forgives by forgetting. Decide whether your character should. It is one rule of her number, written once in memory.md, and every scene has to live with it.
- Take one character of your own game and two of her scenes. Next to each of her lines, write what it reads. If one line reads her number and the other reads nothing, play them in that order after an unkind deed: you will watch her forget.
Read up
Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.
The neighbour's meter as a whole blueprint: edge cases such as a refused gift that still counts as a visit or a player who is away for a week, its tests, and the code your AI can build from.
How to Keep Your Game Characters Consistent
Character sheets of fixed facts turned into rules, and a model checker that names the exact path of scenes on which somebody warms up without a cause or talks about what they never heard.
The same kind of memory for a whole group instead of one person: a deed that also moves the groups tied to it, and the edge cases of borders and ties that come with that.
A short article on what a character's feelings should do in play: show in pictures, words and deeds, not flip back and forth, and not let a pile of small favours buy a big result.
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.
You want a shopkeeper in your game to treat the player differently after the player has cheated her. What has to exist in the game for that to work?
Next lesson Timed Dialogue Choices: When Silence Becomes an Answer
How useful was this page?
Nobody has rated this page yet.