     public private(set) var halfmoves: UInt
 
     /// The target move location for an en passant.
-    public var enPassantTarget: Square? {
-        guard let (move, piece, _, _, _, _) = _moveHistory.last else { return nil }
-        guard piece.kind.isPawn && abs(move.rankChange) == 2 else { return nil }
-        return Square(file: move.start.file, rank: move.isUpward ? 3 : 6)
-    }
+    public private(set) var enPassantTarget: Square?
 
     /// The captured piece for the last move.
     public var captureForLastMove: Piece? {

                board[rook][new] = true
            }
        }
        _moveHistory.append((move, piece, capture, attackersToKing, halfmoves, rights))
        if let capture = capture {
            board[capture][captureSquare] = false
        }


    #if swift(>=3)

    /// An error in position validation.
    public enum PositionError: ErrorProtocol {

        /// Found number other than 1 for king count.
        case wrongKingCount(Color)

        /// King missing for castling right.
        case missingKing(CastlingRights.Right)

        /// Rook missing for castling right.
        case missingRook(CastlingRights.Right)

        /// Wrong rank for en passant target.
        case wrongEnPassantTargetRank(Rank)

        /// Non empty en passant target square.
        case nonEmptyEnPassantTarget(Square, Piece)

        /// Pawn missing for previous en passant.
        case missingEnPassantPawn(Square)

        /// Piece found at start of en passant move.
        case nonEmptyEnPassantSquare(Square, Piece)

    }

    /// An error in move execution.
    ///
    /// Thrown by the `execute(move:promotion:)` or `execute(uncheckedMove:promotion:)` method for a `Game` instance.
