// search to overwrite a previous full search TT value, so we use a different
// position key in case of an excluded move.
excludedMove = ss->excludedMove;
- posKey = pos.key() ^ Key(excludedMove);
+ posKey = pos.key() ^ Key(excludedMove << 16); // isn't a very good hash
tte = TT.probe(posKey, ttHit);
ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE;
ttMove = rootNode ? thisThread->rootMoves[thisThread->PVIdx].pv[0]
// Step 8. Null move search with verification search (is omitted in PV nodes)
if ( !PvNode
&& eval >= beta
- && ss->staticEval >= beta - 36 * depth / ONE_PLY + 225)
+ && ss->staticEval >= beta - 36 * depth / ONE_PLY + 225
+ && (ss->ply >= thisThread->nmp_ply || ss->ply % 2 == thisThread->pair))
{
assert(eval - beta >= 0);
return nullValue;
// Do verification search at high depths
+ R += ONE_PLY;
+ // disable null move pruning for side to move for the first part of the remaining search tree
+ int nmp_ply = thisThread->nmp_ply;
+ int pair = thisThread->pair;
+ thisThread->nmp_ply = ss->ply + 3 * (depth-R) / 4;
+ thisThread->pair = (ss->ply % 2) == 0;
+
Value v = depth-R < ONE_PLY ? qsearch<NonPV, false>(pos, ss, beta-1, beta)
: search<NonPV>(pos, ss, beta-1, beta, depth-R, false, true);
+ thisThread->pair = pair;
+ thisThread->nmp_ply = nmp_ply;
if (v >= beta)
return nullValue;