Merge commit '14f6eab07d1d1e1a59372974e5534128676e9440' into cluster

This is the last commit before there are more conflicts.
This commit is contained in:
Steinar H. Gunderson
2025-12-24 13:51:24 +01:00
11 changed files with 128 additions and 74 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.binaries }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
EMU: ${{ matrix.config.emu }}
EXT: ${{ matrix.config.ext }}
@@ -62,7 +62,7 @@ jobs:
if [ $COMP == ndk ]; then
export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
fi
$COMPILER -v
$COMPCXX -v
- name: Test help target
run: make help
+3 -3
View File
@@ -10,7 +10,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.binaries }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
EXT: ${{ matrix.config.ext }}
NAME: ${{ matrix.config.simple_name }}
@@ -50,7 +50,7 @@ jobs:
run: make net
- name: Check compiler
run: $COMPILER -v
run: $COMPCXX -v
- name: Test help target
run: make help
@@ -59,7 +59,7 @@ jobs:
run: git --version
- name: Check compiler
run: $COMPILER -v
run: $COMPCXX -v
- name: Show g++ cpu info
if: runner.os != 'macOS'
+2 -2
View File
@@ -6,7 +6,7 @@ jobs:
name: ${{ matrix.sanitizers.name }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
CXXFLAGS: "-Werror"
strategy:
@@ -47,7 +47,7 @@ jobs:
run: make net
- name: Check compiler
run: $COMPILER -v
run: $COMPCXX -v
- name: Test help target
run: make help
+3 -3
View File
@@ -6,7 +6,7 @@ jobs:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
CXXFLAGS: "-Werror"
strategy:
@@ -172,9 +172,9 @@ jobs:
if [ $COMP == ndk ]; then
export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
fi
$COMPILER -v
$COMPCXX -v
else
echo "$COMPILER -v" > script.sh
echo "$COMPCXX -v" > script.sh
docker run --rm --platform ${{ matrix.config.platform }} -v ${{ github.workspace }}/src:/app sf_builder
fi
+1 -1
View File
@@ -11,7 +11,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.binaries }}
runs-on: ${{ matrix.config.os }}
env:
COMPILER: ${{ matrix.config.compiler }}
COMPCXX: ${{ matrix.config.compiler }}
COMP: ${{ matrix.config.comp }}
EXT: ${{ matrix.config.ext }}
NAME: ${{ matrix.config.simple_name }}
-5
View File
@@ -549,11 +549,6 @@ else
endif
endif
### Travis CI script uses COMPILER to overwrite CXX
ifdef COMPILER
COMPCXX=$(COMPILER)
endif
### Allow overwriting CXX from command line
ifdef COMPCXX
CXX=$(COMPCXX)
+1 -1
View File
@@ -29,7 +29,7 @@ class Position;
namespace Eval {
constexpr inline int SmallNetThreshold = 1165, PsqtOnlyThreshold = 2500;
constexpr inline int SmallNetThreshold = 1274, PsqtOnlyThreshold = 2389;
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
// for the build process (profile-build and fishtest) to work. Do not change the
+68 -10
View File
@@ -60,10 +60,9 @@ using psqt_vec_t = __m256i;
#define vec_set_16(a) _mm512_set1_epi16(a)
#define vec_max_16(a, b) _mm512_max_epi16(a, b)
#define vec_min_16(a, b) _mm512_min_epi16(a, b)
inline vec_t vec_msb_pack_16(vec_t a, vec_t b) {
vec_t compacted = _mm512_packs_epi16(_mm512_srli_epi16(a, 7), _mm512_srli_epi16(b, 7));
return _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 2, 4, 6, 1, 3, 5, 7), compacted);
}
// Inverse permuted at load time
#define vec_msb_pack_16(a, b) \
_mm512_packs_epi16(_mm512_srli_epi16(a, 7), _mm512_srli_epi16(b, 7))
#define vec_load_psqt(a) _mm256_load_si256(a)
#define vec_store_psqt(a, b) _mm256_store_si256(a, b)
#define vec_add_psqt_32(a, b) _mm256_add_epi32(a, b)
@@ -84,10 +83,9 @@ using psqt_vec_t = __m256i;
#define vec_set_16(a) _mm256_set1_epi16(a)
#define vec_max_16(a, b) _mm256_max_epi16(a, b)
#define vec_min_16(a, b) _mm256_min_epi16(a, b)
inline vec_t vec_msb_pack_16(vec_t a, vec_t b) {
vec_t compacted = _mm256_packs_epi16(_mm256_srli_epi16(a, 7), _mm256_srli_epi16(b, 7));
return _mm256_permute4x64_epi64(compacted, 0b11011000);
}
// Inverse permuted at load time
#define vec_msb_pack_16(a, b) \
_mm256_packs_epi16(_mm256_srli_epi16(a, 7), _mm256_srli_epi16(b, 7))
#define vec_load_psqt(a) _mm256_load_si256(a)
#define vec_store_psqt(a, b) _mm256_store_si256(a, b)
#define vec_add_psqt_32(a, b) _mm256_add_epi32(a, b)
@@ -227,6 +225,62 @@ class FeatureTransformer {
return FeatureSet::HashValue ^ (OutputDimensions * 2);
}
static constexpr void order_packs([[maybe_unused]] uint64_t* v) {
#if defined(USE_AVX512) // _mm512_packs_epi16 ordering
uint64_t tmp0, tmp1;
tmp0 = v[2], tmp1 = v[3];
v[2] = v[8], v[3] = v[9];
v[8] = v[4], v[9] = v[5];
v[4] = tmp0, v[5] = tmp1;
tmp0 = v[6], tmp1 = v[7];
v[6] = v[10], v[7] = v[11];
v[10] = v[12], v[11] = v[13];
v[12] = tmp0, v[13] = tmp1;
#elif defined(USE_AVX2) // _mm256_packs_epi16 ordering
std::swap(v[2], v[4]);
std::swap(v[3], v[5]);
#endif
}
static constexpr void inverse_order_packs([[maybe_unused]] uint64_t* v) {
#if defined(USE_AVX512) // Inverse _mm512_packs_epi16 ordering
uint64_t tmp0, tmp1;
tmp0 = v[2], tmp1 = v[3];
v[2] = v[4], v[3] = v[5];
v[4] = v[8], v[5] = v[9];
v[8] = tmp0, v[9] = tmp1;
tmp0 = v[6], tmp1 = v[7];
v[6] = v[12], v[7] = v[13];
v[12] = v[10], v[13] = v[11];
v[10] = tmp0, v[11] = tmp1;
#elif defined(USE_AVX2) // Inverse _mm256_packs_epi16 ordering
std::swap(v[2], v[4]);
std::swap(v[3], v[5]);
#endif
}
void permute_weights([[maybe_unused]] void (*order_fn)(uint64_t*)) const {
#if defined(USE_AVX2)
#if defined(USE_AVX512)
constexpr IndexType di = 16;
#else
constexpr IndexType di = 8;
#endif
uint64_t* b = reinterpret_cast<uint64_t*>(const_cast<BiasType*>(&biases[0]));
for (IndexType i = 0; i < HalfDimensions * sizeof(BiasType) / sizeof(uint64_t); i += di)
order_fn(&b[i]);
for (IndexType j = 0; j < InputDimensions; ++j)
{
uint64_t* w =
reinterpret_cast<uint64_t*>(const_cast<WeightType*>(&weights[j * HalfDimensions]));
for (IndexType i = 0; i < HalfDimensions * sizeof(WeightType) / sizeof(uint64_t);
i += di)
order_fn(&w[i]);
}
#endif
}
// Read network parameters
bool read_parameters(std::istream& stream) {
@@ -234,16 +288,20 @@ class FeatureTransformer {
read_leb_128<WeightType>(stream, weights, HalfDimensions * InputDimensions);
read_leb_128<PSQTWeightType>(stream, psqtWeights, PSQTBuckets * InputDimensions);
permute_weights(inverse_order_packs);
return !stream.fail();
}
// Write network parameters
bool write_parameters(std::ostream& stream) const {
permute_weights(order_packs);
write_leb_128<BiasType>(stream, biases, HalfDimensions);
write_leb_128<WeightType>(stream, weights, HalfDimensions * InputDimensions);
write_leb_128<PSQTWeightType>(stream, psqtWeights, PSQTBuckets * InputDimensions);
permute_weights(inverse_order_packs);
return !stream.fail();
}
@@ -274,8 +332,8 @@ class FeatureTransformer {
static_assert((HalfDimensions / 2) % OutputChunkSize == 0);
constexpr IndexType NumOutputChunks = HalfDimensions / 2 / OutputChunkSize;
vec_t Zero = vec_zero();
vec_t One = vec_set_16(127);
const vec_t Zero = vec_zero();
const vec_t One = vec_set_16(127);
const vec_t* in0 = reinterpret_cast<const vec_t*>(&(accumulation[perspectives[p]][0]));
const vec_t* in1 =
+40 -40
View File
@@ -59,8 +59,8 @@ static constexpr double EvalLevel[10] = {1.043, 1.017, 0.952, 1.009, 0.971,
// Futility margin
Value futility_margin(Depth d, bool noTtCutNode, bool improving, bool oppWorsening) {
Value futilityMult = 118 - 44 * noTtCutNode;
Value improvingDeduction = 53 * improving * futilityMult / 32;
Value worseningDeduction = (309 + 47 * improving) * oppWorsening * futilityMult / 1024;
Value improvingDeduction = 52 * improving * futilityMult / 32;
Value worseningDeduction = (310 + 48 * improving) * oppWorsening * futilityMult / 1024;
return futilityMult * d - improvingDeduction - worseningDeduction;
}
@@ -72,15 +72,15 @@ constexpr int futility_move_count(bool improving, Depth depth) {
// Add correctionHistory value to raw staticEval and guarantee evaluation does not hit the tablebase range
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) / 11175;
v += cv * std::abs(cv) / 9260;
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
int stat_bonus(Depth d) { return std::clamp(245 * d - 320, 0, 1296); }
int stat_bonus(Depth d) { return std::clamp(211 * d - 315, 0, 1291); }
// History and stats update malus, based on depth
int stat_malus(Depth d) { return (d < 4 ? 554 * d - 303 : 1203); }
int stat_malus(Depth d) { return (d < 4 ? 572 * d - 285 : 1372); }
// Add a small random component to draw evaluations to avoid 3-fold blindness
Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes & 0x2); }
@@ -345,12 +345,12 @@ void Search::Worker::iterative_deepening() {
// Reset aspiration window starting size
Value avg = rootMoves[pvIdx].averageScore;
delta = 10 + avg * avg / 12493;
delta = 11 + avg * avg / 11254;
alpha = std::max(avg - delta, -VALUE_INFINITE);
beta = std::min(avg + delta, VALUE_INFINITE);
// Adjust optimism based on root move's averageScore (~4 Elo)
optimism[us] = 132 * avg / (std::abs(avg) + 89);
optimism[us] = 125 * avg / (std::abs(avg) + 91);
optimism[~us] = -optimism[us];
// Start with a small aspiration window and, in the case of a fail
@@ -547,10 +547,10 @@ void Search::Worker::clear() {
for (StatsType c : {NoCaptures, Captures})
for (auto& to : continuationHistory[inCheck][c])
for (auto& h : to)
h->fill(-67);
h->fill(-65);
for (size_t i = 1; i < reductions.size(); ++i)
reductions[i] = int((19.80 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
reductions[i] = int((20.14 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
}
@@ -636,7 +636,7 @@ Value Search::Worker::search(
assert(0 <= ss->ply && ss->ply < MAX_PLY);
(ss + 1)->excludedMove = bestMove = Move::none();
bestMove = Move::none();
(ss + 2)->killers[0] = (ss + 2)->killers[1] = Move::none();
(ss + 2)->cutoffCnt = 0;
ss->multipleExtensions = (ss - 1)->multipleExtensions;
@@ -782,7 +782,7 @@ Value Search::Worker::search(
// Use static evaluation difference to improve quiet move ordering (~9 Elo)
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
{
int bonus = std::clamp(-13 * int((ss - 1)->staticEval + ss->staticEval), -1578, 1291);
int bonus = std::clamp(-14 * int((ss - 1)->staticEval + ss->staticEval), -1644, 1384);
bonus = bonus > 0 ? 2 * bonus : bonus / 2;
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()] << bonus;
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
@@ -805,7 +805,7 @@ Value Search::Worker::search(
// If eval is really low check with qsearch if it can exceed alpha, if it can't,
// return a fail low.
// Adjust razor margin according to cutoffCnt. (~1 Elo)
if (eval < alpha - 488 - (289 - 142 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
if (eval < alpha - 471 - (276 - 148 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
{
value = qsearch<NonPV>(pos, ss, alpha - 1, alpha);
if (value < alpha)
@@ -816,21 +816,21 @@ Value Search::Worker::search(
// The depth condition is important for mate finding.
if (!ss->ttPv && depth < 12
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening)
- (ss - 1)->statScore / 267
- (ss - 1)->statScore / 284
>= beta
&& eval >= beta && eval < VALUE_TB_WIN_IN_MAX_PLY && (!ttMove || ttCapture))
return beta > VALUE_TB_LOSS_IN_MAX_PLY ? (eval + beta) / 2 : eval;
// Step 9. Null move search with verification search (~35 Elo)
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 16878
&& eval >= beta && ss->staticEval >= beta - 20 * depth + 314 && !excludedMove
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 18001
&& eval >= beta && ss->staticEval >= beta - 21 * depth + 315 && !excludedMove
&& pos.non_pawn_material(us) && ss->ply >= thisThread->nmpMinPly
&& beta > VALUE_TB_LOSS_IN_MAX_PLY)
{
assert(eval - beta >= 0);
// Null move dynamic reduction based on depth and eval
Depth R = std::min(int(eval - beta) / 144, 6) + depth / 3 + 4;
Depth R = std::min(int(eval - beta) / 152, 6) + depth / 3 + 4;
ss->currentMove = Move::null();
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
@@ -878,7 +878,7 @@ Value Search::Worker::search(
// 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 + 170 - 64 * improving;
probCutBeta = beta + 169 - 63 * improving;
if (
!PvNode && depth > 3
&& std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
@@ -935,7 +935,7 @@ Value Search::Worker::search(
moves_loop: // When in check, search starts here
// Step 12. A small Probcut idea, when we are in check (~4 Elo)
probCutBeta = beta + 409;
probCutBeta = beta + 436;
if (ss->inCheck && !PvNode && ttCapture && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 4 && ttValue >= probCutBeta
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
@@ -1019,7 +1019,7 @@ moves_loop: // When in check, search starts here
{
Piece capturedPiece = pos.piece_on(move.to_sq());
int futilityEval =
ss->staticEval + 297 + 284 * lmrDepth + PieceValue[capturedPiece]
ss->staticEval + 287 + 277 * lmrDepth + PieceValue[capturedPiece]
+ thisThread->captureHistory[movedPiece][move.to_sq()][type_of(capturedPiece)]
/ 7;
if (futilityEval < alpha)
@@ -1027,7 +1027,7 @@ moves_loop: // When in check, search starts here
}
// SEE based pruning for captures and checks (~11 Elo)
if (!pos.see_ge(move, -203 * depth))
if (!pos.see_ge(move, -199 * depth))
continue;
}
else
@@ -1039,15 +1039,15 @@ moves_loop: // When in check, search starts here
+ thisThread->pawnHistory[pawn_structure_index(pos)][movedPiece][move.to_sq()];
// Continuation history based pruning (~2 Elo)
if (lmrDepth < 6 && history < -4040 * depth)
if (lmrDepth < 6 && history < -4173 * depth)
continue;
history += 2 * thisThread->mainHistory[us][move.from_to()];
lmrDepth += history / 5637;
lmrDepth += history / 5285;
Value futilityValue =
ss->staticEval + (bestValue < ss->staticEval - 59 ? 141 : 58) + 125 * lmrDepth;
ss->staticEval + (bestValue < ss->staticEval - 54 ? 128 : 58) + 131 * lmrDepth;
// Futility pruning: parent node (~13 Elo)
if (!ss->inCheck && lmrDepth < 15 && futilityValue <= alpha)
@@ -1061,7 +1061,7 @@ moves_loop: // When in check, search starts here
lmrDepth = std::max(lmrDepth, 0);
// Prune moves with negative SEE (~4 Elo)
if (!pos.see_ge(move, -27 * lmrDepth * lmrDepth))
if (!pos.see_ge(move, -26 * lmrDepth * lmrDepth))
continue;
}
}
@@ -1081,11 +1081,11 @@ moves_loop: // When in check, search starts here
// so changing them requires tests at these types of time controls.
// Recursive singular search is avoided.
if (!rootNode && move == ttMove && !excludedMove
&& depth >= 4 - (thisThread->completedDepth > 30) + ss->ttPv
&& depth >= 4 - (thisThread->completedDepth > 32) + ss->ttPv
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3)
{
Value singularBeta = ttValue - (58 + 58 * (ss->ttPv && !PvNode)) * depth / 64;
Value singularBeta = ttValue - (64 + 59 * (ss->ttPv && !PvNode)) * depth / 64;
Depth singularDepth = newDepth / 2;
ss->excludedMove = move;
@@ -1100,11 +1100,11 @@ moves_loop: // When in check, search starts here
// We make sure to limit the extensions in some way to avoid a search explosion
if (!PvNode && ss->multipleExtensions <= 16)
{
extension = 2 + (value < singularBeta - 22 && !ttCapture);
extension = 2 + (value < singularBeta - 11 && !ttCapture);
depth += depth < 14;
}
if (PvNode && !ttCapture && ss->multipleExtensions <= 5
&& value < singularBeta - 37)
&& value < singularBeta - 38)
extension = 2;
}
@@ -1139,7 +1139,7 @@ moves_loop: // When in check, search starts here
else if (PvNode && move == ttMove && move.to_sq() == prevSq
&& thisThread->captureHistory[movedPiece][move.to_sq()]
[type_of(pos.piece_on(move.to_sq()))]
> 4026)
> 3807)
extension = 1;
}
@@ -1189,10 +1189,10 @@ moves_loop: // When in check, search starts here
ss->statScore = 2 * thisThread->mainHistory[us][move.from_to()]
+ (*contHist[0])[movedPiece][move.to_sq()]
+ (*contHist[1])[movedPiece][move.to_sq()]
+ (*contHist[3])[movedPiece][move.to_sq()] - 4723;
+ (*contHist[3])[movedPiece][move.to_sq()] - 5007;
// Decrease/increase reduction for moves with a good/bad history (~8 Elo)
r -= ss->statScore / 13659;
r -= ss->statScore / 12901;
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
if (depth >= 2 && moveCount > 1 + rootNode)
@@ -1211,7 +1211,7 @@ moves_loop: // When in check, search starts here
{
// Adjust full-depth search based on LMR results - if the result
// was good enough search deeper, if it was bad enough search shallower.
const bool doDeeperSearch = value > (bestValue + 47 + 2 * newDepth); // (~1 Elo)
const bool doDeeperSearch = value > (bestValue + 42 + 2 * newDepth); // (~1 Elo)
const bool doShallowerSearch = value < bestValue + newDepth; // (~2 Elo)
newDepth += doDeeperSearch - doShallowerSearch;
@@ -1329,7 +1329,7 @@ moves_loop: // When in check, search starts here
else
{
// Reduce other moves if we have found at least one score improvement (~2 Elo)
if (depth > 2 && depth < 12 && beta < 14206 && value > -12077)
if (depth > 2 && depth < 12 && beta < 13132 && value > -13295)
depth -= 2;
assert(depth > 0);
@@ -1359,7 +1359,7 @@ moves_loop: // When in check, search starts here
// Adjust best value for fail high cases at non-pv nodes
if (!PvNode && bestValue >= beta && std::abs(bestValue) < VALUE_TB_WIN_IN_MAX_PLY
&& std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY && std::abs(alpha) < VALUE_TB_WIN_IN_MAX_PLY)
bestValue = (bestValue * (depth + 2) + beta) / (depth + 3);
bestValue = (bestValue * depth + beta) / (depth + 1);
if (!moveCount)
bestValue = excludedMove ? alpha : ss->inCheck ? mated_in(ss->ply) : VALUE_DRAW;
@@ -1372,9 +1372,9 @@ moves_loop: // When in check, search starts here
// Bonus for prior countermove that caused the fail low
else if (!priorCapture && prevSq != SQ_NONE)
{
int bonus = (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -14963)
int bonus = (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -14761)
+ ((ss - 1)->moveCount > 11)
+ (!ss->inCheck && bestValue <= ss->staticEval - 150);
+ (!ss->inCheck && bestValue <= ss->staticEval - 144);
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
stat_bonus(depth) * bonus);
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()]
@@ -1534,7 +1534,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
if (bestValue > alpha)
alpha = bestValue;
futilityBase = ss->staticEval + 226;
futilityBase = ss->staticEval + 246;
}
const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory,
@@ -1614,7 +1614,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
continue;
// Do not search moves with bad enough SEE values (~5 Elo)
if (!pos.see_ge(move, -78))
if (!pos.see_ge(move, -79))
continue;
}
@@ -1682,7 +1682,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) {
int reductionScale = reductions[d] * reductions[mn];
return (reductionScale + 1107 - delta * 725 / rootDelta) / 1024 + (!i && reductionScale > 956);
return (reductionScale + 1123 - delta * 832 / rootDelta) / 1024 + (!i && reductionScale > 1025);
}
namespace {
@@ -1771,7 +1771,7 @@ void update_all_stats(const Position& pos,
if (!pos.capture_stage(bestMove))
{
int bestMoveBonus = bestValue > beta + 168 ? quietMoveBonus // larger bonus
int bestMoveBonus = bestValue > beta + 185 ? quietMoveBonus // larger bonus
: stat_bonus(depth); // smaller bonus
// Increase stats for the best move in case it was a quiet move
+7 -6
View File
@@ -139,7 +139,7 @@ void UCIEngine::loop() {
else if (token == "go")
go(pos, is);
else if (token == "position")
position(is);
position(pos, is);
else if (token == "ucinewgame")
engine.search_clear();
else if (token == "isready" && Cluster::is_root())
@@ -273,7 +273,7 @@ void UCIEngine::bench(Position& pos, std::istream& args) {
else if (token == "setoption")
setoption(is);
else if (token == "position")
position(is);
position(pos, is);
else if (token == "ucinewgame")
{
engine.search_clear(); // search_clear may take a while
@@ -300,7 +300,7 @@ void UCIEngine::setoption(std::istringstream& is) {
engine.get_options().setoption(is);
}
void UCIEngine::position(std::istringstream& is) {
void UCIEngine::position(Position& pos, std::istringstream& is) {
std::string token, fen;
is >> token;
@@ -323,6 +323,7 @@ void UCIEngine::position(std::istringstream& is) {
moves.push_back(token);
}
pos.set(fen, engine.get_options()["UCI_Chess960"], pos.state());
engine.set_position(fen, moves);
}
@@ -366,12 +367,12 @@ std::string UCIEngine::format_score(const Score& s) {
constexpr int TB_CP = 20000;
const auto format =
overload{[](Score::Mate mate) -> std::string {
auto m = (mate.plies > 0 ? (mate.plies + 1) : -mate.plies) / 2;
auto m = (mate.plies > 0 ? (mate.plies + 1) : mate.plies) / 2;
return std::string("mate ") + std::to_string(m);
},
[](Score::TBWin tb) -> std::string {
return std::string("cp ")
+ std::to_string((tb.plies > 0 ? TB_CP - tb.plies : -TB_CP + tb.plies));
+ std::to_string((tb.plies > 0 ? TB_CP - tb.plies : -TB_CP - tb.plies));
},
[](Score::InternalUnits units) -> std::string {
return std::string("cp ") + std::to_string(units.value);
@@ -399,7 +400,7 @@ std::string UCIEngine::wdl(Value v, const Position& pos) {
int wdl_w = win_rate_model(v, pos);
int wdl_l = win_rate_model(-v, pos);
int wdl_d = 1000 - wdl_w - wdl_l;
ss << " wdl " << wdl_w << " " << wdl_d << " " << wdl_l;
ss << wdl_w << " " << wdl_d << " " << wdl_l;
return ss.str();
}
+1 -1
View File
@@ -58,7 +58,7 @@ class UCIEngine {
void go(Position& pos, std::istringstream& is);
void bench(Position& pos, std::istream& args);
void position(std::istringstream& is);
void position(Position& pos, std::istringstream& is);
void setoption(std::istringstream& is);
static void on_update_no_moves(const Engine::InfoShort& info);