Node 结构体裁剪

将部分成员改为仅在启用树调试时才使用
This commit is contained in:
CalciteM Team 2019-08-01 22:28:58 +08:00
parent a22c06018a
commit 8d050479fd
2 changed files with 17 additions and 7 deletions

View File

@ -95,19 +95,25 @@ struct NineChessAi_ab::Node *NineChessAi_ab::addNode(
newNode->move = move;
nodeCount++;
#ifdef DEBUG_AB_TREE
newNode->id = nodeCount;
#endif
newNode->pruned = false;
player = player; // Remove warning
#ifdef DEBUG_AB_TREE
#if ((defined HASH_MAP_ENABLE) || (defined BOOK_LEARNING) || (defined THREEFOLD_REPETITION))
newNode->hash = 0;
#endif
#endif
#ifdef DEBUG_AB_TREE
#ifdef HASH_MAP_ENABLE
newNode->isHash = false;
#endif
#endif
#ifdef DEBUG_AB_TREE
newNode->player = player;
@ -696,8 +702,10 @@ int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node)
// 获取哈希值
uint64_t hash = chessTemp.getHash();
#ifdef DEBUG_AB_TREE
node->hash = hash;
#endif
#endif
#ifdef HASH_MAP_ENABLE
// 检索 hashmap
@ -709,7 +717,9 @@ int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node)
if (probeVal != INT32_MIN && node != rootNode) {
hashHitCount++;
#ifdef DEBUG_AB_TREE
node->isHash = true;
#endif
node->value = probeVal;
if (type != hashfEXACT && type != hashfEMPTY) {

View File

@ -61,15 +61,9 @@ public:
int value; // 节点的值
vector<struct Node*> children; // 子节点列表
struct Node* parent; // 父节点
size_t id; // 结点编号
bool pruned; // 是否在此处剪枝
#if ((defined HASH_MAP_ENABLE) || (defined BOOK_LEARNING) || (defined THREEFOLD_REPETITION))
uint64_t hash; // 哈希值
#endif
#ifdef HASH_MAP_ENABLE
bool isHash; // 是否从 Hash 读取
#endif /* HASH_MAP_ENABLE */
#ifdef DEBUG_AB_TREE
size_t id; // 结点编号
string cmd;
enum NineChess::Player player; // 此招是谁下的
int depth; // 深度
@ -86,6 +80,12 @@ public:
int nPiecesNeedRemove; // 手中有多少可去的子,如对手有可去的子则为负数
int result; // 终局结果,-1为负0为未到终局1为胜走棋阶段被闷棋则为 -2/2布局阶段闷棋为 -3
struct Node* root; // 根节点
#ifdef HASH_MAP_ENABLE
bool isHash; // 是否从 Hash 读取
#endif /* HASH_MAP_ENABLE */
#if ((defined HASH_MAP_ENABLE) || (defined BOOK_LEARNING) || (defined THREEFOLD_REPETITION))
uint64_t hash; // 哈希值
#endif
#endif /* DEBUG_AB_TREE */
};