- CheckExtension[1] = Options["Check Extension (PV nodes)"].value<Depth>();
- CheckExtension[0] = Options["Check Extension (non-PV nodes)"].value<Depth>();
- SingleEvasionExtension[1] = Options["Single Evasion Extension (PV nodes)"].value<Depth>();
- SingleEvasionExtension[0] = Options["Single Evasion Extension (non-PV nodes)"].value<Depth>();
- PawnPushTo7thExtension[1] = Options["Pawn Push to 7th Extension (PV nodes)"].value<Depth>();
- PawnPushTo7thExtension[0] = Options["Pawn Push to 7th Extension (non-PV nodes)"].value<Depth>();
- PassedPawnExtension[1] = Options["Passed Pawn Extension (PV nodes)"].value<Depth>();
- PassedPawnExtension[0] = Options["Passed Pawn Extension (non-PV nodes)"].value<Depth>();
- PawnEndgameExtension[1] = Options["Pawn Endgame Extension (PV nodes)"].value<Depth>();
- PawnEndgameExtension[0] = Options["Pawn Endgame Extension (non-PV nodes)"].value<Depth>();
- MateThreatExtension[1] = Options["Mate Threat Extension (PV nodes)"].value<Depth>();
- MateThreatExtension[0] = Options["Mate Threat Extension (non-PV nodes)"].value<Depth>();
-
- MinimumSplitDepth = Options["Minimum Split Depth"].value<int>() * ONE_PLY;
- MaxThreadsPerSplitPoint = Options["Maximum Number of Threads per Split Point"].value<int>();
- MultiPV = Options["MultiPV"].value<int>();
- UseLogFile = Options["Use Search Log"].value<bool>();
-
- if (UseLogFile)
- LogFile.open(Options["Search Log Filename"].value<std::string>().c_str(), std::ios::out | std::ios::app);
-
- read_weights(pos.side_to_move());
-
- // Set the number of active threads
- int newActiveThreads = Options["Threads"].value<int>();
- if (newActiveThreads != ThreadsMgr.active_threads())
- {
- ThreadsMgr.set_active_threads(newActiveThreads);
- init_eval(ThreadsMgr.active_threads());
- }
-
- // Wake up needed threads
- for (int i = 1; i < newActiveThreads; i++)
- ThreadsMgr.wake_sleeping_thread(i);
-
- // Set thinking time
- int myTime = time[pos.side_to_move()];
- int myIncrement = increment[pos.side_to_move()];
- if (UseTimeManagement)
- TimeMgr.init(myTime, myIncrement, movesToGo, pos.startpos_ply_counter());
-
- // Set best NodesBetweenPolls interval to avoid lagging under
- // heavy time pressure.
- if (MaxNodes)
- NodesBetweenPolls = Min(MaxNodes, 30000);
- else if (myTime && myTime < 1000)
- NodesBetweenPolls = 1000;
- else if (myTime && myTime < 5000)
- NodesBetweenPolls = 5000;
- else
- NodesBetweenPolls = 30000;
-
- // Write search information to log file
- if (UseLogFile)
- LogFile << "Searching: " << pos.to_fen() << endl
- << "infinite: " << infinite
- << " ponder: " << ponder
- << " time: " << myTime
- << " increment: " << myIncrement
- << " moves to go: " << movesToGo << endl;
-
- // We're ready to start thinking. Call the iterative deepening loop function
- id_loop(pos, searchMoves);
-
- if (UseLogFile)
- LogFile.close();
-
- // This makes all the threads to go to sleep
- ThreadsMgr.set_active_threads(1);
-
- return !Quit;
-}
-