Skip to content

Commit

Permalink
Bench: 24439508
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Dec 19, 2024
1 parent 1401211 commit 7fc2496
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
36 changes: 18 additions & 18 deletions src/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#define MatCorrEntry() (&thread->matCorrHistory[thread->pos.stm][MatCorrIndex(&thread->pos)])
#define ContCorrEntry(offset) (&(*(ss-offset)->contCorr)[piece((ss-1)->move)][toSq((ss-1)->move)])

#define QuietHistoryUpdate(move, bonus) (HistoryBonus(QuietEntry(move), bonus, 5425))
#define PawnHistoryUpdate(move, bonus) (HistoryBonus(PawnEntry(move), bonus, 8325))
#define NoisyHistoryUpdate(move, bonus) (HistoryBonus(NoisyEntry(move), bonus, 14750))
#define ContHistoryUpdate(offset, move, bonus) (HistoryBonus(ContEntry(offset, move), bonus, 23000))
#define PawnCorrHistoryUpdate(bonus) (HistoryBonus(PawnCorrEntry(), bonus, 1475))
#define MatCorrHistoryUpdate(bonus) (HistoryBonus(MatCorrEntry(), bonus, 1060))
#define ContCorrHistoryUpdate(offset, bonus) (HistoryBonus(ContCorrEntry(offset), bonus, 1150))
#define QuietHistoryUpdate(move, bonus) (HistoryBonus(QuietEntry(move), bonus, 5150))
#define PawnHistoryUpdate(move, bonus) (HistoryBonus(PawnEntry(move), bonus, 8825))
#define NoisyHistoryUpdate(move, bonus) (HistoryBonus(NoisyEntry(move), bonus, 16650))
#define ContHistoryUpdate(offset, move, bonus) (HistoryBonus(ContEntry(offset, move), bonus, 21345))
#define PawnCorrHistoryUpdate(bonus) (HistoryBonus(PawnCorrEntry(), bonus, 1590))
#define MatCorrHistoryUpdate(bonus) (HistoryBonus(MatCorrEntry(), bonus, 965))
#define ContCorrHistoryUpdate(offset, bonus) (HistoryBonus(ContCorrEntry(offset), bonus, 1145))


INLINE int PawnStructure(const Position *pos) { return pos->pawnKey & (PAWN_HISTORY_SIZE - 1); }
Expand All @@ -53,15 +53,15 @@ INLINE void HistoryBonus(int16_t *cur, int bonus, int div) {
}

INLINE int Bonus(Depth depth) {
return MIN(2535, 275 * depth - 318);
return MIN(2490, 273 * depth - 325);
}

INLINE int Malus(Depth depth) {
return -MIN(890, 538 * depth - 159);
return -MIN(836, 523 * depth - 159);
}

INLINE int CorrectionBonus(int score, int eval, Depth depth) {
return CLAMP((score - eval) * depth / 4, -197, 240);
return CLAMP((score - eval) * depth / 4, -193, 253);
}

INLINE void UpdateContHistories(Stack *ss, Move move, int bonus) {
Expand Down Expand Up @@ -142,12 +142,12 @@ INLINE int GetHistory(const Thread *thread, Stack *ss, Move move) {
}

INLINE int GetCorrectionHistory(const Thread *thread, const Stack *ss) {
return *PawnCorrEntry() / 26
+ *MatCorrEntry() / 25
+ *ContCorrEntry(2) / 50
+ *ContCorrEntry(3) / 44
+ *ContCorrEntry(4) / 47
+ *ContCorrEntry(5) / 48
+ *ContCorrEntry(6) / 48
+ *ContCorrEntry(7) / 48;
return *PawnCorrEntry() / 20
+ *MatCorrEntry() / 26
+ *ContCorrEntry(2) / 46
+ *ContCorrEntry(3) / 45
+ *ContCorrEntry(4) / 46
+ *ContCorrEntry(5) / 43
+ *ContCorrEntry(6) / 45
+ *ContCorrEntry(7) / 43;
}
2 changes: 1 addition & 1 deletion src/movepicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ 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 > 12000
if ( mp->list.moves[mp->list.next-1].score > 11400
|| (mp->list.moves[mp->list.next-1].score > -11000 && SEE(pos, move, mp->threshold)))
return move;
else
Expand Down
26 changes: 13 additions & 13 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.40 + log(depth) * log(moves) / 3.42, // capture
Reductions[1][depth][moves] = 1.83 + log(depth) * log(moves) / 2.54; // quiet
Reductions[0][depth][moves] = 0.44 + log(depth) * log(moves) / 3.54, // capture
Reductions[1][depth][moves] = 1.92 + log(depth) * log(moves) / 2.49; // quiet
}

// Checks whether a move was already searched in multi-pv mode
Expand Down Expand Up @@ -158,7 +158,7 @@ static int Quiescence(Thread *thread, Stack *ss, int alpha, int beta) {
if (eval > alpha)
alpha = eval;

futility = eval + 113;
futility = eval + 136;
bestScore = eval;

moveloop:
Expand Down Expand Up @@ -357,18 +357,18 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth
// Reverse Futility Pruning
if ( depth < 7
&& eval >= beta
&& eval - 76 * (depth - improving) - (ss-1)->histScore / 107 >= beta
&& (!ttMove || GetHistory(thread, ss, ttMove) > 7600))
&& eval - 68 * (depth - improving) - (ss-1)->histScore / 107 >= beta
&& (!ttMove || GetHistory(thread, ss, ttMove) > 7500))
return eval;

// Null Move Pruning
if ( eval >= beta
&& eval >= ss->staticEval
&& ss->staticEval >= beta + 145 - 17 * depth
&& (ss-1)->histScore < 24400
&& ss->staticEval >= beta + 160 - 18 * depth
&& (ss-1)->histScore < 26500
&& pos->nonPawnCount[sideToMove] > (depth > 8)) {

Depth reduction = 4 + depth / 4 + MIN(3, (eval - beta) / 231);
Depth reduction = 4 + depth / 4 + MIN(3, (eval - beta) / 230);

ss->move = NOMOVE;
ss->continuation = &thread->continuation[0][0][EMPTY][0];
Expand Down Expand Up @@ -449,7 +449,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 / 8950;
int R = Reductions[quiet][MIN(31, depth)][MIN(31, moveCount)] - ss->histScore / 9330;
Depth lmrDepth = depth - 1 - R;

// Quiet late move pruning
Expand Down Expand Up @@ -497,7 +497,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 - 3 && ss->doubleExtensions <= 5)
if (!pvNode && score < singularBeta - 1 && 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 @@ -531,7 +531,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 / 9285;
r -= ss->histScore / 10225;
// Reduce less in pv nodes
r -= pvNode;
// Reduce less when improving
Expand All @@ -550,7 +550,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 + 5 + 7 * (newDepth - lmrDepth);
bool deeper = score > bestScore + 2 + 6 * (newDepth - lmrDepth);

newDepth += deeper;

Expand Down Expand Up @@ -740,7 +740,7 @@ static void *IterativeDeepening(void *voidThread) {
Limits.optimalUsage = MIN(500, Limits.optimalUsage);

double nodeRatio = 1.0 - (double)thread->rootMoves[0].nodes / (MAX(1, pos->nodes));
double timeRatio = 0.5 + 2.5 * nodeRatio;
double timeRatio = 0.52 + 2.87 * nodeRatio;

// If an iteration finishes after optimal time usage, stop the search
if ( Limits.timelimit
Expand Down

0 comments on commit 7fc2496

Please sign in to comment.