diff --git a/NineChess/src/config.h b/NineChess/src/config.h index bd9aeebc..6ed73df1 100644 --- a/NineChess/src/config.h +++ b/NineChess/src/config.h @@ -3,7 +3,7 @@ //#define DEBUG -//#define RANDOM_MOVE +#define RANDOM_MOVE #define DEAL_WITH_HORIZON_EFFECT diff --git a/NineChess/src/ninechessai_ab.cpp b/NineChess/src/ninechessai_ab.cpp index 8bca8e7d..4a56822a 100644 --- a/NineChess/src/ninechessai_ab.cpp +++ b/NineChess/src/ninechessai_ab.cpp @@ -607,7 +607,7 @@ int NineChessAi_ab::alphaBetaPruning(int depth) openingBook.push_back(chess_.getHash()); } else { // 暂时在此处清空开局库 - clearBookHashMap(); + openingBook.clear(); } } #endif @@ -653,6 +653,10 @@ int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node) // 临时增加的深度,克服水平线效应用 int epsilon = 0; +#ifdef BOOK_LEARNING + bool hitBook = false; // 是否在开局库中出现过 +#endif + #ifdef HASH_MAP_ENABLE // 哈希值 HashValue hashValue; @@ -711,10 +715,11 @@ int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node) // 检索开局库 HashValue hashValue; - if (chessContext->turn == NineChess::PLAYER1 && - findBookHash(hash, hashValue)) { - // 对走棋一方扣分 - node->value--; + if(findBookHash(hash, hashValue)) { + if (chessContext->turn == NineChess::PLAYER2) { + // 是否需对后手扣分 + hitBook = true; + } } #endif @@ -940,6 +945,12 @@ int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node) // 排序子节点树 sortLegalMoves(node); // (13%) +#ifdef BOOK_LEARNING + if (hitBook) { + node->value++; + } +#endif + // 返回 return node->value; }