in the search

Code: Select all

```
// TTable lookup
U64 key = get_key(B);
const TTEntry *tte = tt_find(key);
move_t tt_move;
if (tte) {
si->best = tt_move = tte->depth > 0 ? tte->move : NoMove;
current_eval = tte->eval;
if (ply > 0 && can_return_tt(is_pv, tte, depth, beta, ply))
return adjust_tt_score(tte->score, ply);
}
```

Code: Select all

```
// TTable lookup
U64 key = get_key(B);
const TTEntry *tte = tt_find(key);
move_t tt_move;
int current_eval;
if (tte) {
si->best = tt_move = tte->move;
current_eval = tte->eval;
if (can_return_tt(is_pv, tte, depth, beta, ply))
return adjust_tt_score(tte->score, ply);
}
```

Code: Select all

```
static inline bool can_return_tt(bool is_pv, const TTEntry *tte, int depth, int beta, int ply)
{
if (is_pv)
return tte->depth >= depth && tte->type == ScoreExact;
else {
const int tt_score = adjust_tt_score(tte->score, ply);
return (tte->depth >= depth
|| tt_score >= max(mate_in(MAX_PLY), beta)
|| tt_score < min(mated_in(MAX_PLY), beta))
&& ((tte->type == ScoreLbound && tt_score >= beta)
||(tte->type == ScoreUbound && tt_score < beta));
}
}
```

Any suggestions are welcome!

PS: Of course I check for repetition draws (search and qsearch) *before* the TTable blocks shown above