ss->currentMove = ttMove; // Can be MOVE_NONE
// If ttMove is quiet, update killers, history, counter move on TT hit
- if (ttValue >= beta && ttMove && !pos.capture_or_promotion(ttMove) && !inCheck)
+ if (ttValue >= beta && ttMove && !pos.capture_or_promotion(ttMove))
update_stats(pos, ss, ttMove, depth, nullptr, 0);
return ttValue;
}
ss->currentMove = move;
- if (!SpNode && !captureOrPromotion && quietCount < 64)
- quietsSearched[quietCount++] = move;
// Step 14. Make the move
pos.do_move(move, st, givesCheck);
ss->reduction = reduction<PvNode>(improving, depth, moveCount);
if ( (!PvNode && cutNode)
- || History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO
|| ( History[pos.piece_on(to_sq(move))][to_sq(move)]
+ CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq]
[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO))
}
}
+ if (!SpNode && !captureOrPromotion && move != bestMove && quietCount < 64)
+ quietsSearched[quietCount++] = move;
+
// Step 19. Check for splitting the search
if ( !SpNode
&& Threads.size() >= 2
: inCheck ? mated_in(ss->ply) : DrawValue[pos.side_to_move()];
// Quiet best move: update killers, history and countermoves
- else if (bestValue >= beta && !pos.capture_or_promotion(bestMove) && !inCheck)
- update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount - 1);
+ else if (bestMove && !pos.capture_or_promotion(bestMove))
+ update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount);
tte->save(posKey, value_to_tt(bestValue, ss->ply),
bestValue >= beta ? BOUND_LOWER :
// Detect non-capture evasions that are candidates to be pruned
evasionPrunable = InCheck
&& bestValue > VALUE_MATED_IN_MAX_PLY
- && !pos.capture(move)
- && !pos.can_castle(pos.side_to_move());
+ && !pos.capture(move);
// Don't search moves with negative SEE values
if ( (!InCheck || evasionPrunable)
*pv = MOVE_NONE;
}
- // update_stats() updates killers, history and countermoves stats after a fail-high
- // of a quiet move.
- void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt) {
+ // update_stats() updates killers, history, countermove history and
+ // countermoves stats for a quiet best move.
+
+ void update_stats(const Position& pos, Stack* ss, Move move,
+ Depth depth, Move* quiets, int quietsCnt) {
if (ss->killers[0] != move)
{