Square

public struct Square : Hashable
extension Square: CustomStringConvertible

Square on Board.

  • Index of file of the square.

    Declaration

    Swift

    public var file: Int { get }
  • Index of rank of the square.

    Declaration

    Swift

    public var rank: Int { get }
  • Human readable coorsinate on the square.

    Declaration

    Swift

    public var coordinate: String { get }

Initializers

  • Initializes Square with its index.

    • index: Index of square in Board.squares array.

    Declaration

    Swift

    public init(index: Int)
  • Initializes Square with file and rank indexes.

    • file: File index (from 0 to 7).
    • rank: Rank index (from 0 to 7).

    Declaration

    Swift

    public init(file: Int, rank: Int)
  • Initializes a square from human readable coordinate string.

    Declaration

    Swift

    public init(coordinate: String)

    Parameters

    coordinate

    Square coordinate in format like: "e4", "d5", etc.

  • Creates new square with file and rank offsets.

    Declaration

    Swift

    public func translate(file: Int, rank: Int) -> Square

    Parameters

    file

    File offset.

    rank

    Rank offset.

    Return Value

    New square with necessary offset.

  • Declaration

    Swift

    public var description: String { get }