From 2c1d448d8feb5bb5db5f3b766fbe7f28ddcf0e1f Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 12:16:27 +0100 Subject: [PATCH 1/5] FP with some test conds | bench 968174 --- source/move.h | 7 ++++++- source/search.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/source/move.h b/source/move.h index 0f04047..6a0e7aa 100644 --- a/source/move.h +++ b/source/move.h @@ -49,12 +49,17 @@ public: return m_move >> 12; } - int IsCapture() { + bool IsCapture() { return (GetFlags() == capture || GetFlags() == epCapture || GetFlags() == knightPromoCapture || GetFlags() == bishopPromoCapture || GetFlags() == rookPromoCapture || GetFlags() == queenPromoCapture); } + bool IsQuiet() { + return (GetFlags() == quiet || GetFlags() == kingCastle + || GetFlags() == queenCastle || GetFlags() == doublePawnPush); + } + void PrintMove() { std::cout << squareCoords[MoveFrom()] << squareCoords[MoveTo()]; diff --git a/source/search.cpp b/source/search.cpp index 4730f4c..fcd8c81 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -236,6 +236,16 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { if (!isLegal) continue; + // Futility pruning + // If our static eval is far below alpha, there is only a small chance + // that a quiet move will help us so we skip them + int fpMargin = 100; + if (!isPV && !board.InCheck() && currMove.IsQuiet() + && depth <= 2 && staticEval + fpMargin < alpha) { + positionIndex--; + continue; + } + int reductions = GetReductions(board, currMove, depth, moveSeen, ply); // First move (suspected PV node) -- 2.47.3 From 58a3e8f79245b07bc2ff457472a319adf2d8e2e3 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 12:42:17 +0100 Subject: [PATCH 2/5] FP before making move | bench 768886 --- source/search.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index fcd8c81..3c6a61d 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -231,21 +231,20 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { for (int i = 0; i < board.currentMoveIndex; i++) { Move currMove = board.moveList[i]; - Board copy = board; - bool isLegal = copy.MakeMove(currMove); - - if (!isLegal) continue; - // Futility pruning // If our static eval is far below alpha, there is only a small chance // that a quiet move will help us so we skip them int fpMargin = 100; if (!isPV && !board.InCheck() && currMove.IsQuiet() && depth <= 2 && staticEval + fpMargin < alpha) { - positionIndex--; continue; } + Board copy = board; + bool isLegal = copy.MakeMove(currMove); + + if (!isLegal) continue; + int reductions = GetReductions(board, currMove, depth, moveSeen, ply); // First move (suspected PV node) -- 2.47.3 From f0d8b8804ea4069d830614018d1379c1217409b0 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 12:52:40 +0100 Subject: [PATCH 3/5] depth dependent fp margin | bench 884159 --- source/search.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 3c6a61d..7084caf 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -234,8 +234,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { // Futility pruning // If our static eval is far below alpha, there is only a small chance // that a quiet move will help us so we skip them - int fpMargin = 100; - if (!isPV && !board.InCheck() && currMove.IsQuiet() + int fpMargin = 100 + 50 * depth; + if (!isPV && ply && !board.InCheck() && currMove.IsQuiet() && depth <= 2 && staticEval + fpMargin < alpha) { continue; } -- 2.47.3 From a9b4d7021974f53c7222bec9899321beeb579188 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 16:36:25 +0100 Subject: [PATCH 4/5] decreased depth in fp | bench 836212 --- source/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/search.cpp b/source/search.cpp index 7084caf..b67aa44 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -236,7 +236,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 + 50 * depth; if (!isPV && ply && !board.InCheck() && currMove.IsQuiet() - && depth <= 2 && staticEval + fpMargin < alpha) { + && depth <= 1 && staticEval + fpMargin < alpha) { continue; } -- 2.47.3 From 22f9e929f51764ad0fad11229500183177d963b8 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 26 Mar 2025 16:52:22 +0100 Subject: [PATCH 5/5] mate score condition + new margin | bench 684523 --- source/search.cpp | 6 +++--- source/search.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index b67aa44..31c7d2b 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -234,9 +234,9 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { // Futility pruning // If our static eval is far below alpha, there is only a small chance // that a quiet move will help us so we skip them - int fpMargin = 100 + 50 * depth; + int fpMargin = 100 * depth; if (!isPV && ply && !board.InCheck() && currMove.IsQuiet() - && depth <= 1 && staticEval + fpMargin < alpha) { + && depth <= 5 && staticEval + fpMargin < alpha && results.score > MATE_SCORE) { continue; } @@ -297,7 +297,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { if (moveSeen == 0) { if (board.InCheck()) { // checkmate - return -99000 + ply; + return MATE_SCORE + ply; } else { // stalemate return 0; } diff --git a/source/search.h b/source/search.h index 0e92068..1490fb4 100644 --- a/source/search.h +++ b/source/search.h @@ -7,6 +7,7 @@ namespace SEARCH { +constexpr int MATE_SCORE = -99000; constexpr int maxDepth = 64; constexpr int maxHistory = 16384; -- 2.47.3