From f1d1684927bcfb05000a82091c9efbd08a8f8ec6 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sat, 29 Mar 2025 01:37:45 +0100 Subject: [PATCH 1/3] reading TT in qs | bench 3919997 --- source/search.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index bbe248f..68fe205 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -128,6 +128,7 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int return reduction; } +template static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { if (!benchStarted && nodes % 1024 == 0) { if (sw.GetElapsedMS() >= timeToSearch) { @@ -136,9 +137,22 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { } } + if constexpr (!isPV) { + TTEntry *entry = TT.GetRawEntry(board.hashKey); + if (entry->hashKey == board.hashKey) { + if (entry->nodeType == PV){ + return {entry->score, entry->bestMove}; + } else if (entry->nodeType == AllNode && entry->score <= alpha) { + return entry->score; + } else if (entry->nodeType == CutNode && entry->score >= beta) { + return entry->score; + } + } + } + int bestScore = HCE::Evaluate(board); - if (bestScore>= beta) { + if (bestScore >= beta) { return bestScore; } @@ -156,7 +170,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { Board copy = board; int isLegal = copy.MakeMove(board.moveList[i]); if (!isLegal) continue; - int score = -Quiescence(copy, -beta, -alpha, ply + 1).score; + int score = -Quiescence(copy, -beta, -alpha, ply + 1).score; positionIndex--; if (score >= beta) { @@ -197,7 +211,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { } } - if (depth <= 0) return Quiescence(board, alpha, beta, ply); + if (depth <= 0) return Quiescence(board, alpha, beta, ply); const int staticEval = HCE::Evaluate(board); -- 2.47.3 From 58a415f9c42290f7c6fea8c6d7670ddcaa155976 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sat, 29 Mar 2025 01:56:41 +0100 Subject: [PATCH 2/3] not returning TT score in qs | bench 3801453 --- source/search.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 68fe205..11d4734 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -137,20 +137,15 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { } } + int bestScore = HCE::Evaluate(board); + if constexpr (!isPV) { TTEntry *entry = TT.GetRawEntry(board.hashKey); if (entry->hashKey == board.hashKey) { - if (entry->nodeType == PV){ - return {entry->score, entry->bestMove}; - } else if (entry->nodeType == AllNode && entry->score <= alpha) { - return entry->score; - } else if (entry->nodeType == CutNode && entry->score >= beta) { - return entry->score; - } + bestScore = entry->score; } } - int bestScore = HCE::Evaluate(board); if (bestScore >= beta) { return bestScore; -- 2.47.3 From 5ca96c774662caabbece68500744d353d9e21c82 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sat, 29 Mar 2025 02:20:29 +0100 Subject: [PATCH 3/3] not checking isPV | bench 3451231 --- source/search.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 11d4734..16544fa 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -128,7 +128,6 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int return reduction; } -template static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { if (!benchStarted && nodes % 1024 == 0) { if (sw.GetElapsedMS() >= timeToSearch) { @@ -139,11 +138,9 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { int bestScore = HCE::Evaluate(board); - if constexpr (!isPV) { - TTEntry *entry = TT.GetRawEntry(board.hashKey); - if (entry->hashKey == board.hashKey) { - bestScore = entry->score; - } + TTEntry *entry = TT.GetRawEntry(board.hashKey); + if (entry->hashKey == board.hashKey) { + bestScore = entry->score; } @@ -165,7 +162,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { Board copy = board; int isLegal = copy.MakeMove(board.moveList[i]); if (!isLegal) continue; - int score = -Quiescence(copy, -beta, -alpha, ply + 1).score; + int score = -Quiescence(copy, -beta, -alpha, ply + 1).score; positionIndex--; if (score >= beta) { @@ -206,7 +203,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { } } - if (depth <= 0) return Quiescence(board, alpha, beta, ply); + if (depth <= 0) return Quiescence(board, alpha, beta, ply); const int staticEval = HCE::Evaluate(board); -- 2.47.3