Skip to content

Commit 7d6ac67

Browse files
authored
Consider repetitions in TB probing (#1027)
has_repeated was hardcoded to false, so Fathom never knew if the root position had repeated before, and could rank a drawn position as a win. Search usually catches this via upcoming_repetition and is_draw, but when DTZ succeeds we stop probing TB in search. The wrong score then gets written to TT and returned via TT cutoff before any repetition check can correct it, which might cause the engine to report an incorrect eval. Bench: 2851948
1 parent 4a2efd5 commit 7d6ac67

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/board.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ impl Board {
260260
self.state.repetition != 0 && self.state.repetition < ply
261261
}
262262

263+
pub const fn is_repetition(&self) -> bool {
264+
self.state.repetition != 0
265+
}
266+
263267
pub fn draw_by_fifty_move_rule(&self) -> bool {
264268
self.halfmove_clock() >= 100 && (!self.in_check() || self.has_legal_moves())
265269
}

src/tb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn rank_rootmoves(td: &mut ThreadData) {
117117
0,
118118
ep_square,
119119
td.board.side_to_move() == Color::White,
120-
false,
120+
td.board.is_repetition(),
121121
true,
122122
tb_ptr,
123123
);

0 commit comments

Comments
 (0)