added Transposition tables
This commit is contained in:
1 parent
2e984643c0
commit
7c4fbc1f6d
4 files changed
+93
-15
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
static U64 initialSeed = 0x60919C48E57863B9;
|
||||
|
||||
TTEntry TTable[hashSize];
|
||||
|
||||
// 2[colors] * 6[pieces] * 64[squares]
|
||||
U64 zKeys[2][6][64];
|
||||
|
||||
@@ -76,3 +78,31 @@ U64 GetHashKey(Board &board) {
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
int ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
|
||||
TTEntry *current = &TTable[hashKey % hashSize];
|
||||
|
||||
if (current->hashKey == hashKey) {
|
||||
if (current->depth >= depth) {
|
||||
if (current->nodeType == PV){
|
||||
return current->score;
|
||||
} else if (current->nodeType == AllNode && current->score <= alpha) {
|
||||
return alpha;
|
||||
} else if (current->nodeType == CutNode && current->score >= beta) {
|
||||
return beta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returning unknown value
|
||||
return 10000;
|
||||
}
|
||||
|
||||
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType) {
|
||||
TTEntry *current = &TTable[hashKey % hashSize];
|
||||
|
||||
current->hashKey = hashKey;
|
||||
current->nodeType = nodeType;
|
||||
current->score = score;
|
||||
current->depth = depth;
|
||||
}
|
||||
Reference in new issue
Block a user