diff --git a/NineChess/src/MemoryPool.h b/NineChess/src/MemoryPool.h index bae976ea..78488371 100644 --- a/NineChess/src/MemoryPool.h +++ b/NineChess/src/MemoryPool.h @@ -75,7 +75,7 @@ class MemoryPool private: union Slot_ { value_type element; - Slot_* next; + union Slot_* next; }; typedef char* data_pointer_; diff --git a/NineChess/src/config.h b/NineChess/src/config.h index 4e42a325..0c96cbda 100644 --- a/NineChess/src/config.h +++ b/NineChess/src/config.h @@ -25,6 +25,8 @@ #define RANDOM_MOVE +#define MILL_FIRST + //#define DEAL_WITH_HORIZON_EFFECT #define IDS_SUPPORT diff --git a/NineChess/src/ninechess.cpp b/NineChess/src/ninechess.cpp index 5d2753e0..d824f0d1 100644 --- a/NineChess/src/ninechess.cpp +++ b/NineChess/src/ninechess.cpp @@ -1625,11 +1625,11 @@ bool NineChess::win(bool forceDraw) return false; } -int NineChess::isInMills(int pos) +int NineChess::isInMills(int pos, bool test) { int n = 0; int pos1, pos2; - char m = board_[pos] & '\x30'; + char m = test? INT32_MAX : board_[pos] & '\x30'; for (int i = 0; i < 3; i++) { pos1 = millTable[pos][i][0]; pos2 = millTable[pos][i][1]; diff --git a/NineChess/src/ninechess.h b/NineChess/src/ninechess.h index 443de547..60d5fe11 100644 --- a/NineChess/src/ninechess.h +++ b/NineChess/src/ninechess.h @@ -475,7 +475,7 @@ public: protected: // 判断棋盘pos处的棋子处于几个“三连”中 - int isInMills(int pos); + int isInMills(int pos, bool test = false); // 判断玩家的所有棋子是否都处于“三连”状态 bool isAllInMills(char ch); diff --git a/NineChess/src/ninechessai_ab.cpp b/NineChess/src/ninechessai_ab.cpp index 4816b856..5c554590 100644 --- a/NineChess/src/ninechessai_ab.cpp +++ b/NineChess/src/ninechessai_ab.cpp @@ -153,7 +153,16 @@ struct NineChessAi_ab::Node *NineChessAi_ab::addNode( if (parent) { // 若没有启用置换表,或启用了但为叶子节点,则 bestMove 为0 if (bestMove == 0 || move != bestMove) { +#ifdef MILL_FIRST + // 优先成三 + if (chessTemp.getStage() == NineChess::GAME_PLACING && move > 0 && chessTemp.isInMills(move, true)) { + parent->children.insert(parent->children.begin(), newNode); + } else { + parent->children.push_back(newNode); + } +#else parent->children.push_back(newNode); +#endif } else { // 如果启用了置换表并且不是叶子结点,把哈希得到的最优着法换到首位 parent->children.insert(parent->children.begin(), newNode);