Depth depth, bool mateThreat, int* moves, MovePicker* mp, int master, bool pvNode);
private:
- friend void poll(SearchStack ss[], int ply);
+ friend void poll();
int ActiveThreads;
volatile bool AllThreadsShouldExit, AllThreadsShouldSleep;
// Step 14. Reduced search
- int ReductionLevel; // 0 = most aggressive reductions, 7 = minimum reductions
-
// Reduction lookup tables (initialized at startup) and their getter functions
- int8_t PVReductionMatrix[8][64][64]; // [depth][moveNumber]
- int8_t NonPVReductionMatrix[8][64][64]; // [depth][moveNumber]
+ int8_t PVReductionMatrix[64][64]; // [depth][moveNumber]
+ int8_t NonPVReductionMatrix[64][64]; // [depth][moveNumber]
- inline Depth pv_reduction(Depth d, int mn) { return (Depth) PVReductionMatrix[ReductionLevel][Min(d / 2, 63)][Min(mn, 63)]; }
- inline Depth nonpv_reduction(Depth d, int mn) { return (Depth) NonPVReductionMatrix[ReductionLevel][Min(d / 2, 63)][Min(mn, 63)]; }
+ inline Depth pv_reduction(Depth d, int mn) { return (Depth) PVReductionMatrix[Min(d / 2, 63)][Min(mn, 63)]; }
+ inline Depth nonpv_reduction(Depth d, int mn) { return (Depth) NonPVReductionMatrix[Min(d / 2, 63)][Min(mn, 63)]; }
// Common adjustments
const Value EasyMoveMargin = Value(0x200);
// Last seconds noise filtering (LSN)
- const bool UseLSNFiltering = true;
+ const bool UseLSNFiltering = false;
const int LSNTime = 4000; // In milliseconds
const Value LSNValue = value_from_centipawns(200);
bool loseOnTime = false;
bool UseTimeManagement, InfiniteSearch, PonderSearch, StopOnPonderhit;
bool FirstRootMove, AbortSearch, Quit, AspirationFailLow;
- // Show current line?
- bool ShowCurrentLine;
-
// Log file
bool UseLogFile;
std::ofstream LogFile;
int current_search_time();
int nps();
- void poll(SearchStack ss[], int ply);
+ void poll();
void ponderhit();
void wait_for_stop_or_ponderhit();
void init_ss_array(SearchStack ss[]);
MinimumSplitDepth = get_option_value_int("Minimum Split Depth") * OnePly;
MaxThreadsPerSplitPoint = get_option_value_int("Maximum Number of Threads per Split Point");
- ShowCurrentLine = get_option_value_bool("UCI_ShowCurrLine");
MultiPV = get_option_value_int("MultiPV");
Chess960 = get_option_value_bool("UCI_Chess960");
UseLogFile = get_option_value_bool("Use Search Log");
return !Quit;
}
-// init_reduction_tables() is called by init_search() and initializes
-// the tables used by LMR.
-static void init_reduction_tables(int8_t pvTable[64][64], int8_t nonPvTable[64][64], int pvInhib, int nonPvInhib)
-{
- double pvBase = 1.001 - log(3.0) * log(16.0) / pvInhib;
- double nonPvBase = 1.001 - log(3.0) * log(4.0) / nonPvInhib;
+/// init_search() is called during startup. It initializes various lookup tables
+
+void init_search() {
+
+ // Init our reduction lookup tables
for (int i = 1; i < 64; i++) // i == depth (OnePly = 1)
for (int j = 1; j < 64; j++) // j == moveNumber
{
- double pvRed = pvBase + log(double(i)) * log(double(j)) / pvInhib;
- double nonPVRed = nonPvBase + log(double(i)) * log(double(j)) / nonPvInhib;
-
- pvTable[i][j] = (int8_t) ( pvRed >= 1.0 ? floor( pvRed * int(OnePly)) : 0);
- nonPvTable[i][j] = (int8_t) (nonPVRed >= 1.0 ? floor(nonPVRed * int(OnePly)) : 0);
+ double pvRed = 0.5 + log(double(i)) * log(double(j)) / 6.0;
+ double nonPVRed = 0.5 + log(double(i)) * log(double(j)) / 3.0;
+ PVReductionMatrix[i][j] = (int8_t) ( pvRed >= 1.0 ? floor( pvRed * int(OnePly)) : 0);
+ NonPVReductionMatrix[i][j] = (int8_t) (nonPVRed >= 1.0 ? floor(nonPVRed * int(OnePly)) : 0);
}
-}
-
-// init_search() is called during startup. It initializes various lookup tables
-void init_search() {
-
- // Init reduction lookup tables
- for (int i = 0; i < 8; i++)
- init_reduction_tables(PVReductionMatrix[i], NonPVReductionMatrix[i], int(4 * pow(1.3, i)), int(2 * pow(1.3, i)));
// Init futility margins array
for (int i = 0; i < 16; i++) // i == depth (OnePly = 2)
beta = Min(ValueByIteration[Iteration - 1] + AspirationDelta, VALUE_INFINITE);
}
- // Choose optimum reduction level
- ReductionLevel = 2;
-
- if (UseTimeManagement)
- {
- int level = int(floor(log(float(MaxSearchTime) / current_search_time()) / log(2.0) + 1.0));
- ReductionLevel = Min(Max(level, 0), 7);
- }
- else
- {
- //FIXME
- }
-
// Search to the current depth, rml is updated and sorted, alpha and beta could change
value = root_search(p, ss, rml, &alpha, &beta);
if (nullValue >= value_mate_in(PLY_MAX))
nullValue = beta;
- if (depth < 6 * OnePly)
- return nullValue;
+ // Do zugzwang verification search for high depths, don't store in TT
+ // if search was stopped.
+ if ( ( depth < 6 * OnePly
+ || search(pos, ss, beta, depth-5*OnePly, ply, false, threadID) >= beta)
+ && !AbortSearch
+ && !TM.thread_should_stop(threadID))
+ {
+ assert(value_to_tt(nullValue, ply) == nullValue);
- // Do zugzwang verification search
- Value v = search(pos, ss, beta, depth-5*OnePly, ply, false, threadID);
- if (v >= beta)
+ TT.store(posKey, nullValue, VALUE_TYPE_NS_LO, depth, MOVE_NONE);
return nullValue;
+ }
} else {
// The null move failed low, which means that we may be faced with
// some kind of threat. If the previous move was reduced, check if
alpha = bestValue;
// If we are near beta then try to get a cutoff pushing checks a bit further
- bool deepChecks = depth == -OnePly && staticValue >= beta - PawnValueMidgame / 8;
+ bool deepChecks = (depth == -OnePly && staticValue >= beta - PawnValueMidgame / 8);
// Initialize a MovePicker object for the current position, and prepare
// to search the moves. Because the depth is <= 0 here, only captures,
NodesSincePoll++;
if (NodesSincePoll >= NodesBetweenPolls)
{
- poll(ss, ply);
+ poll();
NodesSincePoll = 0;
}
}
// looks at the time consumed so far and decides if it's time to abort the
// search.
- void poll(SearchStack ss[], int ply) {
+ void poll() {
static int lastInfoTime;
int t = current_search_time();
cout << "info nodes " << TM.nodes_searched() << " nps " << nps()
<< " time " << t << " hashfull " << TT.full() << endl;
-
- // We only support current line printing in single thread mode
- if (ShowCurrentLine && TM.active_threads() == 1)
- {
- cout << "info currline";
- for (int p = 0; p < ply; p++)
- cout << " " << ss[p].currentMove;
-
- cout << endl;
- }
}
// Should we stop the search?