class_docstr: Base class for defining an agent.
docstr: Constructor for AgentBaseClass.
  
  Args:
      o_space: observation space, gym.spaces.tuple_space.Tuple is not
          supported.
      a_space: action space, limits to gym.spaces.discrete.Discrete.
docstr_tok: ["Constructor","for","AgentBaseClass",".","Args",":","o_space",":","observation","space",",","gym.spaces.tuple_space.Tuple","is","not","supported",".","a_space",":","action","space",",","limits","to","gym.spaces.discrete.Discrete","."]
code: def __init__(self, o_space, a_space):
      """
      Constructor for AgentBaseClass.
  
      Args:
          o_space: observation space, gym.spaces.tuple_space.Tuple is not
              supported.
          a_space: action space, limits to gym.spaces.discrete.Discrete.
      """
      if self._classname(a_space) != "gym.spaces.discrete.Discrete":
          raise ValueError(
              "Action space {0} incompatible with {1}. (Only supports "
              "Discrete action spaces.)".format(a_space, self)
          )
      self._num_actions = a_space.n
  
      # We assume the observation is in one of the following cases:
      # 1. discrete, and takes values from 0 to n - 1
      # 2. can be discretized, and the raw state is converted to an internal
      #    state taking values from 0 to n - 1
      # 3. raw, such as images from Atari games
      #
      # OpenAI gym supports the following observation types:
      # Discrete, Box, MultiBinary, MultiDiscrete and Tuple. Discrete
      # corresponds to case 1. Box, MultiBinary and MultiDiscrete can be
      # either case 2 or 3. Tuple is a mix of case 1, 2 or 3, and is not
      # supported currently.
      #
      # The observation-related parameters are defined as follows:
      # _discrete_observation_space: True for cases 1 and 2, False otherwise.
      #   State is represented by a scalar.
      # _space_discretizer: Not none for case 2 to indicate a conversion on
      #   state is required. None otherwise.
      # _shape_of_inputs: (n, ) for cases 1 and 2 to indicate it is a vector
      #   of length n. For case 3, it is the shape of array that represents
      #   the state. For example, an image input will have shape denoted as
      #   tuple (channel, width, height).
      if not (
          self._classname(o_space) == "gym.spaces.discrete.Discrete"
          or self._classname(o_space)
          == "gym.spaces.multi_binary.MultiBinary"
          or self._classname(o_space) == "gym.spaces.box.Box"
          or self._classname(o_space)
          == "gym.spaces.multi_discrete.MultiDiscrete"
      ):
          raise ValueError(
              "Unsupported observation space type: {0}".format(o_space)
          )
  
      self._space_discretizer = None
      self._discrete_observation_space = (
          self._classname(o_space) == "gym.spaces.discrete.Discrete"
      )
      # Set self._num_states for discrete observation space only.
      # Otherwise set it to None so that an exception will be raised
      # should it be used later in the code.
      self._num_states = (
          o_space.n if self._discrete_observation_space else None
      )
  
      if (
          self._classname(o_space) == "gym.spaces.discrete.Discrete"
          or self._classname(o_space)
          == "gym.spaces.multi_binary.MultiBinary"
      ):
          self._shape_of_inputs = (o_space.n,)
      else:
          self._shape_of_inputs = o_space.shape
  
      self._preprocessor = None
      self._best_model = None
  
imports: from abc import ABCMeta, abstractmethod
  import numpy
  from importlib import import_module
  from .shared.discretize import BoxSpaceDiscretizer
label_desc: Use image node_id 1 to create a new AgentBaseClass object from inherited base classes: object with example: obj = AgentBaseClass(o_space, a_space)