class_docstr: A state-settable environment for Tic-Tac-Toe game.
  
  For MCTS/AlphaZero, we need to keep states of the environment in a node and
  later restore them once MCTS selects which node to visit. This requires
  calling into get_state() and set_state() functions.
  
  The states are a 3 x 3 array where 0 = empty, 1 = player, 2 = opponent.
  The action is a 2-d vector to indicate the position for the player's move.
class_docstr_tok: ["A","state-settable","environment","for","Tic-Tac-Toe","game",".","For","MCTS\/AlphaZero",",","we","need","to","keep","states","of","the","environment","in","a","node","and","later","restore","them","once","MCTS","selects","which","node","to","visit",".","This","requires","calling","into","get_state","(",")","and","set_state","(",")","functions",".","The","states","are","a","3","x","3","array","where","0","=","empty",",","1","=","player",",","2","=","opponent",".","The","action","is","a","2-d","vector","to","indicate","the","position","for","the","player","'s","move","."]
code: def _step(self, action: np.ndarray):
      action = tuple(action)
      if self._states[action] != 0:
          return TimeStep(
              StepType.LAST,
              TicTacToeEnvironment.REWARD_ILLEGAL_MOVE,
              self._discount,
              self._states,
          )
  
      self._states[action] = 1
  
      is_final, reward = self._check_states(self._states)
      if is_final:
          return TimeStep(
              StepType.LAST, reward, self._discount, self._states
          )
  
      # TODO(b/152638947): handle multiple agents properly.
      # Opponent places '2' on the board.
      opponent_action = self._opponent_play(self._states)
      self._states[opponent_action] = 2
  
      is_final, reward = self._check_states(self._states)
  
      step_type = StepType.MID
      if np.all(self._states == 0):
          step_type = StepType.FIRST
      elif is_final:
          step_type = StepType.LAST
  
      return TimeStep(step_type, reward, self._discount, self._states)
  
file_path: agents/tf_agents/environments/examples/tic_tac_toe_environment.py
imports: import copy
  import numpy
  from tf_agents.environments import py_environment
  from tf_agents.specs import BoundedArraySpec
  from tf_agents.trajectories.time_step import StepType
  from tf_agents.trajectories.time_step import TimeStep
label_desc: Use image node_id 9 for calling the TicTacToeEnvironment obj's underlying member method code with example usage: obj._step(action) and returns: TimeStep, TimeStep, TimeStep