Skip to content

Commit

Permalink
Fix mistake with TT
Browse files Browse the repository at this point in the history
Bench: 1033376
  • Loading branch information
Dannyj1 committed Dec 13, 2023
1 parent d1b5c68 commit cbafad2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace Zagreus {
MoveListPool* moveListPool = MoveListPool::getInstance();
TranspositionTable* tt = tt;
TranspositionTable* tt = TranspositionTable::getTT();

template <PieceColor color>
Move getBestMove(senjo::GoParams params, ZagreusEngine& engine, Bitboard& board,
Expand Down Expand Up @@ -132,8 +132,7 @@ int search(Bitboard& board, int alpha, int beta, int16_t depth, Move& previousMo
}

if (!IS_PV_NODE) {
int ttScore = tt->getScore(board.getZobristHash(), depth, alpha,
beta);
int ttScore = tt->getScore(board.getZobristHash(), depth, alpha, beta);

if (ttScore != INT32_MIN) {
return ttScore;
Expand Down Expand Up @@ -233,6 +232,7 @@ int qsearch(Bitboard& board, int alpha, int beta, int16_t depth, Move& previousM
SearchContext& context,
senjo::SearchStats& searchStats) {
constexpr PieceColor OPPOSITE_COLOR = color == WHITE ? BLACK : WHITE;
constexpr TTNodeType IS_PV_NODE = nodeType == PV ? EXACT_NODE : FAIL_LOW_NODE;

if (board.isDraw()) {
return DRAW_SCORE;
Expand All @@ -243,6 +243,15 @@ int qsearch(Bitboard& board, int alpha, int beta, int16_t depth, Move& previousM
return beta;
}

if (!IS_PV_NODE) {
int ttScore = TranspositionTable::getTT()->getScore(board.getZobristHash(), depth, alpha,
beta);

if (ttScore != INT32_MIN) {
return ttScore;
}
}

searchStats.qnodes += 1;

bool inCheck = board.isKingInCheck<color>();
Expand Down Expand Up @@ -307,8 +316,7 @@ int qsearch(Bitboard& board, int alpha, int beta, int16_t depth, Move& previousM

if (score > alpha) {
if (score >= beta) {
moveListPool->releaseMoveList(moves);
// tt->addPosition(board.getZobristHash(), depth, score, FAIL_HIGH_NODE, 0);
moveListPool->releaseMoveList(moves);;
return beta;
}

Expand Down

0 comments on commit cbafad2

Please sign in to comment.