diff --git a/include/config.h b/include/config.h index c5a26e9f..9da51de3 100644 --- a/include/config.h +++ b/include/config.h @@ -107,6 +107,8 @@ #define COMPARE_SCORE_PREFERRED #else #define COMPARE_RATING_ONLY +//#define COMPARE_RATING_1ST_VALUE_2ND +//#define COMPARE_VALUE_1ST_RATING_2ND #endif // HOSTORY_HEURISTIC #define PREFETCH_SUPPORT diff --git a/src/ai/search.cpp b/src/ai/search.cpp index f7c1a65d..e8d5b6ed 100644 --- a/src/ai/search.cpp +++ b/src/ai/search.cpp @@ -83,7 +83,7 @@ depth_t AIAlgorithm::changeDepth(depth_t origDepth) const depth_t placingDepthTable_12[] = { +1, 2, +2, 4, /* 0 ~ 3 */ - +4, 12, +12, 12, /* 4 ~ 7 */ + +4, 12, +12, 18, /* 4 ~ 7 */ +12, 16, +16, 16, /* 8 ~ 11 */ +16, 16, +16, 17, /* 12 ~ 15 */ +17, 16, +16, 15, /* 16 ~ 19 */ @@ -271,7 +271,7 @@ Node *Node::addChild( } #endif // TT_MOVE_ENABLE - // 若没有启用置换表,或启用了但为叶子节点,则 ttMove 为0 + // 若没有启用置换表,或启用了但为叶子节点,则 nextMove 为0 square_t sq = SQ_0; if (m > 0) { @@ -386,6 +386,30 @@ Node *Node::addChild( #ifdef ALPHABETA_AI 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 return second->rating - first->rating; #endif @@ -1039,7 +1063,7 @@ void AIAlgorithm::undoNullMove() } #ifdef ALPHABETA_AI -const char* AIAlgorithm::ttMove() +const char* AIAlgorithm::nextMove() { char charChoose = '*'; @@ -1050,11 +1074,15 @@ const char* AIAlgorithm::ttMove() Board::printBoard(); int moveIndex = 0; + bool foundBest = false; int cs = root->childrenSize; for (int i = 0; i < cs; i++) { if (root->children[i]->move != best) { charChoose = ' '; + } else { + charChoose = '*'; + foundBest = true; } loggerDebug("[%.2d] %d\t%s\t%d\t%d\t%u %c\n", moveIndex, @@ -1112,8 +1140,11 @@ const char* AIAlgorithm::ttMove() } #endif // TRANSPOSITION_TABLE_DEBUG #endif // TRANSPOSITION_TABLE_ENABLE - - return moveToCommand(best); + if (foundBest == false) { + assert(0); + } else { + return moveToCommand(best); + } } #endif // ALPHABETA_AI diff --git a/src/ai/search.h b/src/ai/search.h index d90a8be9..6cd35eaa 100644 --- a/src/ai/search.h +++ b/src/ai/search.h @@ -185,7 +185,7 @@ public: int search(depth_t depth); // 返回最佳走法的命令行 - const char *ttMove(); + const char *nextMove(); #endif // ALPHABETA_AI // 暂存局面 diff --git a/src/base/aithread.cpp b/src/base/aithread.cpp index ab068315..17bd7009 100644 --- a/src/base/aithread.cpp +++ b/src/base/aithread.cpp @@ -109,12 +109,7 @@ deque openingBookDeque( 21, 23, 19, 20, 17, 18, - 15, 10, - 26, 12, - 28, 11, - 27, 9, -15, - 29, -12, 25, - 13, -25 + 15, } ); @@ -196,7 +191,7 @@ void AiThread::run() strCommand = "draw"; emitCommand(); } else { - strCommand = ai.ttMove(); + strCommand = ai.nextMove(); if (strCommand && strcmp(strCommand, "error!") != 0) { loggerDebug("Computer: %s\n\n", strCommand); emitCommand();