diff --git a/pettingzoo/atari/basketball_pong/basketball_pong.py b/pettingzoo/atari/basketball_pong/basketball_pong.py new file mode 100644 index 000000000..b019e5dc3 --- /dev/null +++ b/pettingzoo/atari/basketball_pong/basketball_pong.py @@ -0,0 +1,21 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(num_players=2, **kwargs): + assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" + mode_mapping = {2: 45, 4: 49} + mode = mode_mapping[num_players] + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="pong", num_players=num_players, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/basketball_pong_v3.py b/pettingzoo/atari/basketball_pong_v3.py index cd84a9d7e..684251c85 100644 --- a/pettingzoo/atari/basketball_pong_v3.py +++ b/pettingzoo/atari/basketball_pong_v3.py @@ -1,20 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(num_players=2, **kwargs): - assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" - mode_mapping = {2: 45, 4: 49} - mode = mode_mapping[num_players] - return BaseAtariEnv( - game="pong", - num_players=num_players, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .basketball_pong.basketball_pong import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/boxing/boxing.py b/pettingzoo/atari/boxing/boxing.py new file mode 100644 index 000000000..82ac99206 --- /dev/null +++ b/pettingzoo/atari/boxing/boxing.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="boxing", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/boxing_v2.py b/pettingzoo/atari/boxing_v2.py index 29b090637..42478e4fa 100644 --- a/pettingzoo/atari/boxing_v2.py +++ b/pettingzoo/atari/boxing_v2.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="boxing", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .boxing.boxing import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/combat_plane/combat_plane.py b/pettingzoo/atari/combat_plane/combat_plane.py new file mode 100644 index 000000000..63820630e --- /dev/null +++ b/pettingzoo/atari/combat_plane/combat_plane.py @@ -0,0 +1,27 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + +avaliable_versions = { + "bi-plane": 15, + "jet": 21, +} + + +def raw_env(game_version="bi-plane", guided_missile=True, **kwargs): + assert ( + game_version in avaliable_versions + ), "game_version must be either 'jet' or 'bi-plane'" + mode = avaliable_versions[game_version] + (0 if guided_missile else 1) + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="combat", num_players=2, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/combat_plane_v2.py b/pettingzoo/atari/combat_plane_v2.py index 9188212ff..aae54e5f2 100644 --- a/pettingzoo/atari/combat_plane_v2.py +++ b/pettingzoo/atari/combat_plane_v2.py @@ -1,27 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - -avaliable_versions = { - "bi-plane": 15, - "jet": 21, -} - - -def raw_env(game_version="bi-plane", guided_missile=True, **kwargs): - assert ( - game_version in avaliable_versions - ), "game_version must be either 'jet' or 'bi-plane'" - mode = avaliable_versions[game_version] + (0 if guided_missile else 1) - - return BaseAtariEnv( - game="combat", - num_players=2, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .combat_plane.combat_plane import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/combat_tank/combat_tank.py b/pettingzoo/atari/combat_tank/combat_tank.py new file mode 100644 index 000000000..634d7c100 --- /dev/null +++ b/pettingzoo/atari/combat_tank/combat_tank.py @@ -0,0 +1,30 @@ +import os +import warnings +from glob import glob + +from ..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): + if has_maze is False and is_invisible is False and billiard_hit is False: + warnings.warn( + "combat_tank has interesting parameters to consider overriding including is_invisible, billiard_hit and has_maze" + ) + start_mapping = { + (False, False): 1, + (False, True): 8, + (True, False): 10, + (True, True): 13, + } + mode = start_mapping[(is_invisible, billiard_hit)] + has_maze + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="combat", num_players=2, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/combat_tank_v2.py b/pettingzoo/atari/combat_tank_v2.py index 78a794c00..fe1a96b52 100644 --- a/pettingzoo/atari/combat_tank_v2.py +++ b/pettingzoo/atari/combat_tank_v2.py @@ -1,30 +1 @@ -import os -import warnings - -from .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): - if has_maze is False and is_invisible is False and billiard_hit is False: - warnings.warn( - "combat_tank has interesting parameters to consider overriding including is_invisible, billiard_hit and has_maze" - ) - start_mapping = { - (False, False): 1, - (False, True): 8, - (True, False): 10, - (True, True): 13, - } - mode = start_mapping[(is_invisible, billiard_hit)] + has_maze - - return BaseAtariEnv( - game="combat", - num_players=2, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .combat_tank.combat_tank import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/double_dunk/double_dunk.py b/pettingzoo/atari/double_dunk/double_dunk.py new file mode 100644 index 000000000..ad23b0378 --- /dev/null +++ b/pettingzoo/atari/double_dunk/double_dunk.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="double_dunk", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/double_dunk_v3.py b/pettingzoo/atari/double_dunk_v3.py index ec8c35a61..e4a88f287 100644 --- a/pettingzoo/atari/double_dunk_v3.py +++ b/pettingzoo/atari/double_dunk_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="double_dunk", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .double_dunk.double_dunk import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/entombed_competitive/entombed_competitive.py b/pettingzoo/atari/entombed_competitive/entombed_competitive.py new file mode 100644 index 000000000..8becbda5d --- /dev/null +++ b/pettingzoo/atari/entombed_competitive/entombed_competitive.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="entombed", num_players=2, mode_num=2, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/entombed_competitive_v3.py b/pettingzoo/atari/entombed_competitive_v3.py index 3f4060288..010f90cfa 100644 --- a/pettingzoo/atari/entombed_competitive_v3.py +++ b/pettingzoo/atari/entombed_competitive_v3.py @@ -1,17 +1,5 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="entombed", - num_players=2, - mode_num=2, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .entombed_competitive.entombed_competitive import ( # noqa: F401 + env, + parallel_env, + raw_env, +) diff --git a/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py b/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py new file mode 100644 index 000000000..b38b3c1de --- /dev/null +++ b/pettingzoo/atari/entombed_cooperative/entombed_cooperative.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="entombed", num_players=2, mode_num=3, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/entombed_cooperative_v3.py b/pettingzoo/atari/entombed_cooperative_v3.py index 0009e0172..c8aa70173 100644 --- a/pettingzoo/atari/entombed_cooperative_v3.py +++ b/pettingzoo/atari/entombed_cooperative_v3.py @@ -1,17 +1,5 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="entombed", - num_players=2, - mode_num=3, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .entombed_cooperative.entombed_cooperative import ( # noqa: F401 + env, + parallel_env, + raw_env, +) diff --git a/pettingzoo/atari/flag_capture/flag_capture.py b/pettingzoo/atari/flag_capture/flag_capture.py new file mode 100644 index 000000000..f367523f7 --- /dev/null +++ b/pettingzoo/atari/flag_capture/flag_capture.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="flag_capture", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/flag_capture_v2.py b/pettingzoo/atari/flag_capture_v2.py index 752e54055..17127f742 100644 --- a/pettingzoo/atari/flag_capture_v2.py +++ b/pettingzoo/atari/flag_capture_v2.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="flag_capture", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .flag_capture.flag_capture import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/foozpong/foozpong.py b/pettingzoo/atari/foozpong/foozpong.py new file mode 100644 index 000000000..36d8e50c9 --- /dev/null +++ b/pettingzoo/atari/foozpong/foozpong.py @@ -0,0 +1,21 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(num_players=4, **kwargs): + assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" + mode_mapping = {2: 19, 4: 21} + mode = mode_mapping[num_players] + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="pong", num_players=num_players, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/foozpong_v3.py b/pettingzoo/atari/foozpong_v3.py index cf1a421a6..56001c341 100644 --- a/pettingzoo/atari/foozpong_v3.py +++ b/pettingzoo/atari/foozpong_v3.py @@ -1,20 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(num_players=4, **kwargs): - assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" - mode_mapping = {2: 19, 4: 21} - mode = mode_mapping[num_players] - return BaseAtariEnv( - game="pong", - num_players=num_players, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .foozpong.foozpong import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/ice_hockey/ice_hockey.py b/pettingzoo/atari/ice_hockey/ice_hockey.py new file mode 100644 index 000000000..f51486c5d --- /dev/null +++ b/pettingzoo/atari/ice_hockey/ice_hockey.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="ice_hockey", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/ice_hockey_v2.py b/pettingzoo/atari/ice_hockey_v2.py index fdb9f2399..b49c212c0 100644 --- a/pettingzoo/atari/ice_hockey_v2.py +++ b/pettingzoo/atari/ice_hockey_v2.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="ice_hockey", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .ice_hockey.ice_hockey import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/joust/joust.py b/pettingzoo/atari/joust/joust.py new file mode 100644 index 000000000..de09e9f32 --- /dev/null +++ b/pettingzoo/atari/joust/joust.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="joust", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/joust_v3.py b/pettingzoo/atari/joust_v3.py index 98ed35e8e..84f73c833 100644 --- a/pettingzoo/atari/joust_v3.py +++ b/pettingzoo/atari/joust_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="joust", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .joust.joust import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/mario_bros/mario_bros.py b/pettingzoo/atari/mario_bros/mario_bros.py new file mode 100644 index 000000000..949c869d8 --- /dev/null +++ b/pettingzoo/atari/mario_bros/mario_bros.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="mario_bros", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/mario_bros_v3.py b/pettingzoo/atari/mario_bros_v3.py index 3aca41756..ef8749aa7 100644 --- a/pettingzoo/atari/mario_bros_v3.py +++ b/pettingzoo/atari/mario_bros_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="mario_bros", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .mario_bros.mario_bros import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/maze_craze/maze_craze.py b/pettingzoo/atari/maze_craze/maze_craze.py new file mode 100644 index 000000000..c202f028c --- /dev/null +++ b/pettingzoo/atari/maze_craze/maze_craze.py @@ -0,0 +1,41 @@ +import os +import warnings +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + +avaliable_versions = { + "robbers": 2, + "race": 1, + "capture": 12, +} + + +def raw_env(game_version="robbers", visibilty_level=0, **kwargs): + if game_version == "robbers" and visibilty_level == 0: + warnings.warn( + "maze_craze has different versions of the game via the `game_version` argument, consider overriding." + ) + assert ( + game_version in avaliable_versions + ), f"`game_version` parameter must be one of {avaliable_versions.keys()}" + assert ( + 0 <= visibilty_level < 4 + ), "visibility level must be between 0 and 4, where 0 is 100% visibility and 3 is 0% visibility" + base_mode = (avaliable_versions[game_version] - 1) * 4 + mode = base_mode + visibilty_level + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="maze_craze", + num_players=2, + mode_num=mode, + env_name=name, + **kwargs, + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/maze_craze_v3.py b/pettingzoo/atari/maze_craze_v3.py index 4fe65eb34..d43822636 100644 --- a/pettingzoo/atari/maze_craze_v3.py +++ b/pettingzoo/atari/maze_craze_v3.py @@ -1,36 +1 @@ -import os -import warnings - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - -avaliable_versions = { - "robbers": 2, - "race": 1, - "capture": 12, -} - - -def raw_env(game_version="robbers", visibilty_level=0, **kwargs): - if game_version == "robbers" and visibilty_level == 0: - warnings.warn( - "maze_craze has different versions of the game via the `game_version` argument, consider overriding." - ) - assert ( - game_version in avaliable_versions - ), f"`game_version` parameter must be one of {avaliable_versions.keys()}" - assert ( - 0 <= visibilty_level < 4 - ), "visibility level must be between 0 and 4, where 0 is 100% visibility and 3 is 0% visibility" - base_mode = (avaliable_versions[game_version] - 1) * 4 - mode = base_mode + visibilty_level - return BaseAtariEnv( - game="maze_craze", - num_players=2, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs, - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .maze_craze.maze_craze import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/othello/othello.py b/pettingzoo/atari/othello/othello.py new file mode 100644 index 000000000..687b4e52a --- /dev/null +++ b/pettingzoo/atari/othello/othello.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="othello", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/othello_v3.py b/pettingzoo/atari/othello_v3.py index db31958a0..45b43afa5 100644 --- a/pettingzoo/atari/othello_v3.py +++ b/pettingzoo/atari/othello_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="othello", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .othello.othello import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/pong/pong.py b/pettingzoo/atari/pong/pong.py new file mode 100644 index 000000000..94656b776 --- /dev/null +++ b/pettingzoo/atari/pong/pong.py @@ -0,0 +1,50 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + +avaliable_2p_versions = { + "classic": 4, + "two_paddles": 10, + "soccer": 14, + "foozpong": 19, + "hockey": 27, + "handball": 35, + "volleyball": 39, + "basketball": 45, +} +avaliable_4p_versions = { + "classic": 6, + "two_paddles": 11, + "soccer": 16, + "foozpong": 21, + "hockey": 29, + "quadrapong": 33, + "handball": 37, + "volleyball": 41, + "basketball": 49, +} + + +def raw_env(num_players=2, game_version="classic", **kwargs): + assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" + versions = avaliable_2p_versions if num_players == 2 else avaliable_4p_versions + assert ( + game_version in versions + ), f"pong version {game_version} not supported for number of players {num_players}. Available options are {list(versions)}" + mode = versions[game_version] + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="pong", + num_players=num_players, + mode_num=mode, + env_name=name, + **kwargs, + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/pong_v3.py b/pettingzoo/atari/pong_v3.py index e4ce78c74..0d46176b8 100644 --- a/pettingzoo/atari/pong_v3.py +++ b/pettingzoo/atari/pong_v3.py @@ -1,45 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - -avaliable_2p_versions = { - "classic": 4, - "two_paddles": 10, - "soccer": 14, - "foozpong": 19, - "hockey": 27, - "handball": 35, - "volleyball": 39, - "basketball": 45, -} -avaliable_4p_versions = { - "classic": 6, - "two_paddles": 11, - "soccer": 16, - "foozpong": 21, - "hockey": 29, - "quadrapong": 33, - "handball": 37, - "volleyball": 41, - "basketball": 49, -} - - -def raw_env(num_players=2, game_version="classic", **kwargs): - assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" - versions = avaliable_2p_versions if num_players == 2 else avaliable_4p_versions - assert ( - game_version in versions - ), f"pong version {game_version} not supported for number of players {num_players}. Available options are {list(versions)}" - mode = versions[game_version] - return BaseAtariEnv( - game="pong", - num_players=num_players, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs, - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .pong.pong import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/quadrapong/quadrapong.py b/pettingzoo/atari/quadrapong/quadrapong.py new file mode 100644 index 000000000..6d8859160 --- /dev/null +++ b/pettingzoo/atari/quadrapong/quadrapong.py @@ -0,0 +1,20 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + mode = 33 + num_players = 4 + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="pong", num_players=num_players, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/quadrapong_v4.py b/pettingzoo/atari/quadrapong_v4.py index f8d2ed9e5..59e8e96d0 100644 --- a/pettingzoo/atari/quadrapong_v4.py +++ b/pettingzoo/atari/quadrapong_v4.py @@ -1,19 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - mode = 33 - num_players = 4 - return BaseAtariEnv( - game="pong", - num_players=num_players, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .quadrapong.quadrapong import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/space_invaders/space_invaders.py b/pettingzoo/atari/space_invaders/space_invaders.py new file mode 100644 index 000000000..4dfaf79f2 --- /dev/null +++ b/pettingzoo/atari/space_invaders/space_invaders.py @@ -0,0 +1,32 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env( + alternating_control=False, + moving_shields=True, + zigzaging_bombs=False, + fast_bomb=False, + invisible_invaders=False, + **kwargs +): + mode = 33 + ( + moving_shields * 1 + + zigzaging_bombs * 2 + + fast_bomb * 4 + + invisible_invaders * 8 + + alternating_control * 16 + ) + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="space_invaders", num_players=2, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/space_invaders_v2.py b/pettingzoo/atari/space_invaders_v2.py index 3ea314ecf..6b8f93b84 100644 --- a/pettingzoo/atari/space_invaders_v2.py +++ b/pettingzoo/atari/space_invaders_v2.py @@ -1,31 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env( - alternating_control=False, - moving_shields=True, - zigzaging_bombs=False, - fast_bomb=False, - invisible_invaders=False, - **kwargs -): - mode = 33 + ( - moving_shields * 1 - + zigzaging_bombs * 2 - + fast_bomb * 4 - + invisible_invaders * 8 - + alternating_control * 16 - ) - return BaseAtariEnv( - game="space_invaders", - num_players=2, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .space_invaders.space_invaders import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/space_war/space_war.py b/pettingzoo/atari/space_war/space_war.py new file mode 100644 index 000000000..2700ec6eb --- /dev/null +++ b/pettingzoo/atari/space_war/space_war.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="space_war", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/space_war_v2.py b/pettingzoo/atari/space_war_v2.py index fc09e4430..504588c8c 100644 --- a/pettingzoo/atari/space_war_v2.py +++ b/pettingzoo/atari/space_war_v2.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="space_war", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .space_war.space_war import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/surround/surround.py b/pettingzoo/atari/surround/surround.py new file mode 100644 index 000000000..2b85f01c3 --- /dev/null +++ b/pettingzoo/atari/surround/surround.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="surround", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/surround_v2.py b/pettingzoo/atari/surround_v2.py index d756f71c6..2e8e332f7 100644 --- a/pettingzoo/atari/surround_v2.py +++ b/pettingzoo/atari/surround_v2.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="surround", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .surround.surround import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/tennis/tennis.py b/pettingzoo/atari/tennis/tennis.py new file mode 100644 index 000000000..4adcbd6e5 --- /dev/null +++ b/pettingzoo/atari/tennis/tennis.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="tennis", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/tennis_v3.py b/pettingzoo/atari/tennis_v3.py index 7f255fcee..6e8e5c608 100644 --- a/pettingzoo/atari/tennis_v3.py +++ b/pettingzoo/atari/tennis_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="tennis", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .tennis.tennis import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/video_checkers/video_checkers.py b/pettingzoo/atari/video_checkers/video_checkers.py new file mode 100644 index 000000000..0d33b5c3d --- /dev/null +++ b/pettingzoo/atari/video_checkers/video_checkers.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="video_checkers", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/video_checkers_v4.py b/pettingzoo/atari/video_checkers_v4.py index a8d518ccf..da7e82ff7 100644 --- a/pettingzoo/atari/video_checkers_v4.py +++ b/pettingzoo/atari/video_checkers_v4.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="video_checkers", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .video_checkers.video_checkers import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/volleyball_pong/volleyball_pong.py b/pettingzoo/atari/volleyball_pong/volleyball_pong.py new file mode 100644 index 000000000..f15f169be --- /dev/null +++ b/pettingzoo/atari/volleyball_pong/volleyball_pong.py @@ -0,0 +1,21 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(num_players=4, **kwargs): + assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" + mode_mapping = {2: 39, 4: 41} + mode = mode_mapping[num_players] + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="pong", num_players=num_players, mode_num=mode, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/volleyball_pong_v3.py b/pettingzoo/atari/volleyball_pong_v3.py index 6d3814896..84b9bd1c8 100644 --- a/pettingzoo/atari/volleyball_pong_v3.py +++ b/pettingzoo/atari/volleyball_pong_v3.py @@ -1,20 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(num_players=4, **kwargs): - assert num_players == 2 or num_players == 4, "pong only supports 2 or 4 players" - mode_mapping = {2: 39, 4: 41} - mode = mode_mapping[num_players] - return BaseAtariEnv( - game="pong", - num_players=num_players, - mode_num=mode, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .volleyball_pong.volleyball_pong import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/warlords/warlords.py b/pettingzoo/atari/warlords/warlords.py new file mode 100644 index 000000000..67567d36e --- /dev/null +++ b/pettingzoo/atari/warlords/warlords.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="warlords", num_players=4, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/warlords_v3.py b/pettingzoo/atari/warlords_v3.py index ea3718515..e25b7bdeb 100644 --- a/pettingzoo/atari/warlords_v3.py +++ b/pettingzoo/atari/warlords_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="warlords", - num_players=4, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .warlords.warlords import env, parallel_env, raw_env # noqa: F401 diff --git a/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py b/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py new file mode 100644 index 000000000..2f93c0ccc --- /dev/null +++ b/pettingzoo/atari/wizard_of_wor/wizard_of_wor.py @@ -0,0 +1,18 @@ +import os +from glob import glob + +from ..base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn + + +def raw_env(**kwargs): + name = os.path.basename(__file__).split(".")[0] + parent_file = glob("./pettingzoo/atari/" + name + "*.py") + version_num = parent_file[0].split("_")[-1].split(".")[0] + name = name + "_" + version_num + return BaseAtariEnv( + game="wizard_of_wor", num_players=2, mode_num=None, env_name=name, **kwargs + ) + + +env = base_env_wrapper_fn(raw_env) +parallel_env = parallel_wrapper_fn(env) diff --git a/pettingzoo/atari/wizard_of_wor_v3.py b/pettingzoo/atari/wizard_of_wor_v3.py index 5433f936d..944435c6e 100644 --- a/pettingzoo/atari/wizard_of_wor_v3.py +++ b/pettingzoo/atari/wizard_of_wor_v3.py @@ -1,17 +1 @@ -import os - -from .base_atari_env import BaseAtariEnv, base_env_wrapper_fn, parallel_wrapper_fn - - -def raw_env(**kwargs): - return BaseAtariEnv( - game="wizard_of_wor", - num_players=2, - mode_num=None, - env_name=os.path.basename(__file__)[:-3], - **kwargs - ) - - -env = base_env_wrapper_fn(raw_env) -parallel_env = parallel_wrapper_fn(env) +from .wizard_of_wor.wizard_of_wor import env, parallel_env, raw_env # noqa: F401