encapsulated positionHistory | bench 1857933
This commit is contained in:
1 parent
aa0d34eb8e
commit
2e8c23103f
6 files changed
+34
-37
No files matched your search
+28
-1
@@ -92,6 +92,31 @@ void ListScores(Board &board, int ply, SearchContext& ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsThreefold(Board& board, SearchContext& ctx) {
|
||||
for (int i = 0; i < board.positionIndex; i++) {
|
||||
if (ctx.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]));
|
||||
}
|
||||
|
||||
static bool IsDraw(Board &board, SearchContext& ctx) {
|
||||
return IsFifty(board) || IsInsuffMat(board) || IsThreefold(board, ctx);
|
||||
}
|
||||
|
||||
static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int ply) {
|
||||
int reduction = 0;
|
||||
|
||||
@@ -147,6 +172,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply, Searc
|
||||
Board copy = board;
|
||||
int isLegal = copy.MakeMove(board.moveList[i]);
|
||||
if (!isLegal) continue;
|
||||
ctx.positionHistory[copy.positionIndex] = copy.hashKey;
|
||||
ctx.nodes++;
|
||||
int score = -Quiescence<mode>(copy, -beta, -alpha, ply + 1, ctx).score;
|
||||
|
||||
@@ -191,7 +217,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
||||
}
|
||||
|
||||
ctx.pvLine.SetLength(ply);
|
||||
if (ply && (board.IsDraw())) return 0;
|
||||
if (ply && (IsDraw(board, ctx))) return 0;
|
||||
|
||||
|
||||
// if NOT PV node then we try to hit the TTable
|
||||
@@ -261,6 +287,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
||||
bool isLegal = copy.MakeMove(currMove);
|
||||
|
||||
if (!isLegal) continue;
|
||||
ctx.positionHistory[copy.positionIndex] = copy.hashKey;
|
||||
ctx.nodes++;
|
||||
|
||||
int reductions = GetReductions(board, currMove, depth, moveSeen, ply);
|
||||
|
||||
Reference in new issue
Block a user