Board

public struct Board : Hashable

A class that represents a chess board with pieces.

  • Initializes board with empty squares.

    Declaration

    Swift

    public init()
  • Provides access to board squares directly by indexes.

    Declaration

    Swift

    public subscript(index: Int) -> Piece? { get set }

    Parameters

    index

    Index of square.

    Return Value

    A Piece that put on specified square or nil if square is empty.

  • Provides access to board squares via Square object.

    Declaration

    Swift

    public subscript(square: Square) -> Piece? { get set }

    Parameters

    square

    A Square on board that should be accessed.

    Return Value

    A Piece that put on specified square or nil if square is empty.

  • Provides access to board squares via human readable coordinate.

    Declaration

    Swift

    public subscript(coordinate: String) -> Piece? { get set }

    Parameters

    coordinate

    A square coordinate in format like "e4" or "d5".

    Return Value

    A Piece that put on specified square or nil if square is empty.

  • Provides a list of pieces presented on board.

    Declaration

    Swift

    public func enumeratedPieces() -> [(Square, Piece)]

    Return Value

    Array of tupples that contain pieces and their squares.