position: 解决特定条件下每3次go出现1个 draw 的问题
nRepetition 由静态变量改为全局变量 用例: position fen O@@OOOO@/OOO**@O@/@O@@O@@O b m p 10 0 12 0 0 2 14 moves (3,4)->(2,4) (3,5)->(3,4) (2,4)->(2,5)
This commit is contained in:
parent
e009643ca2
commit
eda027f975
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
18
src/uci.cpp
18
src/uci.cpp
|
@ -41,6 +41,11 @@ using namespace std;
|
|||
|
||||
extern vector<string> setup_bench(Position *, istream &);
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
extern int nRepetition;
|
||||
extern vector<Key> 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)
|
||||
|
|
Loading…
Reference in New Issue