Exemplo n.º 1
0
    def _create_environment(self, config):
        """Constructor for an instance of the environment.

          Args:
            config: Object providing configurations via attributes.

          Returns:
            Wrapped OpenAI Gym environment.
        """
        if self.playground:
            self.args['render'] = True
        env = gym.make(config.env, **self.args)
        if config.max_length:
            env = wrappers.LimitDuration(env, config.max_length)
        env = wrappers.RangeNormalize(env)
        env = wrappers.ClipAction(env)
        env = wrappers.ConvertTo32Bit(env)
        return env
Exemplo n.º 2
0
def _create_environment(config):
    """Constructor for an instance of the environment.

  Args:
    config: Object providing configurations via attributes.

  Returns:
    Wrapped OpenAI Gym environment.
  """
    if isinstance(config.env, str):
        env = gym.make('test-' + config.env)
    else:
        env = config.env()
    if config.max_length:
        env = wrappers.LimitDuration(env, config.max_length)
    env = wrappers.RangeNormalize(env)
    env = wrappers.ClipAction(env)
    env = wrappers.ConvertTo32Bit(env)
    return env