AI: 能成三就优先成三
能成三就优先成三, 除非置换表中记录了最优着法. 完成此功能, 相关修改用 MILL_FIRST 控制, 启用此宏. 自对弈时长缩短一半.
This commit is contained in:
parent
cfe4ce4e9b
commit
c82aab9a88
|
@ -56,7 +56,7 @@
|
||||||
//#define EVALUATE_MOTIF
|
//#define EVALUATE_MOTIF
|
||||||
#endif /* EVALUATE_ENABLE */
|
#endif /* EVALUATE_ENABLE */
|
||||||
|
|
||||||
//#define MILL_FIRST
|
#define MILL_FIRST
|
||||||
|
|
||||||
//#define DEAL_WITH_HORIZON_EFFECT
|
//#define DEAL_WITH_HORIZON_EFFECT
|
||||||
|
|
||||||
|
|
|
@ -221,8 +221,7 @@ struct AIAlgorithm::Node *AIAlgorithm::addNode(
|
||||||
if (bestMove == 0 || move != bestMove) {
|
if (bestMove == 0 || move != bestMove) {
|
||||||
#ifdef MILL_FIRST
|
#ifdef MILL_FIRST
|
||||||
// 优先成三
|
// 优先成三
|
||||||
if (tempGame.getPhase() == PHASE_PLACING && move > 0 &&
|
if (move > 0 && tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.sideToMove)) {
|
||||||
tempGame.position.board.inHowManyMills2((square_t)move)) {
|
|
||||||
int pcs = parent->childrenSize;
|
int pcs = parent->childrenSize;
|
||||||
for (int i = pcs; i >= 1; i--) {
|
for (int i = pcs; i >= 1; i--) {
|
||||||
parent->children[i] = parent->children[i - 1];
|
parent->children[i] = parent->children[i - 1];
|
||||||
|
|
|
@ -225,7 +225,7 @@ int Board::inHowManyMills(square_t square)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Board::inHowManyMills2(square_t square)
|
int Board::inHowManyMills(square_t square, player_t player)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int square_1, square_2;
|
int square_1, square_2;
|
||||||
|
@ -233,7 +233,7 @@ int Board::inHowManyMills2(square_t square)
|
||||||
for (int l = 0; l < LINE_TYPES_COUNT; l++) {
|
for (int l = 0; l < LINE_TYPES_COUNT; l++) {
|
||||||
square_1 = millTable[square][l][0];
|
square_1 = millTable[square][l][0];
|
||||||
square_2 = millTable[square][l][1];
|
square_2 = millTable[square][l][1];
|
||||||
if (locations[square_1] & locations[square_2]) {
|
if (player & locations[square_1] & locations[square_2]) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
// 判断棋盘 square 处的棋子处于几个“三连”中
|
// 判断棋盘 square 处的棋子处于几个“三连”中
|
||||||
int inHowManyMills(square_t square);
|
int inHowManyMills(square_t square);
|
||||||
int inHowManyMills2(square_t square);
|
int inHowManyMills(square_t square, player_t player);
|
||||||
|
|
||||||
// 判断玩家的所有棋子是否都处于“三连”状态
|
// 判断玩家的所有棋子是否都处于“三连”状态
|
||||||
bool isAllInMills(player_t);
|
bool isAllInMills(player_t);
|
||||||
|
|
Loading…
Reference in New Issue