diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-24 16:42:35 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-24 16:42:35 +0100 |
| commit | 90050da015f3988ab3188eb19629aed262454fef (patch) | |
| tree | b63fadc9b4cf15cc4bc80f06c6e5102e24438f83 | |
| parent | 975ad849d1d1474e601ad2f4bf48ea0e4405251c (diff) | |
Debug pawns moves
| -rw-r--r-- | src/ChessArbiter.cpp | 14 | ||||
| -rw-r--r-- | tests/chessarbiter.cpp | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/ChessArbiter.cpp b/src/ChessArbiter.cpp index 57f280f..fe83662 100644 --- a/src/ChessArbiter.cpp +++ b/src/ChessArbiter.cpp @@ -309,12 +309,16 @@ std::vector<std::string> ChessArbiter::ListLegalMoves(bool isBlack) { bool IsDstEmpty = board.IsEmpty(dst); // Pawns side moves - if ((srcp.piece == 'p' || srcp.piece == 'P') && (src[0] != dst[0])) { - if (!IsDstEmpty) { - Piece attacked = board.GetPieceAt(dst); - if (srcp.isBlack != attacked.isBlack) + if (srcp.piece == 'p' || srcp.piece == 'P') { + if ((src[0] != dst[0])) { + if (!IsDstEmpty) { + Piece attacked = board.GetPieceAt(dst); + if (srcp.isBlack != attacked.isBlack) + moves.push_back(move); + } else if (dst == fen.en_passant) { moves.push_back(move); - } else if (dst == fen.en_passant) { + } + } else if (IsDstEmpty) { moves.push_back(move); } } else { diff --git a/tests/chessarbiter.cpp b/tests/chessarbiter.cpp index 354f3f1..868ea2c 100644 --- a/tests/chessarbiter.cpp +++ b/tests/chessarbiter.cpp @@ -450,4 +450,7 @@ TEST_CASE("ParseSAN", "[ParseSAN]") { a.Setup( "r1bq1rk1/p4ppp/2p2n2/1pbPp3/3n4/P1NB3P/1PPP1PPN/R1BQ1RK1 b - - 0 10"); CHECK(a.ParseSAN("exd5") == "c6d5"); + + a.Setup("rnbqkbnr/pp3ppp/4p3/2pp4/3PP3/8/PPPN1PPP/R1BQKBNR w KQkq - 0 4"); + CHECK(a.ParseSAN("exd5") == "e4d5"); } |
