Closed BimmerBass closed 3 years ago
Alright, I have gotten it down to one game out of 150. The fen is: 8/2B5/2p2k2/3p3p/b2P1K1P/5N2/5r2/4R3 b - - 3 43. Here Loki suggests the move f4f3. PGN: [Event "test"] [Site ""] [Date "2021.02.23"] [Round "58"] [White "Loki 1.0.2"] [Black "Loki 1.1.0"] [Result "1-0"] [WhiteElo "?"] [BlackElo "?"] [Variant "Standard"] [TimeControl "-"] [ECO "E36"] [Opening "Nimzo-Indian Defense: Classical Variation, Noa Variation, Botvinnik Variation"] [Termination "Illegal move"] [Annotator ""]
It still isn't reproducible by just entering the fen and searching, so i assume that it is a bug with the transposition table. Loki still passes perft tests.
The problem seems to have been fixed by adding new PRNG for the hashkeys, and re-setting the SearchPv when probing the transposition table.
Alright, after having disabled all search optimizations (not move ordering heuristics) including use of transposition table and hash move ordering, Loki now only makes legal moves. I then tested a match between a version using transposition table and one that does not: The version not using tt seems to not make illegal moves, which suggests that it is the transposition table that is the cause of the bug.
The problem seemed to be caused by the UCI functions parse_position and parse_perft taking the input string as std::string instead of char. Because I passed a char this might've shortened the input string. The problem now seems to be fixed (with transposition table), but I will first push the change when I'm done testing strength increases for pruning and reductions.
Loki sometimes suggests illegal moves that are part of the PV, but I recently noticed that it also gives illegal moves in the "bestmove" uci command. The particular position is: 8/6R1/5k2/8/8/6PK/5P2/2r5 w - - 1 50 Here Loki played white and suggested f6g7 (SAN: Kxg7) when it had little time left. Weirdly enough, I haven't been able to reproduce it after that, but I suspect it is because Loki made a mistake and only displayed black's response to its suggested best move for white.
I say this because it passes all perft tests, so there isn't a problem with the move generation, but rather it is the search function where the problem is.