mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 01:29:36 +00:00
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.
This commit is contained in:
parent
0e1ad3ad33
commit
0d68b523a3
6 changed files with 16 additions and 7 deletions
|
@ -114,6 +114,7 @@ void benchmark(const Position& current, istream& is) {
|
||||||
|
|
||||||
int64_t nodes = 0;
|
int64_t nodes = 0;
|
||||||
Search::StateStackPtr st;
|
Search::StateStackPtr st;
|
||||||
|
Search::MovesVectPtr mv;
|
||||||
Time::point elapsed = Time::now();
|
Time::point elapsed = Time::now();
|
||||||
|
|
||||||
for (size_t i = 0; i < fens.size(); i++)
|
for (size_t i = 0; i < fens.size(); i++)
|
||||||
|
@ -130,7 +131,7 @@ void benchmark(const Position& current, istream& is) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Threads.start_thinking(pos, limits, vector<Move>(), st);
|
Threads.start_thinking(pos, limits, vector<Move>(), st, mv);
|
||||||
Threads.wait_for_think_finished();
|
Threads.wait_for_think_finished();
|
||||||
nodes += Search::RootPos.nodes_searched();
|
nodes += Search::RootPos.nodes_searched();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace Search {
|
||||||
Color RootColor;
|
Color RootColor;
|
||||||
Time::point SearchTime;
|
Time::point SearchTime;
|
||||||
StateStackPtr SetupStates;
|
StateStackPtr SetupStates;
|
||||||
|
MovesVectPtr SetupMoves;
|
||||||
}
|
}
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
|
@ -93,6 +93,7 @@ struct SignalsType {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::auto_ptr<std::stack<StateInfo> > StateStackPtr;
|
typedef std::auto_ptr<std::stack<StateInfo> > StateStackPtr;
|
||||||
|
typedef std::auto_ptr<std::vector<Move> > MovesVectPtr;
|
||||||
|
|
||||||
extern volatile SignalsType Signals;
|
extern volatile SignalsType Signals;
|
||||||
extern LimitsType Limits;
|
extern LimitsType Limits;
|
||||||
|
@ -101,6 +102,7 @@ extern Position RootPos;
|
||||||
extern Color RootColor;
|
extern Color RootColor;
|
||||||
extern Time::point SearchTime;
|
extern Time::point SearchTime;
|
||||||
extern StateStackPtr SetupStates;
|
extern StateStackPtr SetupStates;
|
||||||
|
extern MovesVectPtr SetupMoves;
|
||||||
|
|
||||||
extern void init();
|
extern void init();
|
||||||
extern size_t perft(Position& pos, Depth depth);
|
extern size_t perft(Position& pos, Depth depth);
|
||||||
|
|
|
@ -357,8 +357,8 @@ void ThreadPool::wait_for_think_finished() {
|
||||||
// start_thinking() wakes up the main thread sleeping in MainThread::idle_loop()
|
// start_thinking() wakes up the main thread sleeping in MainThread::idle_loop()
|
||||||
// so to start a new search, then returns immediately.
|
// so to start a new search, then returns immediately.
|
||||||
|
|
||||||
void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
|
void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, const std::vector<Move>& searchMoves,
|
||||||
const std::vector<Move>& searchMoves, StateStackPtr& states) {
|
StateStackPtr& setupStates, MovesVectPtr& setupMoves) {
|
||||||
wait_for_think_finished();
|
wait_for_think_finished();
|
||||||
|
|
||||||
SearchTime = Time::now(); // As early as possible
|
SearchTime = Time::now(); // As early as possible
|
||||||
|
@ -368,7 +368,8 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
|
||||||
|
|
||||||
RootPos = pos;
|
RootPos = pos;
|
||||||
Limits = limits;
|
Limits = limits;
|
||||||
SetupStates = states; // Ownership transfer here
|
SetupStates = setupStates; // Ownership transfer here
|
||||||
|
SetupMoves = setupMoves; // Ownership transfer here
|
||||||
RootMoves.clear();
|
RootMoves.clear();
|
||||||
|
|
||||||
for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
|
for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
|
||||||
|
|
|
@ -151,8 +151,8 @@ struct ThreadPool : public std::vector<Thread*> {
|
||||||
void read_uci_options();
|
void read_uci_options();
|
||||||
Thread* available_slave(Thread* master) const;
|
Thread* available_slave(Thread* master) const;
|
||||||
void wait_for_think_finished();
|
void wait_for_think_finished();
|
||||||
void start_thinking(const Position&, const Search::LimitsType&,
|
void start_thinking(const Position&, const Search::LimitsType&, const std::vector<Move>&,
|
||||||
const std::vector<Move>&, Search::StateStackPtr&);
|
Search::StateStackPtr&, Search::MovesVectPtr&);
|
||||||
|
|
||||||
bool sleepWhileIdle;
|
bool sleepWhileIdle;
|
||||||
Depth minimumSplitDepth;
|
Depth minimumSplitDepth;
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace {
|
||||||
// Keep track of position keys along the setup moves (from start position to the
|
// 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.
|
// position just before to start searching). Needed by repetition draw detection.
|
||||||
Search::StateStackPtr SetupStates;
|
Search::StateStackPtr SetupStates;
|
||||||
|
Search::MovesVectPtr SetupMoves;
|
||||||
|
|
||||||
void set_option(istringstream& up);
|
void set_option(istringstream& up);
|
||||||
void set_position(Position& pos, istringstream& up);
|
void set_position(Position& pos, istringstream& up);
|
||||||
|
@ -148,10 +149,13 @@ namespace {
|
||||||
|
|
||||||
pos.set(fen, Options["UCI_Chess960"], Threads.main_thread());
|
pos.set(fen, Options["UCI_Chess960"], Threads.main_thread());
|
||||||
SetupStates = Search::StateStackPtr(new std::stack<StateInfo>());
|
SetupStates = Search::StateStackPtr(new std::stack<StateInfo>());
|
||||||
|
SetupMoves = Search::MovesVectPtr(new std::vector<Move>());
|
||||||
|
SetupMoves->reserve(200); // Try to avoid reallocations
|
||||||
|
|
||||||
// Parse move list (if any)
|
// Parse move list (if any)
|
||||||
while (is >> token && (m = move_from_uci(pos, token)) != MOVE_NONE)
|
while (is >> token && (m = move_from_uci(pos, token)) != MOVE_NONE)
|
||||||
{
|
{
|
||||||
|
SetupMoves->push_back(m);
|
||||||
SetupStates->push(StateInfo());
|
SetupStates->push(StateInfo());
|
||||||
pos.do_move(m, SetupStates->top());
|
pos.do_move(m, SetupStates->top());
|
||||||
}
|
}
|
||||||
|
@ -211,6 +215,6 @@ namespace {
|
||||||
else if (token == "ponder") limits.ponder = true;
|
else if (token == "ponder") limits.ponder = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Threads.start_thinking(pos, limits, searchMoves, SetupStates);
|
Threads.start_thinking(pos, limits, searchMoves, SetupStates, SetupMoves);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue