Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ void clearCounterMoves(void) {
}
}

uint8_t justPawns(board *pos) {
return !((pos->bitboards[N] | pos->bitboards[n] | pos->bitboards[B] |
pos->bitboards[b] | pos->bitboards[R] | pos->bitboards[r] |
pos->bitboards[Q] | pos->bitboards[q]) &
pos->occupancies[pos->side]);
}


// quiescence search
int quiescence(int alpha, int beta, board* position, time* time) {
if ((searchNodes & 2047) == 0) {
Expand Down Expand Up @@ -524,13 +532,14 @@ int negamax(int alpha, int beta, int depth, board* position, time* time, bool cu

int canPrune = in_check == 0 && pvNode == 0;


// reverse futility pruning
if (depth <= 2 && !pvNode && !in_check && static_eval - 82 * depth >= beta)
return static_eval;

// null move pruning
if (depth >= nullMoveDepth && in_check == 0 && position->ply && static_eval >= beta) {
if (depth >= nullMoveDepth &&
!in_check && position->ply && static_eval >= beta &&
!justPawns(position)) {
struct copyposition copyPosition;
// preserve board state
copyBoard(position, &copyPosition);
Expand Down
3 changes: 3 additions & 0 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once


#include <stdint.h>
#include "structs.h"
#include "time.h"
#include "values.h"
Expand Down Expand Up @@ -37,6 +39,7 @@ void quiescence_sort_moves(moves *moveList, board* position);
void enable_pv_scoring(moves *moveList, board* position);
void printMove(int move);
int getLmrReduction(int depth, int moveNumber);
uint8_t justPawns(board *pos);
void clearCounterMoves(void);
int quiescence(int alpha, int beta, board* position, time* time);
int negamax(int alpha, int beta, int depth, board* position, time* time, bool cutNode);
Expand Down