Exemple #1
0
def test_multi_env_continous_state_discrete_actions():
    env = make_parallelized_gym_env('CartPole-v0', 0, 2, action_processor=SimpleDiscreteProcessor())
    state = env.reset()
    assert tuple(state.size()) == (2, 4)
    assert type(state) is Variable
    action, log_probs = get_multinomial_action(state, env.action_space.n)
    state, _, _, _ = env.step(action)
    assert type(state) is Variable
    assert tuple(state.size()) == (2, 4)
def test_multi_env_continous_state_continous_actions():
    env = make_parallelized_gym_env('MountainCarContinuous-v0', 0, 2)
    state = env.reset()
    action, log_probs = get_gaussian_action(state, env.action_space.shape[0])
    assert isinstance(state, torch.Tensor)
    assert tuple(state.size()) == (2, 2)
    state, _, _, _ = env.step(action)
    assert isinstance(state, torch.Tensor)
    assert tuple(state.size()) == (2, 2)
def test_multi_env_one_hot_state_one_hot_actions():
    env = make_parallelized_gym_env('FrozenLake-v0', 0, 2)
    state = env.reset()
    assert state.size() == (2, env.observation_space.n)
    assert isinstance(state, torch.Tensor)
    actions, log_probs = get_multinomial_action(state, env.action_space.n)
    assert actions.size() == (2, )
    state, _, _, _ = env.step(actions)
    assert isinstance(state, torch.Tensor)
    assert state.size() == (2, env.observation_space.n)
Exemple #4
0
def test_multi_env_continous_states_multiple_continous_actions():
    #TODO: change this to use something other than roboschool?
    try:
        import roboschool
        env = make_parallelized_gym_env('RoboschoolHumanoid-v1', 0, 2)
        state = env.reset()
        action, log_probs = get_gaussian_action(state, env.action_space.shape[0])
        assert type(state) is Variable
        assert tuple(state.size()) == (2, env.observation_space.shape[0])
        state, _, _, _ = env.step(action)
        assert type(state) is Variable
        assert tuple(state.size()) == (2, env.observation_space.shape[0])
    except ImportError:
        logging.warning('No roboschool was installed therefore `test_multi_env_continous_states_multiple_continous_actions` could not be run')
        pass