若为先手则第一着棋抢占星位

This commit is contained in:
CalciteM 2019-06-23 15:27:32 +08:00
parent d0fc84787c
commit 4b96b675e5
2 changed files with 15 additions and 1 deletions

View File

@ -252,6 +252,12 @@ public:
return currentPos; return currentPos;
} }
// 判断位置点是否为星位 (星位是经常会先占的位置)
static bool isStartPoint(int pos)
{
return (pos == 17 || pos == 19 || pos == 21 || pos == 23);
}
// 获取当前步数 // 获取当前步数
int getStep() const int getStep() const
{ {
@ -281,6 +287,7 @@ public:
{ {
return winner; return winner;
} }
// 玩家1和玩家2的用时 // 玩家1和玩家2的用时
void getElapsedTimeMS(int &p1_ms, int &p2_ms); void getElapsedTimeMS(int &p1_ms, int &p2_ms);

View File

@ -61,10 +61,17 @@ void NineChessAi_ab::buildChildren(Node *node)
if ((chessTemp.context.stage) & (NineChess::GAME_PLACING | NineChess::GAME_NOTSTARTED)) { if ((chessTemp.context.stage) & (NineChess::GAME_PLACING | NineChess::GAME_NOTSTARTED)) {
for (int i = NineChess::POS_BEGIN; i < NineChess::POS_END; i++) { for (int i = NineChess::POS_BEGIN; i < NineChess::POS_END; i++) {
if (!chessTemp.board_[i]) { if (!chessTemp.board_[i]) {
if (node == rootNode && chessTemp.context.stage == NineChess::GAME_NOTSTARTED) {
// 若为先手,则抢占星位
if (NineChess::isStartPoint(i)) {
addNode(node, INT32_MAX, i);
}
} else {
addNode(node, 0, i); addNode(node, 0, i);
} }
} }
} }
}
// 对于中局移子 // 对于中局移子
else { else {
int newPos; int newPos;