Skip to content

Commit

Permalink
Bench: 26587524
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Dec 20, 2024
1 parent 1401211 commit 14de179
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/movegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,10 @@ void GenLegalMoves(Position *pos, MoveList *list) {
}
pos->nodes = 0;
}

int LegalMoveCount(Position *pos) {
MoveList list;
list.count = list.next = 0;
GenLegalMoves(pos, &list);
return list.count;
}
1 change: 1 addition & 0 deletions src/movegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ void GenNoisyMoves(const Position *pos, MoveList *list);
void GenQuietMoves(const Position *pos, MoveList *list);
void GenAllMoves(const Position *pos, MoveList *list);
void GenLegalMoves(Position *pos, MoveList *list);
int LegalMoveCount(Position *pos);
16 changes: 12 additions & 4 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ static int Quiescence(Thread *thread, Stack *ss, int alpha, int beta) {
return alpha;
}

// Position is drawn
if (IsRepetition(pos) || pos->rule50 >= 100)
// Position is drawn by repetition
if (IsRepetition(pos))
return DrawScore(pos);

// Position is drawn by 50 move rule
if (pos->rule50 >= 100 && (!pos->checkers || LegalMoveCount(pos) > 0))
return DrawScore(pos);

// If we are at max depth, return static eval
Expand Down Expand Up @@ -260,8 +264,12 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth
return alpha;
}

// Position is drawn
if (IsRepetition(pos) || pos->rule50 >= 100)
// Position is drawn by repetition
if (IsRepetition(pos))
return DrawScore(pos);

// Position is drawn by 50 move rule
if (pos->rule50 >= 100 && (!pos->checkers || LegalMoveCount(pos) > 0))
return DrawScore(pos);

// Max depth reached
Expand Down

0 comments on commit 14de179

Please sign in to comment.