HASH: 下第二盘时不明原因变慢故新开局时清除哈希表 (WAR)

This commit is contained in:
CalciteM Team 2019-07-14 21:53:12 +08:00
parent e4ea2851c2
commit 3bf5381afd
3 changed files with 8 additions and 4 deletions

View File

@ -35,7 +35,8 @@ void AiThread::setAi(const NineChess &chess)
ai_ab.setChess(*(this->chess_));
#ifdef HASH_MAP_ENABLE
//ai_ab.clearHashMap();
// TODO: 下第二盘时不明原因变慢,临时方案为清除哈希表
ai_ab.clearHashMap();
#endif
mutex.unlock();

View File

@ -97,16 +97,19 @@ namespace CTSL //Concurrent Thread Safe Library
#endif
}
#ifndef DISABLE_HASHBUCKET
//Function to clean up the hasp map, i.e., remove all entries from it
void clear()
{
#ifdef DISABLE_HASHBUCKET
memset(hashTable, 0, sizeof(HashNode<K, V>) * hashSize);
#else
for(size_t i = 0; i < hashSize; i++)
{
(hashTable[i]).clear();
}
}
#endif
}
private:
#ifdef DISABLE_HASHBUCKET

View File

@ -1007,7 +1007,7 @@ int NineChessAi_ab::recordHash(int value, int alpha, int beta, int depth, HashTy
void NineChessAi_ab::clearHashMap()
{
//hashMapMutex.lock();
//hashmap.clear();
hashmap.clear();
//hashMapMutex.unlock();
}
#endif /* HASH_MAP_ENABLE */