int MultiPV, UCIMultiPV;
// Time management variables
- int SearchStartTime, MaxNodes, MaxDepth, ExactMaxTime;
+ int MaxNodes, MaxDepth, ExactMaxTime;
bool UseTimeManagement, InfiniteSearch, Pondering, StopOnPonderhit;
bool FirstRootMove, StopRequest, QuitRequest, AspirationFailLow;
TimeManager TimeMgr;
void update_gains(const Position& pos, Move move, Value before, Value after);
void do_skill_level(Move* best, Move* ponder);
- int current_search_time();
+ int current_search_time(int set = 0);
std::string value_to_uci(Value v);
std::string speed_to_uci(int64_t nodes);
void poll(const Position& pos);
// Initialize global search-related variables
StopOnPonderhit = StopRequest = QuitRequest = AspirationFailLow = SendSearchedNodes = false;
NodesSincePoll = 0;
- SearchStartTime = get_system_time();
+ current_search_time(get_system_time());
ExactMaxTime = maxTime;
MaxDepth = maxDepth;
MaxNodes = maxNodes;
// current_search_time() returns the number of milliseconds which have passed
// since the beginning of the current search.
- int current_search_time() {
+ int current_search_time(int set) {
- return get_system_time() - SearchStartTime;
+ static int searchStartTime;
+
+ if (set)
+ searchStartTime = set;
+
+ return get_system_time() - searchStartTime;
}
std::stringstream s;
if (abs(v) < VALUE_MATE - PLY_MAX * ONE_PLY)
- s << "cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns
+ s << "cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns
else
- s << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2;
+ s << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2;
return s.str();
}
assert(threadID >= 0 && threadID < MAX_THREADS);
int i;
- bool allFinished = false;
+ bool allFinished;
while (true)
{
if (threads[threadID].state == THREAD_INITIALIZING)
threads[threadID].state = THREAD_AVAILABLE;
- // Grab the lock to avoid races with wake_sleeping_thread()
+ // Grab the lock to avoid races with Thread::wake_up()
lock_grab(&threads[threadID].sleepLock);
// If we are master and all slaves have finished do not go to sleep