hash: 新增 HASH_MAP_DEBUG 宏可在需要时启用

此宏相关代码尚未完善。
This commit is contained in:
CalciteM Team 2019-08-18 12:40:06 +08:00
parent 50f2530050
commit 7c91e9b6b4
3 changed files with 11 additions and 2 deletions

View File

@ -59,11 +59,12 @@
//define DEEPER_IF_ONLY_ONE_LEGAL_MOVE
#define HASH_MAP_ENABLE
#define CLEAR_HASH_MAP
#ifdef HASH_MAP_ENABLE
#define CLEAR_HASH_MAP
#define HASH_MAP_CUTDOWN
#endif /* HASH_MAP_ENABLE */
//#define HASH_MAP_DEBUG
#endif
#define MEMORY_POOL

View File

@ -53,12 +53,14 @@ NineChessAi_ab::NineChessAi_ab() :
nodeCount(0),
evaluatedNodeCount(0),
#ifdef HASH_MAP_ENABLE
#ifdef HASH_MAP_DEBUG
hashEntryCount(0),
hashHitCount(0),
hashInsertNewCount(0),
hashAddrHitCount(0),
hashReplaceCozDepthCount(0),
hashReplaceCozHashCount(0),
#endif
#endif
requiredQuit(false)
{
@ -834,7 +836,9 @@ int NineChessAi_ab::alphaBetaPruning(depth_t depth, value_t alpha, value_t beta,
value_t probeVal = probeHash(hash, depth, alpha, beta, bestMove, type);
if (probeVal != INT16_MIN /* TODO: valUNKOWN */ && node != rootNode) {
#ifdef HASH_MAP_DEBUG
hashHitCount++;
#endif
#ifdef DEBUG_AB_TREE
node->isHash = true;
#endif
@ -1118,7 +1122,9 @@ const char* NineChessAi_ab::bestMove()
evaluatedNodeCount = 0;
#ifdef HASH_MAP_ENABLE
#ifdef HASH_MAP_DEBUG
qDebug() << "Hash hit count:" << hashHitCount;
#endif
#endif
//qDebug() << "sizeof(Node) = " << sizeof(Node);

View File

@ -248,6 +248,7 @@ private:
size_t evaluatedNodeCount;
#ifdef HASH_MAP_ENABLE
#ifdef HASH_MAP_DEBUG
// Hash 统计数据
size_t hashEntryCount;
size_t hashHitCount;
@ -255,6 +256,7 @@ private:
size_t hashAddrHitCount;
size_t hashReplaceCozDepthCount;
size_t hashReplaceCozHashCount;
#endif
#endif
// 局面数据栈