Skip to content

Commit

Permalink
Remove FutilityMoveCounts array. (official-stockfish#2024)
Browse files Browse the repository at this point in the history
This is a functional simplification that removes the FutilityMoveCounts array with a simple equation using only ints.

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 14175 W: 3123 L: 2987 D: 8065

LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 9900 W: 1735 L: 1597 D: 6568

Bench: 3380343
  • Loading branch information
protonspring authored and mcostalba committed Mar 5, 2019
1 parent 714e857 commit 1aab5b4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ namespace {
return Value((175 - 50 * improving) * d / ONE_PLY);
}

// Futility and reductions lookup tables, initialized at startup
int FutilityMoveCounts[2][16]; // [improving][depth]
// Reductions lookup table, initialized at startup
int Reductions[64]; // [depth or moveNumber]

template <bool PvNode> Depth reduction(bool i, Depth d, int mn) {
int r = Reductions[std::min(d / ONE_PLY, 63)] * Reductions[std::min(mn, 63)] / 1024;
return ((r + 512) / 1024 + (!i && r > 1024) - PvNode) * ONE_PLY;
}

constexpr int futility_move_count(bool improving, int depth) {
return (5 + depth * depth) * (1 + improving) / 2;
}

// History and stats update bonus, based on depth
int stat_bonus(Depth depth) {
int d = depth / ONE_PLY;
Expand Down Expand Up @@ -159,12 +162,6 @@ void Search::init() {

for (int i = 1; i < 64; ++i)
Reductions[i] = int(1024 * std::log(i) / std::sqrt(1.95));

for (int d = 0; d < 16; ++d)
{
FutilityMoveCounts[0][d] = int(2.4 + 0.74 * pow(d, 1.78));
FutilityMoveCounts[1][d] = int(5.0 + 1.00 * pow(d, 2.00));
}
}


Expand Down Expand Up @@ -957,8 +954,7 @@ namespace {
&& bestValue > VALUE_MATED_IN_MAX_PLY)
{
// Skip quiet moves if movecount exceeds our FutilityMoveCount threshold
moveCountPruning = depth < 16 * ONE_PLY
&& moveCount >= FutilityMoveCounts[improving][depth / ONE_PLY];
moveCountPruning = moveCount >= futility_move_count(improving,depth / ONE_PLY);

if ( !captureOrPromotion
&& !givesCheck
Expand Down

0 comments on commit 1aab5b4

Please sign in to comment.