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%
This commit is contained in:
Calcitem 2021-01-10 20:27:47 +08:00
parent 0dd4a5e7e2
commit 31da244933
2 changed files with 27 additions and 1 deletions

View File

@ -314,6 +314,32 @@ 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) {
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();

View File

@ -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"