From 31da244933ef57ed0b33abffc951a4e5d3c620cb Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 10 Jan 2021 20:27:47 +0800 Subject: [PATCH] repetition: Detect 3-fold repetition during searching Ref: tscp181c if (ply && reps()) return 0; Test result: Played: 8300 rep-detect Vs no-rep-detect 11.49% : 84.25% : 4.24% 11.27% : 86.13% : 2.59% 48.81% : 47.76% +1.05% --- src/search.cpp | 26 ++++++++++++++++++++++++++ src/ui/flutter/pubspec.yaml | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 64d8e4eb..e1229ae8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -314,6 +314,32 @@ Value search(Position *pos, Sanmill::Stack &ss, Depth depth, Depth ori return bestValue; } +#ifdef THREEFOLD_REPETITION + // if this isn't the root of the search tree (where we have + // to pick a move and can't simply return VALUE_DRAW) then check to + // see if the position is a repeat. if so, we can assume that + // this line is a draw and return VALUE_DRAW. + + if (depth != originDepth) { + for (int i = (int)posKeyHistory.size() - 2; i >= 0; i--) { + if (posKey == posKeyHistory[i]) { + return VALUE_DRAW; + } + } + + int size = ss.size(); + + for (int i = size - 1; i >= 0; i--) { + if (type_of(ss[i].move) == MOVETYPE_REMOVE) { + break; + } + if (posKey == ss[i].st.key) { + return VALUE_DRAW; + } + } + } +#endif // THREEFOLD_REPETITION + MovePicker mp(*pos); Move nextMove = mp.next_move(); const int moveCount = mp.move_count(); diff --git a/src/ui/flutter/pubspec.yaml b/src/ui/flutter/pubspec.yaml index 61bcb183..34da4347 100644 --- a/src/ui/flutter/pubspec.yaml +++ b/src/ui/flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: sanmill description: A new Flutter project. -version: 0.14.0+1294 +version: 0.15.0+1318 environment: sdk: ">=2.1.0 <3.0.0"