From 09ab31974ba111a408b8488e3e83ba362d206ec0 Mon Sep 17 00:00:00 2001 From: rektdie Date: Tue, 18 Mar 2025 12:34:21 +0100 Subject: [PATCH] rewrote IsThreefold | bench 1154407 --- source/board.cpp | 2 +- source/search.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/board.cpp b/source/board.cpp index 0e86b65..be515c8 100644 --- a/source/board.cpp +++ b/source/board.cpp @@ -344,8 +344,8 @@ void Board::MakeMove(Move move) { GenAttackMaps(*this); - positionHistory[positionIndex] = hashKey; positionIndex++; + positionHistory[positionIndex] = hashKey; } bool Board::InPossibleZug(bool side) { diff --git a/source/search.cpp b/source/search.cpp index a7dbaad..7e5cec7 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -84,14 +84,14 @@ void ListScores(Board &board, int ply) { } static bool IsThreefold(Board &board) { - int count = 0; - - for (int i = positionIndex - 1; i >= 0; i--) { - if (positionHistory[i] == board.hashKey) count++; - - if (count >= 3) return true; + for (int i = 0; i < positionIndex; i++) { + if (positionHistory[i] == board.hashKey) { + // repetition found + return true; + } } + // no repetition return false; }