Perfect Chess
BEHIND THE BOARD

About Perfect Chess.

Perfect play. Just be patient

The computer resolves every legal continuation before choosing a move. It can search them itself or use solved endgames. Finishing from the starting position remains practically out of reach.

Vibe coding project:
coding comes from OpenAI Codex, the vibe from me

Optional: Use solved endgames

Enable the checkbox to resolve eligible subtrees from locally hosted Syzygy tables for up to five pieces, including kings and pawns. The complete WDL and non-rounded DTZ collection is about 1.06 GB. Your browser downloads only the verified 256-KiB blocks it needs and caches them. It does not send positions to Lichess’s tablebase API.

Each lookup replaces a solved subtree. Unvisited descendants are excluded from Visited and outcome counters; Endgame subtrees solved counts the replacements. Castling rights, unsafe repeated-history win/loss cases, uncertain fifty-move boundaries and unavailable data remain in the ordinary search. Every legal root action is still resolved before the computer acts.

Data: Syzygy, distributed via the Lichess file mirror. Reader: shakmaty-syzygy, compiled to WebAssembly. Credits and licenses · Complete reader and integration source.

Optional: Keep solved variations in memory

Under Full search details → Advanced · solution memory (optional), this option keeps fully proved board nodes in this tab’s RAM, including the outcome of every legal action and an optimal action. Later turns can reuse them immediately when the position, move counters, complete repetition history and rule model match exactly. It also retains completed subtrees from a search whose overall root is still Unknown. It never treats an unfinished branch as solved.

No solution data is written to disk or uploaded. The option starts off. Its default memory budget is 64 MB, adjustable under Full search details. The budget counts a conservative estimate of retained strings and records; JavaScript engine overhead is additional. At the budget limit, the search pauses before the unsaved node closes. Increase the budget or clear solution memory, then choose Retry. Existing proved records remain intact. A sudden tab or operating-system termination cannot always be caught.

Records survive new moves, resets and individual search workers in the same tab. Closing or reloading the tab clears them. This makes later decisions cheaper; it does not make the first complete search from the starting position practical. With solved endgames enabled, its verified boundaries may also be retained; modes are stored separately. Reused subtrees contribute one visited boundary, with no invented descendant counts.

02 / THE NUMBERS

The first few moves.

A half-move, or ply, is one move by one player. A full move contains White’s move and Black’s reply.

White’s first choices20
Black’s replies to each20
First full-move sequences400

After the particular move 1. e4, Black has 20 legal replies. The number 400 counts the replies across all 20 possible White opening moves.

Exact board-move sequences from the standard starting position, at each depth.
Half-movesLast move playedMove sequences
1White’s first move20
2Black’s first reply400
3White’s second move8,902
4Black’s second reply197,281
5White’s third move4,865,609
6Black’s third reply119,060,324
7White’s fourth move3,195,901,860
8Black’s fourth reply84,998,978,956

These perft counts are move sequences, not distinct positions: different paths can reach the same board. They exclude draw-claim branches and do not count complete games or give a maximum for the live search. Sources: JuddPerft’s published counts and Stockfish’s depth-seven test.

TRY THE SCALE

Depth, speed and time.

Nodes through this depth88,319,013,353
Time at the selected speed~ 46.6 years

Includes the starting node and each layer through the chosen depth. Speeds are illustrative; this calculator does not run the chess search.

30 choices per half-move, for 80 half-moves.

That imaginary tree contains about 15.3 octotrigintillion nodes, including earlier layers. At the selected speed, visiting it would take approximately:

Calculating…

An illustration of exponential growth. Real chess has a changing branching factor; this example is not a forecast for your game.

03 / NUMBER NAMES

Yes, those numbers have names.

The display uses the English short scale: million, billion, trillion, and so on. Each step is 1,000 times larger. An English billion is a German Milliarde, not a Billion.

million
1 followed by 6 zeros
billion
1 followed by 9 zeros
centillion
1 followed by 303 zeros
ducentillion
1 followed by 603 zeros

For rarer names, the app combines Latin roots using the Conway–Wechsler naming system. These are systematic extensions, not everyday vocabulary. The digits stay numeric: 6.21 centillion means 6.21 times a centillion. A bigger name expresses the size of an estimate, not greater certainty.

Read more: Wikipedia — Names of large numbers.

04 / RULES

Rules covered.

The board and search use the same rules, checked against FIDE Laws, Articles 3, 5 and 9.

Legal moves & check
Piece movement, captures, blocked paths and pins. A move cannot expose or leave your king in check.
Both castling wings
Both colors and wings. Clear space between king and rook; the king cannot castle out of, through or into check. Lost rights stay lost.
En passant
Only immediately after the qualifying double pawn move, and only when the capturing side’s king remains safe.
Every promotion
Queen, rook, bishop or knight, for either color, including captures. Choices do not depend on previously captured pieces.
Checkmate & stalemate
Both end a line immediately. Checkmate takes precedence over the automatic 75-move draw.
Position repetition
Threefold permits a claim; fivefold ends automatically. Identity includes the side to move, castling rights and legal en passant.
50 / 75 moves
Without a pawn move or capture: 50 moves per player permits a claim; 75 ends automatically. That is 100 / 150 half-moves.
Draw claims
Claims now and claims with an intended qualifying move are separate optional actions. Both claim grounds remain available when they coexist.

Dead positions: a limitation.

The app immediately recognizes king vs king, king and one bishop or knight vs king, bishops-only positions with all bishops on the same square color, and proven locked king-and-pawn fortresses. It does not immediately recognize every possible dead position. Those lines may be explored further until they resolve to draws, adding work and delaying the game’s end.

Clock forfeits, touch-move, scoresheets, arbiters and tournament penalties are outside this app. Chess960 and other variants are not supported.

05 / PLAYING

Playing and building positions.

Your side of the board

Choose Computer plays → Black or White; you play the other color. Changing sides keeps the position, cancels the search and flips the board. Computer White searches before its first move.

Click a piece and a destination, or drag it. Legal targets are highlighted. Promotion opens a choice of all four pieces. Captured pieces sit outside the board.

What happens after a full proof?

The computer plays a proven winning move, resigns a forced loss, or claims/offers a draw. Choose Decline & continue to keep playing against its proven move without repeated draw offers. A visible ending notice explains why play stopped. Play on reverses a resignation or agreement and continues with optimal board moves, without further resignations or draw offers. A claimed draw can be continued this way only if a board move preserves the proven draw. Mandatory rule endings—such as checkmate, stalemate or the 75-move rule—still end play; Undo or reset explores a different line. Undoing a resignation also restarts the computer when it is still its turn.

A drawn position can still be won or lost after mistakes. Counting winning branches does not determine the best move.

The moving pieces are hypothetical

The moving pieces show the search branch; faint pieces mark the actual game. View actual board pauses the search and restores the played position.

Pause, step, stop or start again

Pause keeps progress; Next position steps once. Stop, reset, undo or changing sides discards the search. Hidden tabs pause. Reloading or closing loses progress and all retained solution memory. Fully solved variations remain reusable across searches in the same tab when the memory option is on. The animation targets up to 120 fps; search can be slower.

Analyze an endgame or another position loads FEN and small solvable examples. FEN starts a new repetition history. Undo also reverses resignation or an accepted draw. About opens separately so your game stays available.

Build your own position

Open Edit position to place, move or erase pieces. Use Clear board, Initial position, Reset edits, Undo and Redo. Advanced controls set the side to move, castling rights, en passant and move counters. Import or copy FEN to share a setup.

Play position permits extra pieces and pawns with a warning. It requires one king per side, no pawns on the first or last rank, consistent castling/en passant settings and a non-moving king out of check. These checks do not prove the position could arise in a real game. Playing starts a fresh history; opening the editor only pauses the current game.

Templates offers thirteen positions. The two full-army examples have 18 pieces each and a complete 939-node tree. Their clock starts at 0: every line ends within three halfmoves through checkmate or stalemate on the board. There is no inherited repetition or move-count shortcut. They automatically select the computer to move first and turn solved endgames off; you can change either choice before playing. Other templates cover mate versus stalemate, rook underpromotion, two knights, pawn races, legal and pinned en passant, a blocked pawn, the wrong bishop, bishop-and-knight mate and castling. All start with a fresh halfmove clock. Selecting a template loads the editor immediately. Play position applies it. Reset template restarts that position; pressing the resulting New game button returns to the standard board. A new player move rearms Reset template. Custom setups use the same behavior with Reset position.

06 / THE DISPLAY

Reading the display.

Who wins with perfect play?

The highlighted With perfect play… panel asks Who will win? while the outcome is still being calculated. Once the analysis is complete, it says White wins the game, A draw is forced, or Black wins the game. A small Proven tag marks a fully calculated outcome. The draw result means neither side can win against perfect defense. The panel describes the analysis’s starting position; when the actual game ends, it shows Game over and that game’s final result.

The three counters below it are search statistics. They count fully solved board subtrees, including terminal and intermediate positions along different paths. They are not votes, probabilities or a count of distinct board positions.

For example, if Black has 100 replies, 99 losing and one winning, Black chooses the winning reply. That position is won for Black despite the 99 White-win replies. Working backwards, each White node keeps White’s best result; each Black node keeps Black’s best. This is how minimax finds the perfect-play outcome rather than taking a majority.

“Still open” means the calculation is unfinished, not that all outcomes are equally likely. Finding many winning or drawn subtrees cannot settle the starting position by itself. The full root result still passes the same completion and consistency checks before the computer uses it.

The narrow bar to the left of the board follows the position currently displayed on the board. During live search it can be fully white for a known White win, fully black for a known Black win, or half white / half black for a known draw in that hypothetical position. Checkmates, automatic draws and already solved endgames can color it immediately. An unfinished position stays neutral with ?; there is no heuristic score or winning percentage. Testing an optional draw claim alone does not mean that the board position is drawn. The right-hand With perfect play… panel still describes the search’s starting position, independently of the live bar. Pause and Next position retain this distinction. View actual board returns the bar to the actual-game view, and the draw bar follows the board’s orientation when flipped.

Visited / Projected total
Visited is exact. Projected total extrapolates from observed branching and terminal depths. Depth-first samples are biased: this is a rough estimate, not a maximum, percentage or stopping rule.
Depth / deepest
Current and deepest search depth, in half-moves. These are hypothetical moves.
Elapsed / Projected search time
Elapsed excludes pauses. Projected remaining time uses the estimated node count and observed speed; it can change by many orders of magnitude.
Search memory
Estimated memory for the active path, history and pending branches. Finished branches are released from the active stack. Optional solution memory keeps their proved strategies separately in RAM, within its selected budget. Browser heap, when available, may exclude the search worker. Neither figure is total computer RAM.
Search statistics · solved subtrees
Completed board subtrees, including terminal positions and solved ancestors. Claim-only leaves are excluded. Paths can repeat positions: these are neither unique-position counts nor win probabilities. The search starting position may still be unproven; use the highlighted perfect-play result, not these counts. Click Draw subtrees ⓘ to see direct ending rules, solved ancestors and separately counted optional claims.
Root replies proven
A reply is proven only when all its continuations finish. Every starting reply must be resolved.

How long will the search take?

The two measured full-army templates use their known exact tree sizes when started unchanged, with solved endgames and solution memory off. Estimated time left uses the remaining nodes and your measured speed; no result is preloaded and the full search still runs. Other positions show a time scenario, rather than a reliable ETA. The geometric model assumes a regular tree, while chess branches can have very different lengths. It can show minutes for a search that finishes in seconds, or be far too optimistic. Animation speed, loading and browser performance also affect elapsed time. Pause time is excluded.

Time-scale warnings

The first yellow-triangle comparison is the next meal in your local time: breakfast at 09:00, lunch at 13:00 or dinner at 19:00. Only the next one is included; after dinner it is tomorrow’s breakfast. Then come midnight, year-end and increasingly distant astronomical events in chronological order. Messages stay for at least 10 seconds, with 20-second gaps, and appear only when the current estimate exceeds that milestone. They illustrate scale; they do not predict a completion date.

Calendar dates use local time. Astronomical times are approximate, and an Andromeda collision is uncertain. References: NASA: stellar stages, the Sun’s future, galactic orbit and ESA/Hubble: Andromeda.

07 / LIMITS & TESTING

What has been checked.

A completed proof gives the best win/draw/loss result, provided the rules, code and any enabled tablebase data are correct. This app has not solved the starting position and has not been formally verified.

125Passing rules, solver, editor and display tests
1,048Independent reference positions
26,506Legal moves compared
459,691Nodes in move-generation benchmarks

Audit: 4 November 2026. Reference data: python-chess. Eleven small complete trees also matched all outcomes and counters. RAM-only reuse is tested for exact history matching, unfinished-node rejection, budget exhaustion and retry, legal special moves, worker lifetime reuse, and absence of disk/network access. The endgame reader additionally matched 95 independently probed positions, with tests for root actions, historical draw claims, failures and complete conversion to mate. Tests cannot prove correctness for every possible position.

Why is the tree finite?

The 75-move rule limits play between pawn moves and captures. Only finitely many such resets are possible. The resulting tree is finite, but far too large to finish in practice from the starting position.

Why search again after my next move?

With solution memory enabled, an exactly matching solved descendant can supply its proven reply without searching again. With it off, cleared or lost after a reload, the next turn starts a fresh search.

What runs in the browser?

JavaScript runs the game and search in your browser, with a Web Worker for the search. A WebAssembly reader probes locally hosted Syzygy data. HTML and CSS provide the interface. Python supplies independent test data only. There is no server-side chess calculation.

What happens at a resource limit?

An interrupted or failed search remains Unknown. The computer does not turn it into a draw or play an unproven move.

Move generation uses chess.js 1.4.0 (BSD license). The app adds draw claims, automatic draw rules, exhaustive search and a final check of the completed result.

Shannon described exhaustive chess search in 1950. This project lets you watch it.

“Perfect” means choosing the best available result after a completed search. Even perfect play can lose from an already lost position.