     /// The current halfmove clock.
     public var halfmoves: UInt {
         var n: UInt = 0
-        for (_, piece, capture) in _moveHistory.reverse() {
+        for (_, piece, capture, _) in _moveHistory.reverse() {
             if capture != nil { break }
             if case .Pawn = piece { break }
             n += 1


    /// The target move location for an en passant.
    public var enPassantTarget: Square? {
        guard let (move, piece, _) = _moveHistory.last, case .Pawn = piece else {
            return nil
        }
        guard abs(move.rankChange) == 2 else {


    /// Undoes the previous move and returns it, if any.
    public func undoMove() -> Move? {
        guard let (move, piece, capture, attackers) = _moveHistory.popLast() else {
            return nil
        }
        var captureSquare = move.end
