remove_piece: 将更新棋盘上棋子数以及检查游戏结束条件的语句提前

提前到判断 false 条件之后马上进行,更新 hash 值之前。
This commit is contained in:
Calcitem 2020-09-20 16:39:53 +08:00
parent e0ed37a13e
commit 962cece2c5
1 changed files with 6 additions and 5 deletions

View File

@ -762,6 +762,12 @@ bool Position::remove_piece(Square s, bool updateCmdlist)
return false; return false;
} }
pieceCountOnBoard[them]--;
if (check_gameover_condition()) {
goto out;
}
revert_key(s); revert_key(s);
if (rule.hasBannedLocations && phase == PHASE_PLACING) { if (rule.hasBannedLocations && phase == PHASE_PLACING) {
@ -784,14 +790,9 @@ bool Position::remove_piece(Square s, bool updateCmdlist)
currentSquare = SQ_0; currentSquare = SQ_0;
pieceCountNeedRemove--; pieceCountNeedRemove--;
pieceCountOnBoard[them]--;
// Remove piece completed // Remove piece completed
if (check_gameover_condition()) {
goto out;
}
if (pieceCountNeedRemove > 0) { if (pieceCountNeedRemove > 0) {
return true; return true;
} }