Skip to content

Commit a191791

Browse files
daniel-monroevondele
authored andcommitted
Clean up code and comments
closes #6416 No functional change
1 parent bd82b9e commit a191791

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/search.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,12 @@ Value Search::Worker::search(
834834
// bigger than the previous static evaluation at our turn (if we were in
835835
// check at our previous move we go back until we weren't in check) and is
836836
// false otherwise. The improving flag is used in various pruning heuristics.
837+
// Similarly, opponentWorsening is true if our static evaluation is better
838+
// for us than at the last ply.
837839
improving = ss->staticEval > (ss - 2)->staticEval;
838840
opponentWorsening = ss->staticEval > -(ss - 1)->staticEval;
839841

842+
// Hindsight adjustment of reductions based on static evaluation difference.
840843
if (priorReduction >= 3 && !opponentWorsening)
841844
depth++;
842845
if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1)->staticEval > 173)
@@ -856,7 +859,7 @@ Value Search::Worker::search(
856859

857860
return futilityMult * d //
858861
- 2094 * improving * futilityMult / 1024 //
859-
- 1324 * opponentWorsening * futilityMult / 4096 //
862+
- 331 * opponentWorsening * futilityMult / 1024 //
860863
+ std::abs(correctionValue) / 158105;
861864
};
862865

@@ -904,7 +907,7 @@ Value Search::Worker::search(
904907

905908
// Step 10. Internal iterative reductions
906909
// At sufficient depth, reduce depth for PV/Cut nodes without a TTMove.
907-
// (*Scaler) Especially if they make IIR less aggressive.
910+
// (*Scaler) Making IIR more aggressive scales poorly.
908911
if (!allNode && depth >= 6 && !ttData.move && priorReduction <= 3)
909912
depth--;
910913

@@ -1018,12 +1021,11 @@ Value Search::Worker::search(
10181021
Depth r = reduction(improving, depth, moveCount, delta);
10191022

10201023
// Increase reduction for ttPv nodes (*Scaler)
1021-
// Smaller or even negative value is better for short time controls
1022-
// Bigger value is better for long time controls
1024+
// Larger values scale well
10231025
if (ss->ttPv)
10241026
r += 946;
10251027

1026-
// Step 14. Pruning at shallow depth.
1028+
// Step 14. Pruning at shallow depths.
10271029
// Depth conditions are important for mate finding.
10281030
if (!rootNode && pos.non_pawn_material(us) && !is_loss(bestValue))
10291031
{
@@ -1068,15 +1070,15 @@ Value Search::Worker::search(
10681070

10691071
history += 76 * mainHistory[us][move.raw()] / 32;
10701072

1071-
// (*Scaler): Generally, a lower divisor scales well
1073+
// (*Scaler): Generally, lower divisors scales well
10721074
lmrDepth += history / 3220;
10731075

10741076
Value futilityValue = ss->staticEval + 47 + 171 * !bestMove + 134 * lmrDepth
10751077
+ 90 * (ss->staticEval > alpha);
10761078

10771079
// Futility pruning: parent node
10781080
// (*Scaler): Generally, more frequent futility pruning
1079-
// scales well with respect to time and threads
1081+
// scales well
10801082
if (!ss->inCheck && lmrDepth < 11 && futilityValue <= alpha)
10811083
{
10821084
if (bestValue <= futilityValue && !is_decisive(bestValue)
@@ -1218,8 +1220,7 @@ Value Search::Worker::search(
12181220
ss->reduction = 0;
12191221

12201222
// Do a full-depth search when reduced LMR search fails high
1221-
// (*Scaler) Usually doing more shallower searches
1222-
// doesn't scale well to longer TCs
1223+
// (*Scaler) Shallower searches here don't scale well
12231224
if (value > alpha)
12241225
{
12251226
// Adjust full-depth search based on LMR results - if the result was
@@ -1347,7 +1348,7 @@ Value Search::Worker::search(
13471348

13481349
if (value >= beta)
13491350
{
1350-
// (*Scaler) Especially if they make cutoffCnt increment more often.
1351+
// (*Scaler) Infrequent and small updates scale well
13511352
ss->cutoffCnt += (extension < 2) || PvNode;
13521353
assert(value >= beta); // Fail high
13531354
break;
@@ -1450,10 +1451,9 @@ Value Search::Worker::search(
14501451
// Adjust correction history if the best move is not a capture
14511452
// and the error direction matches whether we are above/below bounds.
14521453
if (!ss->inCheck && !(bestMove && pos.capture(bestMove))
1453-
&& (bestValue < ss->staticEval) == !bestMove)
1454+
&& (bestValue > ss->staticEval) == bool(bestMove))
14541455
{
1455-
auto bonus = std::clamp(int(bestValue - ss->staticEval) * depth
1456-
/ (8 + 2 * (bestValue > ss->staticEval)),
1456+
auto bonus = std::clamp(int(bestValue - ss->staticEval) * depth / (bestMove ? 10 : 8),
14571457
-CORRECTION_HISTORY_LIMIT / 4, CORRECTION_HISTORY_LIMIT / 4);
14581458
update_correction_history(pos, ss, *this, bonus);
14591459
}

0 commit comments

Comments
 (0)