dartchess icon indicating copy to clipboard operation
dartchess copied to clipboard

Bug in Castling?

Open topse opened this issue 11 months ago • 0 comments

Hi,

Library Version: dartchess: ^0.6.1

I am using the following test-code to query the allowed moves of the king:

    String fen =
        "rnbqk2r/ppppbppp/4p1N1/4P3/8/B7/PPPPBPPP/RN1QK2R w KQkq - 0 1";
    final chess = Chess.fromSetup(Setup.parseFen(fen));

    SquareSet set = chess.legalMovesOf(Squares.e1);
    for (var element in set.squares) {
      developer.log(element.toString());
    }
    Iterable<Square> squares = set.squares;
    expect(squares.length, 2);
    expect(squares.first, Squares.f1);
    expect(squares.last, Squares.g1);

Expected: King has two fields, f1 and g1 (in case of castling). Problem: legalMovesOf gives back the fields f1 and h1, which seems to be odd?

When executing a move, it is possible to execute the move chess.play(NormalMove(from: Squares.e1, to: Squares.g1));, which again seems to be odd, as g1 is not recognized as a legal move.

Best Regards, Tobias

topse avatar Mar 07 '24 11:03 topse