}
constexpr int futility_move_count(bool improving, Depth depth) {
- return (5 + depth * depth) * (1 + improving) / 2 - 1;
+ return (4 + depth * depth) / (2 - improving);
}
// History and stats update bonus, based on depth
Value value_from_tt(Value v, int ply, int r50c);
void update_pv(Move* pv, Move move, Move* childPv);
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
- void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus);
+ void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus, int depth);
void update_all_stats(const Position& pos, Stack* ss, Move bestMove, Value bestValue, Value beta, Square prevSq,
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth);
ttMove = rootNode ? thisThread->rootMoves[thisThread->pvIdx].pv[0]
: ttHit ? tte->move() : MOVE_NONE;
ttPv = PvNode || (ttHit && tte->is_pv());
+
+ if (ttPv && depth > 12 && ss->ply - 1 < MAX_LPH && !pos.captured_piece() && is_ok((ss-1)->currentMove))
+ thisThread->lowPlyHistory[ss->ply - 1][from_to((ss-1)->currentMove)] << stat_bonus(depth - 5);
+
// thisThread->ttHitAverage can be used to approximate the running average of ttHit
thisThread->ttHitAverage = (ttHitAverageWindow - 1) * thisThread->ttHitAverage / ttHitAverageWindow
+ ttHitAverageResolution * ttHit;
if (ttValue >= beta)
{
if (!pos.capture_or_promotion(ttMove))
- update_quiet_stats(pos, ss, ttMove, stat_bonus(depth));
+ update_quiet_stats(pos, ss, ttMove, stat_bonus(depth), depth);
// Extra penalty for early quiet moves of the previous ply
if ((ss-1)->moveCount <= 2 && !priorCapture)
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
+ &thisThread->lowPlyHistory,
&thisThread->captureHistory,
contHist,
countermove,
- ss->killers);
+ ss->killers,
+ depth > 12 ? ss->ply : MAX_PLY);
value = bestValue;
singularLMR = moveCountPruning = false;
if (PvNode)
bestValue = std::min(bestValue, maxValue);
- if (!excludedMove)
+ if (!excludedMove && !(rootNode && thisThread->pvIdx))
tte->save(posKey, value_to_tt(bestValue, ss->ply), ttPv,
bestValue >= beta ? BOUND_LOWER :
PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER,
if (!pos.capture_or_promotion(bestMove))
{
- update_quiet_stats(pos, ss, bestMove, bonus2);
+ update_quiet_stats(pos, ss, bestMove, bonus2, depth);
// Decrease all the non-best quiet moves
for (int i = 0; i < quietCount; ++i)
// update_quiet_stats() updates move sorting heuristics
- void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus) {
+ void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus, int depth) {
if (ss->killers[0] != move)
{
Square prevSq = to_sq((ss-1)->currentMove);
thisThread->counterMoves[pos.piece_on(prevSq)][prevSq] = move;
}
+
+ if (depth > 12 && ss->ply < MAX_LPH)
+ thisThread->lowPlyHistory[ss->ply][from_to(move)] << stat_bonus(depth - 7);
}
// When playing with strength handicap, choose best move among a set of RootMoves