Skip to content

Commit

Permalink
Shrink Reductions[] array to one dimension
Browse files Browse the repository at this point in the history
This is a non-functional patch which shrinks the reductions array.
This saves about 8Kb of memory.

The only slow part of master's reductions array is the calculation
of the log values, so using a separate array for those values and
calculating the rest real-time appears to be just as fast as master.

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 63245 W: 13906 L: 13866 D: 35473
http://tests.stockfishchess.org/tests/view/5c7b571f0ebc5925cffdc104

No funcional change.
  • Loading branch information
protonspring authored and mcostalba committed Mar 5, 2019
1 parent 58bbbd1 commit 714e857
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ namespace {

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

template <bool PvNode> Depth reduction(bool i, Depth d, int mn) {
return (Reductions[i][std::min(d / ONE_PLY, 63)][std::min(mn, 63)] - PvNode) * ONE_PLY;
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;
}

// History and stats update bonus, based on depth
Expand Down Expand Up @@ -156,18 +157,8 @@ namespace {

void Search::init() {

for (int imp = 0; imp <= 1; ++imp)
for (int d = 1; d < 64; ++d)
for (int mc = 1; mc < 64; ++mc)
{
double r = log(d) * log(mc) / 1.95;

Reductions[imp][d][mc] = std::round(r);

// Increase reduction for non-PV nodes when eval is not improving
if (!imp && r > 1.0)
Reductions[imp][d][mc]++;
}
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)
{
Expand Down

0 comments on commit 714e857

Please sign in to comment.