encapsulated positionIndex and moved isdraw to board class
This commit is contained in:
1 parent
dd6f0b94f5
commit
aa0d34eb8e
7 files changed
+35
-41
No files matched your search
+1
-28
@@ -92,31 +92,6 @@ void ListScores(Board &board, int ply, SearchContext& ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsThreefold(Board &board) {
|
||||
for (int i = 0; i < positionIndex; i++) {
|
||||
if (positionHistory[i] == board.hashKey) {
|
||||
// repetition found
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// no repetition
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsFifty(Board &board) {
|
||||
return (board.halfMoves >= 100);
|
||||
}
|
||||
|
||||
static bool IsInsuffMat(Board &board) {
|
||||
return (board.occupied.PopCount() <= 3
|
||||
&& !(board.pieces[Pawn] | board.pieces[Queen] | board.pieces[Rook]));
|
||||
}
|
||||
|
||||
bool IsDraw(Board &board) {
|
||||
return IsFifty(board) || IsInsuffMat(board) || IsThreefold(board);
|
||||
}
|
||||
|
||||
static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int ply) {
|
||||
int reduction = 0;
|
||||
|
||||
@@ -174,7 +149,6 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply, Searc
|
||||
if (!isLegal) continue;
|
||||
ctx.nodes++;
|
||||
int score = -Quiescence<mode>(copy, -beta, -alpha, ply + 1, ctx).score;
|
||||
positionIndex--;
|
||||
|
||||
if (score >= beta) {
|
||||
return score;
|
||||
@@ -217,7 +191,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
||||
}
|
||||
|
||||
ctx.pvLine.SetLength(ply);
|
||||
if (ply && (IsThreefold(board) || IsFifty(board) || IsInsuffMat(board))) return 0;
|
||||
if (ply && (board.IsDraw())) return 0;
|
||||
|
||||
|
||||
// if NOT PV node then we try to hit the TTable
|
||||
@@ -316,7 +290,6 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
||||
}
|
||||
|
||||
moveSeen++;
|
||||
positionIndex--;
|
||||
|
||||
if (ctx.searchStopped) return 0;
|
||||
|
||||
|
||||
Reference in new issue
Block a user