Python gym.register() Examples

The following are 8 code examples of gym.register(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gym , or try the search function .
Example #1
Source File: test_registration.py    From DQN-DDPG_Stock_Trading with MIT License 6 votes vote down vote up
def test_missing_lookup():
    registry = registration.EnvRegistry()
    registry.register(id='Test-v0', entry_point=None)
    registry.register(id='Test-v15', entry_point=None)
    registry.register(id='Test-v9', entry_point=None)
    registry.register(id='Other-v100', entry_point=None)
    try:
        registry.spec('Test-v1')  # must match an env name but not the version above
    except error.DeprecatedEnv:
        pass
    else:
        assert False

    try:
        registry.spec('Unknown-v1')
    except error.UnregisteredEnv:
        pass
    else:
        assert False 
Example #2
Source File: safelife_env.py    From safelife with Apache License 2.0 5 votes vote down vote up
def register(cls):
        """Registers a few canonical environments with OpenAI Gym."""
        for name in [
            "append-still", "prune-still",
            "append-still-easy", "prune-still-easy",
            "append-spawn", "prune-spawn",
            "navigation", "challenge"
        ]:
            gym.register(
                id="safelife-{}-v1".format(name),
                entry_point=SafeLifeEnv,
                kwargs={
                    'level_iterator': SafeLifeLevelIterator('random/' + name),
                },
            ) 
Example #3
Source File: model_envs.py    From imitation with MIT License 5 votes vote down vote up
def register_cliff(suffix, kwargs):
    gym.register(
        f"imitation/CliffWorld{suffix}-v0",
        entry_point="imitation.envs.examples.model_envs:CliffWorld",
        kwargs=kwargs,
    ) 
Example #4
Source File: run_ray.py    From iroko with Apache License 2.0 5 votes vote down vote up
def get_gym(env_config):
    import gym
    iterations = env_config["iterations"]
    gym.register(id='dc-iroko-v0',
                 entry_point='dc_gym.env_iroko:DCEnv',
                 max_episode_steps=iterations,
                 )
    env = gym.make('dc-iroko-v0', conf=env_config)
    return env 
Example #5
Source File: __init__.py    From mbpo with MIT License 5 votes vote down vote up
def register_mujoco_environments():
    """Register softlearning mujoco environments."""
    for mujoco_environment in MUJOCO_ENVIRONMENT_SPECS:
        gym.register(**mujoco_environment)

    gym_ids = tuple(
        environment_spec['id']
        for environment_spec in  MUJOCO_ENVIRONMENT_SPECS)

    return gym_ids 
Example #6
Source File: __init__.py    From mbpo with MIT License 5 votes vote down vote up
def register_general_environments():
    """Register gym environments that don't fall under a specific category."""
    for general_environment in GENERAL_ENVIRONMENT_SPECS:
        gym.register(**general_environment)

    gym_ids = tuple(
        environment_spec['id']
        for environment_spec in  GENERAL_ENVIRONMENT_SPECS)

    return gym_ids 
Example #7
Source File: __init__.py    From mbpo with MIT License 5 votes vote down vote up
def register_multiworld_environments():
    """Register custom environments from multiworld package."""
    for multiworld_environment in MULTIWORLD_ENVIRONMENT_SPECS:
        gym.register(**multiworld_environment)

    gym_ids = tuple(
        environment_spec['id']
        for environment_spec in  MULTIWORLD_ENVIRONMENT_SPECS)

    return gym_ids 
Example #8
Source File: __init__.py    From mbpo with MIT License 5 votes vote down vote up
def register_mbpo_environments():
    for mbpo_environment in MBPO_ENVIRONMENT_SPECS:
        gym.register(**mbpo_environment)

    gym_ids = tuple(
        environment_spec['id']
        for environment_spec in  MBPO_ENVIRONMENT_SPECS)

    return gym_ids