mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Precalculate FutilityMargins
This way we don't need to copy+paste formula everywhere No functional change Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
27393ebae2
commit
973e574e1f
1 changed files with 13 additions and 3 deletions
|
@ -185,6 +185,8 @@ namespace {
|
||||||
// and near frontier nodes.
|
// and near frontier nodes.
|
||||||
const Value FutilityMarginQS = Value(0x80);
|
const Value FutilityMarginQS = Value(0x80);
|
||||||
|
|
||||||
|
Value FutilityMargins[2 * PLY_MAX_PLUS_2]; // Initialized at startup.
|
||||||
|
|
||||||
// Each move futility margin is decreased
|
// Each move futility margin is decreased
|
||||||
const Value IncrementalFutilityMargin = Value(0x8);
|
const Value IncrementalFutilityMargin = Value(0x8);
|
||||||
|
|
||||||
|
@ -576,6 +578,14 @@ void init_threads() {
|
||||||
for (i = 0; i < THREAD_MAX; i++)
|
for (i = 0; i < THREAD_MAX; i++)
|
||||||
Threads[i].activeSplitPoints = 0;
|
Threads[i].activeSplitPoints = 0;
|
||||||
|
|
||||||
|
// Init futility margins array
|
||||||
|
FutilityMargins[0] = FutilityMargins[1] = Value(0);
|
||||||
|
|
||||||
|
for (i = 2; i < 2 * PLY_MAX_PLUS_2; i++)
|
||||||
|
{
|
||||||
|
FutilityMargins[i] = Value(112 * bitScanReverse32(i * i / 2)); // FIXME: test using log instead of BSR
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize global locks
|
// Initialize global locks
|
||||||
lock_init(&MPLock, NULL);
|
lock_init(&MPLock, NULL);
|
||||||
lock_init(&IOLock, NULL);
|
lock_init(&IOLock, NULL);
|
||||||
|
@ -1458,7 +1468,7 @@ namespace {
|
||||||
|
|
||||||
// Calculate depth dependant futility pruning parameters
|
// Calculate depth dependant futility pruning parameters
|
||||||
const int FutilityMoveCountMargin = 3 + (1 << (3 * int(depth) / 8));
|
const int FutilityMoveCountMargin = 3 + (1 << (3 * int(depth) / 8));
|
||||||
const int PostFutilityValueMargin = 112 * bitScanReverse32(int(depth) * int(depth) / 2);
|
const int PostFutilityValueMargin = FutilityMargins[int(depth)];
|
||||||
|
|
||||||
// Evaluate the position statically
|
// Evaluate the position statically
|
||||||
if (!isCheck)
|
if (!isCheck)
|
||||||
|
@ -1626,7 +1636,7 @@ namespace {
|
||||||
int preFutilityValueMargin = 0;
|
int preFutilityValueMargin = 0;
|
||||||
|
|
||||||
if (newDepth >= OnePly)
|
if (newDepth >= OnePly)
|
||||||
preFutilityValueMargin = 112 * bitScanReverse32(int(newDepth) * int(newDepth) / 2);
|
preFutilityValueMargin = FutilityMargins[int(newDepth)];
|
||||||
|
|
||||||
Value futilityCaptureValue = ss[ply].eval + pos.endgame_value_of_piece_on(move_to(move)) + preFutilityValueMargin + ei.futilityMargin + 90;
|
Value futilityCaptureValue = ss[ply].eval + pos.endgame_value_of_piece_on(move_to(move)) + preFutilityValueMargin + ei.futilityMargin + 90;
|
||||||
|
|
||||||
|
@ -1663,7 +1673,7 @@ namespace {
|
||||||
{
|
{
|
||||||
int preFutilityValueMargin = 0;
|
int preFutilityValueMargin = 0;
|
||||||
if (predictedDepth >= OnePly)
|
if (predictedDepth >= OnePly)
|
||||||
preFutilityValueMargin = 112 * bitScanReverse32(int(predictedDepth) * int(predictedDepth) / 2);
|
preFutilityValueMargin = FutilityMargins[int(predictedDepth)];
|
||||||
|
|
||||||
preFutilityValueMargin += H.gain(pos.piece_on(move_from(move)), move_from(move), move_to(move)) + 45;
|
preFutilityValueMargin += H.gain(pos.piece_on(move_from(move)), move_from(move), move_to(move)) + 45;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue