{
  "id": "endgame-tablebase",
  "title": "Endgame tablebase",
  "lang": "en",
  "source_lang": "en",
  "summary": "An endgame tablebase stores exhaustively computed results for game positions with limited material, enabling exact evaluation and optimal play under specified rules.",
  "category": "computer-science",
  "subcategory": "software",
  "type": "concept",
  "aliases": [
    "Endgame database",
    "Chess endgame tablebase"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/endgame-tablebase/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/endgame-tablebase/",
      "json": "https://aiwiki.page/zh/endgame-tablebase.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "An endgame tablebase is a precomputed collection of exact results for positions in a game, especially chess, with a restricted number or selection of pieces. For each covered position, it records whether the player to move can force a win, must lose against perfect play, or can secure a draw. Some formats also record the distance to checkmate or another specified event. Unlike a heuristic evaluation function, a tablebase does not estimate a position’s value: it supplies a result established by exhaustive computation under a defined set of rules."
    },
    {
      "heading": "Coverage and position representation",
      "text": "Chess tablebases are usually classified by the maximum number of pieces on the board, counting both kings. A five-piece tablebase, for example, can cover positions containing two kings and three other pieces. An individual material class might consist of king and rook against king and bishop.\n\nMaterial alone does not identify a position. A lookup must also distinguish:\n\n- The squares occupied by the pieces.\n- Which player is to move.\n- Relevant special-move rights, such as en passant.\n- Any additional rule state required by the tablebase’s interpretation of draws.\n\nMany practical formats omit positions with castling rights. The half-move counter used for the fifty-move rule is often handled by the probing software rather than included directly in every stored position. Repetition claims likewise depend on game history, which a board-position lookup alone does not describe.\n\n“Complete” coverage is therefore relative to a specification: the permitted pieces, legal positions, supported special moves, and treatment of draw rules. A collection covering one material class also depends on results for positions reached through captures and promotions."
    },
    {
      "heading": "Construction by retrograde analysis",
      "text": "The standard construction method is retrograde analysis: reasoning backward from positions whose results are already known. This is a form of exhaustive dynamic programming on the directed graph of legal positions.\n\nA simplified win–draw–loss construction proceeds as follows:\n\n- Enumerate the legal positions within the chosen coverage.\n- Identify terminal positions, including checkmates and stalemates.\n- Mark a position as winning if at least one legal move reaches a position that is losing for the opponent.\n- Mark a nonterminal position as losing if every legal move reaches a position that is winning for the opponent.\n- Repeat until no further results can be propagated.\n- Classify the unresolved positions as draws.\n\nThe last step requires qualifications: it applies when the graph, boundary results, and treatment of infinite play and draw rules have been specified correctly. An unresolved position is not a draw merely because a limited computation failed to prove a win.\n\nCaptures lead to positions with fewer pieces, so construction normally uses previously generated, smaller tablebases. Promotions may lead to another material class with the same number of pieces and must also be accounted for. Pawn movement introduces further dependencies that generators can exploit when organizing the computation.\n\nThis process is closely related to minimax reasoning. A winning player needs only one move that preserves a forced win; a losing classification requires that every legal defense fail. Unlike ordinary forward exploration of a game tree, tablebase generation attempts to solve the entire covered position space, including positions unlikely to occur in actual games."
    },
    {
      "heading": "Stored results and distance metrics",
      "text": "“Optimal play” depends on the quantity being optimized. Several tablebase metrics are used, and they need not recommend the same move.\n\nWin–draw–loss\n\nWin–draw–loss, or WDL, gives the game-theoretic outcome from the perspective of the side to move. A basic WDL result does not distinguish a quick win from one requiring hundreds of moves.\n\nSome formats use a richer classification to distinguish wins and losses affected by the fifty-move rule. Syzygy tablebases, for example, distinguish ordinary wins and losses from cursed wins and blessed losses. A cursed win is winning when the fifty-move restriction is disregarded but drawable under its rule-aware interpretation; a blessed loss is the corresponding result for the defender.\n\nThese categories must be interpreted together with the format’s conventions and the current game state.\n\nDistance to mate\n\nDistance to mate, or DTM, measures the distance to checkmate under the convention that the winning side minimizes that distance and the losing side maximizes it. Distances are commonly expressed in plies, with one ply representing one player’s move.\n\nDTM provides a precise answer to a shortest-mate question. However, traditional DTM values often disregard the fifty-move rule. A mathematically forced mate may therefore not be enforceable in a game where a draw can be claimed before the required progress occurs.\n\nDistance to conversion\n\nDistance to conversion, or DTC, measures the distance to a specified material-changing event, typically a capture or pawn promotion. Its exact definition depends on the tablebase system.\n\nConversion can divide a long ending into smaller problems. Nevertheless, the fastest conversion is not necessarily the fastest checkmate, and it does not by itself guarantee compliance with move-count draw rules.\n\nDistance to zeroing\n\nDistance to zeroing, or DTZ, concerns the distance to a move that resets the fifty-move counter: a pawn move or capture. Practical definitions also account for terminal outcomes such as mate and may encode rule-dependent distinctions.\n\nDTZ is useful for preserving wins while respecting the move counter. It is not simply the distance to the nearest available pawn move or capture: the continuation must preserve the relevant game-theoretic outcome. In Syzygy, WDL and DTZ information are used together."
    },
    {
      "heading": "The importance of draw rules",
      "text": "An exact result is always exact under specified rules. This is particularly important in chess because the same arrangement of pieces can have different practical consequences depending on the preceding play.\n\nUnder the fifty-move rule, a player can claim a draw after the required sequence without a pawn move or capture. Modern standard chess rules also provide an automatic draw after seventy-five moves by each player without either event, except when the final move checkmates. Repetition rules introduce additional history dependence.\n\nConsider a position that requires another twenty moves before the winning side can force a capture. It may be a valid win immediately after the counter has reset but not when forty qualifying moves have already elapsed. A tablebase that ignores the counter can correctly establish an unrestricted win while failing to establish a win in the current game.\n\nAccordingly, software must combine tablebase information with the current half-move count, applicable competition rules, and, where relevant, repetition history."
    },
    {
      "heading": "Storage and probing",
      "text": "The main practical obstacle is the enormous number of positions. Adding a piece expands the state space substantially, and generation may require more storage and working memory than the final compressed files.\n\nImplementations reduce these costs through:\n\n- Canonical indexing: assigning each supported position a reproducible numerical address.\n- Symmetry reduction: identifying equivalent positions through permitted board transformations and exchanges of identical pieces.\n- Compact encoding: storing outcomes and distances in specialized data structures.\n- Lossless compression: reducing storage without changing the recorded answers.\n- Caching and selective loading: keeping frequently accessed information in memory while reading other blocks from storage.\n\nNot every apparent symmetry is valid. Pawn movement, promotion direction, and special-move rights restrict which transformations preserve a position’s meaning.\n\nA probe converts a position into the appropriate material class and index, retrieves its stored result, and interprets that result. Move selection can be performed by probing legal successor positions rather than storing a best move for every position. Engines may use compact WDL data during search and consult larger distance files when selecting moves."
    },
    {
      "heading": "Historical development and major systems",
      "text": "Computer-generated endgame analysis developed during the early decades of computer chess. Thomas Ströhlein’s 1970 doctoral work was an important early contribution to systematic endgame computation. Ken Thompson subsequently generated influential collections and used exhaustive analysis to investigate difficult endings.\n\nSeveral later systems became prominent:\n\n- Nalimov tablebases widely distributed distance-to-mate results and became a standard resource for chess software.\n- Lomonosov tablebases, generated using supercomputing resources, extended complete coverage to seven-piece endings in 2012.\n- Syzygy tablebases, developed by Ronald de Man, emphasized compact WDL and DTZ information and efficient engine integration. Complete seven-piece Syzygy data followed in 2018.\n\nThese systems differ in metrics, indexing, compression, and probing conventions. Their outputs are therefore not always interchangeable, even when they cover the same material."
    },
    {
      "heading": "Applications and limitations",
      "text": "Tablebases allow a chess engine to replace uncertain evaluation with exact information once a covered position is reached. They can also influence earlier play: a search reaching a tablebase position obtains a proven result for that branch, although the engine must still account for draw-rule compatibility.\n\nIn chess analysis, tablebases verify endgame studies, uncover defensive resources, and establish whether apparently advantageous positions are actually winning. They have exposed wins requiring exceptionally long or counterintuitive maneuvers and shown that some traditional endgame assessments were incomplete. They also provide exact test cases for search and evaluation software, including systems developed through machine learning.\n\nTheir principal limitations are scope and interpretation. A seven-piece tablebase gives no direct answer for an eight-piece position. It may identify an outcome-preserving move without explaining a useful human plan, and the move preferred by one distance metric may differ from that preferred by another. Exactness also depends on correct generation, file integrity, indexing, and probing code.\n\nFinally, complete endgame coverage is not a solution to chess as a whole. It solves a restricted region of the game’s state space; positions outside that region still require search, evaluation, or other methods."
    }
  ],
  "links": [
    "chess",
    "heuristic-evaluation-function",
    "dynamic-programming",
    "minimax",
    "game-tree",
    "data-structure",
    "lossless-data-compression",
    "machine-learning"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}