diff --git a/source/nnue.cpp b/source/nnue.cpp index b365ace..197b974 100644 --- a/source/nnue.cpp +++ b/source/nnue.cpp @@ -76,7 +76,8 @@ static int32_t Forward(const Board& board, } int16_t Network::Evaluate(const Board& board) { - return Forward(board, this); + return std::clamp(Forward(board, this), (-SEARCH::MATE_SCORE + SEARCH::MAX_PLY), + (SEARCH::MATE_SCORE - SEARCH::MAX_PLY)); } } diff --git a/source/search.cpp b/source/search.cpp index 6db7357..43cffb9 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -288,7 +288,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { // that a quiet move will help us so we skip them int fpMargin = 100 * depth; if (!isPV && ply && currMove.IsQuiet() - && depth <= 5 && staticEval + fpMargin < alpha && results.score > MATE_SCORE) { + && depth <= 5 && staticEval + fpMargin < alpha && results.score > -MATE_SCORE) { continue; } @@ -364,7 +364,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { if (moveSeen == 0) { if (board.InCheck()) { // checkmate - return MATE_SCORE + ply; + return -MATE_SCORE + ply; } else { // stalemate return 0; } diff --git a/source/search.h b/source/search.h index 71336a4..d90542f 100644 --- a/source/search.h +++ b/source/search.h @@ -14,7 +14,7 @@ enum searchMode { nodesMode }; -constexpr int MATE_SCORE = -99000; +constexpr int MATE_SCORE = 32767; constexpr int MAX_DEPTH = 64; constexpr int MAX_PLY = 128; constexpr int MAX_HISTORY = 16384;