From b4a1e0059ad6f1d0b77440ea3a711615744826a1 Mon Sep 17 00:00:00 2001 From: ProgramciDusunur Date: Wed, 25 Dec 2024 15:04:42 +0300 Subject: [PATCH 1/2] if we only have pawns, let's stop doing NMP --- src/search.c | 12 +++++++++++- src/search.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/search.c b/src/search.c index 50905471..1e939256 100644 --- a/src/search.c +++ b/src/search.c @@ -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) { @@ -530,7 +538,9 @@ int negamax(int alpha, int beta, int depth, board* position, time* time, bool cu 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, ©Position); diff --git a/src/search.h b/src/search.h index d0f749ab..482fe4d7 100644 --- a/src/search.h +++ b/src/search.h @@ -7,6 +7,8 @@ #pragma once + +#include #include "structs.h" #include "time.h" #include "values.h" @@ -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); From 748a8b39419beaee78c13ea6cf582b7deadceb70 Mon Sep 17 00:00:00 2001 From: ProgramciDusunur Date: Wed, 25 Dec 2024 15:04:50 +0300 Subject: [PATCH 2/2] bench: 8699257 --- src/search.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/search.c b/src/search.c index 1e939256..29891b78 100644 --- a/src/search.c +++ b/src/search.c @@ -532,7 +532,6 @@ 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;