diff --git a/src/ai/movegen.cpp b/src/ai/movegen.cpp index d352e046..9fdfee8d 100644 --- a/src/ai/movegen.cpp +++ b/src/ai/movegen.cpp @@ -150,7 +150,7 @@ int StateInfo::generateMoves(Stack &moves) for (int i = Board::MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) { square = static_cast(MoveList::movePriorityTable[i]); if (boardLocations[square] & opponent) { - if (rule.allowRemoveMill || !position->board.inHowManyMills(square)) { + if (rule.allowRemoveMill || !position->board.inHowManyMills(square, PLAYER_NOBODY)) { moves.push_back((move_t)-square); } } diff --git a/src/game/board.cpp b/src/game/board.cpp index 3ec16e53..34b2e5eb 100644 --- a/src/game/board.cpp +++ b/src/game/board.cpp @@ -197,25 +197,14 @@ square_t Board::polarToSquare(int r, int s) return static_cast(r * N_SEATS + s - 1); } -int Board::inHowManyMills(square_t square) -{ - int n = 0; - - for (int l = 0; l < LINE_TYPES_COUNT; l++) { - if ((locations[square] & 0x30) & - locations[millTable[square][l][0]] & - locations[millTable[square][l][1]]) { - n++; - } - } - - return n; -} - int Board::inHowManyMills(square_t square, player_t player) { int n = 0; + if (player == PLAYER_NOBODY) { + player = player_t(locations[square] & 0x30); + } + for (int l = 0; l < LINE_TYPES_COUNT; l++) { if (player & locations[millTable[square][l][0]] & @@ -306,7 +295,7 @@ bool Board::isAllInMills(player_t player) { for (square_t i = SQ_BEGIN; i < SQ_END; i = static_cast(i + 1)) { if (locations[i] & (uint8_t)player) { - if (!inHowManyMills(i)) { + if (!inHowManyMills(i, PLAYER_NOBODY)) { return false; } } diff --git a/src/game/board.h b/src/game/board.h index ca00d9d9..c8e8a913 100644 --- a/src/game/board.h +++ b/src/game/board.h @@ -69,7 +69,6 @@ public: void rotate(int degrees, vector &cmdlist, char *cmdline, int32_t move_, square_t square, bool cmdChange = true); // 判断棋盘 square 处的棋子处于几个“三连”中 - int inHowManyMills(square_t square); int inHowManyMills(square_t square, player_t player); // 判断玩家的所有棋子是否都处于“三连”状态 diff --git a/src/game/position.cpp b/src/game/position.cpp index 1b2f8084..a9ae69a4 100644 --- a/src/game/position.cpp +++ b/src/game/position.cpp @@ -573,7 +573,7 @@ bool StateInfo::capture(square_t square, int8_t updateCmdlist) // 如果当前子是否处于“三连”之中,且对方还未全部处于“三连”之中 if (!rule.allowRemoveMill && - position->board.inHowManyMills(square) && + position->board.inHowManyMills(square, PLAYER_NOBODY) && !position->board.isAllInMills(opponent)) { return false; }