closes https://github.com/official-stockfish/Stockfish/pull/4926
closes https://github.com/official-stockfish/Stockfish/pull/4909
No functional change
Co-Authored-By: fffelix-huang <72808219+fffelix-huang@users.noreply.github.com>
Thanar2
thaspel
theo77186
Thanar2
thaspel
theo77186
+Ting-Hsuan Huang (fffelix-huang)
Tomasz Sobczyk (Sopel97)
Tom Truscott
Tom Vijlbrief (tomtor)
Tomasz Sobczyk (Sopel97)
Tom Truscott
Tom Vijlbrief (tomtor)
#include <algorithm>
#include <cassert>
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <iomanip>
int shuffling = pos.rule50_count();
int simpleEval = simple_eval(pos, stm) + (int(pos.key() & 7) - 3);
int shuffling = pos.rule50_count();
int simpleEval = simple_eval(pos, stm) + (int(pos.key() & 7) - 3);
- bool lazy = abs(simpleEval) >= RookValue + KnightValue + 16 * shuffling * shuffling
- + abs(pos.this_thread()->bestValue)
- + abs(pos.this_thread()->rootSimpleEval);
+ bool lazy = std::abs(simpleEval) >= RookValue + KnightValue + 16 * shuffling * shuffling
+ + std::abs(pos.this_thread()->bestValue)
+ + std::abs(pos.this_thread()->rootSimpleEval);
if (lazy)
v = Value(simpleEval);
if (lazy)
v = Value(simpleEval);
Value optimism = pos.this_thread()->optimism[stm];
// Blend optimism and eval with nnue complexity and material imbalance
Value optimism = pos.this_thread()->optimism[stm];
// Blend optimism and eval with nnue complexity and material imbalance
- optimism += optimism * (nnueComplexity + abs(simpleEval - nnue)) / 512;
- nnue -= nnue * (nnueComplexity + abs(simpleEval - nnue)) / 32768;
+ optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 512;
+ nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / 32768;
int npm = pos.non_pawn_material() / 64;
v = (nnue * (915 + npm + 9 * pos.count<PAWN>()) + optimism * (154 + npm)) / 1024;
int npm = pos.non_pawn_material() / 64;
v = (nnue * (915 + npm + 9 * pos.count<PAWN>()) + optimism * (154 + npm)) / 1024;
#include <array>
#include <cassert>
#include <array>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <cstdint>
#include <cstdlib>
#include <limits>
operator const T&() const { return entry; }
void operator<<(int bonus) {
operator const T&() const { return entry; }
void operator<<(int bonus) {
- assert(abs(bonus) <= D); // Ensure range is [-D, D]
+ assert(std::abs(bonus) <= D); // Ensure range is [-D, D]
static_assert(D <= std::numeric_limits<T>::max(), "D overflows T");
static_assert(D <= std::numeric_limits<T>::max(), "D overflows T");
- entry += bonus - entry * abs(bonus) / D;
+ entry += bonus - entry * std::abs(bonus) / D;
- assert(abs(entry) <= D);
+ assert(std::abs(entry) <= D);
const auto positional = network[bucket]->propagate(transformedFeatures);
if (complexity)
const auto positional = network[bucket]->propagate(transformedFeatures);
if (complexity)
- *complexity = abs(psqt - positional) / OutputScale;
+ *complexity = std::abs(psqt - positional) / OutputScale;
// Give more value to positional evaluation when adjusted flag is set
if (adjusted)
// Give more value to positional evaluation when adjusted flag is set
if (adjusted)
// much above beta, we can (almost) safely prune the previous move.
if (
!PvNode && depth > 3
// much above beta, we can (almost) safely prune the previous move.
if (
!PvNode && depth > 3
- && abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
+ && std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
// If value from transposition table is lower than probCutBeta, don't attempt probCut
// there and in further interactions with transposition table cutoff depth is set to depth - 3
// because probCut search has depth set to depth - 4 but we also do a move before it
// If value from transposition table is lower than probCutBeta, don't attempt probCut
// there and in further interactions with transposition table cutoff depth is set to depth - 3
// because probCut search has depth set to depth - 4 but we also do a move before it
probCutBeta = beta + 425;
if (ss->inCheck && !PvNode && ttCapture && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 4 && ttValue >= probCutBeta
probCutBeta = beta + 425;
if (ss->inCheck && !PvNode && ttCapture && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 4 && ttValue >= probCutBeta
- && abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
+ && std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
return probCutBeta;
const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory,
return probCutBeta;
const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory,
// Recursive singular search is avoided.
if (!rootNode && move == ttMove && !excludedMove
&& depth >= 4 - (thisThread->completedDepth > 27) + 2 * (PvNode && tte->is_pv())
// Recursive singular search is avoided.
if (!rootNode && move == ttMove && !excludedMove
&& depth >= 4 - (thisThread->completedDepth > 27) + 2 * (PvNode && tte->is_pv())
- && abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
+ && std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3)
{
Value singularBeta = ttValue - (66 + 58 * (ss->ttPv && !PvNode)) * depth / 64;
&& tte->depth() >= depth - 3)
{
Value singularBeta = ttValue - (66 + 58 * (ss->ttPv && !PvNode)) * depth / 64;
if (v == -VALUE_INFINITE)
v = VALUE_ZERO;
if (v == -VALUE_INFINITE)
v = VALUE_ZERO;
- bool tb = TB::RootInTB && abs(v) <= VALUE_TB;
+ bool tb = TB::RootInTB && std::abs(v) <= VALUE_TB;
v = tb ? rootMoves[i].tbScore : v;
if (ss.rdbuf()->in_avail()) // Not at first line
v = tb ? rootMoves[i].tbScore : v;
if (ss.rdbuf()->in_avail()) // Not at first line
#include <algorithm>
#include <cassert>
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <deque>
#include <initializer_list>
#include <cstdlib>
#include <deque>
#include <initializer_list>
votes[th->rootMoves[0].pv[0]] += thread_value(th);
for (Thread* th : threads)
votes[th->rootMoves[0].pv[0]] += thread_value(th);
for (Thread* th : threads)
- if (abs(bestThread->rootMoves[0].score) >= VALUE_TB_WIN_IN_MAX_PLY)
+ if (std::abs(bestThread->rootMoves[0].score) >= VALUE_TB_WIN_IN_MAX_PLY)
{
// Make sure we pick the shortest mate / TB conversion or stave off mate the longest
if (th->rootMoves[0].score > bestThread->rootMoves[0].score)
{
// Make sure we pick the shortest mate / TB conversion or stave off mate the longest
if (th->rootMoves[0].score > bestThread->rootMoves[0].score)
- if (abs(v) < VALUE_TB_WIN_IN_MAX_PLY)
+ if (std::abs(v) < VALUE_TB_WIN_IN_MAX_PLY)
ss << "cp " << UCI::to_cp(v);
ss << "cp " << UCI::to_cp(v);
- else if (abs(v) <= VALUE_TB)
+ else if (std::abs(v) <= VALUE_TB)
{
const int ply = VALUE_TB - std::abs(v); // recompute ss->ply
ss << "cp " << (v > 0 ? 20000 - ply : -20000 + ply);
{
const int ply = VALUE_TB - std::abs(v); // recompute ss->ply
ss << "cp " << (v > 0 ? 20000 - ply : -20000 + ply);