Skip to content

Commit

Permalink
Bench: 23851500
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Dec 21, 2024
1 parent 2259da0 commit ad6f955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ static int Quiescence(Thread *thread, Stack *ss, int alpha, int beta) {
return EvalPosition(pos, thread->pawnCache);

// Mate distance pruning
alpha = MAX(alpha, -MATE + ss->ply);
beta = MIN(beta, MATE - ss->ply - 1);
alpha = MAX(alpha, matedIn(ss->ply));
beta = MIN(beta, mateIn(ss->ply + 1));
if (alpha >= beta)
return alpha;

Expand Down Expand Up @@ -227,7 +227,7 @@ static int Quiescence(Thread *thread, Stack *ss, int alpha, int beta) {

// Checkmate
if (inCheck && bestScore == -INFINITE)
return -MATE + ss->ply;
return matedIn(ss->ply);

StoreTTEntry(tte, pos->key, bestMove, ScoreToTT(bestScore, ss->ply), unadjustedEval, 0,
bestScore >= beta ? BOUND_LOWER : BOUND_UPPER);
Expand Down Expand Up @@ -278,8 +278,8 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth
return EvalPosition(pos, thread->pawnCache);

// Mate distance pruning
alpha = MAX(alpha, -MATE + ss->ply);
beta = MIN(beta, MATE - ss->ply - 1);
alpha = MAX(alpha, matedIn(ss->ply));
beta = MIN(beta, mateIn(ss->ply + 1));
if (alpha >= beta)
return alpha;
}
Expand Down Expand Up @@ -629,7 +629,7 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth
// Checkmate or stalemate
if (!moveCount)
bestScore = ss->excluded ? alpha
: inCheck ? -MATE + ss->ply
: inCheck ? matedIn(ss->ply)
: 0;

// Make sure score isn't above the max score given by TBs
Expand Down
3 changes: 3 additions & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#define isMate(score) (abs(score) >= MATE_IN_MAX)
#define isTerminal(score) (isWin(score) || isLoss(score))

#define matedIn(ply) (-MATE + (ply))
#define mateIn(ply) (MATE + (ply))

typedef uint64_t Bitboard;
typedef uint64_t Key;

Expand Down

0 comments on commit ad6f955

Please sign in to comment.