position: refactor: 更名为 remove_ban_stones() 并且执行前需判断规则

此函数内部对规则的判断改为 assert。
This commit is contained in:
Calcitem 2020-09-20 21:01:28 +08:00
parent 346fa2dfb9
commit bd4d69a159
2 changed files with 11 additions and 7 deletions

View File

@ -658,7 +658,10 @@ bool Position::put_piece(Square s, bool updateCmdlist)
phase = PHASE_MOVING;
action = ACTION_SELECT;
clean_banned();
if (rule.hasBannedLocations) {
remove_ban_stones();
}
if (!rule.isDefenderMoveFirst) {
change_side_to_move();
@ -795,7 +798,10 @@ bool Position::remove_piece(Square s, bool updateCmdlist)
if (pieceCountInHand[BLACK] == 0 && pieceCountInHand[WHITE] == 0) {
phase = PHASE_MOVING;
action = ACTION_SELECT;
clean_banned();
if (rule.hasBannedLocations) {
remove_ban_stones();
}
if (rule.isDefenderMoveFirst) {
goto check;
@ -1036,11 +1042,9 @@ int Position::get_mobility_diff(bool includeFobidden)
return diff;
}
void Position::clean_banned()
void Position::remove_ban_stones()
{
if (!rule.hasBannedLocations) {
return;
}
assert(rule.hasBannedLocations);
Square s = SQ_0;

View File

@ -138,7 +138,7 @@ public:
int update();
void update_score();
bool check_gameover_condition();
void clean_banned();
void remove_ban_stones();
void set_side_to_move(Color c);
void change_side_to_move();