Game

public class Game

Chess game.

  • Number of occurrences of each position in game.

    Declaration

    Swift

    public private(set) var positionsCounter: [Board : Int] { get }
  • List of moves made before current game position.

    Declaration

    Swift

    public private(set) var movesHistory: [Move] { get }
  • Current game position.

    Declaration

    Swift

    public var position: Position
  • Indicates whether it’s check in current position.

    Declaration

    Swift

    public var isCheck: Bool { get }
  • Indicates whether it’s mate in current position.

    Declaration

    Swift

    public var isMate: Bool { get }

Initialization

  • Initialize game with given position.

    Declaration

    Swift

    public init(position: Position, moves: [Move] = [])

    Parameters

    position

    Initial game position.

    moves

    List of moves before given position.

Making moves

  • List of legal moves in current game position.

    Declaration

    Swift

    public var legalMoves: [Move] { get }
  • Make move.

    Declaration

    Swift

    public func make(move stringMove: String)

    Parameters

    move

    A move in a long algebraic notation (e.g., "e2e4", "g1f3", "e7e8Q").

  • Make move.

    Declaration

    Swift

    public func make(move: Move)

    Parameters

    move

    A move to make.

Utilities

  • Creates a deep copy of current game.

    Declaration

    Swift

    public func deepCopy() -> Game

    Return Value

    New Game object.