Computes several of the best possible moves for the specified player, and returns a move randomly selected from among them.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
The player for whom the strategist should plan a move. This object must be in the current game model’s
The number of moves from which to randomize the selection.
An object describing the move found by the strategist.
This method looks ahead at the possible moves for the specified player, as well as possible future moves by other players on subsequent turns (according to the
max property) and examines the state of the game model resulting from each possible move. Your game model class provides a score for each state in its
score(for:) method, allowing the strategist to find and rank sequences of future moves that maximize the score for the specified player. This method then returns a random selection representing the first move in one of the most highly ranked sequences.
The object returned is an instance of your custom class implementing the
GKGame protocol. This object was created in your game model’s
game method, describing in your game’s terms a possible move—examine that information to make use of the strategist’s selection. For example, you could implement a computer-controlled player by performing the selected move.
This method returns
nil if the specified player is invalid or has no available moves.