class_docstr: A single-process MCTS agent.
class_docstr_tok: ["A","single-process","MCTS","agent","."]
code: def __init__(
      self,
      network: snt.Module,
      model: models.Model,
      optimizer: snt.Optimizer,
      n_step: int,
      discount: float,
      replay_capacity: int,
      num_simulations: int,
      environment_spec: specs.EnvironmentSpec,
      batch_size: int,
  ):
      extra_spec = {
          "pi": specs.Array(
              shape=(environment_spec.actions.num_values,),
              dtype=np.float32,
          )
      }
      # Create a replay server for storing transitions.
      replay_table = reverb.Table(
          name=adders.DEFAULT_PRIORITY_TABLE,
          sampler=reverb.selectors.Uniform(),
          remover=reverb.selectors.Fifo(),
          max_size=replay_capacity,
          rate_limiter=reverb.rate_limiters.MinSize(1),
          signature=adders.NStepTransitionAdder.signature(
              environment_spec, extra_spec
          ),
      )
      self._server = reverb.Server([replay_table], port=None)
  
      # The adder is used to insert observations into replay.
      address = f"localhost:{self._server.port}"
      adder = adders.NStepTransitionAdder(
          client=reverb.Client(address),
          n_step=n_step,
          discount=discount,
      )
  
      # The dataset provides an interface to sample from replay.
      dataset = datasets.make_reverb_dataset(server_address=address)
      dataset = dataset.batch(batch_size, drop_remainder=True)
  
      tf2_utils.create_variables(
          network, [environment_spec.observations]
      )
  
      # Now create the agent components: actor & learner.
      actor = acting.MCTSActor(
          environment_spec=environment_spec,
          model=model,
          network=network,
          discount=discount,
          adder=adder,
          num_simulations=num_simulations,
      )
  
      learner = learning.AZLearner(
          network=network,
          optimizer=optimizer,
          dataset=dataset,
          discount=discount,
      )
  
      # The parent class combines these together into one 'agent'.
      super().__init__(
          actor=actor,
          learner=learner,
          min_observations=10,
          observations_per_step=1,
      )
  
file_path: acme/acme/agents/tf/mcts/agent.py
imports: from acme import datasets
  from acme import specs
  from acme.adders import reverb
  from acme.agents import agent
  from acme.agents.tf.mcts import acting
  from acme.agents.tf.mcts import learning
  from acme.agents.tf.mcts import models
  from acme.tf import utils
  import numpy
  import reverb
  import sonnet
label_desc: Use image node_id 1 to create a new MCTS object from inherited base classes: agent with example: obj = MCTS(network, model, optimizer, n_step, discount, replay_capacity, num_simulations, environment_spec, batch_size)