-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransposition.cpp
executable file
·62 lines (45 loc) · 1.49 KB
/
transposition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "engine.h"
using namespace std;
int engine::ProbeHash(int Depth, int Alpha, int Beta, vector<move>& Line)
{
bitboard Key = Position.Hash();
pos_info* phashe = &TranspositionTable[ Key % zobrist(TRANSPOSITION_TABLE_SIZE) ];
if( phashe->Key == Key ) {
//Line[ SearchDepth - Depth ] = phashe->Best;
if( !phashe->Best.IsValid() ) return VAL_UNKNOWN;
if (phashe->Depth >= Depth){
Line[ HorizonDepth - Depth ] = phashe->Best;
if (phashe->Flags == HashFlagEXACT)
return phashe->Val;
if ((phashe->Flags == HashFlagALPHA) && (phashe->Val <= Alpha))
return Alpha;
if ((phashe->Flags == HashFlagBETA) && (phashe->Val >= Beta))
return Beta;
}else{
return VAL_UNKNOWN;
}
//RememberBestMove();
}
return VAL_UNKNOWN;
}
void engine::RecordHash(int Depth, int Val, int Flags, move& Move)
{
if( !Move.IsValid() ) return;
bitboard Key = Position.Hash();
pos_info* phashe = &TranspositionTable[ Key % zobrist(TRANSPOSITION_TABLE_SIZE) ];
phashe->Key = Key;
phashe->Val = Val;
phashe->Flags = Flags;
phashe->Depth = Depth;
phashe->Best = Move;
}
move engine::GetTableMove(){
bitboard Key = Position.Hash();
pos_info* phashe = &TranspositionTable[ Key % zobrist(TRANSPOSITION_TABLE_SIZE) ];
if( phashe->Key == Key ) return phashe->Best;
return move();
}
void engine::DeleteBoardFromTable(){
bitboard Key = Position.Hash();
TranspositionTable[ Key % zobrist(TRANSPOSITION_TABLE_SIZE) ] = pos_info();
}