Spielerando

Lesson 7 of 14People and a world that answer8 minFree

Game Characters Who Remember: One Number Every Line Reads

A pixel art beekeeper stands at a garden fence and throws flowers to her neighbour in a pink jacket, then sends wasps at her. A long bar at the top shows how much the neighbour likes her, from left to right. The neighbour waves with a heart over her head when the bar passes the right line, turns her back with a lightning bolt when it passes the left one, and the night sky comes and goes between days.

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.

Keys: Space throw a flower X send a wasp ↓ sleep a night

This little game runs this blueprint's tested code in your browser. Nothing you press is sent anywhere. Its code on GitHub.

The game above is the playable demo of our blueprint Relationship Meters. It runs that blueprint's tested code in your browser.

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:

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

Read up

Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.

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.

Question 1 of 3Easy

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?

All questions of this course · The quiz and the Game Coder IQ

Next lesson Timed Dialogue Choices: When Silence Becomes an Answer

How useful was this page?

Nobody has rated this page yet.

One click, no account. It tells us which pages to make better next.

Last updated: 2026-11-27