}
ss->currentMove = move;
- if (!SpNode && !captureOrPromotion && quietCount < 64)
- quietsSearched[quietCount++] = move;
// Step 14. Make the move
pos.do_move(move, st, givesCheck);
rm.score = -VALUE_INFINITE;
}
+ bool newBestMove = false;
if (value > bestValue)
{
bestValue = SpNode ? splitPoint->bestValue = value : value;
&& (move != EasyMove.get(pos.key()) || moveCount > 1))
EasyMove.clear();
+ newBestMove = true;
bestMove = SpNode ? splitPoint->bestMove = move : move;
if (PvNode && !RootNode) // Update pv even in fail-high case
}
}
+ if (!SpNode && !captureOrPromotion && !newBestMove && 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))
- update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount - 1);
+ else if (bestMove != MOVE_NONE && !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 :
*pv = MOVE_NONE;
}
- // update_stats() updates killers, history and countermoves stats after a fail-high
- // of a quiet move.
+ // 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) {