Instance Method


Returns a Boolean value indicating whether the current state of the game model reflects a win for the specified player.


optional func isWin(for player: GKGameModelPlayer) -> Bool



An instance of your game’s player class (a custom class implementing the GKGameModelPlayer protocol) representing the player evaluating the game model.

Return Value

true if this game model represents a winning state for the specified player; false if the game has been won or has not yet concluded.


If the game has been won or lost, a strategist evaluating the game model can avoid evaluating further moves in the game and can therefore plan a successful move more efficiently.

For some games, merely identifying winning and losing states of the game model and using a sufficiently large maxLookAheadDepth value is enough for a strategist to play the game well. However, you can improve both the game performance and the runtime efficiency of move planning by also implementing the score(for:) method to distinguish the relative desirability of non-game-ending states.

See Also

Evaluating a Game Model

func gameModelUpdates(for: GKGameModelPlayer) -> [GKGameModelUpdate]?

Returns the set of moves available to the specified player.


func score(for: GKGameModelPlayer) -> Int

Returns a number rating the desirability of the game model’s current state from the perspective of the specified player.

func isLoss(for: GKGameModelPlayer) -> Bool

Returns a Boolean value indicating whether the specified player has lost the game.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software