position: Refactor remove_piece()

This commit is contained in:
Calcitem 2021-08-14 21:56:06 +08:00
parent e01b671c99
commit 9173006139
No known key found for this signature in database
GPG Key ID: F2F7C29E054CFB80
1 changed files with 7 additions and 15 deletions

View File

@ -797,29 +797,21 @@ bool Position::remove_piece(Square s, bool updateRecord)
revert_key(s);
Piece pc = board[s];
CLEAR_BIT(byTypeBB[type_of(pc)], s); // TODO: rule.hasBannedLocations and placing need?
CLEAR_BIT(byColorBB[color_of(pc)], s);
updateMobility(MOVETYPE_REMOVE, s);
if (rule.hasBannedLocations && phase == Phase::placing) {
// Remove and put ban
Piece pc = board[s];
CLEAR_BIT(byTypeBB[type_of(pc)], s); // TODO
CLEAR_BIT(byColorBB[color_of(pc)], s);
updateMobility(MOVETYPE_REMOVE, s);
pc = board[s] = BAN_STONE;
update_key(s);
SET_BIT(byTypeBB[type_of(pc)], s);
} else {
// Remove only
const Piece pc = board[s];
CLEAR_BIT(byTypeBB[ALL_PIECES], s);
CLEAR_BIT(byTypeBB[type_of(pc)], s);
CLEAR_BIT(byColorBB[color_of(pc)], s);
updateMobility(MOVETYPE_REMOVE, s);
board[s] = NO_PIECE;
}