X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=b9a8bf8bf26f47d365eb70110714ca9846fd1937;hp=c24d5675d8c1dadbb1de958a5fdd65c276a02be7;hb=214f9dcc278dd322b94f4922924219a970b95009;hpb=aaad48464bc8a269634de371238826d09a6e240d diff --git a/src/position.cpp b/src/position.cpp index c24d5675..b9a8bf8b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -60,11 +60,11 @@ static bool RequestPending = false; /// Constructors -Position::Position(const Position &pos) { +Position::Position(const Position& pos) { copy(pos); } -Position::Position(const std::string &fen) { +Position::Position(const std::string& fen) { from_fen(fen); } @@ -73,7 +73,7 @@ Position::Position(const std::string &fen) { /// string. This function is not very robust - make sure that input FENs are /// correct (this is assumed to be the responsibility of the GUI). -void Position::from_fen(const std::string &fen) { +void Position::from_fen(const std::string& fen) { static const std::string pieceLetters = "KQRBNPkqrbnp"; static const Piece pieces[] = { WK, WQ, WR, WB, WN, WP, BK, BQ, BR, BB, BN, BP }; @@ -1626,6 +1626,21 @@ int Position::see(Square from, Square to) const { // Find all attackers to the destination square, with the moving piece // removed, but possibly an X-ray attacker added behind it. occ = occupied_squares(); + + // Handle enpassant moves + if (ep_square() == to && type_of_piece_on(from) == PAWN) + { + assert(capture == EMPTY); + + Square capQq = (side_to_move() == WHITE)? (to - DELTA_N) : (to - DELTA_S); + capture = piece_on(capQq); + + assert(type_of_piece_on(capQq) == PAWN); + + // Remove the captured pawn + clear_bit(&occ, capQq); + } + while (true) { clear_bit(&occ, from); @@ -1952,7 +1967,7 @@ Value Position::compute_non_pawn_material(Color c) const { /// side to move is checkmated. Note that this function is currently very /// slow, and shouldn't be used frequently inside the search. -bool Position::is_mate() { +bool Position::is_mate() const { if (is_check()) {