Documentation Archive Developer
Search

GameplayKit Changes for Swift

GameplayKit

Removed GKMinmaxStrategist.gameModel
Removed GKMinmaxStrategist.randomSource
Modified GKGameModel
Declaration
From
protocol GKGameModel : NSObjectProtocol, NSCopying {
    var players: [GKGameModelPlayer]? { get }
    var activePlayer: GKGameModelPlayer? { get }
    func setGameModel(_ gameModel: GKGameModel)
    func gameModelUpdatesForPlayer(_ player: GKGameModelPlayer) -> [GKGameModelUpdate]?
    func applyGameModelUpdate(_ gameModelUpdate: GKGameModelUpdate)
    optional func scoreForPlayer(_ player: GKGameModelPlayer) -> Int
    optional func isWinForPlayer(_ player: GKGameModelPlayer) -> Bool
    optional func isLossForPlayer(_ player: GKGameModelPlayer) -> Bool
}
To
protocol GKGameModel : NSObjectProtocol, NSCopying {
    var players: [GKGameModelPlayer]? { get }
    var activePlayer: GKGameModelPlayer? { get }
    func setGameModel(_ gameModel: GKGameModel)
    func gameModelUpdatesForPlayer(_ player: GKGameModelPlayer) -> [GKGameModelUpdate]?
    func applyGameModelUpdate(_ gameModelUpdate: GKGameModelUpdate)
    optional func scoreForPlayer(_ player: GKGameModelPlayer) -> Int
    optional func isWinForPlayer(_ player: GKGameModelPlayer) -> Bool
    optional func isLossForPlayer(_ player: GKGameModelPlayer) -> Bool
    optional func unapplyGameModelUpdate(_ gameModelUpdate: GKGameModelUpdate)
}

DeclarationProtocols
From
class GKMinmaxStrategist : NSObject {
    var gameModel: GKGameModel?
    var maxLookAheadDepth: Int
    var randomSource: GKRandom?
    func bestMoveForPlayer(_ player: GKGameModelPlayer) -> GKGameModelUpdate?
    func randomMoveForPlayer(_ player: GKGameModelPlayer, fromNumberOfBestMoves numMovesToConsider: Int) -> GKGameModelUpdate?
}
--
To
class GKMinmaxStrategist : NSObject, GKStrategist {
    var maxLookAheadDepth: Int
    func bestMoveForPlayer(_ player: GKGameModelPlayer) -> GKGameModelUpdate?
    func randomMoveForPlayer(_ player: GKGameModelPlayer, fromNumberOfBestMoves numMovesToConsider: Int) -> GKGameModelUpdate?
}
GKStrategist