If we get to the point of trying a null move search, the TT pruning code above it didn't produce a cutoff. In particular, it didn't fail low. One reason it didn't could be that the score had a lower bound below beta, but that the entry's stored depth wasn't sufficient at the current search depth.
However, it might still be true that the entry's stored depth is above depth - 5. In that case, after a null move search that fails high, the following verification search at that same depth - 5, will produce a fail low when it reaches the TT pruning code.
In other words, before trying the null move search, we could check whether the TT entry has a depth at least equal to depth - 5 and an upper bound below the current beta. In code:
Code: Select all
if ( !PvNode
&& !ss->skipNullMove
&& depth > OnePly
&& refinedValue >= beta - (depth >= 4 * OnePly ? NullMoveMargin : 0)
&& !isCheck
&& !value_is_mate(beta)
&& pos.non_pawn_material(pos.side_to_move())
// check whether an eventual verification search would not fail low
&& !(depth >= 6 * OnePly && tte && fail_low_from_TT(tte, depth - 5 * OnePly, beta, ply)))
{
// do usual null move stuff here
}