# AIGameStrategy

class AIGameStrategy : NSObject, GKStrategist

A base strategy class.

### Properties

•  console 

The console that the strategy will send messages to.

#### Declaration

Swift

var console: ConsoleViewModel?
•  gameModel 

The game model that will be used in the particular strategy.

#### Declaration

Swift

var gameModel: GKGameModel?
•  randomSource 

The random source that the strategy can use.

#### Declaration

Swift

var randomSource: GKRandom?
•  activated 

A list of positions for all of the active inputs the agent encounters.

#### Declaration

Swift

var activated: [CGPoint] { get set }
•  closestInput 

The closest input to the player.

#### Declaration

Swift

var closestInput: AIAbstractGameSignalSender?
•  closestObject 

The closest object to the player.

#### Declaration

Swift

var closestObject: CGPoint?

### Strategy

•  bestMoveForActivePlayer() 

Returns the best move for the active player.

#### Declaration

Swift

func bestMoveForActivePlayer() -> GKGameModelUpdate?

### Object Detection with Distance

•  closestInput(in:) 

Returns the closest input device relative to the player.

The closest input is determined by finding the minimum distance of all possible inputs that have not been added to the activated list.

#### Declaration

Swift

public func closestInput(in state: AIAbstractGameState) -> AIAbstractGameSignalSender?

#### Parameters

  state  The state the agent will assess to determine which input to target.

#### Return Value

The input device closest to the player, or nil.

•  closestObject(in:) 

Returns the closest object relative to the player.

#### Declaration

Swift

func closestObject(in state: AIAbstractGameState) -> CGPoint?

#### Parameters

  state  The state the agent will assess to determine which object to target.

#### Return Value

The input device closest to the player, or nil.

•  closestPath(to:in:) 

Returns the action responsible for providing the closest path to the specified input.

#### Declaration

Swift

func closestPath(to input: AIAbstractGameSignalSender?, in state: AIAbstractGameState) -> String

#### Parameters

  input  The input for the agent to target.  state  The state the agent will assess to determine the move.
•  closestPath(to:in:) 

Returns the action responsible for providing the closest path to the specified object.

#### Declaration

Swift

func closestPath(to object: CGPoint?, in state: AIAbstractGameState) -> String

#### Parameters

  object  The object for the agent to target.  state  The state the agent will assess to determine the move.
•  closestPath(in:) 

Returns the action responsible for providing the closest path to the exit.

#### Declaration

Swift

func closestPath(in state: AIAbstractGameState) -> String

#### Parameters

  state  The state the agent will assess to determine the move.