title: GKMinmaxStrategist doesn't return any moves
body: <p>I have the following code in my <code>main.swift</code>:</p>
  
  <pre><code>let strategist = GKMinmaxStrategist()
  strategist.gameModel = position
  strategist.maxLookAheadDepth = 1
  strategist.randomSource = nil
  
  let move = strategist.bestMoveForActivePlayer()
  </code></pre>
  
  <p>...where <code>position</code> is an instance of my <code>GKGameModel</code> subclass <code>Position</code>. After this code is run, <code>move</code> is <code>nil</code>. <code>bestMoveForPlayer(position.activePlayer!)</code> also results in <code>nil</code> (but <code>position.activePlayer!</code> results in a <code>Player</code> object).</p>
  
  <p>However,</p>
  
  <pre><code>let moves = position.gameModelUpdatesForPlayer(position.activePlayer!)!
  </code></pre>
  
  <p>results in a non-empty array of possible moves. From Apple's documentation (about <code>bestMoveForPlayer(_:)</code>):</p>
  
  <blockquote>
    <p>Returns nil if the player is invalid, the player is not a part of the game model, or the player has no valid moves available.</p>
  </blockquote>
  
  <p>As far as I know, none of this is the case, but the function still returns <code>nil</code>. What could be going on here?</p>
  
  <p>If it can be of any help, here's my implementation of the <code>GKGameModel</code> protocol:</p>
  
  <pre><code>var players: [GKGameModelPlayer]? = [Player.whitePlayer, Player.blackPlayer]
  var activePlayer: GKGameModelPlayer? {
      return playerToMove
  }
  
  func setGameModel(gameModel: GKGameModel) {
      let position = gameModel as! Position
      pieces = position.pieces
      ply = position.ply
      reloadLegalMoves()
  }
  
  func gameModelUpdatesForPlayer(thePlayer: GKGameModelPlayer) -&gt; [GKGameModelUpdate]? {
      let player = thePlayer as! Player
      let moves = legalMoves(ofPlayer: player)
      return moves.count &gt; 0 ? moves : nil
  }
  
  func applyGameModelUpdate(gameModelUpdate: GKGameModelUpdate) {
      let move = gameModelUpdate as! Move
      playMove(move)
  }
  
  func unapplyGameModelUpdate(gameModelUpdate: GKGameModelUpdate) {
      let move = gameModelUpdate as! Move
      undoMove(move)
  }
  
  func scoreForPlayer(thePlayer: GKGameModelPlayer) -&gt; Int {
      let player = thePlayer as! Player
      var score = 0
      for (_, piece) in pieces {
          score += piece.player == player ? 1 : -1
      }
      return score
  }
  
  func isLossForPlayer(thePlayer: GKGameModelPlayer) -&gt; Bool {
      let player = thePlayer as! Player
      return legalMoves(ofPlayer: player).count == 0
  }
  
  func isWinForPlayer(thePlayer: GKGameModelPlayer) -&gt; Bool {
      let player = thePlayer as! Player
      return isLossForPlayer(player.opponent)
  }
  
  func copyWithZone(zone: NSZone) -&gt; AnyObject {
      let copy = Position(withPieces: pieces.map({ $0.1 }), playerToMove: playerToMove)
      copy.setGameModel(self)
      return copy
  }
  </code></pre>
  
  <p>If there's any other code I should show, let me know.</p>