From 4001ab188da5a635448fdd97b3b3f73d2ce0b51d Mon Sep 17 00:00:00 2001 From: elliottower Date: Wed, 29 Mar 2023 11:01:20 -0400 Subject: [PATCH 01/20] Add pickling tests for all envs in API test, adapt waterworld to be picklable --- pettingzoo/sisl/waterworld/waterworld.py | 5 ++++- pettingzoo/test/api_test.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pettingzoo/sisl/waterworld/waterworld.py b/pettingzoo/sisl/waterworld/waterworld.py index 3564c1592..a8a618fc8 100755 --- a/pettingzoo/sisl/waterworld/waterworld.py +++ b/pettingzoo/sisl/waterworld/waterworld.py @@ -136,6 +136,8 @@ """ +from gymnasium.utils import EzPickle + from pettingzoo import AECEnv from pettingzoo.utils import agent_selector, wrappers from pettingzoo.utils.conversions import parallel_wrapper_fn @@ -154,7 +156,7 @@ def env(**kwargs): parallel_env = parallel_wrapper_fn(env) -class raw_env(AECEnv): +class raw_env(AECEnv, EzPickle): metadata = { "render_modes": ["human", "rgb_array"], "name": "waterworld_v4", @@ -163,6 +165,7 @@ class raw_env(AECEnv): } def __init__(self, *args, **kwargs): + EzPickle.__init__(self, *args, **kwargs) super().__init__() self.env = _env(*args, **kwargs) diff --git a/pettingzoo/test/api_test.py b/pettingzoo/test/api_test.py index 8a445387e..32224e281 100644 --- a/pettingzoo/test/api_test.py +++ b/pettingzoo/test/api_test.py @@ -1,3 +1,4 @@ +import pickle import random import re import warnings @@ -5,6 +6,7 @@ import gymnasium import numpy as np +from gymnasium.utils.env_checker import data_equivalence import pettingzoo from pettingzoo.utils.conversions import ( @@ -451,6 +453,21 @@ def test_action_flexibility(env): env.step(np.zeros_like(action_space.low)) +def test_pickle_env(env): + env.reset() + agent = env.agent_selection + try: + pickled_env = pickle.loads(pickle.dumps(env)) + data_equivalence(env.reset(), pickled_env.reset()) + action = env.action_space(agent).sample() + data_equivalence(env.step(action), pickled_env.step(action)) + env.close() + pickled_env.close() + + except AssertionError as ae: + print("did not save the observations: ", ae) + + def api_test(env, num_cycles=1000, verbose_progress=False): def progress_report(msg): if verbose_progress: @@ -517,6 +534,10 @@ def progress_report(msg): progress_report("Finished test_rewards_terminations_truncations") + test_pickle_env(env) + + progress_report("Finished environment pickle/EzPickle test") + # checks unwrapped attribute assert not isinstance(env.unwrapped, aec_to_parallel_wrapper) assert not isinstance(env.unwrapped, parallel_to_aec_wrapper) From e9476dbec4b71daa71817f4c075393daa5cb2721 Mon Sep 17 00:00:00 2001 From: elliottower Date: Wed, 29 Mar 2023 20:33:05 -0400 Subject: [PATCH 02/20] Refactor pickle test to be separate test (not in API test) --- pettingzoo/mpe/simple/simple.py | 4 +++- pettingzoo/test/api_test.py | 21 --------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/pettingzoo/mpe/simple/simple.py b/pettingzoo/mpe/simple/simple.py index 1de8f17c2..5514edc4a 100644 --- a/pettingzoo/mpe/simple/simple.py +++ b/pettingzoo/mpe/simple/simple.py @@ -43,6 +43,7 @@ """ import numpy as np +from gymnasium.utils import EzPickle from pettingzoo.utils.conversions import parallel_wrapper_fn @@ -51,8 +52,9 @@ from .._mpe_utils.simple_env import SimpleEnv, make_env -class raw_env(SimpleEnv): +class raw_env(SimpleEnv, EzPickle): def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): + EzPickle.__init__(self, max_cycles, continuous_actions, render_mode) scenario = Scenario() world = scenario.make_world() super().__init__( diff --git a/pettingzoo/test/api_test.py b/pettingzoo/test/api_test.py index 32224e281..8a445387e 100644 --- a/pettingzoo/test/api_test.py +++ b/pettingzoo/test/api_test.py @@ -1,4 +1,3 @@ -import pickle import random import re import warnings @@ -6,7 +5,6 @@ import gymnasium import numpy as np -from gymnasium.utils.env_checker import data_equivalence import pettingzoo from pettingzoo.utils.conversions import ( @@ -453,21 +451,6 @@ def test_action_flexibility(env): env.step(np.zeros_like(action_space.low)) -def test_pickle_env(env): - env.reset() - agent = env.agent_selection - try: - pickled_env = pickle.loads(pickle.dumps(env)) - data_equivalence(env.reset(), pickled_env.reset()) - action = env.action_space(agent).sample() - data_equivalence(env.step(action), pickled_env.step(action)) - env.close() - pickled_env.close() - - except AssertionError as ae: - print("did not save the observations: ", ae) - - def api_test(env, num_cycles=1000, verbose_progress=False): def progress_report(msg): if verbose_progress: @@ -534,10 +517,6 @@ def progress_report(msg): progress_report("Finished test_rewards_terminations_truncations") - test_pickle_env(env) - - progress_report("Finished environment pickle/EzPickle test") - # checks unwrapped attribute assert not isinstance(env.unwrapped, aec_to_parallel_wrapper) assert not isinstance(env.unwrapped, parallel_to_aec_wrapper) From 27a90f4b553ab175164bc6c400250bfd314637b4 Mon Sep 17 00:00:00 2001 From: elliottower Date: Thu, 30 Mar 2023 12:46:53 -0400 Subject: [PATCH 03/20] Update init __version__ to 1.23.0, tutorials rollback to 1.22.3 --- pettingzoo/__init__.py | 2 +- tutorials/CleanRL/requirements.txt | 2 +- tutorials/Ray/requirements.txt | 2 +- tutorials/Tianshou/requirements.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pettingzoo/__init__.py b/pettingzoo/__init__.py index 346cca435..2b41f102e 100644 --- a/pettingzoo/__init__.py +++ b/pettingzoo/__init__.py @@ -12,7 +12,7 @@ os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" -__version__ = "1.22.4" +__version__ = "1.23.0" try: import sys diff --git a/tutorials/CleanRL/requirements.txt b/tutorials/CleanRL/requirements.txt index cfcbd8e8c..097c8c395 100644 --- a/tutorials/CleanRL/requirements.txt +++ b/tutorials/CleanRL/requirements.txt @@ -1,5 +1,5 @@ SuperSuit==3.7.2 torch==1.13.1 -pettingzoo[butterfly]==1.22.4 +pettingzoo[butterfly]==1.22.3 # remove this line when SuperSuit has been updated to 3.7.3 tinyscaler==1.2.5 diff --git a/tutorials/Ray/requirements.txt b/tutorials/Ray/requirements.txt index cfc65a587..24a319dd8 100644 --- a/tutorials/Ray/requirements.txt +++ b/tutorials/Ray/requirements.txt @@ -5,4 +5,4 @@ Pillow==9.3.0 torch==1.13.1 SuperSuit==3.7.2 ray[rllib]==2 -pettingzoo==1.22.4 +pettingzoo==1.22.3 diff --git a/tutorials/Tianshou/requirements.txt b/tutorials/Tianshou/requirements.txt index f58b0030e..5acfe48eb 100644 --- a/tutorials/Tianshou/requirements.txt +++ b/tutorials/Tianshou/requirements.txt @@ -1,3 +1,3 @@ -pettingzoo[classic]==1.22.4 +pettingzoo[classic]==1.22.3 packaging==21.3 git+https://github.com/WillDudley/tianshou.git From af6902af31d4c574970828553dcf743058cca956 Mon Sep 17 00:00:00 2001 From: elliottower Date: Thu, 30 Mar 2023 12:54:53 -0400 Subject: [PATCH 04/20] Update CleanRL tutorial requirements.txt after testing --- tutorials/CleanRL/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/CleanRL/requirements.txt b/tutorials/CleanRL/requirements.txt index 097c8c395..6be9c9eb6 100644 --- a/tutorials/CleanRL/requirements.txt +++ b/tutorials/CleanRL/requirements.txt @@ -2,4 +2,4 @@ SuperSuit==3.7.2 torch==1.13.1 pettingzoo[butterfly]==1.22.3 # remove this line when SuperSuit has been updated to 3.7.3 -tinyscaler==1.2.5 +tinyscaler==1.2.4 From ad111a01871023ad0da98d97bd7d5d08af1bbdb7 Mon Sep 17 00:00:00 2001 From: elliottower Date: Fri, 31 Mar 2023 11:50:23 -0400 Subject: [PATCH 05/20] Add pickle test file (not committed by mistake) --- test/pickle_test.py | 141 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 test/pickle_test.py diff --git a/test/pickle_test.py b/test/pickle_test.py new file mode 100644 index 000000000..34875d452 --- /dev/null +++ b/test/pickle_test.py @@ -0,0 +1,141 @@ +import pickle + +import pytest +from gymnasium.utils.env_checker import data_equivalence + +from .all_modules import all_environments + +ALL_ENVS = list(all_environments.items()) +FAILING_ENV_NAMES = ["mpe/simple_world_comm_v2"] +PASSING_ENVS = [ + (name, env_module) + for (name, env_module) in ALL_ENVS + if name not in FAILING_ENV_NAMES +] + + +@pytest.mark.parametrize(("name", "env_module"), PASSING_ENVS) +def test_pickle_env(name, env_module): + env1 = env_module.env(render_mode=None) + env2 = pickle.loads(pickle.dumps(env1)) + + env1.reset(seed=42) + env2.reset(seed=42) + + agent1 = env1.agents[0] + agent2 = env2.agents[0] + + a_space1 = env1.action_space(agent1) + a_space1.seed(42) + a_space2 = env2.action_space(agent2) + a_space2.seed(42) + + iter = 0 + for agent1, agent2 in zip(env1.agent_iter(), env2.agent_iter()): + if iter > 10: + break + assert data_equivalence(agent1, agent2), f"Incorrect agent: {agent1} {agent2}" + + obs1, rew1, term1, trunc1, info1 = env1.last() + obs2, rew2, term2, trunc2, info2 = env2.last() + + if name == "mpe/simple_world_comm_v2": + print("Test") + + if term1 or term2 or trunc1 or trunc2: + break + + assert data_equivalence(obs1, obs2), f"Incorrect observations: {obs1} {obs2}" + assert data_equivalence(rew1, rew2), f"Incorrect rewards: {rew1} {rew2}" + assert data_equivalence(term1, term2), f"Incorrect terms: {term1} {term2}" + assert data_equivalence(trunc1, trunc2), f"Incorrect truncs: {trunc1} {trunc2}" + assert data_equivalence(info1, info2), f"Incorrect info: {info1} {info2}" + + mask = None + if "action_mask" in info1: + mask = info1["action_mask"] + + if isinstance(obs1, dict) and "action_mask" in obs1: + mask = obs1["action_mask"] + + action1 = a_space1.sample(mask=mask) + action2 = a_space2.sample(mask=mask) + + assert data_equivalence( + action1, action2 + ), f"Incorrect actions: {action1} {action2}" + + env1.step(action1) + env2.step(action2) + iter += 1 + env1.close() + env2.close() + + +ALL_ENVS = list(all_environments.items()) +FAILING_ENV_NAMES = [] +PASSING_ENVS = [ + (name, env_module) + for (name, env_module) in ALL_ENVS + if name not in FAILING_ENV_NAMES +] + + +@pytest.mark.skip( + reason="pickling pygame rendered envs does not work well, video system will not be initialized." +) +@pytest.mark.parametrize(("name", "env_module"), PASSING_ENVS) +def test_pickle_env_human(name, env_module): + env1 = env_module.env(render_mode="human") + env2 = pickle.loads(pickle.dumps(env1)) + + env1.reset(seed=42) + env2.reset(seed=42) + + agent1 = env1.agents[0] + agent2 = env2.agents[0] + + a_space1 = env1.action_space(agent1) + a_space1.seed(42) + a_space2 = env2.action_space(agent2) + a_space2.seed(42) + + iter = 0 + for agent1, agent2 in zip(env1.agent_iter(), env2.agent_iter()): + if iter > 5: + break + assert data_equivalence(agent1, agent2), f"Incorrect agent: {agent1} {agent2}" + + obs1, rew1, term1, trunc1, info1 = env1.last() + obs2, rew2, term2, trunc2, info2 = env2.last() + + assert data_equivalence(obs1, obs2), f"Incorrect observations: {obs1} {obs2}" + assert data_equivalence(rew1, rew2), f"Incorrect rewards: {rew1} {rew2}" + assert data_equivalence(term1, term2), f"Incorrect terms: {term1} {term2}" + assert data_equivalence(trunc1, trunc2), f"Incorrect truncs: {trunc1} {trunc2}" + assert data_equivalence(info1, info2), f"Incorrect info: {info1} {info2}" + + if name == "mpe/simple_world_comm_v2": + print("Test") + mask = None + if "action_mask" in info1: + mask = info1["action_mask"] + + if isinstance(obs1, dict) and "action_mask" in obs1: + mask = obs1["action_mask"] + + action1 = a_space1.sample(mask=mask) + action2 = a_space2.sample(mask=mask) + + assert data_equivalence( + action1, action2 + ), f"Incorrect actions: {action1} {action2}" + + if term1 or term2 or trunc1 or trunc2: + break + + env1.step(action1) + env2.step(action2) + iter += 1 + env1.close() + env2.close() From 32ed2e17327d13d05580e6b7dc3ab5cb20ce39d0 Mon Sep 17 00:00:00 2001 From: elliottower Date: Sat, 8 Apr 2023 13:57:20 -0400 Subject: [PATCH 06/20] Remove unnecessary changes, check waterworld/mpe --- docs/conf.py | 12 +++++++++--- pettingzoo/__init__.py | 2 +- tutorials/CleanRL/requirements.txt | 4 ++-- tutorials/Ray/requirements.txt | 4 ++-- tutorials/Tianshou/requirements.txt | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index e378c6536..4ad6a9512 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,8 @@ # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- +from typing import Any, Dict + import pettingzoo project = "PettingZoo" @@ -67,10 +69,14 @@ "dark_logo": "img/PettingZoo_White.svg", "gtag": "G-Q4EGMJ3R24", "versioning": True, - "source_repository": "https://github.com/Farama-Foundation/PettingZoo/", - "source_branch": "master", - "source_directory": "docs/", } +html_context: Dict[str, Any] = {} +html_context["conf_py_path"] = "/docs/" +html_context["display_github"] = True +html_context["github_user"] = "Farama-Foundation" +html_context["github_repo"] = "PettingZoo" +html_context["github_version"] = "master" +html_context["slug"] = "pettingzoo" html_static_path = ["_static"] html_css_files = [] diff --git a/pettingzoo/__init__.py b/pettingzoo/__init__.py index 2b41f102e..346cca435 100644 --- a/pettingzoo/__init__.py +++ b/pettingzoo/__init__.py @@ -12,7 +12,7 @@ os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" -__version__ = "1.23.0" +__version__ = "1.22.4" try: import sys diff --git a/tutorials/CleanRL/requirements.txt b/tutorials/CleanRL/requirements.txt index 6be9c9eb6..cfcbd8e8c 100644 --- a/tutorials/CleanRL/requirements.txt +++ b/tutorials/CleanRL/requirements.txt @@ -1,5 +1,5 @@ SuperSuit==3.7.2 torch==1.13.1 -pettingzoo[butterfly]==1.22.3 +pettingzoo[butterfly]==1.22.4 # remove this line when SuperSuit has been updated to 3.7.3 -tinyscaler==1.2.4 +tinyscaler==1.2.5 diff --git a/tutorials/Ray/requirements.txt b/tutorials/Ray/requirements.txt index 07fa731fe..7c84b646f 100644 --- a/tutorials/Ray/requirements.txt +++ b/tutorials/Ray/requirements.txt @@ -1,9 +1,9 @@ Gymnasium==0.28.1 numpy==1.23.5 -PettingZoo==1.22.3 +PettingZoo==1.22.4 Pillow==9.4.0 ray[rllib]==3.0.0.dev0 SuperSuit==3.7.2 torch==1.13.1 tensorflow-probability==0.19.0 -rlcard==1.1.0 +rlcard==1.1.0 \ No newline at end of file diff --git a/tutorials/Tianshou/requirements.txt b/tutorials/Tianshou/requirements.txt index 5acfe48eb..f58b0030e 100644 --- a/tutorials/Tianshou/requirements.txt +++ b/tutorials/Tianshou/requirements.txt @@ -1,3 +1,3 @@ -pettingzoo[classic]==1.22.3 +pettingzoo[classic]==1.22.4 packaging==21.3 git+https://github.com/WillDudley/tianshou.git From 473a797a9e23f385e29aa261adeb9b4132a3204d Mon Sep 17 00:00:00 2001 From: elliottower Date: Tue, 11 Apr 2023 15:09:31 -0400 Subject: [PATCH 07/20] Use keyword args for EzPickle, replace all relative imports with global --- pettingzoo/atari/base_atari_env.py | 20 ++++++------- .../atari/basketball_pong/basketball_pong.py | 6 +++- pettingzoo/atari/boxing/boxing.py | 6 +++- pettingzoo/atari/combat_plane/combat_plane.py | 6 +++- pettingzoo/atari/combat_tank/combat_tank.py | 6 +++- pettingzoo/atari/double_dunk/double_dunk.py | 6 +++- .../entombed_competitive.py | 6 +++- .../entombed_cooperative.py | 6 +++- pettingzoo/atari/flag_capture/flag_capture.py | 6 +++- pettingzoo/atari/foozpong/foozpong.py | 6 +++- pettingzoo/atari/ice_hockey/ice_hockey.py | 6 +++- pettingzoo/atari/joust/joust.py | 6 +++- pettingzoo/atari/mario_bros/mario_bros.py | 6 +++- pettingzoo/atari/maze_craze/maze_craze.py | 6 +++- pettingzoo/atari/othello/othello.py | 6 +++- pettingzoo/atari/pong/pong.py | 6 +++- pettingzoo/atari/quadrapong/quadrapong.py | 6 +++- .../atari/space_invaders/space_invaders.py | 6 +++- pettingzoo/atari/space_war/space_war.py | 6 +++- pettingzoo/atari/surround/surround.py | 6 +++- pettingzoo/atari/tennis/tennis.py | 6 +++- .../atari/video_checkers/video_checkers.py | 6 +++- .../atari/volleyball_pong/volleyball_pong.py | 6 +++- pettingzoo/atari/warlords/warlords.py | 6 +++- .../atari/wizard_of_wor/wizard_of_wor.py | 6 +++- .../knights_archers_zombies.py | 28 +++++++++---------- pettingzoo/butterfly/pistonball/pistonball.py | 20 ++++++------- pettingzoo/classic/hanabi/hanabi.py | 18 ++++++------ pettingzoo/classic/rlcard_envs/gin_rummy.py | 7 ++++- pettingzoo/mpe/simple/simple.py | 17 +++++++---- .../mpe/simple_adversary/simple_adversary.py | 15 ++++++---- pettingzoo/mpe/simple_crypto/simple_crypto.py | 14 ++++++---- pettingzoo/mpe/simple_push/simple_push.py | 14 ++++++---- .../mpe/simple_reference/simple_reference.py | 15 +++++----- .../simple_speaker_listener.py | 14 ++++++---- pettingzoo/mpe/simple_spread/simple_spread.py | 14 ++++++---- pettingzoo/mpe/simple_tag/simple_tag.py | 19 ++++++------- .../simple_world_comm/simple_world_comm.py | 7 ++--- .../sisl/multiwalker/multiwalker_base.py | 2 +- pettingzoo/sisl/waterworld/waterworld.py | 2 +- pettingzoo/utils/__init__.py | 18 +++++++----- pettingzoo/utils/wrappers/__init__.py | 14 +++++----- .../utils/wrappers/assert_out_of_bounds.py | 2 +- pettingzoo/utils/wrappers/base_parallel.py | 2 +- pettingzoo/utils/wrappers/capture_stdout.py | 4 +-- .../utils/wrappers/clip_out_of_bounds.py | 4 +-- pettingzoo/utils/wrappers/order_enforcing.py | 6 ++-- .../utils/wrappers/terminate_illegal.py | 4 +-- 48 files changed, 276 insertions(+), 148 deletions(-) diff --git a/pettingzoo/atari/base_atari_env.py b/pettingzoo/atari/base_atari_env.py index 3e834d7c4..c609b942c 100644 --- a/pettingzoo/atari/base_atari_env.py +++ b/pettingzoo/atari/base_atari_env.py @@ -49,16 +49,16 @@ def __init__( """ EzPickle.__init__( self, - game, - num_players, - mode_num, - seed, - obs_type, - full_action_space, - env_name, - max_cycles, - render_mode, - auto_rom_install_path, + game=game, + num_players=num_players, + mode_num=mode_num, + seed=seed, + obs_type=obs_type, + full_action_space=full_action_space, + env_name=env_name, + max_cycles=max_cycles, + render_mode=render_mode, + auto_rom_install_path=auto_rom_install_path, ) assert obs_type in ( diff --git a/pettingzoo/atari/basketball_pong/basketball_pong.py b/pettingzoo/atari/basketball_pong/basketball_pong.py index 13490d431..34efa22cd 100644 --- a/pettingzoo/atari/basketball_pong/basketball_pong.py +++ b/pettingzoo/atari/basketball_pong/basketball_pong.py @@ -68,7 +68,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(num_players=2, **kwargs): diff --git a/pettingzoo/atari/boxing/boxing.py b/pettingzoo/atari/boxing/boxing.py index 6750bff12..55fcb0c56 100644 --- a/pettingzoo/atari/boxing/boxing.py +++ b/pettingzoo/atari/boxing/boxing.py @@ -78,7 +78,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/combat_plane/combat_plane.py b/pettingzoo/atari/combat_plane/combat_plane.py index 7cebebfc2..ba56abfb6 100644 --- a/pettingzoo/atari/combat_plane/combat_plane.py +++ b/pettingzoo/atari/combat_plane/combat_plane.py @@ -88,7 +88,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) avaliable_versions = { "bi-plane": 15, diff --git a/pettingzoo/atari/combat_tank/combat_tank.py b/pettingzoo/atari/combat_tank/combat_tank.py index c4d12df24..7870604db 100644 --- a/pettingzoo/atari/combat_tank/combat_tank.py +++ b/pettingzoo/atari/combat_tank/combat_tank.py @@ -86,7 +86,11 @@ import warnings from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(has_maze=True, is_invisible=False, billiard_hit=True, **kwargs): diff --git a/pettingzoo/atari/double_dunk/double_dunk.py b/pettingzoo/atari/double_dunk/double_dunk.py index 97362c77a..88e7e3fb3 100644 --- a/pettingzoo/atari/double_dunk/double_dunk.py +++ b/pettingzoo/atari/double_dunk/double_dunk.py @@ -78,7 +78,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/entombed_competitive/entombed_competitive.py b/pettingzoo/atari/entombed_competitive/entombed_competitive.py index f5fc69e27..08213bf91 100644 --- a/pettingzoo/atari/entombed_competitive/entombed_competitive.py +++ b/pettingzoo/atari/entombed_competitive/entombed_competitive.py @@ -75,7 +75,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py b/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py index 450f5788c..86602bd8c 100644 --- a/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py +++ b/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py @@ -83,7 +83,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/flag_capture/flag_capture.py b/pettingzoo/atari/flag_capture/flag_capture.py index def0ee405..018c86967 100644 --- a/pettingzoo/atari/flag_capture/flag_capture.py +++ b/pettingzoo/atari/flag_capture/flag_capture.py @@ -72,7 +72,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/foozpong/foozpong.py b/pettingzoo/atari/foozpong/foozpong.py index 295bc2b21..acc1630f3 100644 --- a/pettingzoo/atari/foozpong/foozpong.py +++ b/pettingzoo/atari/foozpong/foozpong.py @@ -73,7 +73,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(num_players=4, **kwargs): diff --git a/pettingzoo/atari/ice_hockey/ice_hockey.py b/pettingzoo/atari/ice_hockey/ice_hockey.py index ec65b6331..e164b1933 100644 --- a/pettingzoo/atari/ice_hockey/ice_hockey.py +++ b/pettingzoo/atari/ice_hockey/ice_hockey.py @@ -71,7 +71,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/joust/joust.py b/pettingzoo/atari/joust/joust.py index 20f4441fd..c67debe32 100644 --- a/pettingzoo/atari/joust/joust.py +++ b/pettingzoo/atari/joust/joust.py @@ -75,7 +75,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/mario_bros/mario_bros.py b/pettingzoo/atari/mario_bros/mario_bros.py index 58521a485..3b8c662d0 100644 --- a/pettingzoo/atari/mario_bros/mario_bros.py +++ b/pettingzoo/atari/mario_bros/mario_bros.py @@ -79,7 +79,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/maze_craze/maze_craze.py b/pettingzoo/atari/maze_craze/maze_craze.py index b567adfe3..e9ea11a51 100644 --- a/pettingzoo/atari/maze_craze/maze_craze.py +++ b/pettingzoo/atari/maze_craze/maze_craze.py @@ -88,7 +88,11 @@ import warnings from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) avaliable_versions = { "robbers": 2, diff --git a/pettingzoo/atari/othello/othello.py b/pettingzoo/atari/othello/othello.py index a14ab6825..2959c1105 100644 --- a/pettingzoo/atari/othello/othello.py +++ b/pettingzoo/atari/othello/othello.py @@ -75,7 +75,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/pong/pong.py b/pettingzoo/atari/pong/pong.py index cea18c64c..1d5ad17f8 100644 --- a/pettingzoo/atari/pong/pong.py +++ b/pettingzoo/atari/pong/pong.py @@ -70,7 +70,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) avaliable_2p_versions = { "classic": 4, diff --git a/pettingzoo/atari/quadrapong/quadrapong.py b/pettingzoo/atari/quadrapong/quadrapong.py index 75f0da427..ca626ad59 100644 --- a/pettingzoo/atari/quadrapong/quadrapong.py +++ b/pettingzoo/atari/quadrapong/quadrapong.py @@ -65,7 +65,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/space_invaders/space_invaders.py b/pettingzoo/atari/space_invaders/space_invaders.py index 83891720b..7ce34d6d7 100644 --- a/pettingzoo/atari/space_invaders/space_invaders.py +++ b/pettingzoo/atari/space_invaders/space_invaders.py @@ -78,7 +78,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env( diff --git a/pettingzoo/atari/space_war/space_war.py b/pettingzoo/atari/space_war/space_war.py index 65e016cd1..e66515e92 100644 --- a/pettingzoo/atari/space_war/space_war.py +++ b/pettingzoo/atari/space_war/space_war.py @@ -72,7 +72,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/surround/surround.py b/pettingzoo/atari/surround/surround.py index 6a42c7596..878888843 100644 --- a/pettingzoo/atari/surround/surround.py +++ b/pettingzoo/atari/surround/surround.py @@ -60,7 +60,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/tennis/tennis.py b/pettingzoo/atari/tennis/tennis.py index b64164c11..e4e61c671 100644 --- a/pettingzoo/atari/tennis/tennis.py +++ b/pettingzoo/atari/tennis/tennis.py @@ -74,7 +74,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/video_checkers/video_checkers.py b/pettingzoo/atari/video_checkers/video_checkers.py index 135469fc7..cf780dc20 100644 --- a/pettingzoo/atari/video_checkers/video_checkers.py +++ b/pettingzoo/atari/video_checkers/video_checkers.py @@ -64,7 +64,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/volleyball_pong/volleyball_pong.py b/pettingzoo/atari/volleyball_pong/volleyball_pong.py index f80857d48..e7e1894f3 100644 --- a/pettingzoo/atari/volleyball_pong/volleyball_pong.py +++ b/pettingzoo/atari/volleyball_pong/volleyball_pong.py @@ -73,7 +73,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(num_players=4, **kwargs): diff --git a/pettingzoo/atari/warlords/warlords.py b/pettingzoo/atari/warlords/warlords.py index de2ecbcd4..9c44960e9 100644 --- a/pettingzoo/atari/warlords/warlords.py +++ b/pettingzoo/atari/warlords/warlords.py @@ -60,7 +60,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py b/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py index 4b8506722..16ea0b04e 100644 --- a/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py +++ b/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py @@ -66,7 +66,11 @@ import os from glob import glob -from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn +from pettingzoo.atari.base_atari_env import ( + BaseAtariEnv, + base_env_wrapper_fn, + parallel_wrapper_fn, +) def raw_env(**kwargs): diff --git a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py index 93968a890..1c812a51c 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py +++ b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py @@ -238,20 +238,20 @@ def __init__( ): EzPickle.__init__( self, - spawn_rate, - num_archers, - num_knights, - max_zombies, - max_arrows, - killable_knights, - killable_archers, - pad_observation, - line_death, - max_cycles, - vector_state, - use_typemasks, - sequence_space, - render_mode, + spawn_rate=spawn_rate, + num_arches=num_archers, + num_knights=num_knights, + max_zombies=max_zombies, + max_arrows=max_arrows, + killable_knights=killable_knights, + killable_arches=killable_archers, + pad_observation=pad_observation, + line_death=line_death, + max_cycles=max_cycles, + vector_state=vector_state, + use_typemasks=use_typemasks, + sequence_space=sequence_space, + render_mode=render_mode, ) # variable state space self.sequence_space = sequence_space diff --git a/pettingzoo/butterfly/pistonball/pistonball.py b/pettingzoo/butterfly/pistonball/pistonball.py index bfc38159c..5bb43445c 100644 --- a/pettingzoo/butterfly/pistonball/pistonball.py +++ b/pettingzoo/butterfly/pistonball/pistonball.py @@ -145,16 +145,16 @@ def __init__( ): EzPickle.__init__( self, - n_pistons, - time_penalty, - continuous, - random_drop, - random_rotate, - ball_mass, - ball_friction, - ball_elasticity, - max_cycles, - render_mode, + n_pistons=n_pistons, + time_penalty=time_penalty, + continuous=continuous, + random_drop=random_drop, + random_rotate=random_rotate, + ball_mass=ball_mass, + ball_friction=ball_friction, + ball_elasticity=ball_elasticity, + max_cycles=max_cycles, + render_mode=render_mode, ) self.dt = 1.0 / FPS self.n_pistons = n_pistons diff --git a/pettingzoo/classic/hanabi/hanabi.py b/pettingzoo/classic/hanabi/hanabi.py index 08c218cb3..e770871f1 100644 --- a/pettingzoo/classic/hanabi/hanabi.py +++ b/pettingzoo/classic/hanabi/hanabi.py @@ -287,15 +287,15 @@ def __init__( """ EzPickle.__init__( self, - colors, - ranks, - players, - hand_size, - max_information_tokens, - max_life_tokens, - observation_type, - random_start_player, - render_mode, + colors=colors, + ranks=ranks, + players=players, + hand_size=hand_size, + max_information_tokens=max_information_tokens, + max_life_tokens=max_life_tokens, + observation_type=observation_type, + random_start_player=random_start_player, + render_mode=render_mode, ) # ToDo: Starts diff --git a/pettingzoo/classic/rlcard_envs/gin_rummy.py b/pettingzoo/classic/rlcard_envs/gin_rummy.py index c1d02f550..b660eb70f 100644 --- a/pettingzoo/classic/rlcard_envs/gin_rummy.py +++ b/pettingzoo/classic/rlcard_envs/gin_rummy.py @@ -152,7 +152,12 @@ def __init__( opponents_hand_visible=False, render_mode=None, ): - EzPickle.__init__(self, knock_reward, gin_reward, render_mode) + EzPickle.__init__( + self, + knock_reward=knock_reward, + gin_reward=gin_reward, + render_mode=render_mode, + ) self._opponents_hand_visible = opponents_hand_visible num_planes = 5 if self._opponents_hand_visible else 4 RLCardBase.__init__(self, "gin-rummy", 2, (num_planes, 52)) diff --git a/pettingzoo/mpe/simple/simple.py b/pettingzoo/mpe/simple/simple.py index 5514edc4a..457bb3f81 100644 --- a/pettingzoo/mpe/simple/simple.py +++ b/pettingzoo/mpe/simple/simple.py @@ -45,19 +45,24 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): - EzPickle.__init__(self, max_cycles, continuous_actions, render_mode) + EzPickle.__init__( + self, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, + ) scenario = Scenario() world = scenario.make_world() - super().__init__( + SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_adversary/simple_adversary.py b/pettingzoo/mpe/simple_adversary/simple_adversary.py index 2624640cb..4caa26896 100644 --- a/pettingzoo/mpe/simple_adversary/simple_adversary.py +++ b/pettingzoo/mpe/simple_adversary/simple_adversary.py @@ -55,16 +55,21 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__(self, N=2, max_cycles=25, continuous_actions=False, render_mode=None): - EzPickle.__init__(self, N, max_cycles, continuous_actions, render_mode) + EzPickle.__init__( + self, + N=N, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, + ) scenario = Scenario() world = scenario.make_world(N) super().__init__( diff --git a/pettingzoo/mpe/simple_crypto/simple_crypto.py b/pettingzoo/mpe/simple_crypto/simple_crypto.py index 26885f53b..78588ef47 100644 --- a/pettingzoo/mpe/simple_crypto/simple_crypto.py +++ b/pettingzoo/mpe/simple_crypto/simple_crypto.py @@ -59,12 +59,11 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - """Simple crypto environment. Scenario: @@ -75,7 +74,12 @@ class raw_env(SimpleEnv, EzPickle): def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): - EzPickle.__init__(self, max_cycles, continuous_actions, render_mode) + EzPickle.__init__( + self, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, + ) scenario = Scenario() world = scenario.make_world() super().__init__( diff --git a/pettingzoo/mpe/simple_push/simple_push.py b/pettingzoo/mpe/simple_push/simple_push.py index fe73cf5f1..d445dc94c 100644 --- a/pettingzoo/mpe/simple_push/simple_push.py +++ b/pettingzoo/mpe/simple_push/simple_push.py @@ -50,16 +50,20 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): - EzPickle.__init__(self, max_cycles, continuous_actions, render_mode) + EzPickle.__init__( + self, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, + ) scenario = Scenario() world = scenario.make_world() super().__init__( diff --git a/pettingzoo/mpe/simple_reference/simple_reference.py b/pettingzoo/mpe/simple_reference/simple_reference.py index 0f03a8373..c9cceb01f 100644 --- a/pettingzoo/mpe/simple_reference/simple_reference.py +++ b/pettingzoo/mpe/simple_reference/simple_reference.py @@ -56,12 +56,11 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__( @@ -69,10 +68,10 @@ def __init__( ): EzPickle.__init__( self, - local_ratio, - max_cycles, - continuous_actions, - render_mode, + local_ratio=local_ratio, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, ) assert ( 0.0 <= local_ratio <= 1.0 diff --git a/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py b/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py index c1977f2ee..e287288ee 100644 --- a/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py +++ b/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py @@ -51,16 +51,20 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): - EzPickle.__init__(self, max_cycles, continuous_actions, render_mode) + EzPickle.__init__( + self, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, + ) scenario = Scenario() world = scenario.make_world() super().__init__( diff --git a/pettingzoo/mpe/simple_spread/simple_spread.py b/pettingzoo/mpe/simple_spread/simple_spread.py index c6d0b4c15..475b9c01b 100644 --- a/pettingzoo/mpe/simple_spread/simple_spread.py +++ b/pettingzoo/mpe/simple_spread/simple_spread.py @@ -54,12 +54,11 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__( @@ -71,7 +70,12 @@ def __init__( render_mode=None, ): EzPickle.__init__( - self, N, local_ratio, max_cycles, continuous_actions, render_mode + self, + N=N, + local_ratio=local_ratio, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, ) assert ( 0.0 <= local_ratio <= 1.0 diff --git a/pettingzoo/mpe/simple_tag/simple_tag.py b/pettingzoo/mpe/simple_tag/simple_tag.py index cee12fd88..b03572827 100644 --- a/pettingzoo/mpe/simple_tag/simple_tag.py +++ b/pettingzoo/mpe/simple_tag/simple_tag.py @@ -65,12 +65,11 @@ def bound(x): import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__( @@ -84,12 +83,12 @@ def __init__( ): EzPickle.__init__( self, - num_good, - num_adversaries, - num_obstacles, - max_cycles, - continuous_actions, - render_mode, + num_good=num_good, + num_adversaries=num_adversaries, + num_obstacles=num_obstacles, + max_cycles=max_cycles, + continuous_actions=continuous_actions, + render_mode=render_mode, ) scenario = Scenario() world = scenario.make_world(num_good, num_adversaries, num_obstacles) diff --git a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py index 7ddbe3444..eebf2ff9b 100644 --- a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py +++ b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py @@ -76,12 +76,11 @@ import numpy as np from gymnasium.utils import EzPickle +from pettingzoo.mpe._mpe_utils.core import Agent, Landmark, World +from pettingzoo.mpe._mpe_utils.scenario import BaseScenario +from pettingzoo.mpe._mpe_utils.simple_env import SimpleEnv, make_env from pettingzoo.utils.conversions import parallel_wrapper_fn -from .._mpe_utils.core import Agent, Landmark, World -from .._mpe_utils.scenario import BaseScenario -from .._mpe_utils.simple_env import SimpleEnv, make_env - class raw_env(SimpleEnv, EzPickle): def __init__( diff --git a/pettingzoo/sisl/multiwalker/multiwalker_base.py b/pettingzoo/sisl/multiwalker/multiwalker_base.py index ec21d6d77..8f3165e60 100644 --- a/pettingzoo/sisl/multiwalker/multiwalker_base.py +++ b/pettingzoo/sisl/multiwalker/multiwalker_base.py @@ -16,7 +16,7 @@ from gymnasium.utils import seeding from pygame import gfxdraw -from .._utils import Agent +from pettingzoo.sisl._utils import Agent MAX_AGENTS = 40 diff --git a/pettingzoo/sisl/waterworld/waterworld.py b/pettingzoo/sisl/waterworld/waterworld.py index a8a618fc8..f0e25f007 100755 --- a/pettingzoo/sisl/waterworld/waterworld.py +++ b/pettingzoo/sisl/waterworld/waterworld.py @@ -166,7 +166,7 @@ class raw_env(AECEnv, EzPickle): def __init__(self, *args, **kwargs): EzPickle.__init__(self, *args, **kwargs) - super().__init__() + AECEnv.__init__(self) self.env = _env(*args, **kwargs) self.agents = ["pursuer_" + str(r) for r in range(self.env.num_agents)] diff --git a/pettingzoo/utils/__init__.py b/pettingzoo/utils/__init__.py index 18801e8fe..af9445539 100644 --- a/pettingzoo/utils/__init__.py +++ b/pettingzoo/utils/__init__.py @@ -1,10 +1,14 @@ -from .agent_selector import agent_selector -from .average_total_reward import average_total_reward -from .conversions import aec_to_parallel, parallel_to_aec, turn_based_aec_to_parallel -from .env import AECEnv, ParallelEnv -from .random_demo import random_demo -from .save_observation import save_observation -from .wrappers import ( +from pettingzoo.utils.agent_selector import agent_selector +from pettingzoo.utils.average_total_reward import average_total_reward +from pettingzoo.utils.conversions import ( + aec_to_parallel, + parallel_to_aec, + turn_based_aec_to_parallel, +) +from pettingzoo.utils.env import AECEnv, ParallelEnv +from pettingzoo.utils.random_demo import random_demo +from pettingzoo.utils.save_observation import save_observation +from pettingzoo.utils.wrappers import ( AssertOutOfBoundsWrapper, BaseParallelWrapper, BaseWrapper, diff --git a/pettingzoo/utils/wrappers/__init__.py b/pettingzoo/utils/wrappers/__init__.py index c09dd2b5b..494babb3c 100644 --- a/pettingzoo/utils/wrappers/__init__.py +++ b/pettingzoo/utils/wrappers/__init__.py @@ -1,7 +1,7 @@ -from .assert_out_of_bounds import AssertOutOfBoundsWrapper -from .base import BaseWrapper -from .base_parallel import BaseParallelWrapper -from .capture_stdout import CaptureStdoutWrapper -from .clip_out_of_bounds import ClipOutOfBoundsWrapper -from .order_enforcing import OrderEnforcingWrapper -from .terminate_illegal import TerminateIllegalWrapper +from pettingzoo.utils.wrappers.assert_out_of_bounds import AssertOutOfBoundsWrapper +from pettingzoo.utils.wrappers.base import BaseWrapper +from pettingzoo.utils.wrappers.base_parallel import BaseParallelWrapper +from pettingzoo.utils.wrappers.capture_stdout import CaptureStdoutWrapper +from pettingzoo.utils.wrappers.clip_out_of_bounds import ClipOutOfBoundsWrapper +from pettingzoo.utils.wrappers.order_enforcing import OrderEnforcingWrapper +from pettingzoo.utils.wrappers.terminate_illegal import TerminateIllegalWrapper diff --git a/pettingzoo/utils/wrappers/assert_out_of_bounds.py b/pettingzoo/utils/wrappers/assert_out_of_bounds.py index 125a03533..a394334fc 100644 --- a/pettingzoo/utils/wrappers/assert_out_of_bounds.py +++ b/pettingzoo/utils/wrappers/assert_out_of_bounds.py @@ -1,6 +1,6 @@ from gymnasium.spaces import Discrete -from .base import BaseWrapper +from pettingzoo.utils.wrappers.base import BaseWrapper class AssertOutOfBoundsWrapper(BaseWrapper): diff --git a/pettingzoo/utils/wrappers/base_parallel.py b/pettingzoo/utils/wrappers/base_parallel.py index 599d323b4..332208869 100644 --- a/pettingzoo/utils/wrappers/base_parallel.py +++ b/pettingzoo/utils/wrappers/base_parallel.py @@ -2,7 +2,7 @@ from gymnasium.utils import seeding -from ..env import ParallelEnv +from pettingzoo.utils.env import ParallelEnv class BaseParallelWrapper(ParallelEnv): diff --git a/pettingzoo/utils/wrappers/capture_stdout.py b/pettingzoo/utils/wrappers/capture_stdout.py index 47d843be4..2d7273efa 100644 --- a/pettingzoo/utils/wrappers/capture_stdout.py +++ b/pettingzoo/utils/wrappers/capture_stdout.py @@ -1,5 +1,5 @@ -from ..capture_stdout import capture_stdout -from .base import BaseWrapper +from pettingzoo.utils.capture_stdout import capture_stdout +from pettingzoo.utils.wrappers.base import BaseWrapper class CaptureStdoutWrapper(BaseWrapper): diff --git a/pettingzoo/utils/wrappers/clip_out_of_bounds.py b/pettingzoo/utils/wrappers/clip_out_of_bounds.py index 2fb953117..ea1b596a3 100644 --- a/pettingzoo/utils/wrappers/clip_out_of_bounds.py +++ b/pettingzoo/utils/wrappers/clip_out_of_bounds.py @@ -1,8 +1,8 @@ import numpy as np from gymnasium.spaces import Box -from ..env_logger import EnvLogger -from .base import BaseWrapper +from pettingzoo.utils.env_logger import EnvLogger +from pettingzoo.utils.wrappers.base import BaseWrapper class ClipOutOfBoundsWrapper(BaseWrapper): diff --git a/pettingzoo/utils/wrappers/order_enforcing.py b/pettingzoo/utils/wrappers/order_enforcing.py index dacda2d53..9f0b1a822 100644 --- a/pettingzoo/utils/wrappers/order_enforcing.py +++ b/pettingzoo/utils/wrappers/order_enforcing.py @@ -1,6 +1,6 @@ -from ..env import AECIterable, AECIterator -from ..env_logger import EnvLogger -from .base import BaseWrapper +from pettingzoo.utils.env import AECIterable, AECIterator +from pettingzoo.utils.env_logger import EnvLogger +from pettingzoo.utils.wrappers.base import BaseWrapper class OrderEnforcingWrapper(BaseWrapper): diff --git a/pettingzoo/utils/wrappers/terminate_illegal.py b/pettingzoo/utils/wrappers/terminate_illegal.py index 5a2c0a97d..85e69894c 100644 --- a/pettingzoo/utils/wrappers/terminate_illegal.py +++ b/pettingzoo/utils/wrappers/terminate_illegal.py @@ -1,5 +1,5 @@ -from ..env_logger import EnvLogger -from .base import BaseWrapper +from pettingzoo.utils.env_logger import EnvLogger +from pettingzoo.utils.wrappers.base import BaseWrapper class TerminateIllegalWrapper(BaseWrapper): From a2c420cc7365c14d2874a00a8a3a0aa6c0ae162a Mon Sep 17 00:00:00 2001 From: elliottower Date: Tue, 11 Apr 2023 16:39:58 -0400 Subject: [PATCH 08/20] Fix typo with KAZ ezpickle --- .../knights_archers_zombies/knights_archers_zombies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py index 1c812a51c..b602be03b 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py +++ b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py @@ -239,7 +239,7 @@ def __init__( EzPickle.__init__( self, spawn_rate=spawn_rate, - num_arches=num_archers, + num_archers=num_archers, num_knights=num_knights, max_zombies=max_zombies, max_arrows=max_arrows, From fd65b838bf32d9c364c5dc874432de596530a726 Mon Sep 17 00:00:00 2001 From: elliottower Date: Tue, 11 Apr 2023 17:04:36 -0400 Subject: [PATCH 09/20] Fix typo with KAZ ezpickle --- .../knights_archers_zombies.py | 2 +- test/all_parameter_combs_test.py | 64 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py index b602be03b..e89e191af 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py +++ b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py @@ -244,7 +244,7 @@ def __init__( max_zombies=max_zombies, max_arrows=max_arrows, killable_knights=killable_knights, - killable_arches=killable_archers, + killable_archers=killable_archers, pad_observation=pad_observation, line_death=line_death, max_cycles=max_cycles, diff --git a/test/all_parameter_combs_test.py b/test/all_parameter_combs_test.py index 0bdc70ec7..f2b48fb1f 100644 --- a/test/all_parameter_combs_test.py +++ b/test/all_parameter_combs_test.py @@ -8,38 +8,38 @@ from .all_modules import * # noqa: F403 parameterized_envs = [ - ["atari/boxing_v2", boxing_v2, dict(obs_type="grayscale_image")], - ["atari/boxing_v2", boxing_v2, dict(obs_type="ram")], - ["atari/boxing_v2", boxing_v2, dict(full_action_space=False)], - ["atari/combat_plane_v2", combat_plane_v2, dict(game_version="jet")], - ["atari/combat_plane_v2", combat_plane_v2, dict(guided_missile=True)], - ["atari/combat_tank_v2", combat_tank_v2, dict(has_maze=True)], - ["atari/combat_tank_v2", combat_tank_v2, dict(is_invisible=True)], - ["atari/combat_tank_v2", combat_tank_v2, dict(billiard_hit=True)], - ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="race")], - ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="capture")], - ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=1)], - ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=3)], - [ - "atari/space_invaders_v2", - space_invaders_v2, - dict( - alternating_control=True, - moving_shields=True, - zigzaging_bombs=True, - fast_bomb=True, - invisible_invaders=True, - ), - ], - ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=2)], - ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=3)], - ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=4)], - ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=2)], - ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=3)], - ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=4)], - ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=2)], - ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=3)], - ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=4)], + # ["atari/boxing_v2", boxing_v2, dict(obs_type="grayscale_image")], + # ["atari/boxing_v2", boxing_v2, dict(obs_type="ram")], + # ["atari/boxing_v2", boxing_v2, dict(full_action_space=False)], + # ["atari/combat_plane_v2", combat_plane_v2, dict(game_version="jet")], + # ["atari/combat_plane_v2", combat_plane_v2, dict(guided_missile=True)], + # ["atari/combat_tank_v2", combat_tank_v2, dict(has_maze=True)], + # ["atari/combat_tank_v2", combat_tank_v2, dict(is_invisible=True)], + # ["atari/combat_tank_v2", combat_tank_v2, dict(billiard_hit=True)], + # ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="race")], + # ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="capture")], + # ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=1)], + # ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=3)], + # [ + # "atari/space_invaders_v2", + # space_invaders_v2, + # dict( + # alternating_control=True, + # moving_shields=True, + # zigzaging_bombs=True, + # fast_bomb=True, + # invisible_invaders=True, + # ), + # ], + # ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=2)], + # ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=3)], + # ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=4)], + # ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=2)], + # ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=3)], + # ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=4)], + # ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=2)], + # ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=3)], + # ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=4)], [ "butterfly/knights_archers_zombies_v10", knights_archers_zombies_v10, From 010a4e70a3f90c38ba2b4269fd6da5701bd08e9c Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Tue, 18 Apr 2023 18:37:26 -0400 Subject: [PATCH 10/20] Fix super() calls with ezpickle --- pettingzoo/mpe/simple_adversary/simple_adversary.py | 2 +- pettingzoo/mpe/simple_crypto/simple_crypto.py | 2 +- pettingzoo/mpe/simple_push/simple_push.py | 2 +- pettingzoo/mpe/simple_reference/simple_reference.py | 2 +- .../mpe/simple_speaker_listener/simple_speaker_listener.py | 2 +- pettingzoo/mpe/simple_spread/simple_spread.py | 2 +- pettingzoo/mpe/simple_tag/simple_tag.py | 2 +- pettingzoo/mpe/simple_world_comm/simple_world_comm.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pettingzoo/mpe/simple_adversary/simple_adversary.py b/pettingzoo/mpe/simple_adversary/simple_adversary.py index 4caa26896..f12250b37 100644 --- a/pettingzoo/mpe/simple_adversary/simple_adversary.py +++ b/pettingzoo/mpe/simple_adversary/simple_adversary.py @@ -72,7 +72,7 @@ def __init__(self, N=2, max_cycles=25, continuous_actions=False, render_mode=Non ) scenario = Scenario() world = scenario.make_world(N) - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_crypto/simple_crypto.py b/pettingzoo/mpe/simple_crypto/simple_crypto.py index 78588ef47..d0cf1299a 100644 --- a/pettingzoo/mpe/simple_crypto/simple_crypto.py +++ b/pettingzoo/mpe/simple_crypto/simple_crypto.py @@ -82,7 +82,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): ) scenario = Scenario() world = scenario.make_world() - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_push/simple_push.py b/pettingzoo/mpe/simple_push/simple_push.py index d445dc94c..4020b4603 100644 --- a/pettingzoo/mpe/simple_push/simple_push.py +++ b/pettingzoo/mpe/simple_push/simple_push.py @@ -66,7 +66,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): ) scenario = Scenario() world = scenario.make_world() - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_reference/simple_reference.py b/pettingzoo/mpe/simple_reference/simple_reference.py index c9cceb01f..1769fe661 100644 --- a/pettingzoo/mpe/simple_reference/simple_reference.py +++ b/pettingzoo/mpe/simple_reference/simple_reference.py @@ -78,7 +78,7 @@ def __init__( ), "local_ratio is a proportion. Must be between 0 and 1." scenario = Scenario() world = scenario.make_world() - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py b/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py index e287288ee..5af387d2c 100644 --- a/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py +++ b/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py @@ -67,7 +67,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): ) scenario = Scenario() world = scenario.make_world() - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_spread/simple_spread.py b/pettingzoo/mpe/simple_spread/simple_spread.py index 475b9c01b..3ab368f09 100644 --- a/pettingzoo/mpe/simple_spread/simple_spread.py +++ b/pettingzoo/mpe/simple_spread/simple_spread.py @@ -82,7 +82,7 @@ def __init__( ), "local_ratio is a proportion. Must be between 0 and 1." scenario = Scenario() world = scenario.make_world(N) - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_tag/simple_tag.py b/pettingzoo/mpe/simple_tag/simple_tag.py index b03572827..3e002ab7f 100644 --- a/pettingzoo/mpe/simple_tag/simple_tag.py +++ b/pettingzoo/mpe/simple_tag/simple_tag.py @@ -92,7 +92,7 @@ def __init__( ) scenario = Scenario() world = scenario.make_world(num_good, num_adversaries, num_obstacles) - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py index eebf2ff9b..79716390a 100644 --- a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py +++ b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py @@ -108,7 +108,7 @@ def __init__( world = scenario.make_world( num_good, num_adversaries, num_obstacles, num_food, num_forests ) - super().__init__( + SimpleEnv.__init__( scenario=scenario, world=world, render_mode=render_mode, From 8b5205a0acb0ea4c674caf2f771ce0d60283aaf9 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Tue, 18 Apr 2023 18:38:14 -0400 Subject: [PATCH 11/20] test removing simple_comm_v2 from failing envs --- test/pickle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pickle_test.py b/test/pickle_test.py index 34875d452..39f5e98fe 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -6,7 +6,7 @@ from .all_modules import all_environments ALL_ENVS = list(all_environments.items()) -FAILING_ENV_NAMES = ["mpe/simple_world_comm_v2"] +FAILING_ENV_NAMES = [] PASSING_ENVS = [ (name, env_module) for (name, env_module) in ALL_ENVS From 44a618668ed171a4936e03d435e3706b7ae8b355 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Tue, 18 Apr 2023 19:03:26 -0400 Subject: [PATCH 12/20] fix SimpleEnv init, add absolute import --- pettingzoo/mpe/simple_adversary/simple_adversary.py | 1 + pettingzoo/mpe/simple_crypto/simple_crypto.py | 1 + pettingzoo/mpe/simple_push/simple_push.py | 1 + pettingzoo/mpe/simple_reference/simple_reference.py | 1 + .../mpe/simple_speaker_listener/simple_speaker_listener.py | 1 + pettingzoo/mpe/simple_spread/simple_spread.py | 1 + pettingzoo/mpe/simple_tag/simple_tag.py | 1 + pettingzoo/mpe/simple_world_comm/simple_world_comm.py | 1 + pettingzoo/sisl/pursuit/utils/discrete_agent.py | 2 +- 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pettingzoo/mpe/simple_adversary/simple_adversary.py b/pettingzoo/mpe/simple_adversary/simple_adversary.py index f12250b37..d68e6cdef 100644 --- a/pettingzoo/mpe/simple_adversary/simple_adversary.py +++ b/pettingzoo/mpe/simple_adversary/simple_adversary.py @@ -73,6 +73,7 @@ def __init__(self, N=2, max_cycles=25, continuous_actions=False, render_mode=Non scenario = Scenario() world = scenario.make_world(N) SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_crypto/simple_crypto.py b/pettingzoo/mpe/simple_crypto/simple_crypto.py index d0cf1299a..9234943be 100644 --- a/pettingzoo/mpe/simple_crypto/simple_crypto.py +++ b/pettingzoo/mpe/simple_crypto/simple_crypto.py @@ -83,6 +83,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): scenario = Scenario() world = scenario.make_world() SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_push/simple_push.py b/pettingzoo/mpe/simple_push/simple_push.py index 4020b4603..dee55cf7e 100644 --- a/pettingzoo/mpe/simple_push/simple_push.py +++ b/pettingzoo/mpe/simple_push/simple_push.py @@ -67,6 +67,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): scenario = Scenario() world = scenario.make_world() SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_reference/simple_reference.py b/pettingzoo/mpe/simple_reference/simple_reference.py index 1769fe661..0acb83098 100644 --- a/pettingzoo/mpe/simple_reference/simple_reference.py +++ b/pettingzoo/mpe/simple_reference/simple_reference.py @@ -79,6 +79,7 @@ def __init__( scenario = Scenario() world = scenario.make_world() SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py b/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py index 5af387d2c..c1e268fb9 100644 --- a/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py +++ b/pettingzoo/mpe/simple_speaker_listener/simple_speaker_listener.py @@ -68,6 +68,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None): scenario = Scenario() world = scenario.make_world() SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_spread/simple_spread.py b/pettingzoo/mpe/simple_spread/simple_spread.py index 3ab368f09..e5a3ccbfa 100644 --- a/pettingzoo/mpe/simple_spread/simple_spread.py +++ b/pettingzoo/mpe/simple_spread/simple_spread.py @@ -83,6 +83,7 @@ def __init__( scenario = Scenario() world = scenario.make_world(N) SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_tag/simple_tag.py b/pettingzoo/mpe/simple_tag/simple_tag.py index 3e002ab7f..f6f078dce 100644 --- a/pettingzoo/mpe/simple_tag/simple_tag.py +++ b/pettingzoo/mpe/simple_tag/simple_tag.py @@ -93,6 +93,7 @@ def __init__( scenario = Scenario() world = scenario.make_world(num_good, num_adversaries, num_obstacles) SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py index 79716390a..9bd34fba9 100644 --- a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py +++ b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py @@ -109,6 +109,7 @@ def __init__( num_good, num_adversaries, num_obstacles, num_food, num_forests ) SimpleEnv.__init__( + self, scenario=scenario, world=world, render_mode=render_mode, diff --git a/pettingzoo/sisl/pursuit/utils/discrete_agent.py b/pettingzoo/sisl/pursuit/utils/discrete_agent.py index b22e805e5..1c8b9fb0f 100644 --- a/pettingzoo/sisl/pursuit/utils/discrete_agent.py +++ b/pettingzoo/sisl/pursuit/utils/discrete_agent.py @@ -1,7 +1,7 @@ import numpy as np from gymnasium import spaces -from ..._utils import Agent +from pettingzoo.sisl._utils import Agent ################################################################# # Implements the Single 2D Agent Dynamics From 808086b8c9458898a554bd254f7a4441f649d173 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Tue, 18 Apr 2023 19:33:46 -0400 Subject: [PATCH 13/20] Re-remove simple world comm v2 from pickle test (fails) --- test/pickle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pickle_test.py b/test/pickle_test.py index 39f5e98fe..8c355c492 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -6,7 +6,7 @@ from .all_modules import all_environments ALL_ENVS = list(all_environments.items()) -FAILING_ENV_NAMES = [] +FAILING_ENV_NAMES = ["simple_world_comm_v2"] PASSING_ENVS = [ (name, env_module) for (name, env_module) in ALL_ENVS From a80a36f0bbcc756588baef0d7565f34005ed5410 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Thu, 20 Apr 2023 23:20:45 -0400 Subject: [PATCH 14/20] remove pickle human env and fully remove simple world comm test --- test/pickle_test.py | 69 --------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/test/pickle_test.py b/test/pickle_test.py index 8c355c492..68f32c6c2 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -70,72 +70,3 @@ def test_pickle_env(name, env_module): iter += 1 env1.close() env2.close() - - -ALL_ENVS = list(all_environments.items()) -FAILING_ENV_NAMES = [] -PASSING_ENVS = [ - (name, env_module) - for (name, env_module) in ALL_ENVS - if name not in FAILING_ENV_NAMES -] - - -@pytest.mark.skip( - reason="pickling pygame rendered envs does not work well, video system will not be initialized." -) -@pytest.mark.parametrize(("name", "env_module"), PASSING_ENVS) -def test_pickle_env_human(name, env_module): - env1 = env_module.env(render_mode="human") - env2 = pickle.loads(pickle.dumps(env1)) - - env1.reset(seed=42) - env2.reset(seed=42) - - agent1 = env1.agents[0] - agent2 = env2.agents[0] - - a_space1 = env1.action_space(agent1) - a_space1.seed(42) - a_space2 = env2.action_space(agent2) - a_space2.seed(42) - - iter = 0 - for agent1, agent2 in zip(env1.agent_iter(), env2.agent_iter()): - if iter > 5: - break - assert data_equivalence(agent1, agent2), f"Incorrect agent: {agent1} {agent2}" - - obs1, rew1, term1, trunc1, info1 = env1.last() - obs2, rew2, term2, trunc2, info2 = env2.last() - - assert data_equivalence(obs1, obs2), f"Incorrect observations: {obs1} {obs2}" - assert data_equivalence(rew1, rew2), f"Incorrect rewards: {rew1} {rew2}" - assert data_equivalence(term1, term2), f"Incorrect terms: {term1} {term2}" - assert data_equivalence(trunc1, trunc2), f"Incorrect truncs: {trunc1} {trunc2}" - assert data_equivalence(info1, info2), f"Incorrect info: {info1} {info2}" - - if name == "mpe/simple_world_comm_v2": - print("Test") - mask = None - if "action_mask" in info1: - mask = info1["action_mask"] - - if isinstance(obs1, dict) and "action_mask" in obs1: - mask = obs1["action_mask"] - - action1 = a_space1.sample(mask=mask) - action2 = a_space2.sample(mask=mask) - - assert data_equivalence( - action1, action2 - ), f"Incorrect actions: {action1} {action2}" - - if term1 or term2 or trunc1 or trunc2: - break - - env1.step(action1) - env2.step(action2) - iter += 1 - env1.close() - env2.close() From e56961fbb5d7b26546858d775d2d854377c5ee01 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Fri, 21 Apr 2023 00:06:55 -0400 Subject: [PATCH 15/20] Fix typo in failing env names --- test/pickle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pickle_test.py b/test/pickle_test.py index 68f32c6c2..ae4f5a34b 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -6,7 +6,7 @@ from .all_modules import all_environments ALL_ENVS = list(all_environments.items()) -FAILING_ENV_NAMES = ["simple_world_comm_v2"] +FAILING_ENV_NAMES = ["mpe/simple_world_comm_v2"] PASSING_ENVS = [ (name, env_module) for (name, env_module) in ALL_ENVS From 4759c0973b55b588e3bf0ffb617a8ab4625d7338 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Fri, 21 Apr 2023 12:00:31 -0400 Subject: [PATCH 16/20] Fix typos in param combs test --- test/all_parameter_combs_test.py | 64 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/test/all_parameter_combs_test.py b/test/all_parameter_combs_test.py index f2b48fb1f..0bdc70ec7 100644 --- a/test/all_parameter_combs_test.py +++ b/test/all_parameter_combs_test.py @@ -8,38 +8,38 @@ from .all_modules import * # noqa: F403 parameterized_envs = [ - # ["atari/boxing_v2", boxing_v2, dict(obs_type="grayscale_image")], - # ["atari/boxing_v2", boxing_v2, dict(obs_type="ram")], - # ["atari/boxing_v2", boxing_v2, dict(full_action_space=False)], - # ["atari/combat_plane_v2", combat_plane_v2, dict(game_version="jet")], - # ["atari/combat_plane_v2", combat_plane_v2, dict(guided_missile=True)], - # ["atari/combat_tank_v2", combat_tank_v2, dict(has_maze=True)], - # ["atari/combat_tank_v2", combat_tank_v2, dict(is_invisible=True)], - # ["atari/combat_tank_v2", combat_tank_v2, dict(billiard_hit=True)], - # ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="race")], - # ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="capture")], - # ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=1)], - # ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=3)], - # [ - # "atari/space_invaders_v2", - # space_invaders_v2, - # dict( - # alternating_control=True, - # moving_shields=True, - # zigzaging_bombs=True, - # fast_bomb=True, - # invisible_invaders=True, - # ), - # ], - # ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=2)], - # ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=3)], - # ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=4)], - # ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=2)], - # ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=3)], - # ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=4)], - # ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=2)], - # ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=3)], - # ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=4)], + ["atari/boxing_v2", boxing_v2, dict(obs_type="grayscale_image")], + ["atari/boxing_v2", boxing_v2, dict(obs_type="ram")], + ["atari/boxing_v2", boxing_v2, dict(full_action_space=False)], + ["atari/combat_plane_v2", combat_plane_v2, dict(game_version="jet")], + ["atari/combat_plane_v2", combat_plane_v2, dict(guided_missile=True)], + ["atari/combat_tank_v2", combat_tank_v2, dict(has_maze=True)], + ["atari/combat_tank_v2", combat_tank_v2, dict(is_invisible=True)], + ["atari/combat_tank_v2", combat_tank_v2, dict(billiard_hit=True)], + ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="race")], + ["atari/maze_craze_v3", maze_craze_v3, dict(game_version="capture")], + ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=1)], + ["atari/maze_craze_v3", maze_craze_v3, dict(visibilty_level=3)], + [ + "atari/space_invaders_v2", + space_invaders_v2, + dict( + alternating_control=True, + moving_shields=True, + zigzaging_bombs=True, + fast_bomb=True, + invisible_invaders=True, + ), + ], + ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=2)], + ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=3)], + ["classic/leduc_holdem_v4", leduc_holdem_v4, dict(num_players=4)], + ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=2)], + ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=3)], + ["classic/texas_holdem_v4", texas_holdem_v4, dict(num_players=4)], + ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=2)], + ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=3)], + ["classic/texas_holdem_no_limit_v6", texas_holdem_no_limit_v6, dict(num_players=4)], [ "butterfly/knights_archers_zombies_v10", knights_archers_zombies_v10, From 8d6237d566638badd7d791ed2310d62ea28690da Mon Sep 17 00:00:00 2001 From: Ariel Kwiatkowski Date: Fri, 21 Apr 2023 21:11:47 +0200 Subject: [PATCH 17/20] Update simple_world_comm.py --- pettingzoo/mpe/simple_world_comm/simple_world_comm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py index 9bd34fba9..0c800a7d1 100644 --- a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py +++ b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py @@ -99,6 +99,7 @@ def __init__( num_good, num_adversaries, num_obstacles, + num_food, max_cycles, num_forests, continuous_actions, From a96e4390da8f1e06d3401ef41cd8abada7bdd81c Mon Sep 17 00:00:00 2001 From: Ariel Kwiatkowski Date: Fri, 21 Apr 2023 21:21:02 +0200 Subject: [PATCH 18/20] Update simple_world_comm.py --- .../mpe/simple_world_comm/simple_world_comm.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py index 0c800a7d1..94e3a7f4f 100644 --- a/pettingzoo/mpe/simple_world_comm/simple_world_comm.py +++ b/pettingzoo/mpe/simple_world_comm/simple_world_comm.py @@ -96,14 +96,14 @@ def __init__( ): EzPickle.__init__( self, - num_good, - num_adversaries, - num_obstacles, - num_food, - max_cycles, - num_forests, - continuous_actions, - render_mode, + num_good=num_good, + num_adversaries=num_adversaries, + num_obstacles=num_obstacles, + num_food=num_food, + max_cycles=max_cycles, + num_forests=num_forests, + continuous_actions=continuous_actions, + render_mode=render_mode, ) scenario = Scenario() world = scenario.make_world( From e82207051ca2696b4979582f8994be65da2883ba Mon Sep 17 00:00:00 2001 From: Ariel Kwiatkowski Date: Fri, 21 Apr 2023 21:22:59 +0200 Subject: [PATCH 19/20] Reactivate tests --- test/pickle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pickle_test.py b/test/pickle_test.py index ae4f5a34b..02aaf86b6 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -6,7 +6,7 @@ from .all_modules import all_environments ALL_ENVS = list(all_environments.items()) -FAILING_ENV_NAMES = ["mpe/simple_world_comm_v2"] +FAILING_ENV_NAMES = [] PASSING_ENVS = [ (name, env_module) for (name, env_module) in ALL_ENVS From 1beceaad5f5eba5735803b3c7e4dbec58eb83797 Mon Sep 17 00:00:00 2001 From: elliottower Date: Fri, 21 Apr 2023 16:48:56 -0400 Subject: [PATCH 20/20] Fix action space seeding in pickle test --- test/pickle_test.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/test/pickle_test.py b/test/pickle_test.py index 02aaf86b6..f95d7ea0b 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -3,18 +3,14 @@ import pytest from gymnasium.utils.env_checker import data_equivalence +from pettingzoo.test.seed_test import seed_action_spaces, seed_observation_spaces + from .all_modules import all_environments ALL_ENVS = list(all_environments.items()) -FAILING_ENV_NAMES = [] -PASSING_ENVS = [ - (name, env_module) - for (name, env_module) in ALL_ENVS - if name not in FAILING_ENV_NAMES -] -@pytest.mark.parametrize(("name", "env_module"), PASSING_ENVS) +@pytest.mark.parametrize(("name", "env_module"), ALL_ENVS) def test_pickle_env(name, env_module): env1 = env_module.env(render_mode=None) env2 = pickle.loads(pickle.dumps(env1)) @@ -22,13 +18,10 @@ def test_pickle_env(name, env_module): env1.reset(seed=42) env2.reset(seed=42) - agent1 = env1.agents[0] - agent2 = env2.agents[0] - - a_space1 = env1.action_space(agent1) - a_space1.seed(42) - a_space2 = env2.action_space(agent2) - a_space2.seed(42) + seed_action_spaces(env1) + seed_action_spaces(env2) + seed_observation_spaces(env1) + seed_observation_spaces(env2) iter = 0 for agent1, agent2 in zip(env1.agent_iter(), env2.agent_iter()): @@ -39,9 +32,6 @@ def test_pickle_env(name, env_module): obs1, rew1, term1, trunc1, info1 = env1.last() obs2, rew2, term2, trunc2, info2 = env2.last() - if name == "mpe/simple_world_comm_v2": - print("Test") - if term1 or term2 or trunc1 or trunc2: break @@ -58,8 +48,8 @@ def test_pickle_env(name, env_module): if isinstance(obs1, dict) and "action_mask" in obs1: mask = obs1["action_mask"] - action1 = a_space1.sample(mask=mask) - action2 = a_space2.sample(mask=mask) + action1 = env1.action_space(agent1).sample(mask=mask) + action2 = env2.action_space(agent2).sample(mask=mask) assert data_equivalence( action1, action2