### Create Standard Chess Board Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Initializes a new ChessKit Board object with the standard chess starting position. ```swift let board = Board() ``` -------------------------------- ### Move Piece on Board Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Moves a chess piece on the board from a starting square to a destination square. This operation updates the board state. ```swift let board = Board() // move pawn at e2 to e4 board.move(pieceAt: .e2, to: .e4) ``` -------------------------------- ### Get Legal Moves for Piece Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Retrieves a list of all legal moves for a specific piece at a given square on the board. Useful for AI or move generation. ```swift let board = Board() print(board.legalMoves(forPieceAt: .e2)) // [.e3, .e4] ``` -------------------------------- ### Import ChessKit Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Import the ChessKit library to use its functionalities in your Swift code. This is a prerequisite for all ChessKit operations. ```swift import ChessKit ``` -------------------------------- ### Parse Chess Notation Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Parses various chess notation formats (FEN, PGN, SAN) into their corresponding ChessKit objects (Position, Game, Move). Also demonstrates converting objects back to their string representations. ```swift // parse FEN using Position initializer let fen = "rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2" let position = Position(fen: fen) // convert Position to FEN string let fenString = position.fen // parse PGN using Game initializer let game = Game(pgn: "1. e4 e5 2. Nf3") // convert Game to PGN string let pgnString = game.pgn // parse the move text "e4" from the starting position let move = Move(san: "e4", in: .standard) // convert Move to SAN string let sanString = move.san ``` -------------------------------- ### Create Chess Board from FEN Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Creates a ChessKit Board object from a FEN (Forsyth–Edwards Notation) string. Ensure the FEN string is valid for correct initialization. ```swift if let position = Position(fen: "rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2") { let board = Board(position: position) print(board) } ``` -------------------------------- ### Check Move Legality Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Checks if a specific move is legal on the current board state. Returns a boolean indicating legality. ```swift let board = Board() print(board.canMove(pieceAt: .a1, to: .a8)) // false ``` -------------------------------- ### Check Board State Source: https://github.com/chesskit-app/chesskit-swift/blob/master/README.md Determines the current state of the chess game, such as active, check, stalemate, or checkmate. The state is updated after each move. ```swift let board = Board(position: .init("8/5K1k/8/4Q3/8/8/8/8 w - - 0 1")!) // 8 · · · · · · · · // 7 · · · · · ♔ · ♚ // 6 · · · · · · · · // 5 · · · · ♕ · · · // 4 · · · · · · · · // 3 · · · · · · · · // 2 · · · · · · · · // 1 · · · · · · · · // a b c d e f g h print(board.state) // .active (default) board.move(pieceAt: "e5", to: "g7") print(board.state) // .checkmate(color: .black) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.