In some cases we want to go direcly to the moves loop
without checking for early return. The patch make this
logic more clear and consistent.
Tested for no regression, passed STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 25282 W: 5136 L: 5022 D: 15124
and LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 72007 W: 12133 L: 12095 D: 47779
bench:
9316798
assert(0 <= ss->ply && ss->ply < MAX_PLY);
ss->currentMove = ss->ttMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
assert(0 <= ss->ply && ss->ply < MAX_PLY);
ss->currentMove = ss->ttMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
- (ss+1)->skipNullMove = false; (ss+1)->reduction = DEPTH_ZERO;
+ (ss+1)->skipEarlyPruning = false; (ss+1)->reduction = DEPTH_ZERO;
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
// Step 4. Transposition table lookup
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
// Step 4. Transposition table lookup
TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, ss->staticEval);
}
TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, ss->staticEval);
}
+ if (ss->skipEarlyPruning)
+ goto moves_loop;
+
if ( !pos.captured_piece_type()
&& ss->staticEval != VALUE_NONE
&& (ss-1)->staticEval != VALUE_NONE
if ( !pos.captured_piece_type()
&& ss->staticEval != VALUE_NONE
&& (ss-1)->staticEval != VALUE_NONE
// Step 7. Futility pruning: child node (skipped when in check)
if ( !PvNode
// Step 7. Futility pruning: child node (skipped when in check)
if ( !PvNode
&& depth < 7 * ONE_PLY
&& eval - futility_margin(depth) >= beta
&& eval < VALUE_KNOWN_WIN // Do not return unproven wins
&& depth < 7 * ONE_PLY
&& eval - futility_margin(depth) >= beta
&& eval < VALUE_KNOWN_WIN // Do not return unproven wins
// Step 8. Null move search with verification search (is omitted in PV nodes)
if ( !PvNode
// Step 8. Null move search with verification search (is omitted in PV nodes)
if ( !PvNode
&& depth >= 2 * ONE_PLY
&& eval >= beta
&& pos.non_pawn_material(pos.side_to_move()))
&& depth >= 2 * ONE_PLY
&& eval >= beta
&& pos.non_pawn_material(pos.side_to_move()))
Depth R = (3 + depth / 4 + std::min((eval - beta) / PawnValueMg, 3)) * ONE_PLY;
pos.do_null_move(st);
Depth R = (3 + depth / 4 + std::min((eval - beta) / PawnValueMg, 3)) * ONE_PLY;
pos.do_null_move(st);
- (ss+1)->skipNullMove = true;
+ (ss+1)->skipEarlyPruning = true;
nullValue = depth-R < ONE_PLY ? -qsearch<NonPV, false>(pos, ss+1, -beta, -beta+1, DEPTH_ZERO)
: - search<NonPV, false>(pos, ss+1, -beta, -beta+1, depth-R, !cutNode);
nullValue = depth-R < ONE_PLY ? -qsearch<NonPV, false>(pos, ss+1, -beta, -beta+1, DEPTH_ZERO)
: - search<NonPV, false>(pos, ss+1, -beta, -beta+1, depth-R, !cutNode);
- (ss+1)->skipNullMove = false;
+ (ss+1)->skipEarlyPruning = false;
pos.undo_null_move();
if (nullValue >= beta)
pos.undo_null_move();
if (nullValue >= beta)
return nullValue;
// Do verification search at high depths
return nullValue;
// Do verification search at high depths
- ss->skipNullMove = true;
+ ss->skipEarlyPruning = true;
Value v = depth-R < ONE_PLY ? qsearch<NonPV, false>(pos, ss, beta-1, beta, DEPTH_ZERO)
: search<NonPV, false>(pos, ss, beta-1, beta, depth-R, false);
Value v = depth-R < ONE_PLY ? qsearch<NonPV, false>(pos, ss, beta-1, beta, DEPTH_ZERO)
: search<NonPV, false>(pos, ss, beta-1, beta, depth-R, false);
- ss->skipNullMove = false;
+ ss->skipEarlyPruning = false;
if (v >= beta)
return nullValue;
if (v >= beta)
return nullValue;
// prune the previous move.
if ( !PvNode
&& depth >= 5 * ONE_PLY
// prune the previous move.
if ( !PvNode
&& depth >= 5 * ONE_PLY
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
{
Value rbeta = std::min(beta + 200, VALUE_INFINITE);
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
{
Value rbeta = std::min(beta + 200, VALUE_INFINITE);
&& (PvNode || ss->staticEval + 256 >= beta))
{
Depth d = 2 * (depth - 2 * ONE_PLY) - (PvNode ? DEPTH_ZERO : depth / 2);
&& (PvNode || ss->staticEval + 256 >= beta))
{
Depth d = 2 * (depth - 2 * ONE_PLY) - (PvNode ? DEPTH_ZERO : depth / 2);
- ss->skipNullMove = true;
+ ss->skipEarlyPruning = true;
search<PvNode ? PV : NonPV, false>(pos, ss, alpha, beta, d / 2, true);
search<PvNode ? PV : NonPV, false>(pos, ss, alpha, beta, d / 2, true);
- ss->skipNullMove = false;
+ ss->skipEarlyPruning = false;
tte = TT.probe(posKey);
ttMove = tte ? tte->move() : MOVE_NONE;
tte = TT.probe(posKey);
ttMove = tte ? tte->move() : MOVE_NONE;
{
Value rBeta = ttValue - 2 * depth / ONE_PLY;
ss->excludedMove = move;
{
Value rBeta = ttValue - 2 * depth / ONE_PLY;
ss->excludedMove = move;
- ss->skipNullMove = true;
+ ss->skipEarlyPruning = true;
value = search<NonPV, false>(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode);
value = search<NonPV, false>(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode);
- ss->skipNullMove = false;
+ ss->skipEarlyPruning = false;
ss->excludedMove = MOVE_NONE;
if (value < rBeta)
ss->excludedMove = MOVE_NONE;
if (value < rBeta)
Move killers[2];
Depth reduction;
Value staticEval;
Move killers[2];
Depth reduction;
Value staticEval;