AI RPG with stats: how Yumina tracks health, money and relationships without the story model cheating
Stats drift when the model writing the story also updates them. Yumina hands the numbers to a separate decision model, so a creator writes the rule once and it holds every turn.
What you get as a player
In an AI RPG on Yumina, health, money and relationships are numbers the game keeps, and they change because of what you did. Every account has a free model with no message limit, so playing on that model costs nothing. AI RPG on Yumina is the place to start, and the RPG tag lists worlds to play. The rest of this post is for people who want to know how the engine tracks those numbers.
Why stats drift in an AI RPG
An AI RPG has to write the scene and keep the numbers at the same time. Nearly every AI game asks one model to do both, by writing the reply and appending a directive such as [affection: +2] for the engine to apply.
A week of production turns on Yumina, audited in September, shows what that produces. Depending on the model, stats changed on 78 percent of turns or on 7 percent, and many of the changes were wrong: a character not in the scene gained affection, a stat at its maximum rose again.
A second model owns the numbers
Yumina gives the numbers to a second, smaller model that writes no prose and answers one question per stat with probabilities. In the code it is the continuity judge; in the editor, a switch on each variable called Precise tracking.
A tracked variable belongs to the judge. The story model sees the value as read-only, and any directive it writes for it is dropped:
/** Whether the continuity judge, not the narrative model, owns this variable's
* value. Owned variables render as read-only in the prompt and the model's
* directives for them are dropped: one variable, one writer. */
A number needs a window, the most it may move in one turn. A text variable needs a list of allowed values. New numbers and yes-or-no variables are tracked by default, with a window of 15 percent of the range.
The code is in the open-source repository: run.ts runs the judge inside a turn, jev-client.ts builds the questions and reads the probabilities, and missed-updates.ts is the repair pass.
The question it answers
After the reply has streamed, the engine asks one question per tracked variable, with the creator's rule pasted in word for word:
`This turn only. Given \`player\`'s action and what happens in \`reply\`, by how much should the variable "${name}" (current value \`variables.${name}\`) change? 0 means unchanged.${rules ? ` The author's rule for it: ${rules}` : ""}`
The choices are every whole-number step inside the window. Steps that would push the value past its minimum or maximum are left out, so a stat at its maximum is never offered a way up. A text variable gets its list plus "keep".
The model is given only the player's last line, the reply, the current values and the creator's rule. The lorebook and the system prompt are left out because unrelated context makes it worse at the one question. On Chinese cards the question is in Chinese, which scored higher than English on the same cards.
The question goes to a decision model, not a chat model. Yumina uses Jev (typesafe/jev-1.13) through OpenRouter's decisions endpoint, which takes a question and a list of options and returns a probability for each option instead of text. One call carries up to 255 options, so a window of -127 to +127 is the largest a number can have. The call is bounded by CONTINUITY_TIMEOUT_MS, 1.5 seconds, and a card can switch the whole feature off with one setting.
From probabilities to a number
The model returns a probability for every choice. The engine takes the probability-weighted mean, rounds it, and applies it only if the winning side of zero holds at least 80 percent:
const expected = steps.reduce((sum, d) => sum + d.p * d.delta, 0); // weighted mean
const change = Math.round(expected);
const mass = sideMass(steps, Math.sign(change)); // probability on that side
if (Math.abs(change) >= 1 && mass >= 0.8) apply(change);
else if (mass >= 0.5 && storyWroteSameDirection) apply(change); // two reads agree
Health is 80. The answer is -8 at 20 percent, -10 at 50, -12 at 25 and 0 at 5. The mean is -9.6, rounded to -10; the down side holds 95 percent; health becomes 70. A 50-50 split moves nothing.
The second branch came from October's data. On 31.6 percent of number turns the judge leaned past 50 percent but under the bar, and because the story model's write had been dropped, nobody moved the stat. Now, when the judge leans past 50 percent and the story model wrote the same direction in the same reply, the stat moves by the judge's amount:
// The judge's own size of change either way: the story model only
// confirms the direction, it never sets how far.
Where it runs in a turn
The judge runs after the full reply has streamed and been parsed, with 1.5 seconds for the first attempt and any fallback together. If it answers in time, its changes are applied with the story model's changes to the variables it still owns. If it fails, the turn goes through as if the feature did not exist, with the story model's directives kept, so a slow judge never freezes a stat.
The order inside one turn, from the orchestration in run.ts:
- The reply finishes streaming and the parser reads its directives,
[id: op value]with nine operations: set, add, subtract, multiply, toggle, append, merge, push, delete. - The creator's reply rules run on the text.
- The repair pass asks its yes-or-no questions for untouched variables.
- The judge asks its question for each tracked variable, inside the 1.5-second deadline.
- The engine filters the story model's directives: those for tracked variables are dropped if the judge ran, kept if it did not.
- The surviving changes, the judge's and the story model's, are applied together.
The repair pass
The same model also covers untracked variables. For each AI-writable variable the story model left untouched, it answers one yes-or-no question built from the creator's description and rules: did this turn contain an event that should change it? A yes counts at 85 percent or more. On hand-labelled turns it was right 210 of 210 times at 90 percent and above, and 94 percent of the time between 80 and 90. Flagged variables go to a correction model that may write only those values. The story text never changes.
What it costs
One decision call per reply on the platform's key, output tokens free, about $0.0001 per turn, charged to nobody. A player on their own OpenRouter key is asked on that key first and falls back to the platform key inside the same 1.5 seconds.
| Deadline | 1.5 seconds |
| Choices per question, at most | 255 |
| Default window for a new number | 15 percent of its range |
| Bar to move a number | 80 percent on one side, or 50 percent plus the story model agreeing |
| Repair question, hand-labelled turns | 210 of 210 at 90 percent and above; 94 percent between 80 and 90 |
| Production sample, 101 cards, 7 days | under the bar on 31.6 percent of number turns; agreed with the story model's direction 619 times to 150 |
| Update rate before, by story model | 78 percent of turns down to 7 percent |
Doing the same in your own game
The pattern does not depend on Yumina. Four pieces reproduce it.
- Mark the variables a second model owns as read-only in the story prompt, and drop any directive the story model writes for them.
- After each reply, ask a decision model one question per variable. Paste the author's rule into the question word for word, offer every legal step as an option, and leave out steps that would cross the minimum or maximum.
- Apply the probability-weighted mean only when one side holds at least 80 percent of the probability, or 50 percent with the story model writing the same direction.
- Run it under a deadline with a fallback that keeps the story model's write, so the second model can slow a turn by at most the deadline and can never freeze a value.
The three files linked above are the reference implementation, with the tests that pin the thresholds.
What it does not do yet
The 210 of 210 figure is for the yes-or-no repair question; how accurate the size of a change is has not been measured across the population. The creator docs say a value moves only at 80 percent, while the code also moves it at 50 percent with agreement; the docs are behind. Until October a text variable that allowed an empty value was never offered it, which left two characters narrating a city for 18 turns after the players had walked out.
On Yumina this is built in

A creator opens a variable in Studio, turns on Precise tracking, and sets how far it may move per turn. Players get stats that move for a reason, with the judge's answer and its confidence visible on every turn in Playtest, and nobody pays for the second model. If you are building an AI RPG with stats, that part is done, and the engine is open source if you would rather run it yourself.
FAQ
Can Precise tracking be turned off?
Yes. Each variable has its own switch, and the card has one switch for the whole feature. With it off, the story model writes the variable with directives, as before.
Why did a stat not move when the scene clearly called for it?
The judge needs 80 percent of the probability on one side, or 50 percent plus the story model writing the same direction. If it was unsure and the story model wrote nothing, the stat stays. Playtest shows the answer and the confidence for every variable on every turn.
What about text variables?
Give the variable a list of allowed values. The judge picks from the list or keeps the current value. It never invents a value that is not on the list.