From bd4d69a159b8ff0a2e7e6e03889c854aa9683b49 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 20 Sep 2020 21:01:28 +0800 Subject: [PATCH] =?UTF-8?q?position:=20refactor:=20=E6=9B=B4=E5=90=8D?= =?UTF-8?q?=E4=B8=BA=20remove=5Fban=5Fstones()=20=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=89=8D=E9=9C=80=E5=88=A4=E6=96=AD=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此函数内部对规则的判断改为 assert。 --- src/position.cpp | 16 ++++++++++------ src/position.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 3a4dcbf1..07ca3c59 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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; diff --git a/src/position.h b/src/position.h index 9e79774d..acc2507b 100644 --- a/src/position.h +++ b/src/position.h @@ -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();