<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKMinmaxStrategist/bestMove(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKMinmaxStrategist(im)bestMoveForPlayer:"
  },
  "title" : "bestMove(for:)"
}
-->

# bestMove(for:)

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

```
func bestMove(for player: any GKGameModelPlayer) -> (any GKGameModelUpdate)?
```

## Parameters

`player`

The player for whom the strategist should plan a move. This object must be in the current game model’s [`players`](/documentation/GameplayKit/GKGameModel/players) array.

## Return Value

An object describing the move found by the strategist.

## Discussion

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 [`maxLookAheadDepth`](/documentation/GameplayKit/GKMinmaxStrategist/maxLookAheadDepth) 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:)`](/documentation/GameplayKit/GKGameModel/score(for:)) method, allowing the strategist to find the sequence of future moves that maximizes the score for the specified player and return the first move in that sequence.

The object returned is an instance of your custom class implementing the [`GKGameModelUpdate`](/documentation/GameplayKit/GKGameModelUpdate) protocol. This object was created in your game model’s [`gameModelUpdates(for:)`](/documentation/GameplayKit/GKGameModel/gameModelUpdates(for:)) 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, or provide hints to a human player by indicating the selected move in your game’s user interface.

If multiple possible moves are tied for the best score and the [`randomSource`](/documentation/GameplayKit/GKStrategist/randomSource) property is not `nil`, this method randomly selects from among the tied moves.

This method returns `nil` if the specified player is invalid or has no available moves.

---

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)