Remove useTT compile time flag
This commit is contained in:
parent
5100bc744c
commit
d5f3071733
|
@ -73,10 +73,9 @@ proc getEstimatedMoveScore(self: SearchManager, move: Move): Score =
|
||||||
nonSideToMove = sideToMove.opposite()
|
nonSideToMove = sideToMove.opposite()
|
||||||
if self.previousBestMove != nullMove() and move == self.previousBestMove:
|
if self.previousBestMove != nullMove() and move == self.previousBestMove:
|
||||||
return highestEval() + 1
|
return highestEval() + 1
|
||||||
when defined(useTT):
|
let query = self.transpositionTable.get(self.board.position.zobristKey)
|
||||||
let query = self.transpositionTable.get(self.board.position.zobristKey)
|
if query.success and query.entry.bestMove != nullMove() and query.entry.bestMove == move:
|
||||||
if query.success and query.entry.bestMove != nullMove() and query.entry.bestMove == move:
|
return highestEval() + 1
|
||||||
return highestEval() + 1
|
|
||||||
if move.isCapture():
|
if move.isCapture():
|
||||||
# Implementation of MVVLVA: Most Valuable Victim Least Valuable Attacker
|
# Implementation of MVVLVA: Most Valuable Victim Least Valuable Attacker
|
||||||
# We prioritize moves that capture the most valuable pieces, and as a
|
# We prioritize moves that capture the most valuable pieces, and as a
|
||||||
|
@ -223,19 +222,18 @@ proc search(self: SearchManager, depth, ply: int, alpha, beta: Score): Score {.d
|
||||||
# one because then we wouldn't have a move to return.
|
# one because then we wouldn't have a move to return.
|
||||||
# In practice this should not be a problem
|
# In practice this should not be a problem
|
||||||
return
|
return
|
||||||
when defined(useTT):
|
if ply > 0:
|
||||||
if ply > 0:
|
let query = self.transpositionTable.get(self.board.position.zobristKey, depth.uint8)
|
||||||
let query = self.transpositionTable.get(self.board.position.zobristKey, depth.uint8)
|
if query.success:
|
||||||
if query.success:
|
case query.entry.flag:
|
||||||
case query.entry.flag:
|
of Exact:
|
||||||
of Exact:
|
return query.entry.score
|
||||||
|
of LowerBound:
|
||||||
|
if query.entry.score >= beta:
|
||||||
|
return query.entry.score
|
||||||
|
of UpperBound:
|
||||||
|
if query.entry.score <= alpha:
|
||||||
return query.entry.score
|
return query.entry.score
|
||||||
of LowerBound:
|
|
||||||
if query.entry.score >= beta:
|
|
||||||
return query.entry.score
|
|
||||||
of UpperBound:
|
|
||||||
if query.entry.score <= alpha:
|
|
||||||
return query.entry.score
|
|
||||||
if self.board.drawnByRepetition():
|
if self.board.drawnByRepetition():
|
||||||
return Score(0)
|
return Score(0)
|
||||||
if depth == 0:
|
if depth == 0:
|
||||||
|
@ -299,9 +297,8 @@ proc search(self: SearchManager, depth, ply: int, alpha, beta: Score): Score {.d
|
||||||
if ply == 0:
|
if ply == 0:
|
||||||
self.bestMoveRoot = move
|
self.bestMoveRoot = move
|
||||||
self.bestRootScore = bestScore
|
self.bestRootScore = bestScore
|
||||||
when defined(useTT):
|
let nodeType = if bestScore >= beta: LowerBound elif bestScore <= alpha: UpperBound else: Exact
|
||||||
let nodeType = if bestScore >= beta: LowerBound elif bestScore <= alpha: UpperBound else: Exact
|
self.transpositionTable.store(depth.uint8, bestScore, self.board.position.zobristKey, bestMove, nodeType)
|
||||||
self.transpositionTable.store(depth.uint8, bestScore, self.board.position.zobristKey, bestMove, nodeType)
|
|
||||||
|
|
||||||
return bestScore
|
return bestScore
|
||||||
|
|
||||||
|
|
|
@ -353,11 +353,10 @@ proc startUCISession* =
|
||||||
of NewGame:
|
of NewGame:
|
||||||
session.board = newDefaultChessboard()
|
session.board = newDefaultChessboard()
|
||||||
of Go:
|
of Go:
|
||||||
when defined(useTT):
|
if session.transpositionTable.isNil() or session.transpositionTable.size() == 0:
|
||||||
if session.transpositionTable.isNil() or session.transpositionTable.size() == 0:
|
session.transpositionTable = newTranspositionTable(session.hashTableSize * 1024 * 1024)
|
||||||
session.transpositionTable = newTranspositionTable(session.hashTableSize * 1024 * 1024)
|
if session.debug:
|
||||||
if session.debug:
|
echo &"info string created {session.hashTableSize} MiB TT"
|
||||||
echo &"info string created {session.hashTableSize} MiB TT"
|
|
||||||
session.searchThread = new Thread[tuple[session: UCISession, command: UCICommand]]
|
session.searchThread = new Thread[tuple[session: UCISession, command: UCICommand]]
|
||||||
createThread(session.searchThread[], bestMove, (session, cmd))
|
createThread(session.searchThread[], bestMove, (session, cmd))
|
||||||
if session.debug:
|
if session.debug:
|
||||||
|
|
Loading…
Reference in New Issue