Does Modelling First Make AI Game Code Correct? We Tested It
In our test, asking Claude to write the state machine before the code did not make that code pass the blueprint's tests more often: both versions passed equally often. The answers got much longer. A model on its own was not what made the code right; running the tests was what showed which code was wrong.
What "model first" means here
All over this site we ask your AI to model a mechanic before it builds it: to write down the states the mechanic can be in, such as "on the ground", "rising" and "falling", and every move between them with what causes it, as a small diagram. The hope is that the AI meets the odd paths on paper before they turn into bugs. That is a claim, and until now we had not measured it.
The test
We took blueprints from this site, each with a plain-words description and its own tests, and asked Claude to write the code for each one in a fresh chat. Every request was the same, except that one version ended with this:
Before you write the code, write the state machine as a Mermaid state diagram: every state, and every move between states with what causes it. Walk through every path in it, including odd cases. Then write the code so that it follows your diagram.
The AI never saw the tests or the blueprint's own diagram. Its code then ran against the blueprint's tests, and a run counted as passed only when all of them passed. The other versions we tried at the same time, and how we worked out the ranges, are on the page Does saying "make no mistakes" help AI?.
Claude Opus 5.5 (claude-opus-5-5), on 26 November 2026: 7 blueprints, 2 versions of the request, each twice per blueprint, so 14 runs per version. With the other versions of this experiment, that made 56 scored runs.
What came out
| Version | Passed every test | Likely range |
|---|---|---|
| The plain request | 5 of 14 (36%) | 16–61% |
| Plus “write the state machine first, then the code” | 5 of 14 (36%) | 16–61% |
Compared with the plain request, the request to write the state machine first left the share of runs that passed every test unchanged, with a likely range of −32 to +32 (worked out blueprint by blueprint: −21 to +21). Both ranges include zero: this run cannot tell the two apart from chance. On 5 of 7 blueprints both passed equally often, on 1 more often, on 1 less often. Counting single tests instead of whole runs: 93% against 94% (−1 point, range −5 to +3).
With the request to write the state machine first, Claude Opus 5.5 drew a Mermaid diagram in 14 of 14 answers; without being asked, in 0 of 14. The answers were 6122 tokens (pieces of words) long on average instead of 3436, so 78% longer.
Blueprint by blueprint, the runs that passed every test:
| Blueprint | The plain request | The state machine first |
|---|---|---|
| Checkpoints | 2 of 2 | 2 of 2 |
| Combo System | 0 of 2 | 1 of 2 |
| Cutscene Triggers | 2 of 2 | 2 of 2 |
| Experience and Levels | 0 of 2 | 0 of 2 |
| Item Durability | 0 of 2 | 0 of 2 |
| Stamina System | 1 of 2 | 0 of 2 |
| Wall Slide | 0 of 2 | 0 of 2 |
What this means
- Drawing the model did not make the code more correct here. The AI drew a diagram every time it was asked and then followed it. Where it failed, it failed on the same blueprints as without the diagram.
- The mistakes sat below the level of a state diagram. A state diagram names states such as "sliding" and the moves between them. The failures we took apart were about smaller things: whether gravity pulls before or after the character moves in a frame, whether a timer gets to zero despite rounding, and whether a setting below its stated range is pushed back into range. A diagram of states settles none of these.
- A model nobody checks is more text, not more proof. This site's advice has a second half: let a checker walk the model, such as TLC for a TLA+ spec, and show what it printed. That half was not part of this test.
- When a model still helps. A diagram is something you can read without reading code, so ask for one when you want to look for the odd cases yourself before anything is built, or when a checker will walk it. Do not expect the drawing to make the code right on its own.
Paste this to your AI
Before you write code for [the mechanic], draw it as a Mermaid state diagram: every state, every move and what causes it. Show it to me and wait.
When I agree, write the code so it follows the diagram. Then write a test for every move in the diagram and for every odd case we found, run the tests, and show me what they printed. If a test fails, fix the code, not the test, and tell me which test it was.
What this test does not show
At 14 runs per version, modelling first would have had to add about 32 percentage points of passed runs on Claude Opus 5.5 for this run to notice it at all. A smaller gain, or a small loss, fits these numbers too.
- It tested asking for a model, not checking one. No checker ran over the diagrams the AI drew.
- The AI drew its own diagram, never ours. Handing it the blueprint's diagram is a different question, and it was not part of this run. One check, on experience and levels, compares the code with the blueprint's own diagram, which no version saw; it failed in almost every run.
- One model, small mechanics, one try each. Only Claude, writing one file from a description, with no game around it and no second chance.
Play the mechanics on this page

World
Checkpoints
Checkpoints keep a death from costing the whole level. The player risks only the stretch since the last marker, so a hard part can be tried again and again without walking the same easy part each time.

Combat
Combo System
Combos reward timing: the same button does more for a player who presses it at the right moment.

Story
Cutscene Triggers
A trigger starts a scene at the right moment and in the right place, so the story takes the stage exactly when the player has reached it, and never twice by accident or half done.
Was this page helpful?
Next step
Guide
The Bugs Our Proofs Found in Our Own Code
The failed runs here tripped on rounding and on what happens first within a frame; that page lists such bugs our checks found in our own tested code, from a full tier that stayed locked to a shot a frame late.