A transposition table is a hash table cache used in game-playing and search algorithms like Monte Carlo Tree Search (MCTS) and alpha-beta pruning to store and reuse the evaluated value of game states that can be reached via different sequences of moves (transpositions). It works by generating a hash key (e.g., using Zobrist hashing) for each unique game state encountered during the search. When the algorithm reaches a state, it first checks the table. If the state's hash key is present and the stored information (like value, depth, and node type) is usable, it retrieves the cached value instead of performing a costly re-evaluation or subtree search. This prevents redundant computation of identical board positions arising from different move orders.
Key Mechanism:
- Hashing: A fast, deterministic function converts the game state into a unique integer key for table lookup.
- Entry Storage: Each table entry typically stores the hash key, the computed value (e.g., win probability), the search depth (or iteration count) at which it was computed, a flag indicating the node type (e.g., EXACT, LOWER_BOUND, UPPER_BOUND), and the best move found.
- Replacement Policy: Schemes like always-replace or depth-preferred manage collisions in the fixed-size table, deciding which entry to keep when two states hash to the same location.