AI Agents Wrote All 301 of Our Games. Tests Are the Hard Part.
AI agents do most of the work on TrySolitaire. A person sets the goals and decides what ships. More from TrySolitaire Engineering
Measured: November 14, 2026, on the code that runs the site
Games: all 301
For a while, our code held a file named thievesofegypt.js. It described a two-deck Pyramid: you match pairs of cards that add to 13.
Thieves of Egypt is a real game, and it is nothing like that. It is a Forty Thieves game. Ten columns are dealt as a pyramid, 1-3-5-7-9-10-8-6-4-2. You build down in alternating colours, and the stock turns over once. Three published sources agree on it.
An AI agent wrote that file. It was one of 31 that were not live, and most of them described games that do not exist. Files of that kind came with tests, and some came with guides in several languages. Nothing in the code could tell a real game from an invented one.
AI agents wrote every game on TrySolitaire, all 301 of them. They also wrote the engines and the tests that this post describes, and they wrote the post. An agent can write a card game in less than an hour. With the same confidence, it can write a game that nobody has ever played.
So the hard question was never how to write 300 games. It was how to know that a game is right. This post is our answer so far: 233 games of about 100 lines each, and what each one must pass before it ships.
One File, One Game
This is a whole game. It is called Limited, and its file is 74 lines.
The file starts with the rules in plain words, and where they come from:
// Canonical rules (Morehead & Mott-Smith, "Limited"; Parlett's Forty
// Thieves group): two decks. Twelve tableau columns of three cards, all
// face up. Eight foundations build up in suit from the aces. The
// tableau builds DOWN BY SUIT, strictly one card at a time; an empty
// column takes any single card. The stock deals one card at a time to
// the waste, no redeal. Win: all 104 cards on the foundations.
It ends with the game that it passes to its engine:
super('limited', {
gameName: 'Limited',
pileSizes: COLUMN_SIZES,
// Down by suit, one rank at a time, no wrapping — the
// family's classic build (Morehead & Mott-Smith).
canBuildOn: (card, top) =>
card.suit === top.suit && card.value === top.value - 1,
redeals: 0,
layout: LimitedGame.layoutContract
});
Three keys make the game. pileSizes is the deal. canBuildOn is the build rule. redeals is how often the stock turns over. Between the rules and the keys stand nine numbers for the layout, with their arithmetic.
Look at what the file does not have. There is no drag in it, no tap, no undo, no save, no hint and no animation. Play Limited, and you find all of them.
What the 74 Lines Stand On
Limited’s 74 lines stand on 3,199 lines that it shares with its siblings. Each layer holds only what the games above it do the same way.
We did not design these layers first. We measured them. When we wanted a Klondike engine beside the Forty Thieves engine, we compared the two. The Forty Thieves engine was 711 lines then. 483 of them were about the shape of the board: a stock and a waste over columns. Only 73 were about being Forty Thieves. So the shape became a layer of its own, and 74 games stand on it today.
Spider went the other way. It has no waste pile, and it does not build its foundations card by card. Those are the two things that layer is about. So Spider did not become its child. The 210 lines that both needed moved up a layer instead.
A fix that every sibling gets
A shared layer shows its worth when something is wrong in it. Ours was a game that could not end.
Some games let you turn the stock over as often as you like. For those games, “is a card left in the stock?” is always yes. A board with no move left would never be over. For that reason we could not write three games at all: Saratoga, Trigon and Athena.
The answer is in the stock-and-waste layer, and it is a proof, not a guess. When no card on the board can move, only one thing can still change: which card lies on top of the waste. Turning the stock and recycling it is a fixed cycle, so it must come back to a state that it was in before. The layer walks the cycle. If a card that comes to the top can be played, the game is alive. If the cycle repeats first, the game is over.
const seen = new Set();
for (;;) {
const key = `${stock.length}|${stock.join(',')}|${waste.join(',')}`;
if (seen.has(key)) { return true; }
seen.add(key);
if (stock.length > 0) {
const count = Math.min(drawCount, stock.length);
const turned = stock.slice(stock.length - count).reverse();
stock = stock.slice(0, stock.length - count);
waste = [...waste, ...turned];
} else if (waste.length > 0) {
stock = [...waste].reverse();
waste = [];
continue; // a recycle exposes nothing by itself
} else {
return true;
}
if (playable(waste[waste.length - 1])) { return false; }
}
Saratoga turns three cards at a time. There, the walk also finds the cards that never come to the top. A check that asks only “are cards left?” gets exactly that wrong.
Ten games on this layer turn their stock without limit today. Not one of their files holds a line of this code.
One Board, Four Games, One Line Apart
“A game is a rule set, not a class” is the second decision of our plan, from August 28, 2026. This is what it means in practice.
Streets, Emperor, Rank and File and Number Ten are four games with four names in the books. Here is the whole difference between Emperor and Rank and File, without the comments:
- gameName: 'Emperor',
+ gameName: 'Rank and File',
pileSizes: COLUMN_SIZES,
faceDownRows: FACE_DOWN_ROWS,
canBuildOn: (card, top) =>
card.color !== top.color && card.value === top.value - 1,
+ movesRuns: true,
redeals: 0,
- layout: EmperorGame.layoutContract
+ layout: RankAndFileGame.layoutContract
One line of rules. In Emperor you move one card at a time. In Rank and File a run of cards moves as one, and that is a different game to play.
A key must earn its place
A key such as movesRuns is the only way that a game can differ from its family. So we add one only when four things are true:
- It unlocks a game that has a name in the books.
- It adds, and it changes nothing that exists.
- Its default leaves every live game as it is.
- We break it on purpose in the first game that uses it, and a test fails.
A game file must not hold behaviour. When a game “fixes up” its family’s deal in code, a key is missing. Storehouse started that way. Its fix became the foundationBase key.
How We Know That a Game Is Right
For a new game, an agent reads the rule sources and writes the sheet, the game file, its test and its guide. Then it runs the gates. A person sets the goals and decides what ships.
Two ideas carry most of the weight.
A test must be able to fail
For each rule, we change the rule on purpose and watch which test fails. Here it is for Limited. We turn its build rule upside down:
- card.suit === top.suit && card.value === top.value - 1,
+ card.suit === top.suit && card.value === top.value + 1,
Then we run its tests:
× limited-rules.test.js > Limited rules
> builds down by suit only, and there is NO redeal
→ expected false to be true
Tests 1 failed | 243 passed (244)
One test fails, and it is the right one. The other 243 pass, and that is the interesting part.
240 of them are the playthrough of the family. It plays hundreds of hinted moves on the broken game and finds nothing wrong. A game where you build upward is still a game. Every card is still accounted for, and undo still works. Only Limited’s own small test knows what Limited is. That is why each game has both.
When a test still passes after we break its rule, the test is empty, and we write it again. That has happened more than once: a trigger for an illegal move, an undo of a count of zero, a check that read fewer games than there were.
A gate finds its own subjects
The save gate and the guide gate do not read a list of games. They take every file that imports an engine. A new game cannot be left off them, because there is no list to leave it off.
Before every push, the whole suite runs: more than 25,000 tests in 700 files.
What Went Wrong Anyway
Silence that looked like success. A check over a list must first prove that the list is not empty, and a probe that could measure nothing must fail. One probe cleared Pyramid of a layout fault. It was counting visible cards, not reading where they were.
Seven games with no styles. The script that wires a new game took one block in the stylesheet as proof that the game was styled. Seven games reached a build without their styles. The gate that should have caught them compared each game with its siblings, and the seven were each other’s siblings. We fixed the script and the gate.
Motion that never ran. Our headless browser reported that the user prefers reduced motion. That turns every animation off, so every motion check passed by doing nothing. The browser check now asks for motion in so many words.
Names without rules. This is the story at the top. The rule now: a file with no source is a name, not a rule set. We write the game again from published sources, and we delete the old file, its test and its translated guides. If a source does not state a rule, the file says “not stated”.
What It Costs
| Games | Median lines | All lines | |
|---|---|---|---|
| Spec games on a family engine | 233 | 105 | 25,373 |
| Games with a class of their own | 68 | 1,001 | 76,708 |
| The engines and their shared layers | 15 files | 10,595 |
A spec game is small because 58% of its lines are comments: the rules, and their sources.
A shared layer cuts both ways. A fault in the column engine is a fault in 219 games at once. That is what the family playthroughs are for. When we move code up a layer, every assertion must stay untouched and green.
68 games are not on an engine. 47 are solitaires that agents wrote as classes of their own, before the engines existed. The other 21 are not solitaire at all: Sudoku, Mahjong, Hearts, 2048.
We did not move the flagships. Klondike is the game that people play most: 64,900 games in September. Its file is 4,606 lines, and it stays as it is. So do Spider and FreeCell. The engines exist to make new games cheap. A game that so many people play moves only in a step of its own, with its own proof, or not at all.
The layout does not reduce to a rule. Each game still carries nine numbers for its layout, and a test holds them against the stylesheet.
Reading comes first. A game with no new key takes about 45 minutes, guide included. Before that comes the sheet: the sources with the rule text quoted, the deal as numbers that add up to the deck, and how the game differs from each game that we have. A second pass tries to prove the sheet wrong from another source. Only a sheet that stands is built.
What We Do Not Know Yet
- How to move a flagship. We have no way yet to put Klondike on an engine and be sure that nothing changes for the people who play it each day.
- Where the engines end. Twelve engines hold 233 games. Some families in the books fit none of them. We do not know yet which ones deserve an engine of their own.
- How far a person’s review goes. A person cannot play 233 games with care. The gates carry most of the proof today. We want to know what they still miss.
If you have solved one of these, tell us how.
Follow Along
This is the first post of a series about how the site is built. The next ones:
- The solver that proves a deal can be won, and how our hint went from 0 wins in 1,300 games to 171 in 200. The first part of that story is here.
- A daily video that a program makes, with no editor and nobody watching, and the quarter of a second that a sound mixer lost.
- More than 25,000 tests for card games, and the ones that could not fail.
To get the next post: the engineering section, the RSS feed, or TrySolitaire on LinkedIn.
And the games are there to play:
- Limited, the 74-line game above.
- Rank and File and Emperor, one line apart.
- Saratoga, the game that could not end.
- Thieves of Egypt, the real one.
- All 301 games.
How We Measured
- Games are the live games in our catalogue on November 14, 2026. A spec game is one whose file imports a family engine.
- Lines are the lines of a file, comments and blank lines included. The engines are the 15 files of the engine folder. Comment share counts the lines that are not blank.
- Who wrote the code is in the commit log. An AI agent is the author of all 76 commits to the engine folder, from the first on August 28, 2026. The same is true of the 12 commits to Limited’s test and to its family’s playthrough.
- The figures are drawn by a program from the code and from screenshots of the games. The four boards in the third figure are one shuffle, dealt by each game.
- The broken rule is a real run, on November 14, 2026: Limited’s own 4 tests and the 240 of its family’s playthrough.
- The 711, 483 and 73 lines are in the header of the stock-and-waste layer. The 210 lines, the 45 minutes and the 31 files are from our engine plan, measured between August 28 and September 5, 2026.
- The rules of Thieves of Egypt are from the three sources that its file names: Pretty Good Solitaire, PySolFC and BVS Solitaire.
- The September figure for Klondike is from our September report. Klondike had more games in it than any other game.
Published November 14, 2026 | TrySolitaire Blog · Play Free Solitaire