From 5baabfd3916b49f9960144a8734cd1cd0b8f8a55 Mon Sep 17 00:00:00 2001 From: TerjeKir <42723273+TerjeKir@users.noreply.github.com> Date: Sat, 30 Dec 2023 15:09:47 +0100 Subject: [PATCH] SPSA tune search, history updates (#707) Elo | -2.83 +- 3.55 (95%) SPRT | 8.0+0.08s Threads=1 Hash=32MB LLR | -2.95 (-2.94, 2.94) [0.00, 3.00] Games | N: 19368 W: 5024 L: 5182 D: 9162 Penta | [312, 2473, 4268, 2323, 308] http://chess.grantnet.us/test/34887/ Elo | 3.41 +- 3.00 (95%) SPRT | 40.0+0.40s Threads=1 Hash=128MB LLR | 2.95 (-2.94, 2.94) [0.00, 3.00] Games | N: 24736 W: 6083 L: 5840 D: 12813 Penta | [160, 2858, 6109, 3061, 180] http://chess.grantnet.us/test/34874/ Bench: 23621947 --- src/history.h | 8 ++++---- src/movepicker.c | 6 +++--- src/search.c | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/history.h b/src/history.h index df1952ba..9bf81ead 100644 --- a/src/history.h +++ b/src/history.h @@ -31,10 +31,10 @@ #define NoisyEntry(move) (&thread->captureHistory[piece(move)][toSq(move)][PieceTypeOf(capturing(move))]) #define ContEntry(offset, move) (&(*(ss-offset)->continuation)[piece(move)][toSq(move)]) -#define QuietHistoryUpdate(move, bonus) (HistoryBonus(QuietEntry(move), bonus, 7180)) +#define QuietHistoryUpdate(move, bonus) (HistoryBonus(QuietEntry(move), bonus, 6880)) #define PawnHistoryUpdate(move, bonus) (HistoryBonus(PawnEntry(move), bonus, 8192)) #define NoisyHistoryUpdate(move, bonus) (HistoryBonus(NoisyEntry(move), bonus, 16384)) -#define ContHistoryUpdate(offset, move, bonus) (HistoryBonus(ContEntry(offset, move), bonus, 28650)) +#define ContHistoryUpdate(offset, move, bonus) (HistoryBonus(ContEntry(offset, move), bonus, 30000)) INLINE void HistoryBonus(int16_t *cur, int bonus, int div) { @@ -42,11 +42,11 @@ INLINE void HistoryBonus(int16_t *cur, int bonus, int div) { } INLINE int Bonus(Depth depth) { - return MIN(2545, 315 * depth - 300); + return MIN(2645, 285 * depth - 305); } INLINE int Malus(Depth depth) { - return -MIN(1700, 480 * depth - 205); + return -MIN(1435, 455 * depth - 213); } INLINE void UpdateContHistories(Stack *ss, Move move, int bonus) { diff --git a/src/movepicker.c b/src/movepicker.c index 404d503d..2d8abf5a 100644 --- a/src/movepicker.c +++ b/src/movepicker.c @@ -69,7 +69,7 @@ static void ScoreMoves(MovePicker *mp, const int stage) { : GetCaptureHistory(thread, move) + PieceValue[MG][capturing(move)]; } - SortMoves(list, -1500 * mp->depth); + SortMoves(list, -1835 * mp->depth); } // Returns the next move to try in a position @@ -96,8 +96,8 @@ Move NextMove(MovePicker *mp) { case NOISY_GOOD: // Save seemingly bad noisy moves for later while ((move = PickNextMove(mp))) - if ( mp->list.moves[mp->list.next-1].score > 14350 - 197 * mp->depth - || (mp->list.moves[mp->list.next-1].score > -10085 + 155 * mp->depth && SEE(pos, move, mp->threshold))) + if ( mp->list.moves[mp->list.next-1].score > 14600 - 270 * mp->depth + || (mp->list.moves[mp->list.next-1].score > -10470 + 68 * mp->depth && SEE(pos, move, mp->threshold))) return move; else mp->list.moves[mp->bads++].move = move; diff --git a/src/search.c b/src/search.c index 0dcb851d..174b0409 100644 --- a/src/search.c +++ b/src/search.c @@ -47,8 +47,8 @@ static int Reductions[2][32][32]; CONSTR(1) InitReductions() { for (int depth = 1; depth < 32; ++depth) for (int moves = 1; moves < 32; ++moves) - Reductions[0][depth][moves] = 0.30 + log(depth) * log(moves) / 3.33, // capture - Reductions[1][depth][moves] = 1.50 + log(depth) * log(moves) / 2.80; // quiet + Reductions[0][depth][moves] = 0.33 + log(depth) * log(moves) / 3.20, // capture + Reductions[1][depth][moves] = 1.65 + log(depth) * log(moves) / 2.80; // quiet } // Checks whether a move was already searched in multi-pv mode @@ -312,14 +312,14 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Reverse Futility Pruning if ( depth < 7 && eval >= beta - && eval - 84 * (depth - improving) - (ss-1)->histScore / 160 >= beta - && (!ttMove || GetHistory(thread, ss, ttMove) > 7600)) + && eval - 92 * (depth - improving) - (ss-1)->histScore / 128 >= beta + && (!ttMove || GetHistory(thread, ss, ttMove) > 8650)) return eval; // Null Move Pruning if ( eval >= beta && eval >= ss->staticEval - && ss->staticEval >= beta + 166 - 21 * depth + && ss->staticEval >= beta + 174 - 24 * depth && (ss-1)->histScore < 25000 && pos->nonPawnCount[sideToMove] > (depth > 8)) { @@ -365,7 +365,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Cut if the reduced depth search beats the threshold if (score >= probCutBeta) - return score - 157; + return score - 160; } } @@ -398,7 +398,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth && thread->doPruning && bestScore > -TBWIN_IN_MAX) { - int R = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)] - ss->histScore / 9570; + int R = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)] - ss->histScore / 9000; Depth lmrDepth = depth - 1 - R; // Quiet late move pruning @@ -410,7 +410,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth continue; // SEE pruning - if (lmrDepth < 7 && !SEE(pos, move, quiet ? -46 * depth : -73 * depth)) + if (lmrDepth < 7 && !SEE(pos, move, quiet ? -53 * depth : -73 * depth)) continue; } @@ -446,7 +446,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Singular - extend by 1 or 2 ply if (score < singularBeta) { extension = 1; - if (!pvNode && score < singularBeta - 11 && ss->doubleExtensions <= 5) + if (!pvNode && score < singularBeta - 6 && ss->doubleExtensions <= 5) extension = 2; // MultiCut - ttMove as well as at least one other move seem good enough to beat beta } else if (singularBeta >= beta) @@ -478,7 +478,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Base reduction int r = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)]; // Adjust reduction by move history - r -= ss->histScore / 9570; + r -= ss->histScore / 10275; // Reduce less in pv nodes r -= pvNode; // Reduce less when improving @@ -497,7 +497,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth // Re-search with the same window at full depth if the reduced search failed high if (score > alpha && lmrDepth < newDepth) { - bool deeper = score > bestScore + 33 + 17 * (newDepth - lmrDepth); + bool deeper = score > bestScore + 23 + 13 * (newDepth - lmrDepth); newDepth += deeper;