From 28b9a262cc2268a906f318197bb726d821d06410 Mon Sep 17 00:00:00 2001 From: Mattia Giambirtone Date: Sat, 27 Apr 2024 11:12:13 +0200 Subject: [PATCH] Add specialized .gitignore --- .gitignore | 4 ---- Chess/.gitignore | 12 ++++++++++ Chess/nimfish/nimfishpkg/search.nim | 36 ++++++++++++++--------------- 3 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 Chess/.gitignore diff --git a/.gitignore b/.gitignore index d383900..9698220 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,3 @@ nimcache/ nimblecache/ htmldocs/ bin -Chess/nimfish/nimfishpkg/resources/Pohl.epd -Chess/nimfish/nimfishpkg/resources/*.pgn -# Python -__pycache__ diff --git a/Chess/.gitignore b/Chess/.gitignore new file mode 100644 index 0000000..e08faa4 --- /dev/null +++ b/Chess/.gitignore @@ -0,0 +1,12 @@ +# ---> Nim +nimcache/ +nimblecache/ +htmldocs/ +bin +nimfish/nimfishpkg/resources/*.epd +nimfish/nimfishpkg/resources/*.pgn +# Python +__pycache__ +fast-chess +log.txt +config.json \ No newline at end of file diff --git a/Chess/nimfish/nimfishpkg/search.nim b/Chess/nimfish/nimfishpkg/search.nim index 6b130d6..a85ce42 100644 --- a/Chess/nimfish/nimfishpkg/search.nim +++ b/Chess/nimfish/nimfishpkg/search.nim @@ -198,18 +198,19 @@ proc search(self: SearchManager, depth, ply: int, alpha, beta: Score): Score {.d ## Simple negamax search with alpha-beta pruning if self.shouldStop(): return - let query = self.transpositionTable.get(self.board.position.zobristKey, depth.uint8) - if query.success: - case query.entry.flag: - 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 + # let query = self.transpositionTable.get(self.board.position.zobristKey, depth.uint8) + # if query.success: + # case query.entry.flag: + # 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 if depth == 0: + # Quiescent search gain: 264.8 +/- 71.6 return self.qsearch(0, alpha, beta) var moves = newMoveList() var depth = depth @@ -231,13 +232,12 @@ proc search(self: SearchManager, depth, ply: int, alpha, beta: Score): Score {.d if ply == 0 and self.searchMoves.len() > 0 and move notin self.searchMoves: continue self.board.doMove(move) - var extension = self.getSearchExtension(move) - let zobrist = self.board.position.zobristKey + # var extension = self.getSearchExtension(move) inc(self.nodeCount) # Find the best move for us (worst move # for our opponent, hence the negative sign) var score: Score - var fullDepth = true + #[var fullDepth = true if extension == 0 and i >= 3 and not move.isCapture(): # Late Move Reduction: assume our move orderer did a good job, # so it is not worth to look at all moves at the same depth equally. @@ -245,9 +245,9 @@ proc search(self: SearchManager, depth, ply: int, alpha, beta: Score): Score {.d # it at full depth const reduction = 1 score = -self.search(depth - 1 - reduction, ply + 1, -beta, -alpha) - fullDepth = score > alpha - if fullDepth: - score = -self.search(depth - 1 + extension, ply + 1, -beta, -alpha) + fullDepth = score > alpha]# + #if fullDepth: + score = -self.search(depth - 1 #[+ extension]#, ply + 1, -beta, -alpha) if self.board.position.halfMoveClock >= 100 or self.board.position.repetitionDraw: # Drawing by repetition is *bad* score = Score(0) @@ -259,7 +259,7 @@ proc search(self: SearchManager, depth, ply: int, alpha, beta: Score): Score {.d return bestScore = max(score, bestScore) let nodeType = if score >= beta: LowerBound elif score <= alpha: UpperBound else: Exact - self.transpositionTable.store(depth.uint8, score, zobrist, nodeType) + # self.transpositionTable.store(depth.uint8, score, self.board.position.zobristKey, nodeType) if nodeType == LowerBound: # score >= beta # This move was too good for us, opponent will not search it