repetition: Reduce THREEFOLD_REPETITION region and fix fen()
This commit is contained in:
parent
30db31fafa
commit
ee258ef012
|
@ -363,7 +363,7 @@ const string Position::fen() const
|
|||
<< pieceOnBoardCount[WHITE] << " " << pieceInHandCount[WHITE] << " "
|
||||
<< pieceToRemoveCount << " ";
|
||||
|
||||
ss << st.rule50 << " " << 1 + (gamePly - (sideToMove == BLACK)) / 2;
|
||||
ss << st.rule50 << " " << 1 + (gamePly - (sideToMove == WHITE)) / 2;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ void Position::do_move(Move m)
|
|||
}
|
||||
|
||||
// Increment ply counters. In particular, rule50 will be reset to zero later on
|
||||
// in case of a capture.
|
||||
// in case of a remove.
|
||||
++gamePly;
|
||||
++st.rule50;
|
||||
++st.pliesFromNull;
|
||||
|
@ -474,6 +474,7 @@ out:
|
|||
return k;
|
||||
}
|
||||
|
||||
int repetition;
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
// Position::has_repeated() tests whether there has been at least one repetition
|
||||
|
@ -504,8 +505,6 @@ bool Position::has_repeated(Sanmill::Stack<Position> &ss) const
|
|||
|
||||
/// Position::has_game_cycle() tests if the position has a move which draws by repetition.
|
||||
|
||||
int repetition;
|
||||
|
||||
bool Position::has_game_cycle() const
|
||||
{
|
||||
for (auto i : posKeyHistory) {
|
||||
|
@ -525,15 +524,11 @@ bool Position::has_game_cycle() const
|
|||
|
||||
/// Mill Game
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
extern int repetition;
|
||||
#endif // THREEFOLD_REPETITION
|
||||
|
||||
bool Position::reset()
|
||||
{
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
repetition = 0;
|
||||
#endif // THREEFOLD_REPETITION
|
||||
|
||||
gamePly = 0;
|
||||
st.rule50 = 0;
|
||||
|
@ -940,7 +935,7 @@ bool Position::check_if_game_is_over()
|
|||
}
|
||||
|
||||
if (rule.maxStepsLedToDraw > 0 &&
|
||||
st.rule50 > rule.maxStepsLedToDraw) {
|
||||
rule50_count() > rule.maxStepsLedToDraw) {
|
||||
winner = DRAW;
|
||||
phase = Phase::gameOver;
|
||||
gameOverReason = GameOverReason::drawReasonRule50;
|
||||
|
|
|
@ -92,11 +92,12 @@ int Thread::search()
|
|||
chrono::steady_clock::time_point cycleEnd;
|
||||
#endif
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
if (rootPos->get_phase() == Phase::moving) {
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
if (rootPos->has_game_cycle()) {
|
||||
return 3;
|
||||
}
|
||||
#endif // THREEFOLD_REPETITION
|
||||
|
||||
#if defined(UCI_DO_BEST_MOVE) || defined(QT_GUI_LIB)
|
||||
posKeyHistory.push_back(rootPos->key());
|
||||
|
@ -108,7 +109,7 @@ int Thread::search()
|
|||
if (rootPos->get_phase() == Phase::placing) {
|
||||
posKeyHistory.clear();
|
||||
}
|
||||
#endif // THREEFOLD_REPETITION
|
||||
|
||||
|
||||
MoveList<LEGAL>::shuffle();
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ void clear();
|
|||
|
||||
#include "tt.h"
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
extern vector<Key> posKeyHistory;
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SEARCH_H_INCLUDED
|
||||
|
|
|
@ -38,10 +38,8 @@ using namespace std;
|
|||
|
||||
extern vector<string> setup_bench(Position *, istream &);
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
extern int repetition;
|
||||
extern vector<Key> posKeyHistory;
|
||||
#endif // THREEFOLD_REPETITION
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -71,19 +69,15 @@ void position(Position *pos, istringstream &is)
|
|||
else
|
||||
return;
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
repetition = 0;
|
||||
posKeyHistory.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
|
||||
posKeyHistory.push_back(pos->key());
|
||||
#endif // THREEFOLD_REPETITION
|
||||
}
|
||||
|
||||
// TODO: Stockfish does not have this
|
||||
|
@ -125,9 +119,7 @@ void go(Position *pos)
|
|||
begin:
|
||||
#endif
|
||||
|
||||
#ifdef THREEFOLD_REPETITION
|
||||
repetition = 0;
|
||||
#endif // THREEFOLD_REPETITION
|
||||
|
||||
Threads.start_thinking(pos);
|
||||
|
||||
|
|
Loading…
Reference in New Issue