|
|
|
|
|
|
self._previous_decision_step = decision_steps |
|
|
|
|
|
|
|
# Set action spaces |
|
|
|
if self.group_spec.is_action_discrete(): |
|
|
|
branches = self.group_spec.discrete_action_branches |
|
|
|
if self.group_spec.action_size == 1: |
|
|
|
if self.group_spec.action_spec.is_action_discrete(): |
|
|
|
branches = self.group_spec.action_spec.discrete_action_branches |
|
|
|
if self.group_spec.action_spec.discrete_action_size == 1: |
|
|
|
self._action_space = spaces.Discrete(branches[0]) |
|
|
|
else: |
|
|
|
if flatten_branched: |
|
|
|
|
|
|
"The environment has a non-discrete action space. It will " |
|
|
|
"not be flattened." |
|
|
|
) |
|
|
|
high = np.array([1] * self.group_spec.action_shape) |
|
|
|
high = np.array([1] * self.group_spec.action_spec.continuous_action_size) |
|
|
|
self._action_space = spaces.Box(-high, high, dtype=np.float32) |
|
|
|
|
|
|
|
# Set observations space |
|
|
|
|
|
|
action = self._flattener.lookup_action(action) |
|
|
|
|
|
|
|
spec = self.group_spec |
|
|
|
action = np.array(action).reshape((1, spec.action_size)) |
|
|
|
action = np.array(action).reshape((1, spec.action_spec.action_size)) |
|
|
|
self._env.set_actions(self.name, action) |
|
|
|
|
|
|
|
self._env.step() |
|
|
|