1
0
Fork 0

Execute an implied ucinewgame at startup

execute an implied ucinewgame upon entering the UCI::loop,
to make sure that searches starting with and without an (optional) ucinewgame
command yield the same search.

This is needed now that seach::clear() initializes tables to non-zero default values.

No functional change

Closes #1101
Closes #1104
pull/1118/head
Joost VandeVondele 2017-05-06 13:12:39 +02:00 committed by Joona Kiiski
parent 0c1f119069
commit 7edd1f7ccd
3 changed files with 14 additions and 10 deletions

View File

@ -24,7 +24,6 @@
#include "position.h"
#include "search.h"
#include "thread.h"
#include "tt.h"
#include "uci.h"
#include "syzygy/tbprobe.h"
@ -44,8 +43,6 @@ int main(int argc, char* argv[]) {
Search::init();
Pawns::init();
Threads.init();
Tablebases::init(Options["SyzygyPath"]);
TT.resize(Options["Hash"]);
UCI::loop(argc, argv);

View File

@ -185,7 +185,7 @@ void Search::init() {
}
/// Search::clear() resets search state to zero, to obtain reproducible results
/// Search::clear() resets search state to its initial value, to obtain reproducible results
void Search::clear() {

View File

@ -28,6 +28,7 @@
#include "position.h"
#include "search.h"
#include "thread.h"
#include "tt.h"
#include "timeman.h"
#include "uci.h"
#include "syzygy/tbprobe.h"
@ -137,6 +138,15 @@ namespace {
Threads.start_thinking(pos, States, limits);
}
// On ucinewgame following steps are needed to reset the state
void newgame() {
TT.resize(Options["Hash"]);
Search::clear();
Tablebases::init(Options["SyzygyPath"]);
Time.availableNodes = 0;
}
} // namespace
@ -151,6 +161,8 @@ void UCI::loop(int argc, char* argv[]) {
Position pos;
string token, cmd;
newgame(); // Implied ucinewgame before the first position command
pos.set(StartFEN, false, &States->back(), Threads.main());
for (int i = 1; i < argc; ++i)
@ -185,12 +197,7 @@ void UCI::loop(int argc, char* argv[]) {
<< "\n" << Options
<< "\nuciok" << sync_endl;
else if (token == "ucinewgame")
{
Search::clear();
Tablebases::init(Options["SyzygyPath"]);
Time.availableNodes = 0;
}
else if (token == "ucinewgame") newgame();
else if (token == "isready") sync_cout << "readyok" << sync_endl;
else if (token == "go") go(pos, is);
else if (token == "position") position(pos, is);