Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: IsCapture is not set when an en passant move is manually constructed #445

Open
DrBrask opened this issue Aug 10, 2023 · 1 comment
Open

Comments

@DrBrask
Copy link

DrBrask commented Aug 10, 2023

IsCapture is not set when an en passant move is manually constructed.

This seems to be because the underlying MoveHelper.CreateMoveFromName(...) method doesn't set the captureType for en passant moves.

Here is an example from the test below.

Since EnPassant is true, IsCapture should also be true but it is not.
image

The result is that a manually created EP Move instance does not match what the move generator produces
because Move.Equals says they are different.

Here is a xUnit test:

[Fact]
public void EnPassantTest()
{
    var internalBoard = new ChessChallenge.Chess.Board();
    internalBoard.LoadPosition("1q5k/8/8/3pP3/8/6K1/8/8 w - d6 2 4");
    var board = new Board(internalBoard);
    
    var moves = board.GetLegalMoves();

    // Expect to find e5d6 (EP move)
    var expected = new Move("e5d6", board);   // BUG: This constructor fails to set captureType correctly

    // This fails because "IsCapture" is not set correctly in 'expected'
    Assert.Contains(expected, moves);
}

The correctly generated Move from the move generator looks like this:
image

Position used:
1q5k/8/8/3pP3/8/6K1/8/8 w - d6 2 4

cc @SebLague

DrBrask pushed a commit to DrBrask/Chess-Challenge that referenced this issue Aug 12, 2023
@DrBrask
Copy link
Author

DrBrask commented Aug 13, 2023

Fixed by #447

VitorA29 added a commit to VitorA29/Chess-Challenge that referenced this issue Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant