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; }