예제 #1
0
def test_vector_action_space(base_env=envs.MINERL_OBTAIN_DIAMOND_V0,
                             common_env=None):
    vec_env = wrappers.Vectorized(base_env, common_env)
    assert isinstance(vec_env.action_space, Dict)
    assert isinstance(vec_env.observation_space, Dict)
    print(vec_env.action_space)
    print(vec_env.action_space.spaces)
    assert ('vector' in vec_env.action_space.spaces)
    assert ('vector' in vec_env.observation_space.spaces)
예제 #2
0
def test_wrap_unwrap_action(base_env=envs.MINERL_OBTAIN_DIAMOND_V0,
                            common_envs=None):
    """
    Tests that wrap_action composed with unwrap action is the identity.
    1. Construct an VecWrapper of an EnvSpec called ObtainDiamond
    2. Sample actions from its action space
    3. Wrap and unwrap those actions.
    4. Assert that the result is the same as the sample
    """
    vec_env = wrappers.Vectorized(base_env, common_envs)

    s = base_env.action_space.sample()
    ws = vec_env.wrap_action(s)
    us = vec_env.unwrap_action(ws)
    assert_equal_recursive(s, us)