parent
6ec062e5bc
commit
ac06cb6531
|
@ -51,10 +51,12 @@ void MoveList::generate(AIAlgorithm &ai, Game &tempGame,
|
|||
for (move_t i : movePriorityTable) {
|
||||
square = static_cast<square_t>(i);
|
||||
|
||||
// 如果已经有子占据, 继续检索
|
||||
if (tempGame.boardLocations[square]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 否则如果是空位
|
||||
if (tempGame.position.phase != PHASE_READY || node != root) {
|
||||
ai.addNode(node, VALUE_ZERO, (move_t)square, bestMove, tempGame.position.sideToMove);
|
||||
} else {
|
||||
|
|
|
@ -220,11 +220,18 @@ struct AIAlgorithm::Node *AIAlgorithm::addNode(
|
|||
// 若没有启用置换表,或启用了但为叶子节点,则 bestMove 为0
|
||||
if (bestMove == 0 || move != bestMove) {
|
||||
#ifdef MILL_FIRST
|
||||
// 优先成三 // TODO: Adapt MEMORY_POOL
|
||||
if (tempGame.getPhase() == GAME_PLACING && move > 0 && tempGame.position.board.isInMills(move, true)) {
|
||||
parent->children.insert(parent->children.begin(), newNode);
|
||||
// 优先成三
|
||||
if (tempGame.getPhase() == PHASE_PLACING && move > 0 &&
|
||||
tempGame.position.board.inHowManyMills2((square_t)move)) {
|
||||
int pcs = parent->childrenSize;
|
||||
for (int i = pcs; i >= 1; i--) {
|
||||
parent->children[i] = parent->children[i - 1];
|
||||
}
|
||||
parent->children[0] = newNode;
|
||||
parent->childrenSize++;
|
||||
} else {
|
||||
parent->children.push_back(newNode);
|
||||
parent->children[parent->childrenSize] = newNode;
|
||||
parent->childrenSize++;
|
||||
}
|
||||
#else // MILL_FIRST
|
||||
parent->children[parent->childrenSize] = newNode;
|
||||
|
|
|
@ -225,6 +225,22 @@ int Board::inHowManyMills(square_t square)
|
|||
return n;
|
||||
}
|
||||
|
||||
int Board::inHowManyMills2(square_t square)
|
||||
{
|
||||
int n = 0;
|
||||
int square_1, square_2;
|
||||
|
||||
for (int l = 0; l < LINE_TYPES_COUNT; l++) {
|
||||
square_1 = millTable[square][l][0];
|
||||
square_2 = millTable[square][l][1];
|
||||
if (locations[square_1] & locations[square_2]) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int Board::addMills(square_t square)
|
||||
{
|
||||
// 成三用一个64位整数了,规则如下
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
|
||||
// 判断棋盘 square 处的棋子处于几个“三连”中
|
||||
int inHowManyMills(square_t square);
|
||||
int inHowManyMills2(square_t square);
|
||||
|
||||
// 判断玩家的所有棋子是否都处于“三连”状态
|
||||
bool isAllInMills(player_t);
|
||||
|
|
Loading…
Reference in New Issue