From e2683c47b398b24cec67c06fc4ee74cbf90995ae Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 29 Aug 2016 23:57:02 +0200 Subject: [PATCH] Deal with Stockfish internal API changes. --- src/hashprobe.h | 4 ++-- src/main.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/hashprobe.h b/src/hashprobe.h index 4d0afec9..67b283f5 100644 --- a/src/hashprobe.h +++ b/src/hashprobe.h @@ -3,7 +3,7 @@ #include "types.h" -#include +#include #include #include @@ -19,7 +19,7 @@ public: private: void FillMove(Move move, hashprobe::HashProbeMove* decoded); - void ProbeMove(Position* pos, std::stack* setup_states, bool invert, hashprobe::HashProbeLine* response); + void ProbeMove(Position* pos, std::deque* setup_states, bool invert, hashprobe::HashProbeLine* response); void FillValue(Value value, hashprobe::HashProbeScore* score); }; diff --git a/src/main.cpp b/src/main.cpp index d0817a3d..de220eec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,9 @@ along with this program. If not, see . */ +#include #include +#include #include #include "bitboard.h" @@ -45,13 +47,15 @@ using namespace hashprobe; Status HashProbeImpl::Probe(ServerContext* context, const HashProbeRequest* request, HashProbeResponse *response) { - Position pos(request->fen(), /*isChess960=*/false, Threads.main()); + Position pos; + StateInfo st; + pos.set(request->fen(), /*isChess960=*/false, &st, Threads.main()); if (!pos.pos_is_ok()) { return Status(StatusCode::INVALID_ARGUMENT, "Invalid FEN"); } bool invert = (pos.side_to_move() == BLACK); - Search::StateStackPtr setup_states = Search::StateStackPtr(new std::stack); + StateListPtr setup_states = StateListPtr(new std::deque(1)); ProbeMove(&pos, setup_states.get(), invert, response->mutable_root()); @@ -59,8 +63,8 @@ Status HashProbeImpl::Probe(ServerContext* context, for (const ExtMove* em = moves.begin(); em != moves.end(); ++em) { HashProbeLine *line = response->add_line(); FillMove(em->move, line->mutable_move()); - setup_states->push(StateInfo()); - pos.do_move(em->move, setup_states->top(), pos.gives_check(em->move, CheckInfo(pos))); + setup_states->push_back(StateInfo()); + pos.do_move(em->move, setup_states->back(), pos.gives_check(em->move)); ProbeMove(&pos, setup_states.get(), !invert, line); pos.undo_move(em->move); } @@ -86,7 +90,7 @@ void HashProbeImpl::FillMove(Move move, HashProbeMove* decoded) { } } -void HashProbeImpl::ProbeMove(Position* pos, std::stack* setup_states, bool invert, HashProbeLine* response) { +void HashProbeImpl::ProbeMove(Position* pos, std::deque* setup_states, bool invert, HashProbeLine* response) { bool found; TTEntry *entry = TT.probe(pos->key(), found); response->set_found(found); @@ -120,8 +124,8 @@ void HashProbeImpl::ProbeMove(Position* pos, std::stack* setup_states if (seen.count(pos->key())) break; pv.push(entry->move()); seen.insert(pos->key()); - setup_states->push(StateInfo()); - pos->do_move(entry->move(), setup_states->top(), pos->gives_check(entry->move(), CheckInfo(*pos))); + setup_states->push_back(StateInfo()); + pos->do_move(entry->move(), setup_states->back(), pos->gives_check(entry->move())); entry = TT.probe(pos->key(), found); } -- 2.39.2