Skip to content
Open
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
67 changes: 34 additions & 33 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,16 @@ namespace ironphoenix {
return ttProbe.score;
}

const int staticEval = evaluate(pos);

const bool inCheckNode = pos.inCheck();
const auto& tuning = Tuning::search();

const Color us = pos.sideToMove();
const Color partner = static_cast<Color>(static_cast<unsigned>(us) ^ 2u);

const bool partnerChecked = pos.inCheck(partner);

const bool mateWindow = !(alpha > -MATE_THRESHOLD && beta < MATE_THRESHOLD);

// Null Move Pruning (NMP): keep expensive partner-check detection and
Expand All @@ -524,42 +531,36 @@ namespace ironphoenix {
&& !pvNode
&& ply > 0
&& depth >= NULL_MOVE_MIN_DEPTH
&& staticEval >= beta
&& !partnerChecked
&& !inCheckNode
&& !mateWindow
&& hasNonPawnMaterial(pos, us)) {

const Color partner = static_cast<Color>(static_cast<unsigned>(us) ^ 2u);
if (!pos.inCheck(partner)) {
const int staticEval = evaluate(pos);

if (staticEval >= beta) {
StateInfo nullState;
pos.makeNullMove(nullState);
searchStack_[ply + 1] = HistoryContext{};

// Dynamic null-move reduction: reduce the depth more aggressively
// at deeper nodes and for higher static evaluations.
const int reduction = 4 + depth / 5 + std::min(3, (staticEval - beta) / NULL_MOVE_DIVISOR);
const int nullScore = -negamax(
pos,
depth - reduction,
-beta,
-beta + 1,
ply + 1,
false,
false
);

pos.undoNullMove(nullState);

if (shouldStop())
return 0;

// Never manufacture a mate score from a synthetic pass.
if (nullScore >= beta && nullScore < MATE_THRESHOLD)
return nullScore;
}
}
StateInfo nullState;
pos.makeNullMove(nullState);
searchStack_[ply + 1] = HistoryContext{};

// Dynamic null-move reduction: reduce the depth more aggressively
// at deeper nodes and for higher static evaluations.
const int reduction = 4 + depth / 5 + std::min(3, (staticEval - beta) / NULL_MOVE_DIVISOR);
const int nullScore = -negamax(
pos,
depth - reduction,
-beta,
-beta + 1,
ply + 1,
false,
false
);

pos.undoNullMove(nullState);

if (shouldStop())
return 0;

// Never manufacture a mate score from a synthetic pass.
if (nullScore >= beta && nullScore < MATE_THRESHOLD)
return nullScore;
}

MoveList moves;
Expand Down
Loading