{"type": "session", "harness": "opencode", "id": "chess-0097", "name": "Transposition Tables and Zobrist Hashing"} {"type": "message", "message": {"role": "system", "content": "You are an expert chess programmer."}} {"type": "message", "message": {"role": "user", "content": "Explain transposition tables and Zobrist hashing"}} {"type": "message", "message": {"role": "assistant", "content": "Transposition table (TT): hash table storing positions already evaluated. Key = hash, value = score + best move + depth + flag.\n\nZobrist hashing: assign random 64-bit integer to each (piece, square) pair. Position hash = XOR of all piece-square values. Incremental update: XOR out old piece, XOR in new piece.\n\nReplacement strategies:\n- Always replace: simple, may overwrite better entries.\n- Depth-preferred: keep deeper entries. When slot full, if new depth > stored depth, replace.\n- Age-based: prefer older entries (from earlier search).\n\nTT flags: EXACT (score is exact), LOWER_BOUND (score >= value, fail-high), UPPER_BOUND (score <= value, fail-low).\n\nClustered TT: store 3-4 entries per bucket to reduce conflicts. Stockfish uses 4-entry clusters.\n\nFalse positives: hash collision where different positions hash to same key. Rare with 64-bit hashes.\n\nApplications:\n- Avoid re-evaluating transpositions\n- Move ordering (store best move)\n- Mate detection (store mates with ply info)\n- Cutoff: if TT entry has sufficient depth and bounds, use it directly."}}