mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19:36 +00:00
Avoid a call to apply_weight() in evaluate_king()
Precompute scores in SafetyTable[] instead of calculate them on the fly. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
8e269d781a
commit
fe76787a77
1 changed files with 18 additions and 13 deletions
|
@ -251,9 +251,8 @@ namespace {
|
||||||
15, 15, 15, 15, 15, 15, 15, 15
|
15, 15, 15, 15, 15, 15, 15, 15
|
||||||
};
|
};
|
||||||
|
|
||||||
// SafetyTable[] contains the actual king safety scores. It is initialized
|
// SafetyTable[color][] contains the actual king safety weighted scores
|
||||||
// in init_safety().
|
Score SafetyTable[2][128];
|
||||||
Value SafetyTable[100];
|
|
||||||
|
|
||||||
// Pawn and material hash tables, indexed by the current thread id.
|
// Pawn and material hash tables, indexed by the current thread id.
|
||||||
// Note that they will be initialized at 0 being global variables.
|
// Note that they will be initialized at 0 being global variables.
|
||||||
|
@ -869,9 +868,8 @@ namespace {
|
||||||
// that the king safety scores can sometimes be very big, and that
|
// that the king safety scores can sometimes be very big, and that
|
||||||
// capturing a single attacking piece can therefore result in a score
|
// capturing a single attacking piece can therefore result in a score
|
||||||
// change far bigger than the value of the captured piece.
|
// change far bigger than the value of the captured piece.
|
||||||
Score v = apply_weight(make_score(SafetyTable[attackUnits], 0), WeightKingSafety[Us]);
|
ei.value -= Sign[Us] * SafetyTable[Us][attackUnits];
|
||||||
ei.value -= Sign[Us] * v;
|
ei.futilityMargin[Us] += mg_value(SafetyTable[Us][attackUnits]);
|
||||||
ei.futilityMargin[Us] += mg_value(v);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,22 +1210,29 @@ namespace {
|
||||||
int peak = 0x500;
|
int peak = 0x500;
|
||||||
double a = 0.4;
|
double a = 0.4;
|
||||||
double b = 0.0;
|
double b = 0.0;
|
||||||
|
Value t[100];
|
||||||
|
|
||||||
|
// First setup the base table
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
if (i < b)
|
if (i < b)
|
||||||
SafetyTable[i] = Value(0);
|
t[i] = Value(0);
|
||||||
else
|
else
|
||||||
SafetyTable[i] = Value((int)(a * (i - b) * (i - b)));
|
t[i] = Value((int)(a * (i - b) * (i - b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < 100; i++)
|
for (int i = 1; i < 100; i++)
|
||||||
{
|
{
|
||||||
if (SafetyTable[i] - SafetyTable[i - 1] > maxSlope)
|
if (t[i] - t[i - 1] > maxSlope)
|
||||||
SafetyTable[i] = SafetyTable[i - 1] + Value(maxSlope);
|
t[i] = t[i - 1] + Value(maxSlope);
|
||||||
|
|
||||||
if (SafetyTable[i] > Value(peak))
|
if (t[i] > Value(peak))
|
||||||
SafetyTable[i] = Value(peak);
|
t[i] = Value(peak);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then apply the weights and get the final SafetyTable[] array
|
||||||
|
for (Color c = WHITE; c <= BLACK; c++)
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
SafetyTable[c][i] = apply_weight(make_score(t[i], 0), WeightKingSafety[c]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue