rule50: Judge rule50 and draw (WIP)

This commit is contained in:
Calcitem 2021-01-12 01:07:29 +08:00
parent e02c744a7b
commit 285cee07ef
3 changed files with 7 additions and 2 deletions

View File

@ -935,7 +935,7 @@ bool Position::check_if_game_is_over()
} }
if (rule.maxStepsLedToDraw > 0 && if (rule.maxStepsLedToDraw > 0 &&
rule50_count() > rule.maxStepsLedToDraw) { posKeyHistory.size() > rule.maxStepsLedToDraw) {
winner = DRAW; winner = DRAW;
phase = Phase::gameOver; phase = Phase::gameOver;
gameOverReason = GameOverReason::drawReasonRule50; gameOverReason = GameOverReason::drawReasonRule50;

View File

@ -93,6 +93,9 @@ int Thread::search()
#endif #endif
if (rootPos->get_phase() == Phase::moving) { if (rootPos->get_phase() == Phase::moving) {
if (posKeyHistory.size() > rule.maxStepsLedToDraw) {
return 99;
}
#ifdef THREEFOLD_REPETITION #ifdef THREEFOLD_REPETITION
if (rootPos->has_game_cycle()) { if (rootPos->has_game_cycle()) {
return 3; return 3;

View File

@ -143,7 +143,9 @@ void Thread::idle_loop()
emitCommand(); emitCommand();
} else { } else {
#endif #endif
if (search() == 3) { int ret = search();
if (ret == 3 || ret == 50) {
loggerDebug("Draw\n\n"); loggerDebug("Draw\n\n");
strCommand = "draw"; strCommand = "draw";
emitCommand(); emitCommand();