diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea31b92f0..fbbc609fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ --- repos: - repo: https://github.com/python/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell args: @@ -31,8 +31,7 @@ repos: rev: v3.3.1 hooks: - id: pyupgrade - # TODO: remove `--keep-runtime-typing` option - args: ["--py37-plus", "--keep-runtime-typing"] + args: ["--py37-plus"] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -50,7 +49,7 @@ repos: # TODO: Remove ignoring rules D101, D102, D103, D105 - --add-ignore=D100,D107,D101,D102,D103,D105 exclude: "__init__.py$|^pettingzoo.test|^docs" - additional_dependencies: ["toml"] + additional_dependencies: ["tomli"] - repo: local hooks: - id: pyright diff --git a/pettingzoo/atari/base_atari_env.py b/pettingzoo/atari/base_atari_env.py index c609b942c..1b902bb52 100644 --- a/pettingzoo/atari/base_atari_env.py +++ b/pettingzoo/atari/base_atari_env.py @@ -7,12 +7,17 @@ from gymnasium.utils import EzPickle, seeding from pettingzoo.utils import wrappers -from pettingzoo.utils.conversions import ( # noqa: F401 - parallel_to_aec_wrapper, - parallel_wrapper_fn, -) +from pettingzoo.utils.conversions import parallel_to_aec_wrapper, parallel_wrapper_fn from pettingzoo.utils.env import ParallelEnv +__all__ = [ + "parallel_wrapper_fn", + "parallel_to_aec_wrapper", + "base_env_wrapper_fn", + "BaseAtariEnv", + "ParallelAtariEnv", +] + def base_env_wrapper_fn(raw_env_fn): def env_fn(**kwargs): diff --git a/pettingzoo/atari/basketball_pong_v3.py b/pettingzoo/atari/basketball_pong_v3.py index 684251c85..f184dc7b6 100644 --- a/pettingzoo/atari/basketball_pong_v3.py +++ b/pettingzoo/atari/basketball_pong_v3.py @@ -1 +1,3 @@ -from .basketball_pong.basketball_pong import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.basketball_pong.basketball_pong import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/boxing_v2.py b/pettingzoo/atari/boxing_v2.py index 42478e4fa..148c2278d 100644 --- a/pettingzoo/atari/boxing_v2.py +++ b/pettingzoo/atari/boxing_v2.py @@ -1 +1,3 @@ -from .boxing.boxing import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.boxing.boxing import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/combat_plane_v2.py b/pettingzoo/atari/combat_plane_v2.py index aae54e5f2..d7dcbdcc5 100644 --- a/pettingzoo/atari/combat_plane_v2.py +++ b/pettingzoo/atari/combat_plane_v2.py @@ -1 +1,3 @@ -from .combat_plane.combat_plane import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.combat_plane.combat_plane import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/combat_tank_v2.py b/pettingzoo/atari/combat_tank_v2.py index fe1a96b52..815c31149 100644 --- a/pettingzoo/atari/combat_tank_v2.py +++ b/pettingzoo/atari/combat_tank_v2.py @@ -1 +1,3 @@ -from .combat_tank.combat_tank import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.combat_tank.combat_tank import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/double_dunk_v3.py b/pettingzoo/atari/double_dunk_v3.py index e4a88f287..e16852585 100644 --- a/pettingzoo/atari/double_dunk_v3.py +++ b/pettingzoo/atari/double_dunk_v3.py @@ -1 +1,3 @@ -from .double_dunk.double_dunk import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.double_dunk.double_dunk import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/entombed_competitive_v3.py b/pettingzoo/atari/entombed_competitive_v3.py index 010f90cfa..9f0af1895 100644 --- a/pettingzoo/atari/entombed_competitive_v3.py +++ b/pettingzoo/atari/entombed_competitive_v3.py @@ -1,5 +1,7 @@ -from .entombed_competitive.entombed_competitive import ( # noqa: F401 +from pettingzoo.atari.entombed_competitive.entombed_competitive import ( env, parallel_env, raw_env, ) + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/entombed_cooperative_v3.py b/pettingzoo/atari/entombed_cooperative_v3.py index c8aa70173..81e839b58 100644 --- a/pettingzoo/atari/entombed_cooperative_v3.py +++ b/pettingzoo/atari/entombed_cooperative_v3.py @@ -1,5 +1,7 @@ -from .entombed_cooperative.entombed_cooperative import ( # noqa: F401 +from pettingzoo.atari.entombed_cooperative.entombed_cooperative import ( env, parallel_env, raw_env, ) + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/flag_capture_v2.py b/pettingzoo/atari/flag_capture_v2.py index 17127f742..1df8fc88f 100644 --- a/pettingzoo/atari/flag_capture_v2.py +++ b/pettingzoo/atari/flag_capture_v2.py @@ -1 +1,3 @@ -from .flag_capture.flag_capture import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.flag_capture.flag_capture import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/foozpong_v3.py b/pettingzoo/atari/foozpong_v3.py index 56001c341..110a5526d 100644 --- a/pettingzoo/atari/foozpong_v3.py +++ b/pettingzoo/atari/foozpong_v3.py @@ -1 +1,3 @@ -from .foozpong.foozpong import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.foozpong.foozpong import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/ice_hockey_v2.py b/pettingzoo/atari/ice_hockey_v2.py index b49c212c0..0f53e6d57 100644 --- a/pettingzoo/atari/ice_hockey_v2.py +++ b/pettingzoo/atari/ice_hockey_v2.py @@ -1 +1,3 @@ -from .ice_hockey.ice_hockey import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.ice_hockey.ice_hockey import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/joust_v3.py b/pettingzoo/atari/joust_v3.py index 84f73c833..a0e56a51f 100644 --- a/pettingzoo/atari/joust_v3.py +++ b/pettingzoo/atari/joust_v3.py @@ -1 +1,3 @@ -from .joust.joust import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.joust.joust import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/mario_bros_v3.py b/pettingzoo/atari/mario_bros_v3.py index ef8749aa7..072ae3451 100644 --- a/pettingzoo/atari/mario_bros_v3.py +++ b/pettingzoo/atari/mario_bros_v3.py @@ -1 +1,3 @@ -from .mario_bros.mario_bros import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.mario_bros.mario_bros import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/maze_craze_v3.py b/pettingzoo/atari/maze_craze_v3.py index d43822636..5be0a610e 100644 --- a/pettingzoo/atari/maze_craze_v3.py +++ b/pettingzoo/atari/maze_craze_v3.py @@ -1 +1,3 @@ -from .maze_craze.maze_craze import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.maze_craze.maze_craze import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/othello_v3.py b/pettingzoo/atari/othello_v3.py index 45b43afa5..875a327de 100644 --- a/pettingzoo/atari/othello_v3.py +++ b/pettingzoo/atari/othello_v3.py @@ -1 +1,3 @@ -from .othello.othello import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.othello.othello import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/pong_v3.py b/pettingzoo/atari/pong_v3.py index 0d46176b8..7fd694044 100644 --- a/pettingzoo/atari/pong_v3.py +++ b/pettingzoo/atari/pong_v3.py @@ -1 +1,3 @@ -from .pong.pong import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.pong.pong import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/quadrapong_v4.py b/pettingzoo/atari/quadrapong_v4.py index 59e8e96d0..9f26c7405 100644 --- a/pettingzoo/atari/quadrapong_v4.py +++ b/pettingzoo/atari/quadrapong_v4.py @@ -1 +1,3 @@ -from .quadrapong.quadrapong import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.quadrapong.quadrapong import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/space_invaders_v2.py b/pettingzoo/atari/space_invaders_v2.py index 6b8f93b84..d026d0c6b 100644 --- a/pettingzoo/atari/space_invaders_v2.py +++ b/pettingzoo/atari/space_invaders_v2.py @@ -1 +1,3 @@ -from .space_invaders.space_invaders import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.space_invaders.space_invaders import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/space_war_v2.py b/pettingzoo/atari/space_war_v2.py index 504588c8c..9cc340ba8 100644 --- a/pettingzoo/atari/space_war_v2.py +++ b/pettingzoo/atari/space_war_v2.py @@ -1 +1,3 @@ -from .space_war.space_war import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.space_war.space_war import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/surround_v2.py b/pettingzoo/atari/surround_v2.py index 2e8e332f7..9fcf24ae5 100644 --- a/pettingzoo/atari/surround_v2.py +++ b/pettingzoo/atari/surround_v2.py @@ -1 +1,3 @@ -from .surround.surround import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.surround.surround import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/tennis_v3.py b/pettingzoo/atari/tennis_v3.py index 6e8e5c608..c8d4dc612 100644 --- a/pettingzoo/atari/tennis_v3.py +++ b/pettingzoo/atari/tennis_v3.py @@ -1 +1,3 @@ -from .tennis.tennis import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.tennis.tennis import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/video_checkers_v4.py b/pettingzoo/atari/video_checkers_v4.py index da7e82ff7..ebbfd0d0a 100644 --- a/pettingzoo/atari/video_checkers_v4.py +++ b/pettingzoo/atari/video_checkers_v4.py @@ -1 +1,3 @@ -from .video_checkers.video_checkers import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.video_checkers.video_checkers import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/volleyball_pong_v3.py b/pettingzoo/atari/volleyball_pong_v3.py index 84b9bd1c8..378c1c50b 100644 --- a/pettingzoo/atari/volleyball_pong_v3.py +++ b/pettingzoo/atari/volleyball_pong_v3.py @@ -1 +1,3 @@ -from .volleyball_pong.volleyball_pong import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.volleyball_pong.volleyball_pong import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/warlords_v3.py b/pettingzoo/atari/warlords_v3.py index e25b7bdeb..20bcba0c8 100644 --- a/pettingzoo/atari/warlords_v3.py +++ b/pettingzoo/atari/warlords_v3.py @@ -1 +1,3 @@ -from .warlords.warlords import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.warlords.warlords import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/atari/wizard_of_wor_v3.py b/pettingzoo/atari/wizard_of_wor_v3.py index 944435c6e..70420f925 100644 --- a/pettingzoo/atari/wizard_of_wor_v3.py +++ b/pettingzoo/atari/wizard_of_wor_v3.py @@ -1 +1,3 @@ -from .wizard_of_wor.wizard_of_wor import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.atari.wizard_of_wor.wizard_of_wor import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/butterfly/cooperative_pong/cooperative_pong.py b/pettingzoo/butterfly/cooperative_pong/cooperative_pong.py index 04aa3bd10..d18e054c7 100644 --- a/pettingzoo/butterfly/cooperative_pong/cooperative_pong.py +++ b/pettingzoo/butterfly/cooperative_pong/cooperative_pong.py @@ -74,18 +74,20 @@ from gymnasium.utils import EzPickle, seeding from pettingzoo import AECEnv +from pettingzoo.butterfly.cooperative_pong.ball import Ball +from pettingzoo.butterfly.cooperative_pong.cake_paddle import CakePaddle +from pettingzoo.butterfly.cooperative_pong.manual_policy import ManualPolicy +from pettingzoo.butterfly.cooperative_pong.paddle import Paddle from pettingzoo.utils import wrappers from pettingzoo.utils.agent_selector import agent_selector from pettingzoo.utils.conversions import parallel_wrapper_fn -from .ball import Ball -from .cake_paddle import CakePaddle -from .manual_policy import ManualPolicy # noqa: F401 -from .paddle import Paddle - FPS = 15 +__all__ = ["ManualPolicy", "env", "raw_env", "parallel_env"] + + def deg_to_rad(deg): return deg * np.pi / 180 diff --git a/pettingzoo/butterfly/cooperative_pong_v5.py b/pettingzoo/butterfly/cooperative_pong_v5.py index a2fde2ca7..157b6446f 100644 --- a/pettingzoo/butterfly/cooperative_pong_v5.py +++ b/pettingzoo/butterfly/cooperative_pong_v5.py @@ -1,6 +1,8 @@ -from .cooperative_pong.cooperative_pong import ( # noqa: F401 +from pettingzoo.butterfly.cooperative_pong.cooperative_pong import ( ManualPolicy, env, parallel_env, raw_env, ) + +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] diff --git a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py index e89e191af..01d6a4c34 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py +++ b/pettingzoo/butterfly/knights_archers_zombies/knights_archers_zombies.py @@ -187,19 +187,21 @@ from gymnasium.utils import EzPickle, seeding from pettingzoo import AECEnv +from pettingzoo.butterfly.knights_archers_zombies.manual_policy import ManualPolicy +from pettingzoo.butterfly.knights_archers_zombies.src import constants as const +from pettingzoo.butterfly.knights_archers_zombies.src.img import get_image +from pettingzoo.butterfly.knights_archers_zombies.src.players import Archer, Knight +from pettingzoo.butterfly.knights_archers_zombies.src.weapons import Arrow, Sword +from pettingzoo.butterfly.knights_archers_zombies.src.zombie import Zombie from pettingzoo.utils import agent_selector, wrappers from pettingzoo.utils.conversions import parallel_wrapper_fn -from .manual_policy import ManualPolicy # noqa: F401 -from .src import constants as const -from .src.img import get_image -from .src.players import Archer, Knight -from .src.weapons import Arrow, Sword -from .src.zombie import Zombie - sys.dont_write_bytecode = True +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] + + def env(**kwargs): env = raw_env(**kwargs) env = wrappers.AssertOutOfBoundsWrapper(env) diff --git a/pettingzoo/butterfly/knights_archers_zombies/src/players.py b/pettingzoo/butterfly/knights_archers_zombies/src/players.py index b907db653..06395271f 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/src/players.py +++ b/pettingzoo/butterfly/knights_archers_zombies/src/players.py @@ -4,8 +4,8 @@ import numpy as np import pygame -from . import constants as const -from .img import get_image +from pettingzoo.butterfly.knights_archers_zombies.src import constants as const +from pettingzoo.butterfly.knights_archers_zombies.src.img import get_image class Player(pygame.sprite.Sprite): diff --git a/pettingzoo/butterfly/knights_archers_zombies/src/weapons.py b/pettingzoo/butterfly/knights_archers_zombies/src/weapons.py index 1f49e495c..4b6921092 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/src/weapons.py +++ b/pettingzoo/butterfly/knights_archers_zombies/src/weapons.py @@ -4,8 +4,8 @@ import numpy as np import pygame -from . import constants as const -from .img import get_image +from pettingzoo.butterfly.knights_archers_zombies.src import constants as const +from pettingzoo.butterfly.knights_archers_zombies.src.img import get_image class Arrow(pygame.sprite.Sprite): diff --git a/pettingzoo/butterfly/knights_archers_zombies/src/zombie.py b/pettingzoo/butterfly/knights_archers_zombies/src/zombie.py index 0905870fe..95f49b7dc 100644 --- a/pettingzoo/butterfly/knights_archers_zombies/src/zombie.py +++ b/pettingzoo/butterfly/knights_archers_zombies/src/zombie.py @@ -3,8 +3,8 @@ import numpy as np import pygame -from . import constants as const -from .img import get_image +from pettingzoo.butterfly.knights_archers_zombies.src import constants as const +from pettingzoo.butterfly.knights_archers_zombies.src.img import get_image class Zombie(pygame.sprite.Sprite): diff --git a/pettingzoo/butterfly/knights_archers_zombies_v10.py b/pettingzoo/butterfly/knights_archers_zombies_v10.py index 32f615cdf..6ffbb5904 100644 --- a/pettingzoo/butterfly/knights_archers_zombies_v10.py +++ b/pettingzoo/butterfly/knights_archers_zombies_v10.py @@ -1,6 +1,8 @@ -from .knights_archers_zombies.knights_archers_zombies import ( # noqa: F401 +from pettingzoo.butterfly.knights_archers_zombies.knights_archers_zombies import ( ManualPolicy, env, parallel_env, raw_env, ) + +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] diff --git a/pettingzoo/butterfly/pistonball/pistonball.py b/pettingzoo/butterfly/pistonball/pistonball.py index 5bb43445c..749cd54c6 100644 --- a/pettingzoo/butterfly/pistonball/pistonball.py +++ b/pettingzoo/butterfly/pistonball/pistonball.py @@ -88,15 +88,16 @@ from gymnasium.utils import EzPickle, seeding from pettingzoo import AECEnv +from pettingzoo.butterfly.pistonball.manual_policy import ManualPolicy from pettingzoo.utils import agent_selector, wrappers from pettingzoo.utils.conversions import parallel_wrapper_fn -from .manual_policy import ManualPolicy # noqa: F401 - _image_library = {} FPS = 20 +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] + def get_image(path): from os import path as os_path diff --git a/pettingzoo/butterfly/pistonball_v6.py b/pettingzoo/butterfly/pistonball_v6.py index 4627914dc..1f7ce45a7 100644 --- a/pettingzoo/butterfly/pistonball_v6.py +++ b/pettingzoo/butterfly/pistonball_v6.py @@ -1,6 +1,8 @@ -from .pistonball.pistonball import ( # noqa: F401 +from pettingzoo.butterfly.pistonball.pistonball import ( ManualPolicy, env, parallel_env, raw_env, ) + +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] diff --git a/pettingzoo/classic/chess/chess.py b/pettingzoo/classic/chess/chess.py index 6f6d6d01f..18680f38d 100644 --- a/pettingzoo/classic/chess/chess.py +++ b/pettingzoo/classic/chess/chess.py @@ -92,11 +92,10 @@ from gymnasium.error import DependencyNotInstalled from pettingzoo import AECEnv +from pettingzoo.classic.chess import chess_utils from pettingzoo.utils import wrappers from pettingzoo.utils.agent_selector import agent_selector -from . import chess_utils - def env(render_mode=None): env = raw_env(render_mode=render_mode) diff --git a/pettingzoo/classic/chess/test_chess.py b/pettingzoo/classic/chess/test_chess.py index e93073b63..c37115aab 100644 --- a/pettingzoo/classic/chess/test_chess.py +++ b/pettingzoo/classic/chess/test_chess.py @@ -1,7 +1,7 @@ import chess import numpy as np -from . import chess_utils +from pettingzoo.classic.chess import chess_utils def assert_asserts(x): diff --git a/pettingzoo/classic/chess_v5.py b/pettingzoo/classic/chess_v5.py index f09deae06..b692dc215 100644 --- a/pettingzoo/classic/chess_v5.py +++ b/pettingzoo/classic/chess_v5.py @@ -1 +1,3 @@ -from .chess.chess import env, raw_env # noqa: F401 +from pettingzoo.classic.chess.chess import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/connect_four_v3.py b/pettingzoo/classic/connect_four_v3.py index 31123bdb1..f9e289a4c 100644 --- a/pettingzoo/classic/connect_four_v3.py +++ b/pettingzoo/classic/connect_four_v3.py @@ -1 +1,3 @@ -from .connect_four.connect_four import env, raw_env # noqa: F401 +from pettingzoo.classic.connect_four.connect_four import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/gin_rummy_v4.py b/pettingzoo/classic/gin_rummy_v4.py index 4e10cc423..153cce95f 100644 --- a/pettingzoo/classic/gin_rummy_v4.py +++ b/pettingzoo/classic/gin_rummy_v4.py @@ -1 +1,3 @@ -from .rlcard_envs.gin_rummy import env, raw_env # noqa: F401 +from pettingzoo.classic.rlcard_envs.gin_rummy import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/go/coords.py b/pettingzoo/classic/go/coords.py index b1ba00cd0..2952501db 100644 --- a/pettingzoo/classic/go/coords.py +++ b/pettingzoo/classic/go/coords.py @@ -42,7 +42,7 @@ GTP 'A19' 'T19' 'pass' """ -from . import go_base +from pettingzoo.classic.go import go_base # We provide more than 19 entries here in case of boards larger than 19 x 19. _SGF_COLUMNS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/pettingzoo/classic/go/go.py b/pettingzoo/classic/go/go.py index 13702bccc..834288611 100644 --- a/pettingzoo/classic/go/go.py +++ b/pettingzoo/classic/go/go.py @@ -116,17 +116,14 @@ from gymnasium import spaces from pettingzoo import AECEnv +from pettingzoo.classic.go import coords, go_base from pettingzoo.utils import wrappers from pettingzoo.utils.agent_selector import agent_selector -from . import coords, go_base - def get_image(path): from os import path as os_path - import pygame - cwd = os_path.dirname(__file__) image = pygame.image.load(cwd + "/" + path) sfc = pygame.Surface(image.get_size(), flags=pygame.SRCALPHA) diff --git a/pettingzoo/classic/go/go_base.py b/pettingzoo/classic/go/go_base.py index 24cbbc8c4..e77191e86 100644 --- a/pettingzoo/classic/go/go_base.py +++ b/pettingzoo/classic/go/go_base.py @@ -30,7 +30,7 @@ import numpy as np -from . import coords +from pettingzoo.classic.go import coords N = int(os.environ.get("BOARD_SIZE", 19)) diff --git a/pettingzoo/classic/go_v5.py b/pettingzoo/classic/go_v5.py index 440bce514..b4505c0d0 100644 --- a/pettingzoo/classic/go_v5.py +++ b/pettingzoo/classic/go_v5.py @@ -1 +1,3 @@ -from .go.go import env, raw_env # noqa: F401 +from pettingzoo.classic.go.go import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/hanabi_v4.py b/pettingzoo/classic/hanabi_v4.py index 620c1c2c8..bfb780abc 100644 --- a/pettingzoo/classic/hanabi_v4.py +++ b/pettingzoo/classic/hanabi_v4.py @@ -1 +1,3 @@ -from .hanabi.hanabi import env, raw_env # noqa: F401 +from pettingzoo.classic.hanabi.hanabi import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/leduc_holdem_v4.py b/pettingzoo/classic/leduc_holdem_v4.py index 038ce3c60..c8913f9ff 100644 --- a/pettingzoo/classic/leduc_holdem_v4.py +++ b/pettingzoo/classic/leduc_holdem_v4.py @@ -1 +1,3 @@ -from .rlcard_envs.leduc_holdem import env, raw_env # noqa: F401 +from pettingzoo.classic.rlcard_envs.leduc_holdem import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/rlcard_envs/gin_rummy.py b/pettingzoo/classic/rlcard_envs/gin_rummy.py index b660eb70f..016529eca 100644 --- a/pettingzoo/classic/rlcard_envs/gin_rummy.py +++ b/pettingzoo/classic/rlcard_envs/gin_rummy.py @@ -118,10 +118,9 @@ from rlcard.games.gin_rummy.utils.action_event import GinAction, KnockAction from rlcard.utils.utils import print_card +from pettingzoo.classic.rlcard_envs.rlcard_base import RLCardBase from pettingzoo.utils import wrappers -from .rlcard_base import RLCardBase - def env(**kwargs): render_mode = kwargs.get("render_mode") diff --git a/pettingzoo/classic/rlcard_envs/leduc_holdem.py b/pettingzoo/classic/rlcard_envs/leduc_holdem.py index 515114ba6..7bda0610a 100644 --- a/pettingzoo/classic/rlcard_envs/leduc_holdem.py +++ b/pettingzoo/classic/rlcard_envs/leduc_holdem.py @@ -84,10 +84,9 @@ import gymnasium from rlcard.utils.utils import print_card +from pettingzoo.classic.rlcard_envs.rlcard_base import RLCardBase from pettingzoo.utils import wrappers -from .rlcard_base import RLCardBase - def env(**kwargs): render_mode = kwargs.get("render_mode") diff --git a/pettingzoo/classic/rlcard_envs/texas_holdem.py b/pettingzoo/classic/rlcard_envs/texas_holdem.py index b498636f2..3c87eee6b 100644 --- a/pettingzoo/classic/rlcard_envs/texas_holdem.py +++ b/pettingzoo/classic/rlcard_envs/texas_holdem.py @@ -83,10 +83,9 @@ import numpy as np import pygame +from pettingzoo.classic.rlcard_envs.rlcard_base import RLCardBase from pettingzoo.utils import wrappers -from .rlcard_base import RLCardBase - # Pixel art from Mariia Khmelnytska (https://www.123rf.com/photo_104453049_stock-vector-pixel-art-playing-cards-standart-deck-vector-set.html) diff --git a/pettingzoo/classic/rlcard_envs/texas_holdem_no_limit.py b/pettingzoo/classic/rlcard_envs/texas_holdem_no_limit.py index 298d60517..e3e12fb03 100644 --- a/pettingzoo/classic/rlcard_envs/texas_holdem_no_limit.py +++ b/pettingzoo/classic/rlcard_envs/texas_holdem_no_limit.py @@ -96,10 +96,9 @@ import pygame from gymnasium import spaces +from pettingzoo.classic.rlcard_envs.rlcard_base import RLCardBase from pettingzoo.utils import wrappers -from .rlcard_base import RLCardBase - # Pixel art from Mariia Khmelnytska (https://www.123rf.com/photo_104453049_stock-vector-pixel-art-playing-cards-standart-deck-vector-set.html) diff --git a/pettingzoo/classic/rps_v2.py b/pettingzoo/classic/rps_v2.py index 6087b6fb5..ca4203022 100644 --- a/pettingzoo/classic/rps_v2.py +++ b/pettingzoo/classic/rps_v2.py @@ -1 +1,3 @@ -from .rps.rps import env, parallel_env, raw_env # noqa:F401 +from pettingzoo.classic.rps.rps import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/classic/texas_holdem_no_limit_v6.py b/pettingzoo/classic/texas_holdem_no_limit_v6.py index db9d90825..7c48b7263 100644 --- a/pettingzoo/classic/texas_holdem_no_limit_v6.py +++ b/pettingzoo/classic/texas_holdem_no_limit_v6.py @@ -1 +1,3 @@ -from .rlcard_envs.texas_holdem_no_limit import env, raw_env # noqa: F401 +from pettingzoo.classic.rlcard_envs.texas_holdem_no_limit import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/texas_holdem_v4.py b/pettingzoo/classic/texas_holdem_v4.py index 828c6c805..4f8fe71f5 100644 --- a/pettingzoo/classic/texas_holdem_v4.py +++ b/pettingzoo/classic/texas_holdem_v4.py @@ -1 +1,3 @@ -from .rlcard_envs.texas_holdem import env, raw_env # noqa: F401 +from pettingzoo.classic.rlcard_envs.texas_holdem import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/classic/tictactoe/tictactoe.py b/pettingzoo/classic/tictactoe/tictactoe.py index 635d06c5b..ef00473c8 100644 --- a/pettingzoo/classic/tictactoe/tictactoe.py +++ b/pettingzoo/classic/tictactoe/tictactoe.py @@ -74,10 +74,9 @@ from gymnasium import spaces from pettingzoo import AECEnv +from pettingzoo.classic.tictactoe.board import Board from pettingzoo.utils import agent_selector, wrappers -from .board import Board - def env(render_mode=None): internal_render_mode = render_mode if render_mode != "ansi" else "human" diff --git a/pettingzoo/classic/tictactoe_v3.py b/pettingzoo/classic/tictactoe_v3.py index 80374e54e..0f1775f8f 100644 --- a/pettingzoo/classic/tictactoe_v3.py +++ b/pettingzoo/classic/tictactoe_v3.py @@ -1 +1,3 @@ -from .tictactoe.tictactoe import env, raw_env # noqa: 401 +from pettingzoo.classic.tictactoe.tictactoe import env, raw_env + +__all__ = ["env", "raw_env"] diff --git a/pettingzoo/mpe/simple_adversary_v2.py b/pettingzoo/mpe/simple_adversary_v2.py index a5ef0ce71..c1add6a4a 100644 --- a/pettingzoo/mpe/simple_adversary_v2.py +++ b/pettingzoo/mpe/simple_adversary_v2.py @@ -1 +1,3 @@ -from .simple_adversary.simple_adversary import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple_adversary.simple_adversary import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_crypto_v2.py b/pettingzoo/mpe/simple_crypto_v2.py index 5e447773b..521fe72f7 100644 --- a/pettingzoo/mpe/simple_crypto_v2.py +++ b/pettingzoo/mpe/simple_crypto_v2.py @@ -1 +1,3 @@ -from .simple_crypto.simple_crypto import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple_crypto.simple_crypto import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_push_v2.py b/pettingzoo/mpe/simple_push_v2.py index 7635d9209..24f1b28fd 100644 --- a/pettingzoo/mpe/simple_push_v2.py +++ b/pettingzoo/mpe/simple_push_v2.py @@ -1 +1,3 @@ -from .simple_push.simple_push import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple_push.simple_push import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_reference_v2.py b/pettingzoo/mpe/simple_reference_v2.py index 1e59ab66e..9227b0278 100644 --- a/pettingzoo/mpe/simple_reference_v2.py +++ b/pettingzoo/mpe/simple_reference_v2.py @@ -1 +1,3 @@ -from .simple_reference.simple_reference import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple_reference.simple_reference import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_speaker_listener_v3.py b/pettingzoo/mpe/simple_speaker_listener_v3.py index 25bbcc515..6d83e7136 100644 --- a/pettingzoo/mpe/simple_speaker_listener_v3.py +++ b/pettingzoo/mpe/simple_speaker_listener_v3.py @@ -1,5 +1,7 @@ -from .simple_speaker_listener.simple_speaker_listener import ( # noqa: F401 +from pettingzoo.mpe.simple_speaker_listener.simple_speaker_listener import ( env, parallel_env, raw_env, ) + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_spread_v2.py b/pettingzoo/mpe/simple_spread_v2.py index 53116acff..297102c22 100644 --- a/pettingzoo/mpe/simple_spread_v2.py +++ b/pettingzoo/mpe/simple_spread_v2.py @@ -1 +1,3 @@ -from .simple_spread.simple_spread import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple_spread.simple_spread import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_tag_v2.py b/pettingzoo/mpe/simple_tag_v2.py index 9adb8f517..5d79dec1d 100644 --- a/pettingzoo/mpe/simple_tag_v2.py +++ b/pettingzoo/mpe/simple_tag_v2.py @@ -1 +1,3 @@ -from .simple_tag.simple_tag import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple_tag.simple_tag import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_v2.py b/pettingzoo/mpe/simple_v2.py index 6bd840a22..fa689289f 100644 --- a/pettingzoo/mpe/simple_v2.py +++ b/pettingzoo/mpe/simple_v2.py @@ -1 +1,3 @@ -from .simple.simple import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.mpe.simple.simple import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/mpe/simple_world_comm_v2.py b/pettingzoo/mpe/simple_world_comm_v2.py index d3feeff0e..31940d30b 100644 --- a/pettingzoo/mpe/simple_world_comm_v2.py +++ b/pettingzoo/mpe/simple_world_comm_v2.py @@ -1,5 +1,7 @@ -from .simple_world_comm.simple_world_comm import ( # noqa: F401 +from pettingzoo.mpe.simple_world_comm.simple_world_comm import ( env, parallel_env, raw_env, ) + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/sisl/multiwalker/multiwalker.py b/pettingzoo/sisl/multiwalker/multiwalker.py index f2808fb1c..6490550cb 100755 --- a/pettingzoo/sisl/multiwalker/multiwalker.py +++ b/pettingzoo/sisl/multiwalker/multiwalker.py @@ -123,12 +123,11 @@ from gymnasium.utils import EzPickle from pettingzoo import AECEnv +from pettingzoo.sisl.multiwalker.multiwalker_base import FPS +from pettingzoo.sisl.multiwalker.multiwalker_base import MultiWalkerEnv as _env from pettingzoo.utils import agent_selector, wrappers from pettingzoo.utils.conversions import parallel_wrapper_fn -from .multiwalker_base import FPS -from .multiwalker_base import MultiWalkerEnv as _env - def env(**kwargs): env = raw_env(**kwargs) diff --git a/pettingzoo/sisl/multiwalker_v9.py b/pettingzoo/sisl/multiwalker_v9.py index e70d4d8d2..555eee6a7 100644 --- a/pettingzoo/sisl/multiwalker_v9.py +++ b/pettingzoo/sisl/multiwalker_v9.py @@ -1 +1,3 @@ -from .multiwalker.multiwalker import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.sisl.multiwalker.multiwalker import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/sisl/pursuit/pursuit.py b/pettingzoo/sisl/pursuit/pursuit.py index bfd2a1f10..f68ba9d11 100755 --- a/pettingzoo/sisl/pursuit/pursuit.py +++ b/pettingzoo/sisl/pursuit/pursuit.py @@ -83,11 +83,12 @@ from gymnasium.utils import EzPickle from pettingzoo import AECEnv +from pettingzoo.sisl.pursuit.manual_policy import ManualPolicy +from pettingzoo.sisl.pursuit.pursuit_base import Pursuit as _env from pettingzoo.utils import agent_selector, wrappers from pettingzoo.utils.conversions import parallel_wrapper_fn -from .manual_policy import ManualPolicy # noqa: F401 -from .pursuit_base import Pursuit as _env +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] def env(**kwargs): diff --git a/pettingzoo/sisl/pursuit/pursuit_base.py b/pettingzoo/sisl/pursuit/pursuit_base.py index ed0fc4d2e..66f03dc03 100755 --- a/pettingzoo/sisl/pursuit/pursuit_base.py +++ b/pettingzoo/sisl/pursuit/pursuit_base.py @@ -7,9 +7,13 @@ from gymnasium import spaces from gymnasium.utils import seeding -from .utils import agent_utils, two_d_maps -from .utils.agent_layer import AgentLayer -from .utils.controllers import PursuitPolicy, RandomPolicy, SingleActionPolicy +from pettingzoo.sisl.pursuit.utils import agent_utils, two_d_maps +from pettingzoo.sisl.pursuit.utils.agent_layer import AgentLayer +from pettingzoo.sisl.pursuit.utils.controllers import ( + PursuitPolicy, + RandomPolicy, + SingleActionPolicy, +) class Pursuit: diff --git a/pettingzoo/sisl/pursuit/utils/__init__.py b/pettingzoo/sisl/pursuit/utils/__init__.py index 0a54162cb..b136448bd 100644 --- a/pettingzoo/sisl/pursuit/utils/__init__.py +++ b/pettingzoo/sisl/pursuit/utils/__init__.py @@ -1,8 +1,12 @@ -from .agent_layer import AgentLayer -from .agent_utils import create_agents, feasible_position_exp, set_agents -from .controllers import RandomPolicy, SingleActionPolicy -from .discrete_agent import DiscreteAgent -from .two_d_maps import ( +from pettingzoo.sisl.pursuit.utils.agent_layer import AgentLayer +from pettingzoo.sisl.pursuit.utils.agent_utils import ( + create_agents, + feasible_position_exp, + set_agents, +) +from pettingzoo.sisl.pursuit.utils.controllers import RandomPolicy, SingleActionPolicy +from pettingzoo.sisl.pursuit.utils.discrete_agent import DiscreteAgent +from pettingzoo.sisl.pursuit.utils.two_d_maps import ( add_rectangle, complex_map, cross_map, diff --git a/pettingzoo/sisl/pursuit/utils/agent_utils.py b/pettingzoo/sisl/pursuit/utils/agent_utils.py index 2b384180f..fb1732f88 100644 --- a/pettingzoo/sisl/pursuit/utils/agent_utils.py +++ b/pettingzoo/sisl/pursuit/utils/agent_utils.py @@ -1,6 +1,6 @@ import numpy as np -from .discrete_agent import DiscreteAgent +from pettingzoo.sisl.pursuit.utils.discrete_agent import DiscreteAgent ################################################################# # Implements utility functions for multi-agent DRL diff --git a/pettingzoo/sisl/pursuit_v4.py b/pettingzoo/sisl/pursuit_v4.py index afdad8c8d..fb0892195 100644 --- a/pettingzoo/sisl/pursuit_v4.py +++ b/pettingzoo/sisl/pursuit_v4.py @@ -1 +1,3 @@ -from .pursuit.pursuit import ManualPolicy, env, parallel_env, raw_env # noqa: F401 +from pettingzoo.sisl.pursuit.pursuit import ManualPolicy, env, parallel_env, raw_env + +__all__ = ["ManualPolicy", "env", "parallel_env", "raw_env"] diff --git a/pettingzoo/sisl/waterworld/waterworld.py b/pettingzoo/sisl/waterworld/waterworld.py index f0e25f007..ed3b0c2e2 100755 --- a/pettingzoo/sisl/waterworld/waterworld.py +++ b/pettingzoo/sisl/waterworld/waterworld.py @@ -139,12 +139,11 @@ from gymnasium.utils import EzPickle from pettingzoo import AECEnv +from pettingzoo.sisl.waterworld.waterworld_base import FPS +from pettingzoo.sisl.waterworld.waterworld_base import WaterworldBase as _env from pettingzoo.utils import agent_selector, wrappers from pettingzoo.utils.conversions import parallel_wrapper_fn -from .waterworld_base import FPS -from .waterworld_base import WaterworldBase as _env - def env(**kwargs): env = raw_env(**kwargs) diff --git a/pettingzoo/sisl/waterworld/waterworld_base.py b/pettingzoo/sisl/waterworld/waterworld_base.py index b112802b5..d55facdd4 100755 --- a/pettingzoo/sisl/waterworld/waterworld_base.py +++ b/pettingzoo/sisl/waterworld/waterworld_base.py @@ -8,7 +8,12 @@ from gymnasium.utils import seeding from scipy.spatial import distance as ssd -from .waterworld_models import Evaders, Obstacle, Poisons, Pursuers +from pettingzoo.sisl.waterworld.waterworld_models import ( + Evaders, + Obstacle, + Poisons, + Pursuers, +) FPS = 15 diff --git a/pettingzoo/sisl/waterworld_v4.py b/pettingzoo/sisl/waterworld_v4.py index a0dda3462..412851407 100644 --- a/pettingzoo/sisl/waterworld_v4.py +++ b/pettingzoo/sisl/waterworld_v4.py @@ -1 +1,3 @@ -from .waterworld.waterworld import env, parallel_env, raw_env # noqa: F401 +from pettingzoo.sisl.waterworld.waterworld import env, parallel_env, raw_env + +__all__ = ["env", "parallel_env", "raw_env"] diff --git a/pettingzoo/test/__init__.py b/pettingzoo/test/__init__.py index 71c822db8..2deb868c2 100644 --- a/pettingzoo/test/__init__.py +++ b/pettingzoo/test/__init__.py @@ -1,10 +1,10 @@ -from .api_test import api_test -from .bombardment_test import bombardment_test -from .manual_control_test import manual_control_test -from .max_cycles_test import max_cycles_test -from .parallel_test import parallel_api_test -from .performance_benchmark import performance_benchmark -from .render_test import collect_render_results, render_test -from .save_obs_test import test_save_obs -from .seed_test import parallel_seed_test, seed_test -from .state_test import state_test +from pettingzoo.test.api_test import api_test +from pettingzoo.test.bombardment_test import bombardment_test +from pettingzoo.test.manual_control_test import manual_control_test +from pettingzoo.test.max_cycles_test import max_cycles_test +from pettingzoo.test.parallel_test import parallel_api_test +from pettingzoo.test.performance_benchmark import performance_benchmark +from pettingzoo.test.render_test import collect_render_results, render_test +from pettingzoo.test.save_obs_test import test_save_obs +from pettingzoo.test.seed_test import parallel_seed_test, seed_test +from pettingzoo.test.state_test import state_test diff --git a/pettingzoo/test/bombardment_test.py b/pettingzoo/test/bombardment_test.py index 8da03041b..66faf81f9 100644 --- a/pettingzoo/test/bombardment_test.py +++ b/pettingzoo/test/bombardment_test.py @@ -3,7 +3,7 @@ import numpy as np -from .api_test import test_observation +from pettingzoo.test.api_test import test_observation def bombardment_test(env, cycles=10000): diff --git a/pettingzoo/test/parallel_test.py b/pettingzoo/test/parallel_test.py index bf7d144cb..cc1af02aa 100644 --- a/pettingzoo/test/parallel_test.py +++ b/pettingzoo/test/parallel_test.py @@ -3,6 +3,7 @@ import numpy as np +from pettingzoo.test.api_test import missing_attr_warning from pettingzoo.utils.conversions import ( aec_to_parallel_wrapper, parallel_to_aec_wrapper, @@ -10,8 +11,6 @@ ) from pettingzoo.utils.wrappers import BaseWrapper -from .api_test import missing_attr_warning - def sample_action(env, obs, agent): agent_obs = obs[agent] diff --git a/pettingzoo/utils/env.py b/pettingzoo/utils/env.py index e453ad7c8..c20de8429 100644 --- a/pettingzoo/utils/env.py +++ b/pettingzoo/utils/env.py @@ -1,7 +1,7 @@ from __future__ import annotations import warnings -from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, TypeVar +from typing import Any, Dict, Iterable, Iterator, TypeVar import gymnasium.spaces import numpy as np @@ -29,26 +29,26 @@ class AECEnv: the `api_test` documented in the Developer documentation on the website. """ - metadata: Dict[str, Any] # Metadata for the environment + metadata: dict[str, Any] # Metadata for the environment # All agents that may appear in the environment - possible_agents: List[AgentID] - agents: List[AgentID] # Agents active at any given time + possible_agents: list[AgentID] + agents: list[AgentID] # Agents active at any given time - observation_spaces: Dict[ + observation_spaces: dict[ AgentID, gymnasium.spaces.Space ] # Observation space for each agent # Action space for each agent - action_spaces: Dict[AgentID, gymnasium.spaces.Space] + action_spaces: dict[AgentID, gymnasium.spaces.Space] # Whether each agent has just reached a terminal state - terminations: Dict[AgentID, bool] - truncations: Dict[AgentID, bool] - rewards: Dict[AgentID, float] # Reward from the last step for each agent + terminations: dict[AgentID, bool] + truncations: dict[AgentID, bool] + rewards: dict[AgentID, float] # Reward from the last step for each agent # Cumulative rewards for each agent - _cumulative_rewards: Dict[AgentID, float] - infos: Dict[ - AgentID, Dict[str, Any] + _cumulative_rewards: dict[AgentID, float] + infos: dict[ + AgentID, dict[str, Any] ] # Additional information from the last step for each agent agent_selection: AgentID # The agent currently being stepped @@ -65,20 +65,20 @@ def step(self, action: ActionType) -> None: def reset( self, - seed: Optional[int] = None, - options: Optional[dict] = None, + seed: int | None = None, + options: dict | None = None, ) -> None: """Resets the environment to a starting state.""" raise NotImplementedError - def seed(self, seed: Optional[int] = None) -> None: + def seed(self, seed: int | None = None) -> None: """Reseeds the environment (making the resulting environment deterministic).""" raise NotImplementedError( "Calling seed externally is deprecated; call reset(seed=seed) instead" ) # TODO: Remove `Optional` type below - def observe(self, agent: str) -> Optional[ObsType]: + def observe(self, agent: str) -> ObsType | None: """Returns the observation an agent currently can make. `last()` calls this function. @@ -183,7 +183,7 @@ def agent_iter(self, max_iter: int = 2**63) -> AECIterable: def last( self, observe: bool = True - ) -> Tuple[Optional[ObsType], float, bool, bool, Dict[str, Any]]: + ) -> tuple[ObsType | None, float, bool, bool, dict[str, Any]]: """Returns observation, cumulative reward, terminated, truncated, info for the current agent (specified by self.agent_selection).""" agent = self.agent_selection assert agent @@ -290,19 +290,19 @@ class ParallelEnv: the Developer documentation on the website. """ - metadata: Dict[str, Any] + metadata: dict[str, Any] - agents: List[AgentID] - possible_agents: List[AgentID] - observation_spaces: Dict[ + agents: list[AgentID] + possible_agents: list[AgentID] + observation_spaces: dict[ AgentID, gymnasium.spaces.Space ] # Observation space for each agent - action_spaces: Dict[AgentID, gymnasium.spaces.Space] + action_spaces: dict[AgentID, gymnasium.spaces.Space] def reset( self, - seed: Optional[int] = None, - options: Optional[dict] = None, + seed: int | None = None, + options: dict | None = None, ) -> ObsDict: """Resets the environment. @@ -318,8 +318,8 @@ def seed(self, seed=None): def step( self, actions: ActionDict - ) -> Tuple[ - ObsDict, Dict[str, float], Dict[str, bool], Dict[str, bool], Dict[str, dict] + ) -> tuple[ + ObsDict, dict[str, float], dict[str, bool], dict[str, bool], dict[str, dict] ]: """Receives a dictionary of actions keyed by the agent name. @@ -328,7 +328,7 @@ def step( """ raise NotImplementedError - def render(self) -> None | np.ndarray | str | List: + def render(self) -> None | np.ndarray | str | list: """Displays a rendered frame from the environment, if supported. Alternate render modes in the default environments are `'rgb_array'` diff --git a/test/all_parameter_combs_test.py b/test/all_parameter_combs_test.py index eff6b64c6..5a1a14fe9 100644 --- a/test/all_parameter_combs_test.py +++ b/test/all_parameter_combs_test.py @@ -1,12 +1,33 @@ import pytest +from pettingzoo.atari import ( + boxing_v2, + combat_plane_v2, + combat_tank_v2, + maze_craze_v3, + space_invaders_v2, +) +from pettingzoo.butterfly import knights_archers_zombies_v10, pistonball_v6 +from pettingzoo.classic import ( + go_v5, + hanabi_v4, + leduc_holdem_v4, + texas_holdem_no_limit_v6, + texas_holdem_v4, +) +from pettingzoo.mpe import ( + simple_adversary_v2, + simple_reference_v2, + simple_spread_v2, + simple_tag_v2, + simple_world_comm_v2, +) +from pettingzoo.sisl import multiwalker_v9, pursuit_v4, waterworld_v4 from pettingzoo.test.api_test import api_test from pettingzoo.test.render_test import render_test from pettingzoo.test.seed_test import seed_test from pettingzoo.test.state_test import state_test -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")], diff --git a/test/pickle_test.py b/test/pickle_test.py index f95d7ea0b..0332d4573 100644 --- a/test/pickle_test.py +++ b/test/pickle_test.py @@ -1,12 +1,11 @@ import pickle +from test.all_modules import all_environments 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()) diff --git a/test/pytest_runner_test.py b/test/pytest_runner_test.py index cb6ef8426..ced21b24d 100644 --- a/test/pytest_runner_test.py +++ b/test/pytest_runner_test.py @@ -1,4 +1,5 @@ import os +from test.all_modules import all_environments import pytest @@ -11,8 +12,6 @@ from pettingzoo.test.state_test import state_test from pettingzoo.utils import aec_to_parallel, parallel_to_aec -from .all_modules import all_environments - @pytest.mark.parametrize(("name", "env_module"), list(all_environments.items())) def test_module(name, env_module): diff --git a/test/unwrapped_test.py b/test/unwrapped_test.py index d6597cb37..5cd6b9669 100644 --- a/test/unwrapped_test.py +++ b/test/unwrapped_test.py @@ -1,10 +1,10 @@ +from test.all_modules import all_environments + import pytest from gymnasium import spaces from pettingzoo.utils import conversions, wrappers -from .all_modules import all_environments - def box_action(env, agents): boxable = True