depth: 白方第4步深度上调到18
顺带将 ai.ttMove 修正为 ai.nextMove() 并且多加了几个 nodeCompare 的 策略但未启用。 自对弈时长 10s 多。对比2000盘自对弈结果,速度为修改前的90%。 自对弈棋谱改变,最后一着为 (2,7)->(2,6) 三次重复局面和棋。
This commit is contained in:
parent
4013b5bb7f
commit
36daf7bb4f
|
@ -107,6 +107,8 @@
|
||||||
#define COMPARE_SCORE_PREFERRED
|
#define COMPARE_SCORE_PREFERRED
|
||||||
#else
|
#else
|
||||||
#define COMPARE_RATING_ONLY
|
#define COMPARE_RATING_ONLY
|
||||||
|
//#define COMPARE_RATING_1ST_VALUE_2ND
|
||||||
|
//#define COMPARE_VALUE_1ST_RATING_2ND
|
||||||
#endif // HOSTORY_HEURISTIC
|
#endif // HOSTORY_HEURISTIC
|
||||||
|
|
||||||
#define PREFETCH_SUPPORT
|
#define PREFETCH_SUPPORT
|
||||||
|
|
|
@ -83,7 +83,7 @@ depth_t AIAlgorithm::changeDepth(depth_t origDepth)
|
||||||
|
|
||||||
const depth_t placingDepthTable_12[] = {
|
const depth_t placingDepthTable_12[] = {
|
||||||
+1, 2, +2, 4, /* 0 ~ 3 */
|
+1, 2, +2, 4, /* 0 ~ 3 */
|
||||||
+4, 12, +12, 12, /* 4 ~ 7 */
|
+4, 12, +12, 18, /* 4 ~ 7 */
|
||||||
+12, 16, +16, 16, /* 8 ~ 11 */
|
+12, 16, +16, 16, /* 8 ~ 11 */
|
||||||
+16, 16, +16, 17, /* 12 ~ 15 */
|
+16, 16, +16, 17, /* 12 ~ 15 */
|
||||||
+17, 16, +16, 15, /* 16 ~ 19 */
|
+17, 16, +16, 15, /* 16 ~ 19 */
|
||||||
|
@ -271,7 +271,7 @@ Node *Node::addChild(
|
||||||
}
|
}
|
||||||
#endif // TT_MOVE_ENABLE
|
#endif // TT_MOVE_ENABLE
|
||||||
|
|
||||||
// 若没有启用置换表,或启用了但为叶子节点,则 ttMove 为0
|
// 若没有启用置换表,或启用了但为叶子节点,则 nextMove 为0
|
||||||
square_t sq = SQ_0;
|
square_t sq = SQ_0;
|
||||||
|
|
||||||
if (m > 0) {
|
if (m > 0) {
|
||||||
|
@ -386,6 +386,30 @@ Node *Node::addChild(
|
||||||
#ifdef ALPHABETA_AI
|
#ifdef ALPHABETA_AI
|
||||||
int AIAlgorithm::nodeCompare(const Node *first, const Node *second)
|
int AIAlgorithm::nodeCompare(const Node *first, const Node *second)
|
||||||
{
|
{
|
||||||
|
#ifdef COMPARE_RATING_1ST_VALUE_2ND
|
||||||
|
if (first->rating == second->rating) {
|
||||||
|
if (first->value == second->value) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (first->value < second->value ? 1 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (first->rating < second->rating ? 1 : -1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPARE_VALUE_1ST_RATING_2ND
|
||||||
|
if (first->value == second->value) {
|
||||||
|
if (first->rating == second->rating) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (first->rating < second->rating ? 1 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (first->value < second->value ? 1 : -1);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef COMPARE_RATING_ONLY
|
#ifdef COMPARE_RATING_ONLY
|
||||||
return second->rating - first->rating;
|
return second->rating - first->rating;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1039,7 +1063,7 @@ void AIAlgorithm::undoNullMove()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ALPHABETA_AI
|
#ifdef ALPHABETA_AI
|
||||||
const char* AIAlgorithm::ttMove()
|
const char* AIAlgorithm::nextMove()
|
||||||
{
|
{
|
||||||
char charChoose = '*';
|
char charChoose = '*';
|
||||||
|
|
||||||
|
@ -1050,11 +1074,15 @@ const char* AIAlgorithm::ttMove()
|
||||||
Board::printBoard();
|
Board::printBoard();
|
||||||
|
|
||||||
int moveIndex = 0;
|
int moveIndex = 0;
|
||||||
|
bool foundBest = false;
|
||||||
|
|
||||||
int cs = root->childrenSize;
|
int cs = root->childrenSize;
|
||||||
for (int i = 0; i < cs; i++) {
|
for (int i = 0; i < cs; i++) {
|
||||||
if (root->children[i]->move != best) {
|
if (root->children[i]->move != best) {
|
||||||
charChoose = ' ';
|
charChoose = ' ';
|
||||||
|
} else {
|
||||||
|
charChoose = '*';
|
||||||
|
foundBest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loggerDebug("[%.2d] %d\t%s\t%d\t%d\t%u %c\n", moveIndex,
|
loggerDebug("[%.2d] %d\t%s\t%d\t%d\t%u %c\n", moveIndex,
|
||||||
|
@ -1112,9 +1140,12 @@ const char* AIAlgorithm::ttMove()
|
||||||
}
|
}
|
||||||
#endif // TRANSPOSITION_TABLE_DEBUG
|
#endif // TRANSPOSITION_TABLE_DEBUG
|
||||||
#endif // TRANSPOSITION_TABLE_ENABLE
|
#endif // TRANSPOSITION_TABLE_ENABLE
|
||||||
|
if (foundBest == false) {
|
||||||
|
assert(0);
|
||||||
|
} else {
|
||||||
return moveToCommand(best);
|
return moveToCommand(best);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // ALPHABETA_AI
|
#endif // ALPHABETA_AI
|
||||||
|
|
||||||
const char *AIAlgorithm::moveToCommand(move_t move)
|
const char *AIAlgorithm::moveToCommand(move_t move)
|
||||||
|
|
|
@ -185,7 +185,7 @@ public:
|
||||||
int search(depth_t depth);
|
int search(depth_t depth);
|
||||||
|
|
||||||
// 返回最佳走法的命令行
|
// 返回最佳走法的命令行
|
||||||
const char *ttMove();
|
const char *nextMove();
|
||||||
#endif // ALPHABETA_AI
|
#endif // ALPHABETA_AI
|
||||||
|
|
||||||
// 暂存局面
|
// 暂存局面
|
||||||
|
|
|
@ -109,12 +109,7 @@ deque<int> openingBookDeque(
|
||||||
21, 23,
|
21, 23,
|
||||||
19, 20,
|
19, 20,
|
||||||
17, 18,
|
17, 18,
|
||||||
15, 10,
|
15,
|
||||||
26, 12,
|
|
||||||
28, 11,
|
|
||||||
27, 9, -15,
|
|
||||||
29, -12, 25,
|
|
||||||
13, -25
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -196,7 +191,7 @@ void AiThread::run()
|
||||||
strCommand = "draw";
|
strCommand = "draw";
|
||||||
emitCommand();
|
emitCommand();
|
||||||
} else {
|
} else {
|
||||||
strCommand = ai.ttMove();
|
strCommand = ai.nextMove();
|
||||||
if (strCommand && strcmp(strCommand, "error!") != 0) {
|
if (strCommand && strcmp(strCommand, "error!") != 0) {
|
||||||
loggerDebug("Computer: %s\n\n", strCommand);
|
loggerDebug("Computer: %s\n\n", strCommand);
|
||||||
emitCommand();
|
emitCommand();
|
||||||
|
|
Loading…
Reference in New Issue