Skip to content

Commit

Permalink
Update MPE envs to 1.23.0 (#215)
Browse files Browse the repository at this point in the history
Update MPE envs
  • Loading branch information
elliottower authored May 15, 2023
2 parents 2a60ab1 + 64705ae commit c5f3133
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions test/pettingzoo_api_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest
from pettingzoo.butterfly import knights_archers_zombies_v10
from pettingzoo.mpe import simple_push_v2, simple_world_comm_v2
from pettingzoo.mpe import simple_push_v3, simple_world_comm_v3
from pettingzoo.test import api_test, parallel_test, seed_test

import supersuit
Expand All @@ -15,13 +15,13 @@


def test_pettingzoo_frame_stack():
_env = simple_push_v2.env()
_env = simple_push_v3.env()
wrapped_env = frame_stack_v1(_env)
api_test(wrapped_env)


def test_pettingzoo_frame_skip():
env = simple_push_v2.raw_env(max_cycles=100)
env = simple_push_v3.raw_env(max_cycles=100)
env = frame_skip_v0(env, 3)
env.reset()
x = 0
Expand All @@ -33,14 +33,14 @@ def test_pettingzoo_frame_skip():


def test_pettingzoo_pad_action_space():
_env = simple_world_comm_v2.env()
_env = simple_world_comm_v3.env()
wrapped_env = pad_action_space_v0(_env)
api_test(wrapped_env)
seed_test(lambda: sticky_actions_v0(simple_world_comm_v2.env(), 0.5), 100)
seed_test(lambda: sticky_actions_v0(simple_world_comm_v3.env(), 0.5), 100)


def test_pettingzoo_parallel_env():
_env = simple_world_comm_v2.parallel_env()
_env = simple_world_comm_v3.parallel_env()
wrapped_env = pad_action_space_v0(_env)
parallel_test.parallel_api_test(wrapped_env)

Expand Down Expand Up @@ -69,8 +69,8 @@ def test_pettingzoo_parallel_env():
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.pad_observations_v0(simple_world_comm_v3.env()),
supersuit.pad_action_space_v0(simple_world_comm_v3.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),
Expand All @@ -94,19 +94,19 @@ def test_pettingzoo_aec_api(env):

parallel_wrappers = [
# supersuit.frame_stack_v1(combined_arms_v6.parallel_env(), 8),
supersuit.frame_stack_v1(simple_push_v2.parallel_env(), 8),
supersuit.frame_stack_v1(simple_push_v3.parallel_env(), 8),
# supersuit.reward_lambda_v0(combined_arms_v6.parallel_env(), lambda x: x / 10),
# supersuit.delay_observations_v0(combined_arms_v6.parallel_env(), 3),
supersuit.delay_observations_v0(simple_push_v2.parallel_env(), 3),
supersuit.delay_observations_v0(simple_push_v3.parallel_env(), 3),
# supersuit.dtype_v0(combined_arms_v6.parallel_env(), np.int32),
supersuit.color_reduction_v0(
knights_archers_zombies_v10.parallel_env(vector_state=False), "R"
),
# supersuit.frame_skip_v0(combined_arms_v6.parallel_env(), 4),
supersuit.frame_skip_v0(simple_push_v2.parallel_env(), 4),
supersuit.frame_skip_v0(simple_push_v3.parallel_env(), 4),
# supersuit.max_observation_v0(combined_arms_v6.parallel_env(), 4),
# supersuit.black_death_v3(combined_arms_v6.parallel_env()),
supersuit.black_death_v3(simple_push_v2.parallel_env()),
supersuit.black_death_v3(simple_push_v3.parallel_env()),
]


Expand Down
4 changes: 2 additions & 2 deletions test/test_vector/test_aec_vector_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from pettingzoo.butterfly import knights_archers_zombies_v10
from pettingzoo.classic import rps_v2
from pettingzoo.mpe import simple_world_comm_v2
from pettingzoo.mpe import simple_world_comm_v3

from supersuit import vectorize_aec_env_v0

Expand Down Expand Up @@ -79,6 +79,6 @@ def select_action(vec_env, passes, i):
)
test_vec_env(
vectorize_aec_env_v0(
simple_world_comm_v2.env(), NUM_ENVS, num_cpus=num_cpus
simple_world_comm_v3.env(), NUM_ENVS, num_cpus=num_cpus
)
)
4 changes: 2 additions & 2 deletions test/test_vector/test_env_is_wrapped.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import gymnasium
import pytest
from pettingzoo.mpe import simple_spread_v2
from pettingzoo.mpe import simple_spread_v3

from supersuit import concat_vec_envs_v1, pettingzoo_env_to_vec_env_v1
from supersuit.generic_wrappers.frame_skip import frame_skip_gym
Expand Down Expand Up @@ -33,7 +33,7 @@ def test_env_is_wrapped_cpu():


def test_env_is_wrapped_pettingzoo():
env = simple_spread_v2.parallel_env()
env = simple_spread_v3.parallel_env()
venv1 = pettingzoo_env_to_vec_env_v1(env)
num_envs = 3
venv1 = concat_vec_envs_v1(venv1, num_envs)
Expand Down
4 changes: 2 additions & 2 deletions test/test_vector/test_gym_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import gymnasium
import numpy as np
import pytest
from pettingzoo.mpe import simple_spread_v2
from pettingzoo.mpe import simple_spread_v3

from supersuit import concat_vec_envs_v1, gym_vec_env_v0, pettingzoo_env_to_vec_env_v1

Expand Down Expand Up @@ -96,7 +96,7 @@ def test_mutliproc_single_proc_equivalency():
reason="Wrapper depreciated, see https://github.com/Farama-Foundation/SuperSuit/issues/188"
)
def test_multiagent_mutliproc_single_proc_equivalency():
env = simple_spread_v2.parallel_env(max_cycles=10)
env = simple_spread_v3.parallel_env(max_cycles=10)
env = pettingzoo_env_to_vec_env_v1(env)
num_envs = 3
# uses single threaded vector environment
Expand Down
8 changes: 4 additions & 4 deletions test/test_vector/test_pettingzoo_to_vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import pytest
from pettingzoo.butterfly import knights_archers_zombies_v10
from pettingzoo.mpe import simple_spread_v2, simple_world_comm_v2
from pettingzoo.mpe import simple_spread_v3, simple_world_comm_v3

from supersuit import black_death_v3, concat_vec_envs_v1, pettingzoo_env_to_vec_env_v1


def test_good_env():
env = simple_spread_v2.parallel_env()
env = simple_spread_v3.parallel_env()
max_num_agents = len(env.possible_agents)
env = pettingzoo_env_to_vec_env_v1(env)
assert env.num_envs == max_num_agents
Expand Down Expand Up @@ -37,7 +37,7 @@ def test_good_env():

def test_good_vecenv():
num_envs = 2
env = simple_spread_v2.parallel_env()
env = simple_spread_v3.parallel_env()
max_num_agents = len(env.possible_agents) * num_envs
env = pettingzoo_env_to_vec_env_v1(env)
env = concat_vec_envs_v1(env, num_envs)
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_good_vecenv():


def test_bad_action_spaces_env():
env = simple_world_comm_v2.parallel_env()
env = simple_world_comm_v3.parallel_env()
with pytest.raises(AssertionError):
env = pettingzoo_env_to_vec_env_v1(env)

Expand Down

0 comments on commit c5f3133

Please sign in to comment.