From: Marco Costalba Date: Sat, 2 Mar 2013 12:03:56 +0000 (+0100) Subject: Store moves sent with "position" UCI command X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=0d68b523a390e2f5c37f211316869d798e852289;hp=0e1ad3ad33c65be8cfb2702b3df5500ef9d2f87f Store moves sent with "position" UCI command Store all the game moves until current position. This will be used by next patch. No functional change. --- diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 25dab6cc..fa0aa3e9 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -114,6 +114,7 @@ void benchmark(const Position& current, istream& is) { int64_t nodes = 0; Search::StateStackPtr st; + Search::MovesVectPtr mv; Time::point elapsed = Time::now(); for (size_t i = 0; i < fens.size(); i++) @@ -130,7 +131,7 @@ void benchmark(const Position& current, istream& is) { } else { - Threads.start_thinking(pos, limits, vector(), st); + Threads.start_thinking(pos, limits, vector(), st, mv); Threads.wait_for_think_finished(); nodes += Search::RootPos.nodes_searched(); } diff --git a/src/search.cpp b/src/search.cpp index 76653ff9..15f09bc9 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -44,6 +44,7 @@ namespace Search { Color RootColor; Time::point SearchTime; StateStackPtr SetupStates; + MovesVectPtr SetupMoves; } using std::string; diff --git a/src/search.h b/src/search.h index bd210237..73fa79ae 100644 --- a/src/search.h +++ b/src/search.h @@ -93,6 +93,7 @@ struct SignalsType { }; typedef std::auto_ptr > StateStackPtr; +typedef std::auto_ptr > MovesVectPtr; extern volatile SignalsType Signals; extern LimitsType Limits; @@ -101,6 +102,7 @@ extern Position RootPos; extern Color RootColor; extern Time::point SearchTime; extern StateStackPtr SetupStates; +extern MovesVectPtr SetupMoves; extern void init(); extern size_t perft(Position& pos, Depth depth); diff --git a/src/thread.cpp b/src/thread.cpp index f5b8b5e2..0d8070f2 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -357,8 +357,8 @@ void ThreadPool::wait_for_think_finished() { // start_thinking() wakes up the main thread sleeping in MainThread::idle_loop() // so to start a new search, then returns immediately. -void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, - const std::vector& searchMoves, StateStackPtr& states) { +void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, const std::vector& searchMoves, + StateStackPtr& setupStates, MovesVectPtr& setupMoves) { wait_for_think_finished(); SearchTime = Time::now(); // As early as possible @@ -368,7 +368,8 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, RootPos = pos; Limits = limits; - SetupStates = states; // Ownership transfer here + SetupStates = setupStates; // Ownership transfer here + SetupMoves = setupMoves; // Ownership transfer here RootMoves.clear(); for (MoveList ml(pos); !ml.end(); ++ml) diff --git a/src/thread.h b/src/thread.h index fbd3b7f4..ac6040f2 100644 --- a/src/thread.h +++ b/src/thread.h @@ -151,8 +151,8 @@ struct ThreadPool : public std::vector { void read_uci_options(); Thread* available_slave(Thread* master) const; void wait_for_think_finished(); - void start_thinking(const Position&, const Search::LimitsType&, - const std::vector&, Search::StateStackPtr&); + void start_thinking(const Position&, const Search::LimitsType&, const std::vector&, + Search::StateStackPtr&, Search::MovesVectPtr&); bool sleepWhileIdle; Depth minimumSplitDepth; diff --git a/src/uci.cpp b/src/uci.cpp index c8f50446..3a33b9f4 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -42,6 +42,7 @@ namespace { // Keep track of position keys along the setup moves (from start position to the // position just before to start searching). Needed by repetition draw detection. Search::StateStackPtr SetupStates; + Search::MovesVectPtr SetupMoves; void set_option(istringstream& up); void set_position(Position& pos, istringstream& up); @@ -148,10 +149,13 @@ namespace { pos.set(fen, Options["UCI_Chess960"], Threads.main_thread()); SetupStates = Search::StateStackPtr(new std::stack()); + SetupMoves = Search::MovesVectPtr(new std::vector()); + SetupMoves->reserve(200); // Try to avoid reallocations // Parse move list (if any) while (is >> token && (m = move_from_uci(pos, token)) != MOVE_NONE) { + SetupMoves->push_back(m); SetupStates->push(StateInfo()); pos.do_move(m, SetupStates->top()); } @@ -211,6 +215,6 @@ namespace { else if (token == "ponder") limits.ponder = true; } - Threads.start_thinking(pos, limits, searchMoves, SetupStates); + Threads.start_thinking(pos, limits, searchMoves, SetupStates, SetupMoves); } }