From b3a763941b81f5e894427ad7339dc6aca76df813 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Tue, 31 Jan 2023 00:43:09 +0800 Subject: [PATCH] Check if game is over when parsing fen to position It can solve the problem that after tapping Move Now after this kind of FEN import, AI can't do 2 move in a row. (when specific settings are turned on) **@@@@**/**@OO@**/**@OO@** w m s 4 0 8 0 1 0 0 1 **@@@@**/**@OO@**/**@OO@** w m s 4 0 8 0 0 0 0 1 But it still can't be solved for the following FEN. **@@@@**/**@OO@**/**@OO@** w m r 4 0 8 0 1 0 0 1 Change-Id: Id30a2ca6e81de687a882f1b9aaaf5c596cd243f3 --- src/position.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/position.cpp b/src/position.cpp index edcb206ca..39f1eea96 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -377,6 +377,16 @@ Position &Position::set(const string &fenStr, Thread *th) // handle also common incorrect FEN with fullmove = 0. gamePly = std::max(2 * (gamePly - 1), 0) + (sideToMove == BLACK); + // For Mill only + check_if_game_is_over(); +#if 0 + // It doesn't work + if (pieceToRemoveCount[sideToMove] == 1) { + action = Action::remove; + isStalemateRemoving = true; + } +#endif + thisThread = th; return *this;