return Reductions[PvNode][i][std::min(d / ONE_PLY, 63)][std::min(mn, 63)] * ONE_PLY;
}
+ // History and stats update bonus, based on depth
+ Value stat_bonus(Depth depth) {
+ int d = depth / ONE_PLY ;
+ return Value(d * d + 2 * d - 2);
+ }
+
// Skill structure is used to implement strength limit
struct Skill {
Skill(int l) : level(l) {}
const size_t HalfDensitySize = std::extent<decltype(HalfDensity)>::value;
- Value bonus(Depth depth) { int d = depth / ONE_PLY ; return Value(d * d + 2 * d - 2); }
- Value penalty(Depth depth) { int d = depth / ONE_PLY ; return -Value(d * d + 4 * d + 1); }
-
EasyMoveManager EasyMove;
Value DrawValue[COLOR_NB];
: (tte->bound() & BOUND_UPPER)))
{
// If ttMove is quiet, update move sorting heuristics on TT hit
- if (ttValue >= beta && ttMove)
+ if (ttMove)
{
- if (!pos.capture_or_promotion(ttMove))
- update_stats(pos, ss, ttMove, nullptr, 0, bonus(depth));
+ if (ttValue >= beta)
+ {
+ if (!pos.capture_or_promotion(ttMove))
+ update_stats(pos, ss, ttMove, nullptr, 0, stat_bonus(depth));
- // Extra penalty for a quiet TT move in previous ply when it gets refuted
- if ((ss-1)->moveCount == 1 && !pos.captured_piece())
- update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, penalty(depth));
+ // Extra penalty for a quiet TT move in previous ply when it gets refuted
+ if ((ss-1)->moveCount == 1 && !pos.captured_piece())
+ update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
+ }
+ // Penalty for a quiet ttMove that fails low
+ else if (ttValue < alpha && !pos.capture_or_promotion(ttMove))
+ {
+ Value penalty = -stat_bonus(depth + ONE_PLY);
+ thisThread->history.update(pos.side_to_move(), ttMove, penalty);
+ update_cm_stats(ss, pos.moved_piece(ttMove), to_sq(ttMove), penalty);
+ }
}
return ttValue;
}
+ (fmh ? (*fmh )[moved_piece][to_sq(move)] : VALUE_ZERO)
+ (fmh2 ? (*fmh2)[moved_piece][to_sq(move)] : VALUE_ZERO)
+ thisThread->history.get(~pos.side_to_move(), move)
- - 8000; // Correction factor
+ - 4000; // Correction factor
// Decrease/increase reduction by comparing opponent's stat score
if (ss->history > VALUE_ZERO && (ss-1)->history < VALUE_ZERO)
// Quiet best move: update move sorting heuristics
if (!pos.capture_or_promotion(bestMove))
- update_stats(pos, ss, bestMove, quietsSearched, quietCount, bonus(depth));
+ update_stats(pos, ss, bestMove, quietsSearched, quietCount, stat_bonus(depth));
// Extra penalty for a quiet TT move in previous ply when it gets refuted
if ((ss-1)->moveCount == 1 && !pos.captured_piece())
- update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, penalty(depth));
+ update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
}
// Bonus for prior countermove that caused the fail low
else if ( depth >= 3 * ONE_PLY
&& !pos.captured_piece()
&& is_ok((ss-1)->currentMove))
- update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, bonus(depth));
+ update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, stat_bonus(depth));
tte->save(posKey, value_to_tt(bestValue, ss->ply),
bestValue >= beta ? BOUND_LOWER :