From c82aab9a88244132474dfbf25d5a69ea4d7f7294 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Fri, 18 Oct 2019 01:12:34 +0800 Subject: [PATCH] =?UTF-8?q?AI:=20=E8=83=BD=E6=88=90=E4=B8=89=E5=B0=B1?= =?UTF-8?q?=E4=BC=98=E5=85=88=E6=88=90=E4=B8=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 能成三就优先成三, 除非置换表中记录了最优着法. 完成此功能, 相关修改用 MILL_FIRST 控制, 启用此宏. 自对弈时长缩短一半. --- include/config.h | 2 +- src/ai/search.cpp | 3 +-- src/game/board.cpp | 4 ++-- src/game/board.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/config.h b/include/config.h index d871a56b..f1e3349d 100644 --- a/include/config.h +++ b/include/config.h @@ -56,7 +56,7 @@ //#define EVALUATE_MOTIF #endif /* EVALUATE_ENABLE */ -//#define MILL_FIRST +#define MILL_FIRST //#define DEAL_WITH_HORIZON_EFFECT diff --git a/src/ai/search.cpp b/src/ai/search.cpp index 5e9ab1b6..d9babf41 100644 --- a/src/ai/search.cpp +++ b/src/ai/search.cpp @@ -221,8 +221,7 @@ struct AIAlgorithm::Node *AIAlgorithm::addNode( if (bestMove == 0 || move != bestMove) { #ifdef MILL_FIRST // 优先成三 - if (tempGame.getPhase() == PHASE_PLACING && move > 0 && - tempGame.position.board.inHowManyMills2((square_t)move)) { + if (move > 0 && tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.sideToMove)) { int pcs = parent->childrenSize; for (int i = pcs; i >= 1; i--) { parent->children[i] = parent->children[i - 1]; diff --git a/src/game/board.cpp b/src/game/board.cpp index a7ab609f..127a62cf 100644 --- a/src/game/board.cpp +++ b/src/game/board.cpp @@ -225,7 +225,7 @@ int Board::inHowManyMills(square_t square) return n; } -int Board::inHowManyMills2(square_t square) +int Board::inHowManyMills(square_t square, player_t player) { int n = 0; int square_1, square_2; @@ -233,7 +233,7 @@ int Board::inHowManyMills2(square_t square) 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]) { + if (player & locations[square_1] & locations[square_2]) { n++; } } diff --git a/src/game/board.h b/src/game/board.h index 98ac3040..3fa336b9 100644 --- a/src/game/board.h +++ b/src/game/board.h @@ -70,7 +70,7 @@ public: // 判断棋盘 square 处的棋子处于几个“三连”中 int inHowManyMills(square_t square); - int inHowManyMills2(square_t square); + int inHowManyMills(square_t square, player_t player); // 判断玩家的所有棋子是否都处于“三连”状态 bool isAllInMills(player_t);