Concept
What Is a Transposition?
2. Nf3 Nc6
3. Bb5 a6
2. Bb5 Nc6
3. Nf3 a6
Key
Zobrist Hashing
+ EP + castling
+ side to move
updated on make/unmake
Structure
What's Stored in One TT Entry
(full or partial hash)
(e.g. 14 plies)
mate distance
(for ordering)
(optional replace)
Flags
EXACT, ALPHA, and BETA Bounds
Score is the true minimax value at this depth — all moves were searched and the result lies inside the window.
Fail-low bound — position score is at most stored value (no move raised alpha high enough).
Fail-high bound — position score is at least stored value (a move caused a beta cutoff).
Runtime
TT Lookup During Search
index = zobristKey % ttSize — often 1–4 slots per bucket (cluster) to reduce collisions.Deep dive
Implementation Details
Mate scores depend on distance to mate. Store MATE - ply on write, add ply back on read so the same mate works at different depths in the tree.
Depth-preferred: always replace if new depth ≥ old (most common). Always replace: simpler but weaker. Age/generation: prefer entries from current iterative-deepening pass. Clusters keep multiple entries per hash slot.
Each depth pass fills TT with deeper entries. Shallow results bootstrap move ordering for deeper searches — TT hit rate climbs each iteration. Clear TT on ucinewgame, not every move.
Separate from TT but uses the same Zobrist key stack: if a key repeats three times, declare draw. TT stores search scores; repetition stack stores game history keys.
Hash collisions (different positions, same index/tag) cause rare wrong scores if key tag is too short. Use enough key bits. Never store TT results without verifying tag match.
Reference
TT vs Other Engine Memory
| Structure | Stores | Purpose |
|---|---|---|
| Transposition table | Depth, score, flag, move | Avoid re-searching subtrees |
| Killer moves | 2 quiet moves per ply | Move ordering only |
| History table | Quiet move scores | Move ordering only |
| Repetition stack | Zobrist keys along PV | Draw by threefold |
| Pawn hash (optional) | Pawn structure eval | Eval cache, not search |
Why TT size matters
Larger TT → fewer collisions, more deep entries retained → higher hit rate → fewer nodes. Diminishing returns above ~256–512 MB for most engines. UCI option Hash lets users allocate MB at runtime.
- Clear TT on new game; keep between moves in same game
- Store TT move first in move ordering every node
- Pack entries small — millions of slots fit in RAM
- TT does not replace correct move generation or eval
Explore the engine series
TT powers search cutoffs — see how it fits with alpha-beta and the full engine stack.
Related: Search Algorithm · Move Generation · All Blogs