摆棋阶段优先成三 (WIP)

This commit is contained in:
CalciteM 2019-08-04 03:17:53 +08:00
parent 21f8548791
commit 50c89175b1
5 changed files with 15 additions and 4 deletions

View File

@ -75,7 +75,7 @@ class MemoryPool
private: private:
union Slot_ { union Slot_ {
value_type element; value_type element;
Slot_* next; union Slot_* next;
}; };
typedef char* data_pointer_; typedef char* data_pointer_;

View File

@ -25,6 +25,8 @@
#define RANDOM_MOVE #define RANDOM_MOVE
#define MILL_FIRST
//#define DEAL_WITH_HORIZON_EFFECT //#define DEAL_WITH_HORIZON_EFFECT
#define IDS_SUPPORT #define IDS_SUPPORT

View File

@ -1625,11 +1625,11 @@ bool NineChess::win(bool forceDraw)
return false; return false;
} }
int NineChess::isInMills(int pos) int NineChess::isInMills(int pos, bool test)
{ {
int n = 0; int n = 0;
int pos1, pos2; int pos1, pos2;
char m = board_[pos] & '\x30'; char m = test? INT32_MAX : board_[pos] & '\x30';
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
pos1 = millTable[pos][i][0]; pos1 = millTable[pos][i][0];
pos2 = millTable[pos][i][1]; pos2 = millTable[pos][i][1];

View File

@ -475,7 +475,7 @@ public:
protected: protected:
// 判断棋盘pos处的棋子处于几个“三连”中 // 判断棋盘pos处的棋子处于几个“三连”中
int isInMills(int pos); int isInMills(int pos, bool test = false);
// 判断玩家的所有棋子是否都处于“三连”状态 // 判断玩家的所有棋子是否都处于“三连”状态
bool isAllInMills(char ch); bool isAllInMills(char ch);

View File

@ -153,7 +153,16 @@ struct NineChessAi_ab::Node *NineChessAi_ab::addNode(
if (parent) { if (parent) {
// 若没有启用置换表,或启用了但为叶子节点,则 bestMove 为0 // 若没有启用置换表,或启用了但为叶子节点,则 bestMove 为0
if (bestMove == 0 || move != bestMove) { 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); parent->children.push_back(newNode);
#endif
} else { } else {
// 如果启用了置换表并且不是叶子结点,把哈希得到的最优着法换到首位 // 如果启用了置换表并且不是叶子结点,把哈希得到的最优着法换到首位
parent->children.insert(parent->children.begin(), newNode); parent->children.insert(parent->children.begin(), newNode);