ss->pv = pv;
- bestValue = delta = alpha = -VALUE_INFINITE;
- beta = VALUE_INFINITE;
- optimism[WHITE] = optimism[BLACK] = VALUE_ZERO;
+ bestValue = -VALUE_INFINITE;
if (mainThread)
{
selDepth = 0;
// Reset aspiration window starting size
- if (rootDepth >= 4)
- {
- Value prev = rootMoves[pvIdx].averageScore;
- delta = Value(10) + int(prev) * prev / 16502;
- alpha = std::max(prev - delta,-VALUE_INFINITE);
- beta = std::min(prev + delta, VALUE_INFINITE);
-
- // Adjust optimism based on root move's previousScore
- int opt = 120 * prev / (std::abs(prev) + 161);
- optimism[ us] = Value(opt);
- optimism[~us] = -optimism[us];
- }
+ Value prev = rootMoves[pvIdx].averageScore;
+ delta = Value(10) + int(prev) * prev / 16502;
+ alpha = std::max(prev - delta,-VALUE_INFINITE);
+ beta = std::min(prev + delta, VALUE_INFINITE);
+
+ // Adjust optimism based on root move's previousScore
+ int opt = 102 * prev / (std::abs(prev) + 147);
+ optimism[ us] = Value(opt);
+ optimism[~us] = -optimism[us];
// Start with a small aspiration window and, in the case of a fail
// high/low, re-search with a bigger window until we don't fail
{
if (depth < 2 - capture)
continue;
- // Don't prune the move if opp. King/Queen/Rook is attacked by a slider after the exchanges.
- // Since in see_ge we don't update occupied when the king recaptures, we also don't prune the
- // move when the opp. King gets a discovered slider attack DURING the exchanges.
- Bitboard leftEnemies = pos.pieces(~us, ROOK, QUEEN, KING) & occupied;
+ // Don't prune the move if opp. King/Queen/Rook gets a discovered attack during or after the exchanges
+ Bitboard leftEnemies = pos.pieces(~us, KING, QUEEN, ROOK);
Bitboard attacks = 0;
occupied |= to_sq(move);
while (leftEnemies && !attacks)
{
Square sq = pop_lsb(leftEnemies);
attacks = pos.attackers_to(sq, occupied) & pos.pieces(us) & occupied;
- // Exclude Queen/Rook(s) which were already threatened before SEE
+ // Exclude Queen/Rook(s) which were already threatened before SEE (opp King can't be in check when it's our turn)
if (attacks && sq != pos.square<KING>(~us) && (pos.attackers_to(sq, pos.pieces()) & pos.pieces(us)))
attacks = 0;
}
if ((ss+1)->cutoffCnt > 3)
r++;
+ else if (move == ttMove)
+ r--;
+
ss->statScore = 2 * thisThread->mainHistory[us][from_to(move)]
+ (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]