How Chess Engines Work (Minimax, Alpha-Beta, NNUE)

Close-up of a chessboard with pieces in action and a hand moving a piece, highlighting strategic play.

Modern chess engines beat the best human players by margins that would have seemed absurd thirty years ago. The engine running on a laptop today is stronger than any human who has ever lived. The interesting question isn’t whether they win — it’s how. The answer combines four classical algorithms with one neural-network development from the last six years, glued together by enormous amounts of computational tuning. Here’s how chess engines actually work, from the ground up.

Key takeaways

  • Chess engines use minimax search to look ahead through possible moves, scoring positions and picking the best line.
  • Alpha-beta pruning cuts the search tree dramatically by skipping branches that can’t beat what’s already been found.
  • The evaluation function judges any non-terminal position; modern engines use NNUE neural networks for this since Stockfish 12 (2020).
  • Opening books and endgame tablebases handle the start and end of the game with pre-computed data, freeing the search for the middlegame.
  • Stockfish and Leela Chess Zero are the two leading open-source engines, built on very different architectures.

Step 1: The minimax search

At its core, a chess engine plays by looking ahead through possible moves and choosing the one that leads to the best position. The classical algorithm for this is minimax. The engine assumes both players will play optimally — itself maximizing its evaluation, the opponent minimizing it — and builds a game tree of possible move sequences several plies deep.

A “ply” is a single move by one side. Looking three plies ahead means: my move, opponent’s reply, my response. At each node in the tree, the engine evaluates the resulting position and propagates the values back upward. The move at the root that produces the highest score against optimal opponent play is the chosen move.

Minimax is conceptually simple but computationally explosive. Chess has an average of about 35 legal moves per position. A naive minimax search to depth 6 examines 35^6 ≈ 1.8 billion positions. To depth 10, it’s 2.7 quadrillion. Pure minimax is intractable for any non-trivial depth without optimization.

Step 2: Alpha-beta pruning

Alpha-beta pruning is the algorithm that makes minimax practical. The insight: once the engine has evaluated one move thoroughly, it can stop evaluating any move that the opponent could refute. If move A is known to result in evaluation +0.3 with best play, and the opening of move B already produces -1.0 against one opponent response, there’s no point exploring further — the opponent will choose that refutation, making B worse than A.

The two thresholds — alpha (the best value the maximizer is guaranteed) and beta (the best value the minimizer is guaranteed) — bracket the search. When alpha exceeds beta, the branch is “pruned” and skipped. Properly implemented, alpha-beta reduces the effective branching factor from 35 to roughly 6, which is enormous. A depth-12 search becomes practical instead of impossible.

The order in which moves are searched matters enormously for alpha-beta efficiency — if you search the best move first, more branches get pruned. Modern engines use heuristics (killer moves, history tables, transposition tables) to order moves before searching.

Step 3: The evaluation function

When the search reaches its target depth or a “quiet” position, the engine needs to score the resulting board. This is the evaluation function. Classical evaluation functions combine many handcrafted features: material count (queen = 9, rook = 5, etc.), piece activity, king safety, pawn structure, control of the center, mobility, and dozens of others. Each feature is weighted and summed into a single score, usually expressed in centipawns (hundredths of a pawn).

For decades, this handcrafted approach dominated. Engines like Stockfish (in its pre-NNUE form), Houdini, and Komodo all used variations of this approach with painstakingly tuned weights. The strength of an engine was largely a function of how cleverly its evaluation captured chess intuition.

Step 4: NNUE — the 2020 breakthrough

In 2020, Stockfish 12 integrated a neural-network evaluation function called NNUE (Efficiently Updatable Neural Network), originally developed for shogi engines by Yu Nasu. NNUE replaces the handcrafted evaluation with a small neural network trained on millions of positions.

The key engineering insight in NNUE is “efficient updatability.” Most neural networks are slow to evaluate because they require full forward passes through dense matrix multiplications. NNUE’s architecture is designed so that small changes to the position (a single move) require only small updates to the network’s hidden state, not a full recomputation. This makes NNUE fast enough to use inside the alpha-beta search at every leaf node.

The strength gain from NNUE was immediate and large, one of the biggest single jumps in Stockfish’s history. Modern Stockfish, Komodo Dragon, and many other engines now use NNUE-style evaluation functions trained on positions scored by strong engines.

Step 5: Opening books

The opening phase of a chess game has been studied exhaustively by humans for over a century. There’s enormous theory on what moves are best in known positions — and the engine can use this directly. An “opening book” is a database of move sequences for the start of the game, with pre-computed best-move recommendations.

Engines that use opening books simply look up the current position in the book and play the recommended move, skipping the search entirely for the first moves of the game. This conserves computation for the middlegame, where the position is no longer in the book and the search has to do real work. In top engine competitions the organizers usually assign the opening moves themselves, so the engines start searching from a set position.

A common file format for opening books is Polyglot, a standard many engines and chess GUIs can read.

Step 6: Endgame tablebases

The endgame is the opposite of the opening — fewer pieces, fewer possible positions, more tractable to enumerate. For positions with seven or fewer pieces remaining, complete solutions exist as “endgame tablebases” — databases that record the optimal move and the outcome (win/loss/draw and the distance to mate) for every possible position.

The Syzygy tablebases (released by Ronald de Man) and the older Nalimov tablebases are the standard formats. When a game reaches a position with few enough pieces, the engine consults the tablebase and gets the perfect move without search. This guarantees flawless endgame play in any reachable tablebase position.

The largest complete tablebases cover seven-piece endgames. A complete eight-piece set would be vastly larger again, and none exists yet.

How the pieces fit together

A modern chess engine in 2026 plays a move roughly like this:

  1. Check the opening book. If the position is in the book, play the book’s recommended move and skip everything else.
  2. Check the endgame tablebase. If the position has few enough pieces to be in the tablebase, play the perfect move.
  3. Run alpha-beta search to a target depth (or under a time budget), using NNUE to evaluate leaf positions.
  4. Apply move-ordering heuristics, transposition tables, late-move reductions, and other refinements to make the search efficient.
  5. Return the move at the root with the best evaluated outcome.

The whole pipeline runs in fractions of a second per move at fast time controls, and at long time controls on modern hardware engines commonly report search depths of 30 plies or more.

Leela Chess Zero — the alternative architecture

Stockfish and its successors use alpha-beta search with NNUE evaluation. The other major engine, Leela Chess Zero, takes a fundamentally different approach inspired by DeepMind’s AlphaZero. Leela uses Monte Carlo Tree Search (MCTS) guided by a deep neural network (originally convolutional, with newer networks based on transformers) that supplies both the evaluation and move-selection priors.

Leela doesn’t do exhaustive alpha-beta search. Instead, it grows a search tree probabilistically — exploring promising lines deeply and likely-bad lines shallowly. The neural network is far deeper than NNUE and much slower to evaluate (Leela usually runs on a GPU, while NNUE is built for fast CPU inference), but the MCTS framework compensates by being more selective about which positions to evaluate.

Stockfish is generally regarded as the strongest engine and has won most recent top-level engine championships, with Leela its most consistent challenger. The two architectures represent different bets about where the computational budget is best spent.

What this all means for human players

The strength gap between the best engines and the best human players is now unbridgeable. Magnus Carlsen, the highest-rated human player in history, would lose match after match to a modestly tuned Stockfish running on a laptop. But the engines are also enormous study tools — modern preparation involves running engine analysis on every line, identifying mistakes that would have been invisible to human analysis a generation ago.

The engines have also reshaped the opening landscape. Some openings that humans considered marginal turned out to be sound under engine analysis; others that were considered strong turned out to be drawn or worse. The competitive chess world’s understanding of theory has been updated, line by line, against engine recommendations.

You can see a tiny version of these ideas in our own browser chess game, whose computer opponent runs a shallow search (up to three plies) rather than anything Stockfish-sized. For more on the strategic side of the human game, see our games like chess piece on the wider chess-and-chess-adjacent universe.

What’s missing from this picture

Two things. First, the engines play differently than humans. They find moves that look ugly or counterintuitive but turn out to be objectively best. Human-style play and engine-style play diverge in subtle ways that have generated their own field of analysis.

Second, computational chess isn’t “solved.” Eight-piece tablebases are years from completion. Full chess from the starting position is far beyond current computational reach — Claude Shannon estimated the game tree at around 10^120 possible games, with roughly 10^44 or more legal positions, and no amount of pruning gets close to tractable from the root. The engines are excellent within their lookahead window but they’re not solving the game in any meaningful sense.

Frequently asked questions

What is the strongest chess engine in 2026?

Stockfish is generally considered the strongest, with Leela Chess Zero its main rival in top engine competitions. Their architectures differ — Stockfish uses alpha-beta with NNUE; Leela uses Monte Carlo Tree Search with a deeper neural network. Both are open-source.

What does NNUE stand for?

Efficiently Updatable Neural Network. The “efficiently updatable” part is the key innovation — the network’s hidden state can be updated incrementally as moves are made, rather than recomputed from scratch, which is what makes it fast enough to use inside an alpha-beta search.

Did AlphaZero beat Stockfish?

In 2017, DeepMind’s AlphaZero won a match against Stockfish 8. The match conditions were debated at the time (Stockfish was running without an opening book and with limited hash memory), but the result showed that neural-network-based engines could compete with traditional alpha-beta engines. Modern Stockfish, with NNUE, has closed the gap and may have surpassed AlphaZero on equivalent hardware.

How deep can chess engines search?

At long time controls, modern engines commonly report nominal depths of 30 plies or more, with selective extensions reaching much deeper on critical lines. The depth varies by position complexity and the engine’s move-ordering quality.

Are opening books and tablebases cheating?

Not in any chess-engine context — they’re standard tools. Major engine events such as TCEC typically assign the openings themselves and allow tablebase access in the endgame. The argument that they “aren’t really playing chess” is a philosophical question rather than a competitive rule.

The takeaway

Chess engines combine classical algorithms (minimax, alpha-beta, opening books, endgame tablebases) with modern neural networks (NNUE in Stockfish, deep convolutional networks in Leela) to play chess at a level no human can match. The architecture is more elegant than people assume — five well-understood components tied together carefully. For an entirely different algorithm-driven browser game, the Chrome Dino game has been the subject of its own neural-network experiments (YouTuber Code Bullet’s AI-learns-the-dino-game video is a well-known example), demonstrating that even one-button games invite the same kind of computational analysis.

🔌 Connect any AI assistant to dinogame.gg — we run an MCP server: https://dinogame.gg/mcp