Commit d787bc0d authored by peastman's avatar peastman
Browse files

GymEnvironment supports continuous action spaces

parent 71962e35
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -149,8 +149,13 @@ class GymEnvironment(Environment):
    import gym
    self.env = gym.make(name)
    self.name = name
    space = self.env.action_space
    if 'n' in dir(space):
      super(GymEnvironment, self).__init__(self.env.observation_space.shape,
                                         self.env.action_space.n)
                                           space.n)
    else:
      super(GymEnvironment, self).__init__(
          self.env.observation_space.shape, action_shape=space.shape)

  def reset(self):
    self._state = self.env.reset()
@@ -160,6 +165,9 @@ class GymEnvironment(Environment):
    self._state, reward, self._terminated, info = self.env.step(action)
    return reward

  def __deepcopy__(self, memo):
    return GymEnvironment(self.name)


class Policy(object):
  """A policy for taking actions within an environment.