Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assorted cleanups #5059

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Stockfish {
namespace {

enum Stages {
// generate main search moves
// Generate main search moves
MAIN_TT,
CAPTURE_INIT,
GOOD_CAPTURE,
Expand All @@ -41,26 +41,26 @@ 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,
QCHECK_INIT,
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)
Expand Down Expand Up @@ -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<GenType Type>
void MovePicker::score() {

Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/movepick.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <type_traits> // IWYU pragma: keep

#include "movegen.h"
#include "types.h"
#include "position.h"
#include "types.h"

namespace Stockfish {

Expand Down
12 changes: 6 additions & 6 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include <cstdlib>
#include <initializer_list>
#include <iostream>
#include <utility>
#include <sstream>
#include <utility>

#include "evaluate.h"
#include "misc.h"
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()))]
Expand Down Expand Up @@ -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--;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
#include <string>
#include <vector>

#include "misc.h"
#include "movepick.h"
Expand Down
2 changes: 1 addition & 1 deletion src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#include "thread.h"

#include <algorithm>
#include <array>
#include <cassert>
#include <deque>
#include <memory>
#include <unordered_map>
#include <utility>
#include <array>

#include "misc.h"
#include "movegen.h"
Expand Down
2 changes: 1 addition & 1 deletion src/thread_win32_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(USE_PTHREADS)

#include <pthread.h>
#include <functional>
#include <pthread.h>

namespace Stockfish {

Expand Down
4 changes: 2 additions & 2 deletions src/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <memory>
#include <optional>
#include <sstream>
#include <vector>
#include <cstdint>

#include "benchmark.h"
#include "evaluate.h"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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};

Expand Down
Loading