repetition: Detect 3-fold repetition during searching follow Stockfish

Played 10000
before
11.08% : 87.71% : 1.20%
after
11.92% : 87.36% : 0.70% (draw -0.5%)

Played 6800
before Vs after
11.84% : 86.08% : 2.06%
11.68% : 86.98% : 1.32%
This commit is contained in:
Calcitem 2021-01-10 22:32:54 +08:00
parent 10f7937301
commit 30db31fafa
1 changed files with 13 additions and 10 deletions

View File

@ -197,6 +197,19 @@ Value search(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth ori
Depth epsilon;
#ifdef THREEFOLD_REPETITION
// Check if we have an upcoming move which draws by repetition, or
// if the opponent had an alternative move earlier to this position.
if (/* alpha < VALUE_DRAW && */
depth != originDepth &&
pos->has_repeated(ss)) {
alpha = VALUE_DRAW;
if (alpha >= beta) {
return alpha;
}
}
#endif // THREEFOLD_REPETITION
#ifdef TT_MOVE_ENABLE
Move ttMove = MOVE_NONE;
#endif // TT_MOVE_ENABLE
@ -302,16 +315,6 @@ Value search(Position *pos, Sanmill::Stack<Position> &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 && pos->has_repeated(ss)) {
return VALUE_DRAW;
}
#endif // THREEFOLD_REPETITION
MovePicker mp(*pos);
Move nextMove = mp.next_move();
const int moveCount = mp.move_count();