threefold detection | bench 1143648
This commit is contained in:
1 parent
6c92c561e4
commit
d2b973b869
3 files changed
+23
No files matched your search
@@ -83,6 +83,18 @@ 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;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
||||
if (!benchStarted) {
|
||||
if (sw.GetElapsedMS() >= timeToSearch) {
|
||||
@@ -112,6 +124,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
||||
Board copy = board;
|
||||
copy.MakeMove(board.moveList[i]);
|
||||
int score = -Quiescence(copy, -beta, -alpha, ply + 1).score;
|
||||
positionIndex--;
|
||||
|
||||
if (score >= beta) {
|
||||
return score;
|
||||
@@ -139,6 +152,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ply && IsThreefold(board)) return 0;
|
||||
|
||||
pvLine.SetLength(ply);
|
||||
|
||||
// if NOT PV node then we try to hit the TTable
|
||||
@@ -217,6 +232,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
|
||||
}
|
||||
}
|
||||
|
||||
positionIndex--;
|
||||
|
||||
// Fail high (beta cutoff)
|
||||
if (score >= beta) {
|
||||
if (!currMove.IsCapture()) {
|
||||
|
||||
Reference in new issue
Block a user