Chess engines use a Zobrist hash as a compact fingerprint of a position, then compare that fingerprint with positions in the game or search history. The hash makes matching fast, but it cannot tell an engine by itself how often a position has occurred: the engine needs history, and it must include the game-state details that affect legal moves.
What a Zobrist hash represents
A chess position is more than the arrangement of pieces on the board. A Zobrist key combines pseudorandom values assigned to features that describe the current state. Stockfish’s implementation initializes keys for piece-square pairs, side to move, castling rights and en-passant files; other engines may choose different internal structures, but the key must cover the state relevant to their task. Stockfish position source
As an Amazon Associate I earn from qualifying purchases.
The result is a compact numeric fingerprint. It is useful for quickly identifying a position in structures such as a transposition table, where the same position can be reached by different move orders. It is not a unique proof of identity: hashes can collide, and a key is only as suitable as the state information included in it.
How the key changes after a move
Zobrist hashing uses XOR to combine the keys for the active features. When a move changes the position, the engine can XOR out keys for features that are no longer present and XOR in keys for the new features. Since XORing the same value twice cancels it, the engine can update the key without rebuilding it from every square. Stockfish position source
#1 Best Overall
- Start with the key for the current position.
- Remove the keys for changed features, such as a piece leaving its square or a castling right ending.
- Add keys for the resulting features, including the piece’s new square and any changed side-to-move or en-passant state.
- Use the updated key for lookups and, where needed, compare it with keys in the relevant history.
Why the board diagram is not enough
Under the FIDE Laws of Chess for over-the-board play, positions count as the same only when the same player has the move, the same kinds and colors of pieces occupy the same squares, and the possible moves for all pieces are the same. Thus, two identical-looking board diagrams can be different positions if one side has castling rights or an en-passant capture available and the other does not. FIDE Laws of Chess, effective 1 January 2023
That distinction is why a repetition detector must account for rule-relevant state rather than piece placement alone. It also shows why a repeated hash is not itself a draw decision: the game rules define which occurrences count and what procedure applies.
Why repetition detection needs history
A key describes the current state; it does not record how the game reached it. To determine whether a position has appeared before, an engine must consult prior positions or moves. The relevant scope may include the played game and the current search line, where the engine explores possible moves.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchStockfish’s UCI documentation recommends sending the position’s move list when setting up a position, because the move history is needed for correct threefold-repetition detection. A board snapshot alone cannot establish the number of previous occurrences. Stockfish UCI commands
How an engine can search for a recurrence
Scan or count prior keys
A straightforward approach is to compare the current key with earlier keys in the relevant history, or maintain counts of keys as moves are made and undone. This is conceptually simple, but the exact history window and bookkeeping must match the rules and the engine’s search needs.
Use a specialized lookup structure
Stockfish’s source comments that its repetition detection implements Marcel van Kervinck’s cuckoo algorithm, using two hash tables indexed with Zobrist hashes to find recurring positions. This is one implementation, not a universal requirement; engines can choose different history scans or data structures. Stockfish position source
Three different things to keep separate
- Position key: a compact fingerprint of the current state and the rule-relevant features represented by the engine.
- History: the earlier positions or moves needed to establish whether the current state has occurred before.
- Draw rule: the governing chess rules that say when repetition can be claimed or becomes automatic.
What FIDE repetition rules mean for the engine
Under Article 9.2 of the FIDE Laws effective 1 January 2023, a player with the move may claim a draw when the same position is about to occur for the third time by indicating the intended move, or when it has just occurred for at least the third time. Article 9.6 makes the game drawn when the same position has appeared five times. These rules apply to over-the-board play under the cited Laws. FIDE Laws of Chess
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Consequently, an engine’s repetition check must do more than notice a matching fingerprint. It must use a history appropriate to the current game or search context, distinguish positions according to their move possibilities, and apply the relevant draw rule.
Quick Recap
Best Value
- 🤖 SELF-MOVING CHESS ON A REAL BOARD - Chessnut Move pairs a wooden chessboard with plastic Automated pieces that automatically move across the board, bringing digital games to life.Move can reposition multiple pieces at once to reset games quickly or build study positions with less setup time.
- 🎯 1 MM FULL PIECE RECOGNITION - Identifies every piece and its exact board position for accurate move tracking. A 10 Hz refresh rate and 0.1-second response support automated moves averaging under three seconds.
- 🚂BUILT-IN STOCKFISH ENGINE - Play or practice against built-in engines such as Stockfish directly on Chessnut Move, with adjustable Elo difficulty and no phone, computer, or app required.
- 📹VIDEO & ENDGAME IMPORT VIA APP - Connect to the Chessnut App to import positions or replay tutorial and tournament moves automatically on the physical board. Practice endgames, openings, and tactics with minimal setup.
- 🔗ONLINE PLAY WITH AUTO RESPONSES - Connect through the Chessnut App to Chess-com, Lichess, and other supported platforms; your opponent's moves are automatically played on the physical board.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




