示例#1
0
def test_reshape():
    base_env = DummyEnv(base_obs, base_obs_space, base_act_spaces)
    env = reshape_v0(base_env, (64, 3))
    obs = env.reset()
    assert obs.shape == (64, 3)
    first_obs, _, _, _ = env.step(5)
    assert np.all(np.equal(first_obs, base_obs.reshape([64, 3])))
示例#2
0
 def _load_env(self, env_name, pettingzoo_params):
     from pettingzoo import atari
     from supersuit import resize_v0, frame_skip_v0, reshape_v0, max_observation_v0
     env = importlib.import_module(
         'pettingzoo.atari.{}'.format(env_name)).env(
             obs_type='grayscale_image', **pettingzoo_params)
     env = max_observation_v0(env, 2)
     env = frame_skip_v0(env, 4)
     env = resize_v0(env, 84, 84)
     env = reshape_v0(env, (1, 84, 84))
     return env
示例#3
0
def new_continuous_dummy():
    base_act_spaces = Box(low=np.float32(0.0), high=np.float32(10.0), shape=[3])
    return DummyEnv(base_obs, base_obs_space, base_act_spaces)


def new_dummy():
    return DummyEnv(base_obs, base_obs_space, base_act_spaces)


wrappers = [
    supersuit.color_reduction_v0(new_dummy(), "R"),
    supersuit.resize_v0(dtype_v0(new_dummy(), np.uint8), x_size=5, y_size=10),
    supersuit.resize_v0(dtype_v0(new_dummy(), np.uint8), x_size=5, y_size=10, linear_interp=True),
    supersuit.dtype_v0(new_dummy(), np.int32),
    supersuit.flatten_v0(new_dummy()),
    supersuit.reshape_v0(new_dummy(), (64, 3)),
    supersuit.normalize_obs_v0(new_dummy(), env_min=-1, env_max=5.0),
    supersuit.frame_stack_v1(new_dummy(), 8),
    supersuit.reward_lambda_v0(new_dummy(), lambda x: x / 10),
    supersuit.clip_reward_v0(new_dummy()),
    supersuit.clip_actions_v0(new_continuous_dummy()),
    supersuit.frame_skip_v0(new_dummy(), 4),
    supersuit.frame_skip_v0(new_dummy(), (4, 6)),
    supersuit.sticky_actions_v0(new_dummy(), 0.75),
    supersuit.delay_observations_v0(new_dummy(), 1),
]


@pytest.mark.parametrize("env", wrappers)
def test_basic_wrappers(env):
    env.seed(5)
示例#4
0
    wrapped_env = pad_action_space_v0(_env)
    parallel_test.parallel_play_test(wrapped_env)


wrappers = [
    supersuit.color_reduction_v0(knights_archers_zombies_v4.env(), "R"),
    supersuit.resize_v0(dtype_v0(knights_archers_zombies_v4.env(), np.uint8),
                        x_size=5,
                        y_size=10),
    supersuit.resize_v0(dtype_v0(knights_archers_zombies_v4.env(), np.uint8),
                        x_size=5,
                        y_size=10,
                        linear_interp=True),
    supersuit.dtype_v0(knights_archers_zombies_v4.env(), np.int32),
    supersuit.flatten_v0(knights_archers_zombies_v4.env()),
    supersuit.reshape_v0(knights_archers_zombies_v4.env(), (512 * 512, 3)),
    supersuit.normalize_obs_v0(dtype_v0(knights_archers_zombies_v4.env(),
                                        np.float32),
                               env_min=-1,
                               env_max=5.0),
    supersuit.frame_stack_v1(knights_archers_zombies_v4.env(), 8),
    supersuit.pad_observations_v0(knights_archers_zombies_v4.env()),
    supersuit.pad_action_space_v0(knights_archers_zombies_v4.env()),
    supersuit.black_death_v0(knights_archers_zombies_v4.env()),
    supersuit.agent_indicator_v0(knights_archers_zombies_v4.env(), True),
    supersuit.agent_indicator_v0(knights_archers_zombies_v4.env(), False),
    supersuit.reward_lambda_v0(knights_archers_zombies_v4.env(),
                               lambda x: x / 10),
    supersuit.clip_reward_v0(knights_archers_zombies_v4.env()),
    supersuit.clip_actions_v0(prison_v2.env(continuous=True)),
    supersuit.frame_skip_v0(knights_archers_zombies_v4.env(), 4),
 supersuit.resize_v1(
     dtype_v0(knights_archers_zombies_v10.env(vector_state=False),
              np.uint8),
     x_size=5,
     y_size=10,
 ),
 supersuit.resize_v1(
     dtype_v0(knights_archers_zombies_v10.env(vector_state=False),
              np.uint8),
     x_size=5,
     y_size=10,
     linear_interp=True,
 ),
 supersuit.dtype_v0(knights_archers_zombies_v10.env(), np.int32),
 supersuit.flatten_v0(knights_archers_zombies_v10.env()),
 supersuit.reshape_v0(knights_archers_zombies_v10.env(vector_state=False),
                      (512 * 512, 3)),
 supersuit.normalize_obs_v0(dtype_v0(knights_archers_zombies_v10.env(),
                                     np.float32),
                            env_min=-1,
                            env_max=5.0),
 supersuit.frame_stack_v1(combined_arms_v6.env(), 8),
 supersuit.pad_observations_v0(simple_world_comm_v2.env()),
 supersuit.pad_action_space_v0(simple_world_comm_v2.env()),
 supersuit.black_death_v3(combined_arms_v6.env()),
 supersuit.agent_indicator_v0(knights_archers_zombies_v10.env(), True),
 supersuit.agent_indicator_v0(knights_archers_zombies_v10.env(), False),
 supersuit.reward_lambda_v0(knights_archers_zombies_v10.env(),
                            lambda x: x / 10),
 supersuit.clip_reward_v0(combined_arms_v6.env()),
 supersuit.nan_noop_v0(knights_archers_zombies_v10.env(), 0),
 supersuit.nan_zeros_v0(knights_archers_zombies_v10.env()),