AI: 摆子阶段将棋子摆放在星点和成三的优先级一样
This commit is contained in:
parent
95ea8a2c5d
commit
969aee6c4c
src
|
@ -233,21 +233,25 @@ struct AIAlgorithm::Node *AIAlgorithm::addNode(
|
||||||
// 检测落子点是否能使得本方成三
|
// 检测落子点是否能使得本方成三
|
||||||
int nMills = tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.sideToMove);
|
int nMills = tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.sideToMove);
|
||||||
if (nMills > 0) {
|
if (nMills > 0) {
|
||||||
newNode->rating = static_cast<rating_t>(RATING_ONE_MILL * nMills);
|
newNode->rating += static_cast<rating_t>(RATING_ONE_MILL * nMills);
|
||||||
} else {
|
} else {
|
||||||
// 检测落子点是否能阻止对方成三
|
// 检测落子点是否能阻止对方成三
|
||||||
int nopponentMills = tempGame.position.board.inHowManyMills((square_t)(move & 0x00ff), tempGame.position.opponent);
|
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) {
|
} else if (move < 0) {
|
||||||
// 检测吃子点是否处于对方的三连中
|
// 检测吃子点是否处于对方的三连中
|
||||||
int nopponentMills = tempGame.position.board.inHowManyMills((square_t)((-move) & 0x00ff), tempGame.position.opponent);
|
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
|
#endif // MILL_FIRST
|
||||||
} else {
|
} else {
|
||||||
// 如果启用了置换表并且不是叶子结点
|
// 如果启用了置换表并且不是叶子结点
|
||||||
newNode->rating = RATING_TT;
|
newNode->rating += RATING_TT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
|
|
|
@ -39,7 +39,7 @@ value_t TT::probeHash(const hash_t &hash,
|
||||||
|
|
||||||
if ((hashValue.type == hashfALPHA) && // 最多是 hashValue.value
|
if ((hashValue.type == hashfALPHA) && // 最多是 hashValue.value
|
||||||
(hashValue.value <= alpha)) {
|
(hashValue.value <= alpha)) {
|
||||||
return alpha;
|
return alpha; // TODO: https://github.com/calcitem/NineChess/issues/25
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hashValue.type == hashfBETA) && // 至少是 hashValue.value
|
if ((hashValue.type == hashfBETA) && // 至少是 hashValue.value
|
||||||
|
|
|
@ -142,6 +142,7 @@ enum rating_t : int8_t
|
||||||
// 正值
|
// 正值
|
||||||
RATING_BLOCK_ONE_MILL = 10,
|
RATING_BLOCK_ONE_MILL = 10,
|
||||||
RATING_ONE_MILL = 11,
|
RATING_ONE_MILL = 11,
|
||||||
|
RATING_STAR_SQUARE = 11,
|
||||||
RATING_BLOCK_TWO_MILLS = RATING_BLOCK_ONE_MILL * 2,
|
RATING_BLOCK_TWO_MILLS = RATING_BLOCK_ONE_MILL * 2,
|
||||||
RATING_TWO_MILLS = RATING_ONE_MILL * 2,
|
RATING_TWO_MILLS = RATING_ONE_MILL * 2,
|
||||||
RATING_BLOCK_THREE_MILLS = RATING_BLOCK_ONE_MILL * 3,
|
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); }
|
inline T& operator/=(T& d, int i) { return d = T(int(d) / i); }
|
||||||
|
|
||||||
ENABLE_FULL_OPERATORS_ON(value_t)
|
ENABLE_FULL_OPERATORS_ON(value_t)
|
||||||
|
ENABLE_FULL_OPERATORS_ON(rating_t)
|
||||||
ENABLE_FULL_OPERATORS_ON(direction_t)
|
ENABLE_FULL_OPERATORS_ON(direction_t)
|
||||||
|
|
||||||
ENABLE_INCR_OPERATORS_ON(direction_t)
|
ENABLE_INCR_OPERATORS_ON(direction_t)
|
||||||
|
|
Loading…
Reference in New Issue