<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKStrategist",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(pl)GKStrategist"
  },
  "title" : "GKStrategist"
}
-->

# GKStrategist

A general interface for objects that provide artificial intelligence for use in turn-based (and similar) games.

```
protocol GKStrategist : NSObjectProtocol
```

## Overview

GameplayKit provides two strategist classes, and you can also use this protocol to implement your own. You provide information about your game model to a strategist by implementing the [`GKGameModel`](/documentation/GameplayKit/GKGameModel), [`GKGameModelPlayer`](/documentation/GameplayKit/GKGameModelPlayer), and [`GKGameModelUpdate`](/documentation/GameplayKit/GKGameModelUpdate) protocols in your custom classes, then use the strategist’s methods to find optimal moves.

### Choosing a Strategist

GameplayKit provides two strategist classes:

- The [`GKMinmaxStrategist`](/documentation/GameplayKit/GKMinmaxStrategist) class uses a numeric score for each possible game model state, and performs an exhaustive tree search to find moves that maximize the player’s score while minimizing opponent scores. This strategy can result in optimal gameplay, but requires a scoring method for game models and has a performance cost that increases greatly with game complexity.
- The [`GKMonteCarloStrategist`](/documentation/GameplayKit/GKMonteCarloStrategist) class performs a randomized, probabilistic search for winning end states. This strategy doesn’t always choose the *best* possible move, but is likely to choose *good* moves, and has a low performance cost even for very complex games. In addition, the Monte Carlo strategy is concerned only with whether a game model state represents a win, so you don’t need to implement a scoring method.

### Using a Strategist

Using a strategist in a game requires the following steps:

1. Create classes describing your gameplay model, adopting the [`GKGameModel`](/documentation/GameplayKit/GKGameModel), [`GKGameModelPlayer`](/documentation/GameplayKit/GKGameModelPlayer), and [`GKGameModelUpdate`](/documentation/GameplayKit/GKGameModelUpdate) protocols.
2. Choose a strategist class (one that adopts the [`GKStrategist`](/documentation/GameplayKit/GKStrategist) protocol), create an instance of that class, and configure its properties to determine its gameplay behavior.
3. Point the strategist’s [`gameModel`](/documentation/GameplayKit/GKStrategist/gameModel) property at the instance of your game model class representing the current state of the game in play.
4. Use the [`bestMoveForActivePlayer()`](/documentation/GameplayKit/GKStrategist/bestMoveForActivePlayer()) method to select the best possible move for the current player. This method returns a move object (that is, an instance of the custom class you create to adopt the [`GKGameModelUpdate`](/documentation/GameplayKit/GKGameModelUpdate) protocol).
5. Examine the move object to make use of the move selected by the strategist. You created this instance in the [`gameModelUpdates(for:)`](/documentation/GameplayKit/GKGameModel/gameModelUpdates(for:)) method of your game model class to describe a possible move in your game, so examining the object gives you the information needed to perform that move.

For more information about describing your gameplay model and using strategists, see [The Minmax Strategist](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/Minmax.html#//apple_ref/doc/uid/TP40015172-CH2) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Specifying the Game Model

[`gameModel`](/documentation/GameplayKit/GKStrategist/gameModel)

The model representing the current state of the game.

### Configuring a Strategist

[`randomSource`](/documentation/GameplayKit/GKStrategist/randomSource)

A randomizer object to be used when the strategist randomly selects a move.

### Planning Game Moves

[`bestMoveForActivePlayer()`](/documentation/GameplayKit/GKStrategist/bestMoveForActivePlayer())

Computes and returns the best possible move for the current player.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)