Minor cleanups June 2026

In the spirit of previous such PRs, this PR proposes a collection of nonfunctional changes.

I am happy to incorporate changes from other devs, and revert some of the proposed changes if the maintainers ask me to.

Apart from trivial changes, the proposed changes so far include:

* A requested edit to `AUTHORS` and a resorting of all entries, following DIN 5007 for the treatment of any special characters.
* Exclude the two recent integer type renaming commits from git blame.
* Tightening of some static asserts in `history.h` to avoid overflows. (Note that rounding errors for floating point types could lead to the assert in `operator<<` triggering at run-time.)
* Re-instate the 0.5s maximal thinking time in case of a single legal move and reword the comment to make it clear that it should not be tuned.
* ~~A small refactoring of the network loading code thanks to @dubslow.~~
* A refactoring of the "dtz is dtm" code, also thanks to @dubslow.

closes https://github.com/official-stockfish/Stockfish/pull/6928

No functional change
This commit is contained in:
Robert Nurnberg
2026-07-10 20:12:38 +02:00
committed by Joost VandeVondele
parent eca43a97ef
commit 48a9118251
23 changed files with 87 additions and 182 deletions
+16 -15
View File
@@ -146,6 +146,8 @@ void update_all_stats(const Position& pos,
Move ttMove,
bool PvNode);
// Detect shuffling moves in order to limit search explosions
// Added in #6447 as non-regression, and so its parameters should not be tuned
bool is_shuffling(Move move, Stack* const ss, const Position& pos) {
if (pos.capture_stage(move) || pos.rule50_count() < 10)
return false;
@@ -249,9 +251,9 @@ void Search::Worker::start_searching() {
// Send PV info if it has changed since last output in iterative_deepening().
if (!uciPvSent || bestThread != this)
main_manager()->pv(*bestThread, threads, tt, bestThread->rootDepth);
main_manager()->output_pv(*bestThread, threads, tt, bestThread->rootDepth);
// In rare cases, pv() may change the ponder move through syzygy_extend_pv().
// In rare cases, output_pv() may change the ponder move through syzygy_extend_pv().
std::string ponder;
if (bestThread->rootMoves[0].pv.size() > 1)
ponder = UCIEngine::move(bestThread->rootMoves[0].pv[1], rootPos.is_chess960());
@@ -347,8 +349,7 @@ bool Search::Worker::iterative_deepening() {
rootMoves[i].previousScoreExact = i < multiPV;
}
usize pvFirst = 0;
pvLast = 0;
usize pvFirst = pvLast = 0;
if (!threads.increaseDepth)
searchAgainCounter++;
@@ -411,7 +412,7 @@ bool Search::Worker::iterative_deepening() {
// at nodes > 10M (rather than depth N, which can be reached quickly)
if (mainThread && multiPV == 1 && (bestValue <= alpha || bestValue >= beta)
&& nodes > NODES_LIMIT_OUTPUT)
main_manager()->pv(*this, threads, tt, rootDepth);
main_manager()->output_pv(*this, threads, tt, rootDepth);
// In case of failing low/high increase aspiration window and re-search,
// otherwise exit the loop.
@@ -491,7 +492,7 @@ bool Search::Worker::iterative_deepening() {
if (mainThread && !threads.stop && (pvIdx + 1 == multiPV || nodes > NODES_LIMIT_OUTPUT))
{
main_manager()->pv(*this, threads, tt, rootDepth);
main_manager()->output_pv(*this, threads, tt, rootDepth);
uciPvSent = (pvIdx + 1 == multiPV);
}
@@ -587,9 +588,9 @@ bool Search::Worker::iterative_deepening() {
double totalTime = mainThread->tm.optimum() * fallingEval * reduction
* bestMoveInstability * highBestMoveEffort;
// Cap used time in case of a single legal move for a better viewer experience
if (rootMoves.size() == 1)
totalTime = std::min(561.7, totalTime);
// Cap used time to 0.5s for a better viewer experience
totalTime = std::min(500.0, totalTime);
auto elapsedTime = elapsed();
@@ -700,7 +701,7 @@ void Search::Worker::clear() {
// Main search function for both PV and non-PV nodes
template<NodeType nodeType>
Value Search::Worker::search(
Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, bool cutNode) {
Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, const bool cutNode) {
constexpr bool PvNode = nodeType != NonPV;
constexpr bool rootNode = nodeType == Root;
@@ -1917,7 +1918,7 @@ void update_all_stats(const Position& pos,
if (!PvNode)
// Important: don't remove the cast to a 64-bit number else the multiplication
// can overflow on 32-bit platforms which would change the bench signature
bonus += bonus * u64(quietsSearched.size() + capturesSearched.size()) / 256;
bonus += int(bonus * u64(quietsSearched.size() + capturesSearched.size()) / 256);
if (!pos.capture_stage(bestMove))
{
@@ -2175,7 +2176,7 @@ void syzygy_extend_pv(const OptionsMap& options,
// Finding a draw in this function is an exceptional case, that cannot happen when rule50 is false or
// during engine game play, since we have a winning score, and play correctly
// with TB support. However, it can be that a position is draw due to the 50 move
// rule if it has been been reached on the board with a non-optimal 50 move counter
// rule if it has been reached on the board with a non-optimal 50 move counter
// (e.g. 8/8/6k1/3B4/3K4/4N3/8/8 w - - 54 106 ) which TB with dtz counter rounding
// cannot always correctly rank. See also
// https://github.com/official-stockfish/Stockfish/issues/5175#issuecomment-2058893495
@@ -2196,10 +2197,10 @@ void syzygy_extend_pv(const OptionsMap& options,
<< sync_endl;
}
void SearchManager::pv(Search::Worker& worker,
const ThreadPool& threads,
const TranspositionTable& tt,
Depth depth) {
void SearchManager::output_pv(Search::Worker& worker,
const ThreadPool& threads,
const TranspositionTable& tt,
Depth depth) {
const auto nodes = threads.nodes_searched();
auto& rootMoves = worker.rootMoves;