ChessLib icon indicating copy to clipboard operation
ChessLib copied to clipboard

Position.IsLegal(Move) returns true for many moves that are not legal

Open primitiveType opened this issue 1 year ago • 1 comments

Perhaps there's a different endpoint I should be using to determine whether a move is legal. But when developing a UI with this library, I need a way to determine whether a player-input move is legal. This function sounds like the right one, however it only checks for specific illegal moves- it doesn't check for instance whether the position the piece is moving to is within its capabilities. For instance, I can move a pawn sideways.

I would expect the following test to pass:

    public void MoveIsLegal()
    {
        var illegalMove = Move.Create(Square.F2, Square.F6);

        // construct game and start a new game
        var game = GameFactory.Create(Fen.Fen.StartPositionFen);
        var position = game.Pos;
        var state = new State();

        // verify in check is actually true
        Assert.False(position.IsLegal(illegalMove));
    }

primitiveType avatar Apr 23 '23 17:04 primitiveType