return Value((175 - 50 * improving) * d / ONE_PLY);
}
+ // Margin for pruning capturing moves: almost linear in depth
+ constexpr int CapturePruneMargin[] = { 0,
+ 1 * PawnValueEg * 1055 / 1000,
+ 2 * PawnValueEg * 1042 / 1000,
+ 3 * PawnValueEg * 963 / 1000,
+ 4 * PawnValueEg * 1038 / 1000,
+ 5 * PawnValueEg * 950 / 1000,
+ 6 * PawnValueEg * 930 / 1000
+ };
+
// Futility and reductions lookup tables, initialized at startup
int FutilityMoveCounts[2][16]; // [improving][depth]
int Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber]
Reductions[PV][imp][d][mc] = std::max(Reductions[NonPV][imp][d][mc] - 1, 0);
// Increase reduction for non-PV nodes when eval is not improving
- if (!imp && Reductions[NonPV][imp][d][mc] >= 2)
+ if (!imp && r > 1.0)
Reductions[NonPV][imp][d][mc]++;
}
multiPV = std::min(multiPV, rootMoves.size());
int ct = Options["Contempt"] * PawnValueEg / 100; // From centipawns
- Eval::Contempt = (us == WHITE ? make_score(ct, ct / 2)
- : -make_score(ct, ct / 2));
+ contempt = (us == WHITE ? make_score(ct, ct / 2)
+ : -make_score(ct, ct / 2));
// Iterative deepening loop until requested to stop or the target depth is reached
while ( (rootDepth += ONE_PLY) < DEPTH_MAX
// Reset aspiration window starting size
if (rootDepth >= 5 * ONE_PLY)
{
+ Value previousScore = rootMoves[PVIdx].previousScore;
delta = Value(18);
- alpha = std::max(rootMoves[PVIdx].previousScore - delta,-VALUE_INFINITE);
- beta = std::min(rootMoves[PVIdx].previousScore + delta, VALUE_INFINITE);
+ alpha = std::max(previousScore - delta,-VALUE_INFINITE);
+ beta = std::min(previousScore + delta, VALUE_INFINITE);
ct = Options["Contempt"] * PawnValueEg / 100; // From centipawns
- // Adjust contempt based on current bestValue (dynamic contempt)
- ct += int(std::round(48 * atan(float(bestValue) / 128)));
+ // Adjust contempt based on root move's previousScore (dynamic contempt)
+ ct += int(std::round(48 * atan(float(previousScore) / 128)));
- Eval::Contempt = (us == WHITE ? make_score(ct, ct / 2)
- : -make_score(ct, ct / 2));
+ contempt = (us == WHITE ? make_score(ct, ct / 2)
+ : -make_score(ct, ct / 2));
}
// Start with a small aspiration window and, in the case of a fail
// Step 11. Internal iterative deepening (skipped when in check)
if ( depth >= 6 * ONE_PLY
&& !ttMove
- && (PvNode || ss->staticEval + 256 >= beta))
+ && (PvNode || ss->staticEval + 128 >= beta))
{
Depth d = 3 * depth / 4 - 2 * ONE_PLY;
search<NT>(pos, ss, alpha, beta, d, cutNode, true);
}
else if ( depth < 7 * ONE_PLY
&& !extension
- && !pos.see_ge(move, -PawnValueEg * (depth / ONE_PLY)))
+ && !pos.see_ge(move, -Value(CapturePruneMargin[depth / ONE_PLY])))
continue;
}
static TimePoint lastInfoTime = now();
- int elapsed = Time.elapsed();
+ TimePoint elapsed = Time.elapsed();
TimePoint tick = Limits.startTime + elapsed;
if (tick - lastInfoTime >= 1000)
string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
std::stringstream ss;
- int elapsed = Time.elapsed() + 1;
+ TimePoint elapsed = Time.elapsed() + 1;
const RootMoves& rootMoves = pos.this_thread()->rootMoves;
size_t PVIdx = pos.this_thread()->PVIdx;
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());