删除多余的 Position::generateNullMove()

This commit is contained in:
Calcitem 2020-05-10 19:50:47 +08:00
parent c93d7222ce
commit f86bbec6a4
2 changed files with 0 additions and 113 deletions

View File

@ -27,118 +27,6 @@
#include "search.h"
#include "position.h"
int Position::generateMoves(Stack<move_t, MAX_MOVES> &moves)
{
square_t square;
player_t op;
moves.clear();
// 列出所有合法的下一招
switch (action) {
// 对于选子和落子动作
case ACTION_CHOOSE:
case ACTION_PLACE:
// 对于摆子阶段
if (phase & (PHASE_PLACING | PHASE_READY)) {
for (move_t i : MoveList::movePriorityTable) {
square = static_cast<square_t>(i);
// 如果已经有子占据, 继续检索
if (board.locations[square]) {
continue;
}
#ifdef MCTS_AI
moves.push_back((move_t)square);
#else // MCTS_AI
if (phase != PHASE_READY) {
moves.push_back((move_t)square);
} else {
// 若为先手,则抢占星位
#ifdef FIRST_MOVE_STAR_PREFERRED
if (Board::isStar(square)) {
moves.push_back((move_t)square);
}
#else
moves.push_back((move_t)square);
#endif
}
#endif // MCTS_AI
}
break;
}
// 对于移子阶段
if (phase & PHASE_MOVING) {
square_t newSquare, oldSquare;
// 尽量走理论上较差的位置的棋子
for (int i = Board::MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) {
oldSquare = static_cast<square_t>(MoveList::movePriorityTable[i]);
if (!choose(oldSquare)) {
continue;
}
if (nPiecesOnBoard[sideId] > rule.nPiecesAtLeast ||
!rule.allowFlyWhenRemainThreePieces) {
// 对于棋盘上还有3个子以上或不允许飞子的情况要求必须在着法表中
for (int direction = DIRECTION_BEGIN; direction < DIRECTIONS_COUNT; direction++) {
// 对于原有位置,遍历四个方向的着法,如果棋盘上为空位就加到结点列表中
newSquare = static_cast<square_t>(MoveList::moveTable[oldSquare][direction]);
if (newSquare && !board.locations[newSquare]) {
move_t m = move_t((oldSquare << 8) + newSquare);
moves.push_back((move_t)m);
}
}
} else {
// 对于棋盘上还有不到3个字但允许飞子的情况不要求在着法表中是空位就行
for (newSquare = SQ_BEGIN; newSquare < SQ_END; newSquare = static_cast<square_t>(newSquare + 1)) {
if (!board.locations[newSquare]) {
move_t m = move_t((oldSquare << 8) + newSquare);
moves.push_back((move_t)m);
}
}
}
}
}
break;
// 对于吃子动作
case ACTION_CAPTURE:
op = Player::getOpponent(sideToMove);
if (board.isAllInMills(op)) {
// 全成三的情况
for (int i = Board::MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) {
square = static_cast<square_t>(MoveList::movePriorityTable[i]);
if (board.locations[square] & op) {
moves.push_back((move_t)-square);
}
}
break;
}
// 不是全成三的情况
for (int i = Board::MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) {
square = static_cast<square_t>(MoveList::movePriorityTable[i]);
if (board.locations[square] & op) {
if (rule.allowRemoveMill || !board.inHowManyMills(square, PLAYER_NOBODY)) {
moves.push_back((move_t)-square);
}
}
}
break;
default:
assert(0);
break;
}
return moves.size();
}
int Position::generateNullMove(Stack<move_t, MAX_MOVES> &moves)
{
moves.clear();

View File

@ -228,7 +228,6 @@ public:
void setTips();
// 着法生成
int generateMoves(Stack<move_t, MAX_MOVES> &moves);
int generateNullMove(Stack<move_t, MAX_MOVES> &moves);
bool doNullMove();