(action_space)
return (n_controls, n_actions)
Returns the number of controls and actions for an action space.
Returns the number of controls and actions for an action space.
Returns the number of controls and actions for an action space .
def analyze_action_space(action_space):  # pylint: disable=invalid-name
  """Returns the number of controls and actions for an action space."""
  assert isinstance(
      action_space, (gym.spaces.Discrete, gym.spaces.MultiDiscrete)
  ), 'Action space expected to be Discrete of MultiDiscrete, got {}.'.format(
      type(action_space)
  )
  if isinstance(action_space, gym.spaces.Discrete):
    n_actions = action_space.n
    n_controls = 1
  else:
    (n_controls,) = action_space.nvec.shape
    assert n_controls > 0
    assert np.min(action_space.nvec) == np.max(action_space.nvec), (
        'Every control must have the same number of actions.'
    )
    n_actions = action_space.nvec[0]
  return (n_controls, n_actions)
def analyze_action_space ( action_space ) : # pylint: disable=invalid-name assert isinstance ( action_space , ( gym . spaces . Discrete , gym . spaces . MultiDiscrete ) ) , 'Action space expected to be Discrete of MultiDiscrete, got {}.' . format ( type ( action_space ) ) if isinstance ( action_space , gym . spaces . Discrete ) : n_actions = action_space . n n_controls = 1 else : ( n_controls , ) = action_space . nvec . shape assert n_controls > 0 assert np . min ( action_space . nvec ) == np . max ( action_space . nvec ) , ( 'Every control must have the same number of actions.' ) n_actions = action_space . nvec [ 0 ] return ( n_controls , n_actions )