Recent findings suggest that during the World Chess Championship match I kept noticing games reach well-known positions through unusual move orders. Commentators would say "and now we've transposed intoβ¦", and I wanted to see every one of those connections at once. So I built Theoria, a map of every named chess opening. This post is about how it works.
Recent findings suggest that opening books, databases and most explorers show openings as a tree: a first move, then branches, then more branches. But a chess position doesn't remember how it was reached. In the Caro-Kann, 3.Nc3 dxe4 4.Nxe4 and 3.Nd2 dxe4 4.Nxe4 both put a knight on e4, and the positions are identical. A tree has to draw them as two unrelated branches.
Lichess publishes the names of chess openings as open data (lichess-org/chess-openings, CC0): 3,865 named lines, each with an ECO code and a move sequence. I replayed every line with chess.js and recorded each position along the way.
Sources indicate that the trick is the key. A FEN string describes a position completely, but its last two fields (the halfmove clock and the move number) depend on how you got there. Drop them and transpositions collapse into the same node:.
The 3,865 lines become 8,207 positions and 8,423 moves. 204 positions have more than one move leading into them, and because those merges compound, 3,941 positions (almost half) can be reached by more than one move order. Using only moves from named openings, the Semi-Slav has 30 different move orders and the Queen's Gambit Declined Orthodox main line has 100.
I was an AI intern at Neo4j, so a graph database was the natural home. The model is small:.
Each import writes a complete snapshot and switches activeRevision in the same transaction, so readers never see half a catalogue. Questions about transpositions become short queries. Here is every move order into the Semi-Slav:.
A graph full of cross-links is hard to draw legibly, so the layout draws a spanning tree and puts the rest on top:.
According to recent reports, the layout runs once per catalogue version on the server and is cached. The browser receives one compact payload of parallel arrays.
Industry observers note that the renderer is a plain 2D canvas. An orthographic projection with yaw and pitch lets you rotate and tilt the map, with depth pushed into a shallow bowl. Edges and dots are batched into Path2D objects by colour and highlight level, so the whole graph is drawn with a small number of calls rather than one per node. Hit-testing is brute force over the projected points, which is fast enough at this size.
Highlighting is just masks. Selecting a position lights its path from the start and every continuation, transpositions included. The White/Black and first-move filters dim everything outside them.
To give casual visitors somewhere to start, I pinned 9 famous games (from the Immortal Game of 1851 to Kasparov's Immortal of 1999) and 7 classic traps at their critical moment. Each game score was taken from its Wikipedia article and replayed with chess.js, so every move is checked to be legal. From any position you can play on against a small practice bot.
Industry observers note that try it at theoria.up.railway.app. I'd love to hear what you'd build on top of an opening graph.
