mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 13:17:44 +00:00
Assorted cleanups
Assorted cleanups closes https://github.com/official-stockfish/Stockfish/pull/5046 No functional change Co-Authored-By: Shahin M. Shahin <41402573+peregrineshahin@users.noreply.github.com> Co-Authored-By: cj5716 <125858804+cj5716@users.noreply.github.com>
This commit is contained in:
+16
-21
@@ -67,7 +67,7 @@ constexpr int futility_move_count(bool improving, Depth depth) {
|
||||
Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) {
|
||||
auto cv = w.correctionHistory[pos.side_to_move()][pawn_structure_index<Correction>(pos)];
|
||||
v += cv * std::abs(cv) / 12890;
|
||||
return std::clamp(int(v), VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
|
||||
return std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
|
||||
}
|
||||
|
||||
// History and stats update bonus, based on depth
|
||||
@@ -297,9 +297,9 @@ void Search::Worker::iterative_deepening() {
|
||||
|
||||
// Reset aspiration window starting size
|
||||
Value avg = rootMoves[pvIdx].averageScore;
|
||||
delta = Value(9) + int(avg) * avg / 12480;
|
||||
delta = 9 + avg * avg / 12480;
|
||||
alpha = std::max(avg - delta, -VALUE_INFINITE);
|
||||
beta = std::min(avg + delta, int(VALUE_INFINITE));
|
||||
beta = std::min(avg + delta, VALUE_INFINITE);
|
||||
|
||||
// Adjust optimism based on root move's averageScore (~4 Elo)
|
||||
optimism[us] = 131 * avg / (std::abs(avg) + 95);
|
||||
@@ -350,7 +350,7 @@ void Search::Worker::iterative_deepening() {
|
||||
}
|
||||
else if (bestValue >= beta)
|
||||
{
|
||||
beta = std::min(bestValue + delta, int(VALUE_INFINITE));
|
||||
beta = std::min(bestValue + delta, VALUE_INFINITE);
|
||||
++failedHighCnt;
|
||||
}
|
||||
else
|
||||
@@ -481,7 +481,6 @@ void Search::Worker::clear() {
|
||||
for (auto& h : to)
|
||||
h->fill(-71);
|
||||
|
||||
|
||||
for (size_t i = 1; i < reductions.size(); ++i)
|
||||
reductions[i] = int((20.37 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
|
||||
}
|
||||
@@ -538,7 +537,7 @@ Value Search::Worker::search(
|
||||
|
||||
// Check for the available remaining time
|
||||
if (is_mainthread())
|
||||
main_manager()->check_time(*this);
|
||||
main_manager()->check_time(*thisThread);
|
||||
|
||||
// Used to send selDepth info to GUI (selDepth counts from 1, ply from 0)
|
||||
if (PvNode && thisThread->selDepth < ss->ply + 1)
|
||||
@@ -680,10 +679,8 @@ Value Search::Worker::search(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Value unadjustedStaticEval = VALUE_NONE;
|
||||
|
||||
// Step 6. Static evaluation of the position
|
||||
Value unadjustedStaticEval = VALUE_NONE;
|
||||
if (ss->inCheck)
|
||||
{
|
||||
// Skip early pruning when in check
|
||||
@@ -820,11 +817,10 @@ Value Search::Worker::search(
|
||||
if (cutNode && depth >= 8 && !ttMove)
|
||||
depth -= 2;
|
||||
|
||||
probCutBeta = beta + 182 - 68 * improving;
|
||||
|
||||
// Step 11. ProbCut (~10 Elo)
|
||||
// If we have a good enough capture (or queen promotion) and a reduced search returns a value
|
||||
// much above beta, we can (almost) safely prune the previous move.
|
||||
probCutBeta = beta + 182 - 68 * improving;
|
||||
if (
|
||||
!PvNode && depth > 3
|
||||
&& std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
|
||||
@@ -1285,7 +1281,6 @@ moves_loop: // When in check, search starts here
|
||||
{
|
||||
if (capture)
|
||||
capturesSearched[captureCount++] = move;
|
||||
|
||||
else
|
||||
quietsSearched[quietCount++] = move;
|
||||
}
|
||||
@@ -1424,9 +1419,8 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||
&& (tte->bound() & (ttValue >= beta ? BOUND_LOWER : BOUND_UPPER)))
|
||||
return ttValue;
|
||||
|
||||
Value unadjustedStaticEval = VALUE_NONE;
|
||||
|
||||
// Step 4. Static evaluation of the position
|
||||
Value unadjustedStaticEval = VALUE_NONE;
|
||||
if (ss->inCheck)
|
||||
bestValue = futilityBase = -VALUE_INFINITE;
|
||||
else
|
||||
@@ -1521,7 +1515,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||
|
||||
// If static eval is much lower than alpha and move is not winning material
|
||||
// we can prune this move. (~2 Elo)
|
||||
if (futilityBase <= alpha && !pos.see_ge(move, VALUE_ZERO + 1))
|
||||
if (futilityBase <= alpha && !pos.see_ge(move, 1))
|
||||
{
|
||||
bestValue = std::max(bestValue, futilityBase);
|
||||
continue;
|
||||
@@ -1597,7 +1591,6 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||
if (ss->inCheck && bestValue == -VALUE_INFINITE)
|
||||
{
|
||||
assert(!MoveList<LEGAL>(pos).size());
|
||||
|
||||
return mated_in(ss->ply); // Plies to mate from the root
|
||||
}
|
||||
|
||||
@@ -1615,6 +1608,10 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||
return bestValue;
|
||||
}
|
||||
|
||||
Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) {
|
||||
int reductionScale = reductions[d] * reductions[mn];
|
||||
return (reductionScale + 1177 - delta * 776 / rootDelta) / 1024 + (!i && reductionScale > 842);
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Adjusts a mate or TB score from "plies to mate from the root"
|
||||
@@ -1623,7 +1620,6 @@ namespace {
|
||||
Value value_to_tt(Value v, int ply) {
|
||||
|
||||
assert(v != VALUE_NONE);
|
||||
|
||||
return v >= VALUE_TB_WIN_IN_MAX_PLY ? v + ply : v <= VALUE_TB_LOSS_IN_MAX_PLY ? v - ply : v;
|
||||
}
|
||||
|
||||
@@ -1805,9 +1801,9 @@ Move Skill::pick_best(const RootMoves& rootMoves, size_t multiPV) {
|
||||
for (size_t i = 0; i < multiPV; ++i)
|
||||
{
|
||||
// This is our magic formula
|
||||
int push = int((weakness * int(topScore - rootMoves[i].score)
|
||||
+ delta * (rng.rand<unsigned>() % int(weakness)))
|
||||
/ 128);
|
||||
int push = (weakness * int(topScore - rootMoves[i].score)
|
||||
+ delta * (rng.rand<unsigned>() % int(weakness)))
|
||||
/ 128;
|
||||
|
||||
if (rootMoves[i].score + push >= maxScore)
|
||||
{
|
||||
@@ -1921,7 +1917,6 @@ bool RootMove::extract_ponder_from_tt(const TranspositionTable& tt, Position& po
|
||||
bool ttHit;
|
||||
|
||||
assert(pv.size() == 1);
|
||||
|
||||
if (pv[0] == Move::none())
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user