Skip to content

Commit 627974c

Browse files
FauziAkramDisservin
authored andcommitted
Search + Eval + Movepick Tune
Passed STC: https://tests.stockfishchess.org/tests/view/65ef15220ec64f0526c44b04 LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 24480 W: 6459 L: 6153 D: 11868 Ptnml(0-2): 101, 2798, 6184, 3008, 149 Passed LTC: https://tests.stockfishchess.org/tests/view/65ef4bac0ec64f0526c44f50 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 53316 W: 13561 L: 13203 D: 26552 Ptnml(0-2): 27, 5925, 14408, 6259, 39 closes #5104 Bench: 1715522
1 parent daa3ef9 commit 627974c

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

src/evaluate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks, const Position& pos,
5959
: networks.big.evaluate(pos, true, &nnueComplexity, false);
6060

6161
// Blend optimism and eval with nnue complexity and material imbalance
62-
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 512;
63-
nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / 32768;
62+
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 524;
63+
nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / 31950;
6464

6565
int npm = pos.non_pawn_material() / 64;
66-
int v = (nnue * (915 + npm + 9 * pos.count<PAWN>()) + optimism * (154 + npm)) / 1024;
66+
int v = (nnue * (927 + npm + 9 * pos.count<PAWN>()) + optimism * (159 + npm)) / 1000;
6767

6868
// Damp down the evaluation linearly when shuffling
6969
int shuffling = pos.rule50_count();
70-
v = v * (200 - shuffling) / 214;
70+
v = v * (195 - shuffling) / 228;
7171

7272
// Guarantee evaluation does not hit the tablebase range
7373
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);

src/evaluate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Position;
2929

3030
namespace Eval {
3131

32-
constexpr inline int SmallNetThreshold = 1139, PsqtOnlyThreshold = 2500;
32+
constexpr inline int SmallNetThreshold = 1136, PsqtOnlyThreshold = 2656;
3333

3434
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
3535
// for the build process (profile-build and fishtest) to work. Do not change the

src/movepick.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,18 @@ void MovePicker::score() {
190190
m.value += bool(pos.check_squares(pt) & to) * 16384;
191191

192192
// bonus for escaping from capture
193-
m.value += threatenedPieces & from ? (pt == QUEEN && !(to & threatenedByRook) ? 50000
194-
: pt == ROOK && !(to & threatenedByMinor) ? 25000
195-
: !(to & threatenedByPawn) ? 15000
193+
m.value += threatenedPieces & from ? (pt == QUEEN && !(to & threatenedByRook) ? 51000
194+
: pt == ROOK && !(to & threatenedByMinor) ? 24950
195+
: !(to & threatenedByPawn) ? 14450
196196
: 0)
197197
: 0;
198198

199199
// malus for putting piece en prise
200200
m.value -= !(threatenedPieces & from)
201-
? (pt == QUEEN ? bool(to & threatenedByRook) * 50000
202-
+ bool(to & threatenedByMinor) * 10000
203-
: pt == ROOK ? bool(to & threatenedByMinor) * 25000
204-
: pt != PAWN ? bool(to & threatenedByPawn) * 15000
201+
? (pt == QUEEN ? bool(to & threatenedByRook) * 48150
202+
+ bool(to & threatenedByMinor) * 10650
203+
: pt == ROOK ? bool(to & threatenedByMinor) * 24500
204+
: pt != PAWN ? bool(to & threatenedByPawn) * 14950
205205
: 0)
206206
: 0;
207207
}
@@ -241,7 +241,7 @@ Move MovePicker::select(Pred filter) {
241241
// moves left, picking the move with the highest score from a list of generated moves.
242242
Move MovePicker::next_move(bool skipQuiets) {
243243

244-
auto quiet_threshold = [](Depth d) { return -3330 * d; };
244+
auto quiet_threshold = [](Depth d) { return -3550 * d; };
245245

246246
top:
247247
switch (stage)

src/search.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ namespace {
5555

5656
// Futility margin
5757
Value futility_margin(Depth d, bool noTtCutNode, bool improving, bool oppWorsening) {
58-
Value futilityMult = 121 - 43 * noTtCutNode;
59-
Value improvingDeduction = 3 * improving * futilityMult / 2;
58+
Value futilityMult = 122 - 46 * noTtCutNode;
59+
Value improvingDeduction = 57 * improving * futilityMult / 32;
6060
Value worseningDeduction = (331 + 45 * improving) * oppWorsening * futilityMult / 1024;
6161

6262
return futilityMult * d - improvingDeduction - worseningDeduction;
@@ -69,15 +69,15 @@ constexpr int futility_move_count(bool improving, Depth depth) {
6969
// Add correctionHistory value to raw staticEval and guarantee evaluation does not hit the tablebase range
7070
Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) {
7171
auto cv = w.correctionHistory[pos.side_to_move()][pawn_structure_index<Correction>(pos)];
72-
v += cv * std::abs(cv) / 10759;
72+
v += cv * std::abs(cv) / 11450;
7373
return std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
7474
}
7575

7676
// History and stats update bonus, based on depth
7777
int stat_bonus(Depth d) { return std::min(249 * d - 327, 1192); }
7878

7979
// History and stats update malus, based on depth
80-
int stat_malus(Depth d) { return std::min(516 * d - 299, 1432); }
80+
int stat_malus(Depth d) { return std::min(516 * d - 299, 1254); }
8181

8282
// Add a small random component to draw evaluations to avoid 3-fold blindness
8383
Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes & 0x2); }
@@ -301,12 +301,12 @@ void Search::Worker::iterative_deepening() {
301301

302302
// Reset aspiration window starting size
303303
Value avg = rootMoves[pvIdx].averageScore;
304-
delta = 9 + avg * avg / 12804;
304+
delta = 9 + avg * avg / 12800;
305305
alpha = std::max(avg - delta, -VALUE_INFINITE);
306306
beta = std::min(avg + delta, VALUE_INFINITE);
307307

308308
// Adjust optimism based on root move's averageScore (~4 Elo)
309-
optimism[us] = 131 * avg / (std::abs(avg) + 90);
309+
optimism[us] = 130 * avg / (std::abs(avg) + 90);
310310
optimism[~us] = -optimism[us];
311311

312312
// Start with a small aspiration window and, in the case of a fail
@@ -500,7 +500,7 @@ void Search::Worker::clear() {
500500
h->fill(-71);
501501

502502
for (size_t i = 1; i < reductions.size(); ++i)
503-
reductions[i] = int((19.02 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
503+
reductions[i] = int((19.80 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
504504
}
505505

506506

@@ -732,12 +732,12 @@ Value Search::Worker::search(
732732
// Use static evaluation difference to improve quiet move ordering (~9 Elo)
733733
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
734734
{
735-
int bonus = std::clamp(-14 * int((ss - 1)->staticEval + ss->staticEval), -1621, 1237);
735+
int bonus = std::clamp(-14 * int((ss - 1)->staticEval + ss->staticEval), -1621, 1238);
736736
bonus = bonus > 0 ? 2 * bonus : bonus / 2;
737737
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()] << bonus;
738738
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
739739
thisThread->pawnHistory[pawn_structure_index(pos)][pos.piece_on(prevSq)][prevSq]
740-
<< bonus / 4;
740+
<< bonus / 2;
741741
}
742742

743743
// Set up the improving flag, which is true if current static evaluation is
@@ -828,7 +828,7 @@ Value Search::Worker::search(
828828
// Step 11. ProbCut (~10 Elo)
829829
// If we have a good enough capture (or queen promotion) and a reduced search returns a value
830830
// much above beta, we can (almost) safely prune the previous move.
831-
probCutBeta = beta + 164 - 62 * improving;
831+
probCutBeta = beta + 168 - 64 * improving;
832832
if (
833833
!PvNode && depth > 3
834834
&& std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
@@ -1139,7 +1139,7 @@ Value Search::Worker::search(
11391139
+ (*contHist[3])[movedPiece][move.to_sq()] - 4587;
11401140

11411141
// Decrease/increase reduction for moves with a good/bad history (~8 Elo)
1142-
r -= ss->statScore / 12372;
1142+
r -= ss->statScore / 14956;
11431143

11441144
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
11451145
if (depth >= 2 && moveCount > 1 + rootNode)
@@ -1627,7 +1627,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
16271627

16281628
Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) {
16291629
int reductionScale = reductions[d] * reductions[mn];
1630-
return (reductionScale + 1091 - delta * 759 / rootDelta) / 1024 + (!i && reductionScale > 952);
1630+
return (reductionScale + 1091 - delta * 759 / rootDelta) / 1024 + (!i && reductionScale > 950);
16311631
}
16321632

16331633
namespace {

src/tt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
134134
// Find an entry to be replaced according to the replacement strategy
135135
TTEntry* replace = tte;
136136
for (int i = 1; i < ClusterSize; ++i)
137-
if (replace->depth8 - replace->relative_age(generation8)
138-
> tte[i].depth8 - tte[i].relative_age(generation8))
137+
if (replace->depth8 - replace->relative_age(generation8) * 2
138+
> tte[i].depth8 - tte[i].relative_age(generation8) * 2)
139139
replace = &tte[i];
140140

141141
return found = false, replace;

0 commit comments

Comments
 (0)