Closed jongdetim closed 10 months ago
For completeness sake, I call it in my search function like this:
if (depth == 0 || board.IsCheckmate() || board.IsDraw())
# handle leaf node
isDraw
callls isRepeatedPosition
so it should test for repeated positionsThis is frustrating, as I can't work on this challenge if it's impossible te check whether a game is drawn or not
My best guess is that the issue arises when the first node in your search is the root node / current board state, rather than all the possible moves from that state. This means the root node / current board state is seen multiple times during search, without the move being "undone". However, implementing minimax with a PV table is silly without starting search from the root node... because we can store the best move in the transposition table entry associated with the parent node, among other reasons. How can I avoid revisits of the same state during iterative deepening search being recognized als repetitions of that state? The solution seems to be to only check if a state is a repetition, when a move is being made tó that state.
Well, i just realized there were 2 patches regarding repetition checks, 1.19 and 1.20, and i was still running version 1.18... oops! I'll merge the changes and hopefully that should resolve it.
I can confirm this issue was fixed in version 1.20
With the current implementation of board.IsDraw() it is not possible to check if the game is drawn due to threefold repetition. This is because of a choice made regarding the mentioned function:
However, this means that it's not possible to check for actual threefold repetitions, and my bot stops exploring lines that involve repeated positions, since it think it's a draw. If the first node (current board state) of the search is seen twice, it's recognized as a draw, the search ends and returns NullMove, since there are no legal moves. To the game logic engine, the game is not finished, since the position has only occurred twice.
Using this FEN: 5K1k/Rr6/6PP/8/8/8/8/8 b - - 18 81 My bot is black, and plays Rb8+, after which i play Kf7. Black plays Rb7, and when I then play Kf8, for some reason it doesn't consider the position drawn for a maxdepth = 1 search, but in any further (deeper) searches, the position in the FEN is recognized as drawn.
Solution: board.IsDraw() should return whether the current board state is a draw. This was the previous behavior, but was changed in version 1.17, but I don't understand why. The bot wouldn't search repeating position unnecessarily, since it recognizes the 3rd occurrence as a draw by repetition. Instead, the bot now considers every repeating move a draw.