Instance Method

isLossForPlayer:

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

Declaration

- (BOOL)isLossForPlayer:(id<GKGameModelPlayer>)player;

Parameters

player

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

Return Value

YES if this game model represents a losing state for the specified player; NO if the game has been won or has not yet concluded.

Discussion

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 scoreForPlayer: method to distinguish the relative desirability of non-game-ending states.

See Also

Evaluating a Game Model

- gameModelUpdatesForPlayer:

Returns the set of moves available to the specified player.

Required.

- scoreForPlayer:

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

- isWinForPlayer:

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