diff --git a/src/ai/movegen.cpp b/src/ai/movegen.cpp index f0c5ea26..bb831256 100644 --- a/src/ai/movegen.cpp +++ b/src/ai/movegen.cpp @@ -37,6 +37,8 @@ void Game::generateChildren(const Stack &moves, { int size = moves.size(); + assert(size != 0); + for (int i = 0; i < size; i++) { node->addChild(moves[i], ai, this #ifdef BEST_MOVE_ENABLE @@ -148,8 +150,11 @@ void Game::generateMoves(Stack &moves) break; default: + assert(0); break; } + + assert(moves.size() != 0); } void MoveList::create() diff --git a/src/game/position.cpp b/src/game/position.cpp index 4a900607..b1c96e55 100644 --- a/src/game/position.cpp +++ b/src/game/position.cpp @@ -355,6 +355,8 @@ bool Game::place(square_t square, int8_t updateCmdlist) // 开局阶段未成三 if (n == 0) { + assert(position->nPiecesInHand[BLACK] >= 0 && position->nPiecesInHand[WHITE] >= 0); + // 如果双方都无未放置的棋子 if (position->nPiecesInHand[BLACK] == 0 && position->nPiecesInHand[WHITE] == 0) { // 决胜负 @@ -886,7 +888,7 @@ bool Game::checkGameOverCondition() // 如果中局被“闷” if (position->phase == PHASE_MOVING && position->action == ACTION_CHOOSE && position->board.isAllSurrounded(position->sideId, position->nPiecesOnBoard, position->sideToMove)) { - // 规则要求被“闷”判负,则对手获胜 + // 规则要求被“闷”判负,则对手获胜 // TODO: 应该转移到下面的分支中 position->phase = PHASE_GAMEOVER; if (rule.isLoseWhenNoWay) {