fixed both PVS and QS
This commit is contained in:
1 parent
02b28b2598
commit
28bec280cc
1 file changed
+10
-11
+10
-11
@@ -97,13 +97,12 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
|
||||
nodes++;
|
||||
|
||||
int staticScore = Evaluate(board);
|
||||
int bestScore = alpha;
|
||||
|
||||
if (staticScore >= beta) {
|
||||
return staticScore;
|
||||
}
|
||||
|
||||
int bestScore = alpha;
|
||||
|
||||
if (staticScore > bestScore) {
|
||||
bestScore = staticScore;
|
||||
}
|
||||
@@ -118,7 +117,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
|
||||
if (board.moveList[i].IsCapture()) {
|
||||
Board copy = board;
|
||||
copy.MakeMove(board.moveList[i]);
|
||||
int score = -Quiescence(copy, -beta, -alpha).score;
|
||||
int score = -Quiescence(copy, -beta, -bestScore).score;
|
||||
|
||||
if (score >= beta) {
|
||||
return score;
|
||||
@@ -155,10 +154,10 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
}
|
||||
}
|
||||
|
||||
const int staticEval = Evaluate(board);
|
||||
|
||||
if (depth <= 0) return Quiescence(board, alpha, beta);
|
||||
|
||||
const int staticEval = Evaluate(board);
|
||||
|
||||
if (board.InCheck(board.sideToMove)) {
|
||||
depth++;
|
||||
} else {
|
||||
@@ -204,8 +203,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
}
|
||||
}
|
||||
|
||||
int bestScore = alpha;
|
||||
SearchResults results;
|
||||
SearchResults results(-inf);
|
||||
|
||||
// For all moves
|
||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||
@@ -241,14 +239,15 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
return score;
|
||||
}
|
||||
|
||||
if (score > bestScore) {
|
||||
results.score = std::max(score, results.score);
|
||||
|
||||
if (score > alpha) {
|
||||
nodeType = PV;
|
||||
bestScore = score;
|
||||
alpha = score;
|
||||
results.bestMove = board.moveList[i];
|
||||
}
|
||||
}
|
||||
|
||||
results.score = bestScore;
|
||||
WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
|
||||
if (searchStopped) return 0;
|
||||
return results;
|
||||
@@ -331,4 +330,4 @@ void SearchPosition(Board &board, SearchParams params) {
|
||||
|
||||
void StopSearch() {
|
||||
searchStopped = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user