Geras1mleo / Chess

C# .NET 6.0 Chess Library
MIT License
49 stars 15 forks source link

Checkmate not being recognized #17

Closed brane-games closed 1 year ago

brane-games commented 1 year ago

Describe the bug In a position achieved via the given PGN, a checkmate isn't recognized. It recognizes this as just a check

To Reproduce `// "1. e3 e5 2. d4 e4 3. Nf3 exf3 4. Qxf3 d5 5. Qxf7+ Kxf7 6. e4 Nc6 7. exd5 Qxd5 8. c4 Qe4+ 9. Kd1 Nxd4 10. Bd3 Qxd3+ 11. Ke1 Be7 12. Nc3 Nc2+";

        var listOfMoves = new List<string>() { 
            "e2e3", "e7e5", "d2d4", "e5e4", "g1f3", "exf3", 
            "d1f3", "d7d5", "f3f7", "e8f7", "e3e4", "b8c6", 
            "e4d5", "d8d5", "c2c4", "d5e4", "e1d1", "c6d4",
            "f1d3", "e4d3", "d1e1", "f8e7", "b1c3", "d4c2"};
        var board = ChessBoard.LoadFromFen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
        foreach (var moveInfo in listOfMoves)
        {
            board.Move(moveInfo);
        }
        Assert.True(board.IsEndGame);`

Expected behaviour board.IsEndGame returns true

Additional context Working on a game and this is a legitimate position I got while playing against AI. Needless to say the whole game just stopped in this moment as Checkmate wasn't flagged and I couldn't move 😀

brane-games commented 1 year ago

I forked the repo and started fixing it just to realize it's already fixed! So...when is the next version dropping? 😅

P.S. I'm making a chess game I think is really cool and your awesome library is one of the cornerstones: https://store.steampowered.com/app/2248900/Master_of_Chess

Geras1mleo commented 1 year ago

I forked the repo and started fixing it just to realize it's already fixed! So...when is the next version dropping? 😅

P.S. I'm making a chess game I think is really cool and your awesome library is one of the cornerstones: https://store.steampowered.com/app/2248900/Master_of_Chess

Looks very good!