below the simple implementation of search with transposition table; the result is bad
in some cases it is necessary to disable the use of the table?
any advice?
thank you
G.
Code: Select all
int search(int side, int depth, int alpha, int beta, u64 zobristKey) {
char hashf = hashfALPHA;
int score = -_INFINITE;
Thash * phashe = &hash_array[zobristKey % HASH_SIZE];
if (phashe->zobristKey == zobristKey && phashe->depth >= depth) {
if (phashe->flags == hashfEXACT) {
updatePv(phashe->best);
return phashe->score;
}
else
if (phashe->flags == hashfBETA) {
if (phashe->score >= beta){
updatePv(phashe->best);
return phashe->score;
}
alpha = max(alpha, phashe->score);
}
else if (phashe->flags == hashfALPHA) {
if (phashe->score < alpha){
updatePv(phashe->best);
return phashe->score;
}
beta = min(beta, phashe->score);
}
}
if (depth == 0)
return quiescence();
int n_moves=generateMoves();
Tmove best;
for (ii = 0; ii < n_moves; ii++) {
move = getMoves(ii);
if (ii == 0)
memcpy(&best, move, sizeof(Tmove));
makemove (move);
val = -search(side ^ 1, depth - 1, -beta, -alpha, makeZobristKey());
if (val > score){
memcpy(&best, move, sizeof(Tmove));
score = val;
}
takeback(move);
if (score >= beta) {
storeHash(depth, hashfBETA, zobristKey, score, move);
return score;
}
if (score > alpha) {
hashf = hashfEXACT;
memcpy(&best, move, sizeof(Tmove));
updatePv(mossa);
}
}
storeHash(depth, hashf, zobristKey, score, &best);
return score;
}