Skip to content

Commit

Permalink
SPSA tune search, history updates (#707)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TerjeKir authored Dec 30, 2023
1 parent 1eadc03 commit 5baabfd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
#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) {
*cur += bonus - *cur * abs(bonus) / 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) {
Expand Down
6 changes: 3 additions & 3 deletions src/movepicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {

Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit 5baabfd

Please sign in to comment.