Skip to content

Commit 35ada63

Browse files
committed
Save futilityMargin for both colors
It will be needed by future patches. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
1 parent 06a695d commit 35ada63

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/evaluate.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,8 @@ namespace {
860860
// capturing a single attacking piece can therefore result in a score
861861
// change far bigger than the value of the captured piece.
862862
Score v = apply_weight(make_score(SafetyTable[attackUnits], 0), WeightKingSafety[Us]);
863-
864863
ei.value -= Sign[Us] * v;
865-
866-
if (Us == pos.side_to_move())
867-
ei.futilityMargin += mg_value(v);
864+
ei.futilityMargin[Us] += mg_value(v);
868865
}
869866
}
870867

src/evaluate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Position;
4747

4848
struct EvalInfo {
4949

50-
EvalInfo() : futilityMargin(Value(0)) {}
50+
EvalInfo() { futilityMargin[0] = futilityMargin[1] = Value(0); }
5151

5252
// Middle game and endgame evaluations
5353
Score value;
@@ -96,8 +96,8 @@ struct EvalInfo {
9696
Score mobility;
9797

9898
// Extra futility margin. This is added to the standard futility margin
99-
// in the quiescence search.
100-
Value futilityMargin;
99+
// in the quiescence search. One for each color.
100+
Value futilityMargin[2];
101101
};
102102

103103

src/search.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ namespace {
18211821
if (bestValue >= beta)
18221822
{
18231823
// Store the score to avoid a future costly evaluation() call
1824-
if (!isCheck && !tte && ei.futilityMargin == 0)
1824+
if (!isCheck && !tte && ei.futilityMargin[pos.side_to_move()] == 0)
18251825
TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_EV_LO, Depth(-127*OnePly), MOVE_NONE);
18261826

18271827
return bestValue;
@@ -1840,7 +1840,7 @@ namespace {
18401840
MovePicker mp = MovePicker(pos, ttMove, deepChecks ? Depth(0) : depth, H);
18411841
CheckInfo ci(pos);
18421842
enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame;
1843-
futilityBase = staticValue + FutilityMarginQS + ei.futilityMargin;
1843+
futilityBase = staticValue + FutilityMarginQS + ei.futilityMargin[pos.side_to_move()];
18441844

18451845
// Loop through the moves until no moves remain or a beta cutoff
18461846
// occurs.
@@ -1920,7 +1920,7 @@ namespace {
19201920
{
19211921
// If bestValue isn't changed it means it is still the static evaluation
19221922
// of the node, so keep this info to avoid a future evaluation() call.
1923-
ValueType type = (bestValue == staticValue && !ei.futilityMargin ? VALUE_TYPE_EV_UP : VALUE_TYPE_UPPER);
1923+
ValueType type = (bestValue == staticValue && !ei.futilityMargin[pos.side_to_move()] ? VALUE_TYPE_EV_UP : VALUE_TYPE_UPPER);
19241924
TT.store(pos.get_key(), value_to_tt(bestValue, ply), type, d, MOVE_NONE);
19251925
}
19261926
else if (bestValue >= beta)

0 commit comments

Comments
 (0)