diff --git a/src/position.cpp b/src/position.cpp index 616e7505..6fa7d45e 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -744,8 +744,16 @@ int Position::set_position(const struct Rule *newRule) return -1; } +#ifdef THREEFOLD_REPETITION +extern int nRepetition; +#endif // THREEFOLD_REPETITION + bool Position::reset() { +#ifdef THREEFOLD_REPETITION + nRepetition = 0; +#endif // THREEFOLD_REPETITION + gamePly = 0; st.rule50 = 0; diff --git a/src/search.cpp b/src/search.cpp index d0ec859c..263c746d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -78,6 +78,9 @@ void Search::clear() Threads.clear(); } +#ifdef THREEFOLD_REPETITION +int nRepetition; +#endif // THREEFOLD_REPETITION /// Thread::search() is the main iterative deepening loop. It calls search() /// repeatedly with increasing depth until the allocated thinking time has been @@ -105,8 +108,6 @@ int Thread::search() #endif #ifdef THREEFOLD_REPETITION - static int nRepetition = 0; - if (rootPos->get_phase() == PHASE_MOVING) { Key key = rootPos->key(); diff --git a/src/uci.cpp b/src/uci.cpp index 1bdd3834..a81c22dc 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -41,6 +41,11 @@ using namespace std; extern vector setup_bench(Position *, istream &); +#ifdef THREEFOLD_REPETITION +extern int nRepetition; +extern vector moveHistory; +#endif // THREEFOLD_REPETITION + namespace { @@ -69,11 +74,19 @@ void position(Position *pos, istringstream &is) else return; +#ifdef THREEFOLD_REPETITION + nRepetition = 0; + moveHistory.clear(); +#endif // THREEFOLD_REPETITION + pos->set(fen, Threads.main()); // Parse move list (if any) while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE) { pos->do_move(m); +#ifdef THREEFOLD_REPETITION + moveHistory.push_back(pos->key()); +#endif // THREEFOLD_REPETITION } Threads.main()->us = pos->sideToMove; @@ -113,6 +126,11 @@ void go(Position *pos) #ifdef UCI_AUTO_RE_GO begin: #endif + +#ifdef THREEFOLD_REPETITION + nRepetition = 0; +#endif // THREEFOLD_REPETITION + Threads.start_thinking(pos); if (pos->get_phase() == PHASE_GAMEOVER)