Пример #1
0
def test_visualization():
    inner_env = gym.make('MountainCar-v0')
    env = GymEnv(inner_env)

    env.reset()
    env.visualize()
    assert inner_env.metadata['render.modes'] == env.render_modes
    env.step(env.action_space.sample())
Пример #2
0
def step_bullet_kuka_env(n_steps=1000):
    """Load, step, and visualize a Bullet Kuka environment.

    Args:
        n_steps (int): number of steps to run.

    """
    # Construct the environment
    env = GymEnv(gym.make('KukaBulletEnv-v0', renders=True, isDiscrete=True))

    # Reset the environment and launch the viewer
    env.reset()
    env.visualize()

    step_count = 0
    es = env.step(env.action_space.sample())
    while not es.last and step_count < n_steps:
        es = env.step(env.action_space.sample())
        step_count += 1
Пример #3
0
#!/usr/bin/env python3
"""Example of how to load, step, and visualize an environment."""
import argparse

from garage.envs import GymEnv

parser = argparse.ArgumentParser()
parser.add_argument('--n_steps',
                    type=int,
                    default=1000,
                    help='Number of steps to run')
args = parser.parse_args()

# Construct the environment
env = GymEnv('MountainCar-v0')

# Reset the environment and launch the viewer
env.reset()
env.visualize()

step_count = 0
es = env.step(env.action_space.sample())

while not es.last and step_count < args.n_steps:
    es = env.step(env.action_space.sample())
    step_count += 1

env.close()
Пример #4
0
def test_closes_mujoco():
    garage_env = GymEnv('Ant-v2')
    garage_env.visualize()
    assert garage_env._env.viewer is not None
    garage_env.close()
    assert garage_env._env.viewer is None
Пример #5
0
def test_closes_box2d():
    garage_env = GymEnv('CarRacing-v0')
    garage_env.visualize()
    assert garage_env._env.viewer is not None
    garage_env.close()
    assert garage_env._env.viewer is None