예제 #1
0
def create_environment(level_name, seed, is_test=False):
    """Creates an environment wrapped in a `FlowEnvironment`."""
    if level_name.startswith('doom_'):
        config = None
        p = py_process.PyProcess(PyProcessDoom, level_name, config,
                                 FLAGS.num_action_repeats, seed)
        return environments.FlowEnvironment(p.proxy)
    else:
        if level_name in dmlab30.ALL_LEVELS:
            level_name = 'contributed/dmlab30/' + level_name

        # Note, you may want to use a level cache to speed of compilation of
        # environment maps. See the documentation for the Python interface of DeepMind
        # Lab.
        config = {
            'width': FLAGS.width,
            'height': FLAGS.height,
            'datasetPath': FLAGS.dataset_path,
            'logLevel': 'WARN',
            'gpuDeviceIndex': '0',
            'renderer': FLAGS.renderer,
            'benchmark_mode': FLAGS.benchmark_mode,
        }
        if is_test:
            config['allowHoldOutLevels'] = 'true'
            # Mixer seed for evalution, see
            # https://github.com/deepmind/lab/blob/master/docs/users/python_api.md
            config['mixerSeed'] = 0x600D5EED
        p = py_process.PyProcess(environments.PyProcessDmLab, level_name,
                                 config, FLAGS.num_action_repeats, seed)
        return environments.FlowEnvironment(p.proxy)
예제 #2
0
def create_atari_environment(env_id, seed, is_test=False):
    #   print("Before env proxy")
    config = {'width': 84, 'height': 84, 'level': env_id, 'logLevel': 'warn'}
    env_proxy = py_process.PyProcess(environments.PyProcessAtari, env_id,
                                     config, FLAGS.num_action_repeats, seed)

    environment = environments.FlowEnvironment(env_proxy.proxy)
    return environment
예제 #3
0
def create_environment(level_name, seed, is_test=False):
    """Creates an environment wrapped in a `FlowEnvironment`."""

    # Note, you may want to use a level cache to speed of compilation of
    # environment maps. See the documentation for the Python interface of DeepMind
    # Lab.
    config = {'width': FLAGS.width, 'height': FLAGS.height}
    if is_test:
        config['allowHoldOutLevels'] = 'true'
        # Mixer seed for evalution, see
        # https://github.com/deepmind/lab/blob/master/docs/users/python_api.md
        config['mixerSeed'] = 0x600D5EED
    p = py_process.PyProcess(environments.PyProcessGym, level_name, config)
    return environments.FlowEnvironment(p.proxy)
예제 #4
0
def create_environment(env_sampler,
                       initial_task_name=None,
                       seed=0):
  """Creates an environment wrapped in a `FlowEnvironment`."""
  # Sample a task if not provided
  if initial_task_name is None:
    initial_task_name = np.random.choice(env_sampler.task_names)
  # config is empty dict for now
  config = {}
  p = py_process.PyProcess(environments.PyProcessCraftLab, env_sampler,
                           initial_task_name, config, FLAGS.num_action_repeats,
                           seed)

  flow_env = environments.FlowEnvironment(p.proxy)

  # TODO clean me up, useful for debugging
  # obs_reset = p.proxy.initial()
  # rew, done, obs_step = p.proxy.step(0)
  # output_initial, state_initial = flow_env.initial()
  # output_step, state_step = flow_env.step(0, state_initial)

  return flow_env
예제 #5
0
def create_environment(game_name, state_size):
    """Creates an environment wrapped in a `FlowEnvironment`."""
    config = {'observation_size': state_size}

    p = py_process.PyProcess(environments.PyProcessGym, game_name, config)
    return environments.FlowEnvironment(p.proxy)
예제 #6
0
def create_environment(config, is_test=False):
    """Creates an environment wrapped in a `FlowEnvironment`."""
    p = py_process.PyProcess(environments.PyProcessPommerMan, config=config)
    return environments.FlowEnvironment(p.proxy)