title: GameplayKit Ai with no board model
body: <p>I'm currently developing a game where the players fire projectiles at each other from either side of the screen. (like that Bow masters game on the appstore.) </p>
  
  <p>I'm currently trying to integrate an Ai into the game to play as the opposite team using gameplaykit. </p>
  
  <p>My problem is i'm reading up on how to do it and they use a board and have all the board points laid out in an array, My game doesn't use a board it just has player health and throws projectiles using vectors and impulses so there is no board, just locations on where the projectile lands and if it hits a player or not. </p>
  
  <p><strong>How do i create a GKGameModel for this when I don't have an actual board?</strong></p>
  
  <p>Here is my code that I have so far:</p>
  
  <p><strong>Projectile Shooting Code:</strong></p>
  
  <pre><code>let touchDX = touchLocation.x//your calculation
  let touchDY = touchLocation.y//your calculation
  
  let touchLength = sqrt(touchDX*touchDX+touchDY*touchDY)
  
  let unitVectorDX = touchDX / touchLength
  let unitVectorDY = touchDY / touchLength
  let speed:CGFloat = touchLength / 150
  
  vector = CGVector(dx: -unitVectorDX * speed, dy: unitVectorDY * speed)
  playerBullet.physicsBody?.applyImpulse(vector)
  </code></pre>
  
  <p><strong>AI Code So Far:</strong></p>
  
  <pre><code>class Player: SKNode, GKGameModelPlayer {
  
  var playerSprite = SKSpriteNode()
  var playerId: Int = 0
  
  var health = 100
  
  func createPlayer(playerColor: UIColor, pos: CGPoint, posZ: CGFloat) {
  
      //CREATE PLAYER HERE
      playerSprite = SKSpriteNode(texture: nil, color: playerColor ?? .white, size: CGSize(width: 50, height: 50))
      playerSprite.position = pos
      playerSprite.zPosition = posZ
  }
  
  }
  
  
  
  class Move: NSObject, GKGameModelUpdate {
  
  var value: Int = 0
  var coordinate: CGPoint
  
  
  init(_ coordinate: CGPoint) {
      self.coordinate = coordinate
  }
  
  }
  
  
  class Board: NSObject, GKGameModel {
  
  //Zone is an old concept that doesn't really help but it works
  func copy(with zone: NSZone? = nil) -&gt; Any {
      let copy = Board()
      copy.setGameModel(self)
      return copy
  }
  
  func setGameModel(_ gameModel: GKGameModel) {
      if let board = gameModel as? Board {
          //DO STUFF HERE
  
          //slots = board.slots
          //currentPlayer = board.currentPlayer
      }
  }
  
  
  }
  </code></pre>