Repository navigation
Conversation
BoardState moves to its own header so zobrist.hpp can include it without including board.hpp. Every mutator and castling_rights_index() are now defined inline in zobrist.hpp; only compute_hash(), which needs the full Board, stays in zobrist.cpp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hardcode3
marked this pull request as ready for review
December 2, 2026 19:17
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Inline Zobrist updates behind a
zobrist::Hashclass📄 Description
Zobrist updates were out-of-line free functions in
zobrist.cpp, and they modified a hash passed as a plainuint64_toutput parameter.Board::set_piece()andremove_piece()call them on every move.This PR moves them inline into a small
zobrist::Hashclass that wraps theuint64_t:using Key = uint64_t,NULL_HASHzobrist::Hash,Hash{}compute_hash(board)Hash::compute(board)mutate_piece(sq, piece, key)hash.toggle_piece(sq, piece)mutate_side_to_move(key)hash.toggle_side_to_move()mutate_castling_rights(state, key)hash.toggle_castling_rights(state)mutate_en_passant_square(sq, key)hash.toggle_en_passant_square(sq)mutate_board_state_diff(prev, next, key)hash.apply_state_change(prev, next)uint64_t: every method exceptcompute()is inline, andstatic_asserts check thatHashkeeps the size of auint64_tand stays trivially copyable.value()returns the raw 64 bits.BoardStatemoves toboard_state.hpp, so thatzobrist.hppcan use it inline without includingboard.hpp, which includeszobrist.hpp.zobrist.hppare rewritten to explain what a hash contains and how to update it.🧩 Type of Change
📊 Severity
Board::operator==. The values are unchanged and covered by tests.🔖 Release
🗒️ Changelog Entry
🧪 Testing
clang_debugandclang_releasebuild without warnings. 111/111 tests pass inquick-validation-clang-debugandquick-validation-clang-release.constexprchecks. New tests cover the default value, equality, chaining, stream output andapply_state_change()ignoring the move counters.zobrist.hppandzobrist.cppreach 100% region, line and branch coverage.✅ Checklist
📝 Additional Notes
No benchmark is included, so the speed-up from inlining is expected but not measured.