hash: 哈希表大小由64M调小为32M

* g++ 编译后运行不再提示 std::bad_alloc
* 运行速度反而提升 5%
This commit is contained in:
CalciteM Team 2019-08-01 22:50:09 +08:00
parent 8d050479fd
commit 3e5c856d86
1 changed files with 20 additions and 20 deletions

View File

@ -34,7 +34,7 @@
using namespace CTSL;
#ifdef HASH_MAP_ENABLE
static constexpr int hashsize = 0x4000000; // 8-128M:102s, 4-64M:93s 2-32M:91s 1-16M: 冲突
static constexpr int hashsize = 0x2000000; // 8-128M:102s, 4-64M:93s 2-32M:91s 1-16M: 冲突
HashMap<uint64_t, NineChessAi_ab::HashValue> hashmap(hashsize);
#endif // HASH_MAP_ENABLE
@ -1026,20 +1026,20 @@ int NineChessAi_ab::probeHash(uint64_t hash, int depth, int alpha, int beta, int
type = hashValue.type;
if (hashValue.type == hashfEXACT) {
return hashValue.value;
}
if ((hashValue.type == hashfALPHA) && // 最多是 hashValue.value
(hashValue.value <= alpha)) {
return alpha;
}
if ((hashValue.type == hashfBETA) && // 至少是 hashValue.value
(hashValue.value >= beta)) {
return beta;
if (hashValue.type == hashfEXACT) {
return hashValue.value;
}
if ((hashValue.type == hashfALPHA) && // 最多是 hashValue.value
(hashValue.value <= alpha)) {
return alpha;
}
if ((hashValue.type == hashfBETA) && // 至少是 hashValue.value
(hashValue.value >= beta)) {
return beta;
}
out:
bestMove = hashValue.bestMove;
out:
bestMove = hashValue.bestMove;
return valUNKNOWN;
}
@ -1081,13 +1081,13 @@ int NineChessAi_ab::recordHash(int value, int depth, HashType type, uint64_t has
HashValue hashValue;
memset(&hashValue, 0, sizeof(HashValue));
if (findHash(hash, hashValue) &&
hashValue.type != hashfEMPTY &&
hashValue.depth > depth) {
#ifdef DEBUG_MODE
qDebug() << "Skip recordHash coz depth";
#endif
return -1;
if (findHash(hash, hashValue) &&
hashValue.type != hashfEMPTY &&
hashValue.depth > depth) {
#ifdef DEBUG_MODE
qDebug() << "Skip recordHash coz depth";
#endif
return -1;
}
hashValue.value = value;