diff --git a/src/ai/search.cpp b/src/ai/search.cpp index a5ce7110..44338ffe 100644 --- a/src/ai/search.cpp +++ b/src/ai/search.cpp @@ -233,21 +233,25 @@ struct AIAlgorithm::Node *AIAlgorithm::addNode( // 检测落子点是否能使得本方成三 int nMills = tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.sideToMove); if (nMills > 0) { - newNode->rating = static_cast<rating_t>(RATING_ONE_MILL * nMills); + newNode->rating += static_cast<rating_t>(RATING_ONE_MILL * nMills); } else { // 检测落子点是否能阻止对方成三 int nopponentMills = tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.opponent); - newNode->rating = static_cast<rating_t>(RATING_BLOCK_ONE_MILL * nopponentMills); + newNode->rating += static_cast<rating_t>(RATING_BLOCK_ONE_MILL * nopponentMills); + } + + if (tempGame.getPhase() == PHASE_PLACING && Board::isStar(static_cast<square_t>(move))) { + newNode->rating += RATING_STAR_SQUARE; } } else if (move < 0) { // 检测吃子点是否处于对方的三连中 int nopponentMills = tempGame.position.board.inHowManyMills((square_t)((-move) & 0x00ff), tempGame.position.opponent); - newNode->rating = static_cast<rating_t>(RATING_CAPTURE_ONE_MILL * nopponentMills); + newNode->rating += static_cast<rating_t>(RATING_CAPTURE_ONE_MILL * nopponentMills); } #endif // MILL_FIRST } else { // 如果启用了置换表并且不是叶子结点 - newNode->rating = RATING_TT; + newNode->rating += RATING_TT; } return newNode; diff --git a/src/ai/tt.cpp b/src/ai/tt.cpp index 22e09ec6..6b39e5bb 100644 --- a/src/ai/tt.cpp +++ b/src/ai/tt.cpp @@ -39,7 +39,7 @@ value_t TT::probeHash(const hash_t &hash, if ((hashValue.type == hashfALPHA) && // 最多是 hashValue.value (hashValue.value <= alpha)) { - return alpha; + return alpha; // TODO: https://github.com/calcitem/NineChess/issues/25 } if ((hashValue.type == hashfBETA) && // 至少是 hashValue.value diff --git a/src/game/types.h b/src/game/types.h index 9d7fbef4..8592806f 100644 --- a/src/game/types.h +++ b/src/game/types.h @@ -142,6 +142,7 @@ enum rating_t : int8_t // 正值 RATING_BLOCK_ONE_MILL = 10, RATING_ONE_MILL = 11, + RATING_STAR_SQUARE = 11, RATING_BLOCK_TWO_MILLS = RATING_BLOCK_ONE_MILL * 2, RATING_TWO_MILLS = RATING_ONE_MILL * 2, RATING_BLOCK_THREE_MILLS = RATING_BLOCK_ONE_MILL * 3, @@ -235,6 +236,7 @@ inline T& operator*=(T& d, int i) { return d = T(int(d) * i); } \ inline T& operator/=(T& d, int i) { return d = T(int(d) / i); } ENABLE_FULL_OPERATORS_ON(value_t) +ENABLE_FULL_OPERATORS_ON(rating_t) ENABLE_FULL_OPERATORS_ON(direction_t) ENABLE_INCR_OPERATORS_ON(direction_t)