diff --git a/src/movepick.cpp b/src/movepick.cpp index 33791922e4b..bb068f29da4 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -31,7 +31,7 @@ namespace Stockfish { namespace { enum Stages { - // generate main search moves + // Generate main search moves MAIN_TT, CAPTURE_INIT, GOOD_CAPTURE, @@ -41,17 +41,17 @@ enum Stages { BAD_CAPTURE, BAD_QUIET, - // generate evasion moves + // Generate evasion moves EVASION_TT, EVASION_INIT, EVASION, - // generate probcut moves + // Generate probcut moves PROBCUT_TT, PROBCUT_INIT, PROBCUT, - // generate qsearch moves + // Generate qsearch moves QSEARCH_TT, QCAPTURE_INIT, QCAPTURE, @@ -59,8 +59,8 @@ enum Stages { QCHECK }; -// Sort moves in descending order up to and including -// a given limit. The order of moves smaller than the limit is left unspecified. +// Sort moves in descending order up to and including a given limit. +// The order of moves smaller than the limit is left unspecified. void partial_insertion_sort(ExtMove* begin, ExtMove* end, int limit) { for (ExtMove *sortedEnd = begin, *p = begin + 1; p < end; ++p) @@ -139,9 +139,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, int th, const CapturePieceTo + !(ttm && pos.capture_stage(ttm) && pos.pseudo_legal(ttm) && pos.see_ge(ttm, threshold)); } -// Assigns a numerical value to each move in a list, used -// for sorting. Captures are ordered by Most Valuable Victim (MVV), preferring -// captures with a good history. Quiets moves are ordered using the history tables. +// Assigns a numerical value to each move in a list, used for sorting. +// Captures are ordered by Most Valuable Victim (MVV), preferring captures +// with a good history. Quiets moves are ordered using the history tables. template void MovePicker::score() { @@ -177,7 +177,7 @@ void MovePicker::score() { Square from = m.from_sq(); Square to = m.to_sq(); - // histories + // Histories m.value = 2 * (*mainHistory)[pos.side_to_move()][m.from_to()]; m.value += 2 * (*pawnHistory)[pawn_structure_index(pos)][pc][to]; m.value += 2 * (*continuationHistory[0])[pc][to]; @@ -186,17 +186,17 @@ void MovePicker::score() { m.value += (*continuationHistory[3])[pc][to]; m.value += (*continuationHistory[5])[pc][to]; - // bonus for checks + // Bonus for checks m.value += bool(pos.check_squares(pt) & to) * 16384; - // bonus for escaping from capture + // Bonus for escaping from capture m.value += threatenedPieces & from ? (pt == QUEEN && !(to & threatenedByRook) ? 50000 : pt == ROOK && !(to & threatenedByMinor) ? 25000 : !(to & threatenedByPawn) ? 15000 : 0) : 0; - // malus for putting piece en prise + // Malus for putting piece en prise m.value -= !(threatenedPieces & from) ? (pt == QUEEN ? bool(to & threatenedByRook) * 50000 + bool(to & threatenedByMinor) * 10000 diff --git a/src/movepick.h b/src/movepick.h index 357918a90f2..09bead0286c 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -28,8 +28,8 @@ #include // IWYU pragma: keep #include "movegen.h" -#include "types.h" #include "position.h" +#include "types.h" namespace Stockfish { diff --git a/src/search.cpp b/src/search.cpp index 55a92947d32..96c17a1168e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include #include "evaluate.h" #include "misc.h" @@ -616,7 +616,7 @@ Value Search::Worker::search( update_quiet_stats(pos, ss, *this, ttMove, stat_bonus(depth)); // Extra penalty for early quiet moves of - // the previous ply (~0 Elo on STC, ~2 Elo on LTC). + // the previous ply (~1 Elo on STC, ~2 Elo on LTC) if (prevSq != SQ_NONE && (ss - 1)->moveCount <= 2 && !priorCapture) update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -stat_malus(depth + 1)); @@ -696,7 +696,7 @@ Value Search::Worker::search( else if (excludedMove) { // Providing the hint that this node's accumulator will be used often - // brings significant Elo gain (~13 Elo). + // brings significant Elo gain (~13 Elo) Eval::NNUE::hint_common_parent_position(pos); unadjustedStaticEval = eval = ss->staticEval; } @@ -1072,7 +1072,7 @@ Value Search::Worker::search( extension = -1; } - // Recapture extensions (~1 Elo) + // Recapture extensions (~0 Elo on STC, ~1 Elo on LTC) else if (PvNode && move == ttMove && move.to_sq() == prevSq && thisThread->captureHistory[movedPiece][move.to_sq()] [type_of(pos.piece_on(move.to_sq()))] @@ -1110,7 +1110,7 @@ Value Search::Worker::search( if (ttCapture) r++; - // Decrease reduction for PvNodes (~3 Elo) + // Decrease reduction for PvNodes (~0 Elo on STC, ~2 Elo on LTC) if (PvNode) r--; @@ -1172,7 +1172,7 @@ Value Search::Worker::search( // Step 18. Full-depth search when LMR is skipped else if (!PvNode || moveCount > 1) { - // Increase reduction if ttMove is not present (~1 Elo) + // Increase reduction if ttMove is not present (~6 Elo) if (!ttMove) r += 2; diff --git a/src/search.h b/src/search.h index 4a1c68bb9ce..0d909d641f7 100644 --- a/src/search.h +++ b/src/search.h @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include "misc.h" #include "movepick.h" diff --git a/src/thread.cpp b/src/thread.cpp index 95646601106..5f126c92f1c 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -19,12 +19,12 @@ #include "thread.h" #include +#include #include #include #include #include #include -#include #include "misc.h" #include "movegen.h" diff --git a/src/thread_win32_osx.h b/src/thread_win32_osx.h index 1d9a834f600..16bbcceb568 100644 --- a/src/thread_win32_osx.h +++ b/src/thread_win32_osx.h @@ -29,8 +29,8 @@ #if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(USE_PTHREADS) - #include #include + #include namespace Stockfish { diff --git a/src/timeman.cpp b/src/timeman.cpp index 72a447af5b8..04a83def8f9 100644 --- a/src/timeman.cpp +++ b/src/timeman.cpp @@ -89,8 +89,8 @@ void TimeManagement::init(Search::LimitsType& limits, - moveOverhead * (2 + mtg)); // x basetime (+ z increment) - // If there is a healthy increment, timeLeft can exceed actual available - // game time for the current move, so also cap to 20% of available game time. + // If there is a healthy increment, timeLeft can exceed the actual available + // game time for the current move, so also cap to a percentage of available game time. if (limits.movestogo == 0) { // Use extra time with larger increments diff --git a/src/uci.cpp b/src/uci.cpp index d1d69d69752..776b1b37e16 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -22,13 +22,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include "benchmark.h" #include "evaluate.h" @@ -137,7 +137,7 @@ void UCI::loop() { sync_cout << "readyok" << sync_endl; // Add custom non-UCI commands, mainly for debugging purposes. - // These commands must not be used during a search! + // These commands must NOT be used during a search. else if (token == "flip") pos.flip(); else if (token == "bench") @@ -332,7 +332,7 @@ std::string UCI::value(Value v) { ss << "cp " << to_cp(v); else if (std::abs(v) <= VALUE_TB) { - const int ply = VALUE_TB - std::abs(v); // recompute ss->ply + const int ply = VALUE_TB - std::abs(v); // Recompute ss->ply ss << "cp " << (v > 0 ? 20000 - ply : -20000 + ply); } else @@ -374,9 +374,8 @@ int win_rate_model(Value v, int ply) { // The fitted model only uses data for moves in [8, 120], and is anchored at move 32. double m = std::clamp(ply / 2 + 1, 8, 120) / 32.0; - // The coefficients of a third-order polynomial fit is based on the fishtest data - // for two parameters that need to transform eval to the argument of a logistic - // function. + // The coefficients of a third-order polynomial fit is based on the fishtest data for + // two parameters that need to transform eval to the argument of a logistic function. constexpr double as[] = {-2.00568292, 10.45906746, 1.67438883, 334.45864705}; constexpr double bs[] = {-4.97134419, 36.15096345, -82.25513499, 117.35186805};