Skip to content

Commit b95b1a9

Browse files
committed
Rename futilityMargin in kingDanger in EvalInfo
This is what actually is. A standard naming convention suggests to name a variable with someting resembling _what_ the variable is and not _how_ the variable is used. This normally results in easier to read code. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
1 parent b14846b commit b95b1a9

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/evaluate.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,13 @@ namespace {
837837
// out of bounds errors.
838838
attackUnits = Min(99, Max(0, attackUnits));
839839

840-
// Finally, extract the king danger score from the KingDangerTable[] array.
841-
// Subtract the score from evaluation, and set ei.futilityMargin[].
842-
// The reason for storing the king danger score to futility margin
843-
// is that the king danger scores can sometimes be very big, and that
844-
// capturing a single attacking piece can therefore result in a score
845-
// change far bigger than the value of the captured piece.
840+
// Finally, extract the king danger score from the KingDangerTable[]
841+
// array and subtract the score from evaluation. Set also ei.kingDanger[]
842+
// value that will be used for pruning because this value can sometimes
843+
// be very big, and so capturing a single attacking piece can therefore
844+
// result in a score change far bigger than the value of the captured piece.
846845
ei.value -= Sign[Us] * KingDangerTable[Us][attackUnits];
847-
ei.futilityMargin[Us] = mg_value(KingDangerTable[Us][attackUnits]);
846+
ei.kingDanger[Us] = mg_value(KingDangerTable[Us][attackUnits]);
848847
}
849848
}
850849

src/evaluate.h

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

4848
struct EvalInfo {
4949

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

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

98-
// Extra futility margin. This is added to the standard futility margin
99-
// in the quiescence search. One for each color.
100-
Value futilityMargin[2];
98+
// Value of the danger for the king of the given color
99+
Value kingDanger[2];
101100
};
102101

103102

src/search.cpp

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

16601660
return bestValue;
@@ -1673,7 +1673,7 @@ namespace {
16731673
MovePicker mp = MovePicker(pos, ttMove, deepChecks ? Depth(0) : depth, H);
16741674
CheckInfo ci(pos);
16751675
enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame;
1676-
futilityBase = staticValue + FutilityMarginQS + ei.futilityMargin[pos.side_to_move()];
1676+
futilityBase = staticValue + FutilityMarginQS + ei.kingDanger[pos.side_to_move()];
16771677

16781678
// Loop through the moves until no moves remain or a beta cutoff occurs
16791679
while ( alpha < beta
@@ -1753,7 +1753,7 @@ namespace {
17531753
{
17541754
// If bestValue isn't changed it means it is still the static evaluation
17551755
// of the node, so keep this info to avoid a future evaluation() call.
1756-
ValueType type = (bestValue == staticValue && !ei.futilityMargin[pos.side_to_move()] ? VALUE_TYPE_EV_UP : VALUE_TYPE_UPPER);
1756+
ValueType type = (bestValue == staticValue && !ei.kingDanger[pos.side_to_move()] ? VALUE_TYPE_EV_UP : VALUE_TYPE_UPPER);
17571757
TT.store(pos.get_key(), value_to_tt(bestValue, ply), type, d, MOVE_NONE);
17581758
}
17591759
else if (bestValue >= beta)

0 commit comments

Comments
 (0)