Ejemplo n.º 1
0
def define_batch_env(constructor, num_agents, xvfb=False):
    """Create environments and apply all desired wrappers."""
    with tf.variable_scope("environments"):
        envs = [
            ExternalProcessEnv(constructor, xvfb) for _ in range(num_agents)
        ]
        env = batch_env.BatchEnv(envs, blocking=False)
        env = py_func_batch_env.PyFuncBatchEnv(env)
        return env
Ejemplo n.º 2
0
def define_batch_env(constructor, num_agents, xvfb=False):
    """Create environments and apply all desired wrappers.

  Args:
    constructor: Constructor of an OpenAI gym environment.
    num_agents: Number of environments to combine in the batch.
    xvfb: Frame buffer.
    env_processes: Whether to step environment in external processes.

  Returns:
    In-graph environments object.
  """
    with tf.variable_scope("environments"):
        envs = [
            ExternalProcessEnv(constructor, xvfb) for _ in range(num_agents)
        ]
        env = batch_env.BatchEnv(envs, blocking=False)
        env = py_func_batch_env.PyFuncBatchEnv(env)
        return env
Ejemplo n.º 3
0
def define_batch_env(constructor, num_agents, env_processes=True):
    """Create environments and apply all desired wrappers.

  Args:
    constructor: Constructor of an OpenAI gym environment.
    num_agents: Number of environments to combine in the batch.
    env_processes: Whether to step environment in external processes.

  Returns:
    In-graph environments object.
  """
    with tf.variable_scope('environments'):
        if env_processes:
            envs = [ExternalProcessEnv(constructor) for _ in range(num_agents)]
        else:
            envs = [constructor() for _ in range(num_agents)]
        env = batch_env.BatchEnv(envs, blocking=not env_processes)
        env = in_graph_batch_env.InGraphBatchEnv(env)
        return env