class_docstr: This class handles the MCTS tree.
docstr: This function performs numMCTSSims simulations of MCTS starting from
  canonicalBoard.
  
  Returns:
      probs: a policy vector where the probability of the ith action is
             proportional to Nsa[(s,a)]**(1./temp)
docstr_tok: ["This","function","performs","numMCTSSims","simulations","of","MCTS","starting","from","canonicalBoard",".","Returns",":","probs",":","a","policy","vector","where","the","probability","of","the","ith","action","is","proportional","to","Nsa","[","(","s",",","a",")","]","*","*","(","1.\/temp",")"]
code: def getActionProb(self, canonicalBoard, temp=1):
      """
      This function performs numMCTSSims simulations of MCTS starting from
      canonicalBoard.
  
      Returns:
          probs: a policy vector where the probability of the ith action is
                 proportional to Nsa[(s,a)]**(1./temp)
      """
      for i in range(self.args.numMCTSSims):
          dir_noise = i == 0 and self.dirichlet_noise
          self.search(canonicalBoard, dirichlet_noise=dir_noise)
  
      s = self.game.stringRepresentation(canonicalBoard)
      counts = [
          self.Nsa[(s, a)] if (s, a) in self.Nsa else 0
          for a in range(self.game.getActionSize())
      ]
  
      if temp == 0:
          bestAs = np.array(
              np.argwhere(counts == np.max(counts))
          ).flatten()
          bestA = np.random.choice(bestAs)
          probs = [0] * len(counts)
          probs[bestA] = 1
          return probs
  
      counts = [x ** (1.0 / temp) for x in counts]
      counts_sum = float(sum(counts))
      probs = [x / counts_sum for x in counts]
      return probs
  
file_path: PARL/benchmark/torch/AlphaZero/MCTS.py
imports: import math
  import time
  import numpy
label_desc: Use image node_id 2 for calling the MCTS obj's underlying member method code with example usage: obj.getActionProb(canonicalBoard, temp) and returns: probs, probs