multi-agent-rlenv 3.7.1__tar.gz → 3.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/PKG-INFO +3 -4
  2. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/pyproject.toml +5 -6
  3. multi_agent_rlenv-3.7.3/src/marlenv/adapters/__init__.py +36 -0
  4. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/adapters/pettingzoo_adapter.py +1 -1
  5. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/adapters/smac_adapter.py +2 -15
  6. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/__init__.py +7 -2
  7. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/observation.py +1 -1
  8. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/state.py +1 -1
  9. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/utils/import_placeholders.py +2 -0
  10. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_adapters.py +24 -1
  11. multi_agent_rlenv-3.7.1/src/marlenv/adapters/__init__.py +0 -33
  12. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/.github/workflows/ci.yaml +0 -0
  13. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/.github/workflows/docs.yaml +0 -0
  14. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/.gitignore +0 -0
  15. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/LICENSE +0 -0
  16. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/README.md +0 -0
  17. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/__init__.py +0 -0
  18. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/adapters/gym_adapter.py +0 -0
  19. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/adapters/pymarl_adapter.py +0 -0
  20. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/connectn/__init__.py +0 -0
  21. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/connectn/board.py +0 -0
  22. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/connectn/env.py +0 -0
  23. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/coordinated_grid.py +0 -0
  24. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/deepsea.py +0 -0
  25. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/matrix_game.py +0 -0
  26. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/catalog/two_steps.py +0 -0
  27. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/env_builder.py +0 -0
  28. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/env_pool.py +0 -0
  29. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/exceptions.py +0 -0
  30. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/mock_env.py +0 -0
  31. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/__init__.py +0 -0
  32. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/env.py +0 -0
  33. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/episode.py +0 -0
  34. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/spaces.py +0 -0
  35. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/step.py +0 -0
  36. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/models/transition.py +0 -0
  37. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/py.typed +0 -0
  38. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/utils/__init__.py +0 -0
  39. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/utils/cached_property_collector.py +0 -0
  40. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/utils/schedule.py +0 -0
  41. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/__init__.py +0 -0
  42. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/action_randomizer.py +0 -0
  43. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/agent_id_wrapper.py +0 -0
  44. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/available_actions_mask.py +0 -0
  45. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/available_actions_wrapper.py +0 -0
  46. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/blind_wrapper.py +0 -0
  47. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/centralised.py +0 -0
  48. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/delayed_rewards.py +0 -0
  49. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/last_action_wrapper.py +0 -0
  50. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/paddings.py +0 -0
  51. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/penalty_wrapper.py +0 -0
  52. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/potential_shaping.py +0 -0
  53. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/rlenv_wrapper.py +0 -0
  54. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/state_counter.py +0 -0
  55. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/time_limit.py +0 -0
  56. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/src/marlenv/wrappers/video_recorder.py +0 -0
  57. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/__init__.py +0 -0
  58. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_catalog.py +0 -0
  59. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_deepsea.py +0 -0
  60. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_episode.py +0 -0
  61. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_models.py +0 -0
  62. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_others.py +0 -0
  63. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_pool.py +0 -0
  64. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_schedules.py +0 -0
  65. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_serialization.py +0 -0
  66. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_spaces.py +0 -0
  67. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/test_wrappers.py +0 -0
  68. {multi_agent_rlenv-3.7.1 → multi_agent_rlenv-3.7.3}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multi-agent-rlenv
3
- Version: 3.7.1
3
+ Version: 3.7.3
4
4
  Summary: A strongly typed Multi-Agent Reinforcement Learning framework
5
5
  Project-URL: repository, https://github.com/yamoling/multi-agent-rlenv
6
6
  Author-email: Yannick Molinghen <yannick.molinghen@ulb.be>
@@ -17,9 +17,8 @@ Requires-Dist: laser-learning-environment>=2.6.1; extra == 'all'
17
17
  Requires-Dist: overcooked>=0.1.0; extra == 'all'
18
18
  Requires-Dist: pettingzoo>=1.20; extra == 'all'
19
19
  Requires-Dist: pymunk>=6.0; extra == 'all'
20
- Requires-Dist: pysc2; extra == 'all'
21
20
  Requires-Dist: scipy>=1.10; extra == 'all'
22
- Requires-Dist: smac; extra == 'all'
21
+ Requires-Dist: smacv2; extra == 'all'
23
22
  Requires-Dist: torch>=2.0; extra == 'all'
24
23
  Provides-Extra: gym
25
24
  Requires-Dist: gymnasium>=0.29.1; extra == 'gym'
@@ -33,7 +32,7 @@ Requires-Dist: pymunk>=6.0; extra == 'pettingzoo'
33
32
  Requires-Dist: scipy>=1.10; extra == 'pettingzoo'
34
33
  Provides-Extra: smac
35
34
  Requires-Dist: pysc2; extra == 'smac'
36
- Requires-Dist: smac; extra == 'smac'
35
+ Requires-Dist: smacv2; extra == 'smac'
37
36
  Provides-Extra: torch
38
37
  Requires-Dist: torch>=2.0; extra == 'torch'
39
38
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "multi-agent-rlenv"
3
- version = "3.7.1"
3
+ version = "3.7.3"
4
4
  description = "A strongly typed Multi-Agent Reinforcement Learning framework"
5
5
  authors = [
6
6
  { "name" = "Yannick Molinghen", "email" = "yannick.molinghen@ulb.be" },
@@ -17,7 +17,7 @@ dependencies = ["numpy>=2.0.0", "opencv-python>=4.0", "typing_extensions>=4.0"]
17
17
 
18
18
  [project.optional-dependencies]
19
19
  gym = ["gymnasium>=0.29.1"]
20
- smac = ["smac", "pysc2"]
20
+ smac = ["smacv2", "pysc2"]
21
21
  pettingzoo = ["pettingzoo>=1.20", "pymunk>=6.0", "scipy>=1.10"]
22
22
  overcooked = ["overcooked>=0.1.0"]
23
23
  lle = ["laser-learning-environment>=2.6.1"]
@@ -26,8 +26,7 @@ all = [
26
26
  "gymnasium>0.29.1",
27
27
  "pettingzoo>=1.20",
28
28
  "overcooked>=0.1.0",
29
- "smac",
30
- "pysc2",
29
+ "smacv2",
31
30
  "laser-learning-environment>=2.6.1",
32
31
  "pymunk>=6.0",
33
32
  "scipy>=1.10",
@@ -52,8 +51,8 @@ pythonpath = "src"
52
51
  filterwarnings = "ignore::DeprecationWarning"
53
52
 
54
53
  [tool.uv.sources]
55
- smac = { git = "https://github.com/oxwhirl/smac.git" }
56
- pysc2 = { git = "https://github.com/google-deepmind/pysc2.git" }
54
+ smacv2 = { git = "https://github.com/oxwhirl/smacv2.git", rev = "577ab5a" }
55
+ pysc2 = { git = "https://github.com/google-deepmind/pysc2.git", rev = "0df53d3" }
57
56
 
58
57
 
59
58
  [dependency-groups]
@@ -0,0 +1,36 @@
1
+ from .pymarl_adapter import PymarlAdapter
2
+ from marlenv.utils import dummy_function
3
+
4
+ try:
5
+ from .gym_adapter import Gym, make
6
+
7
+ HAS_GYM = True
8
+ except ImportError:
9
+ HAS_GYM = False
10
+ make = dummy_function("gymnasium")
11
+
12
+ try:
13
+ from .pettingzoo_adapter import PettingZoo
14
+
15
+ HAS_PETTINGZOO = True
16
+ except ImportError:
17
+ HAS_PETTINGZOO = False
18
+
19
+ try:
20
+ from .smac_adapter import SMAC
21
+
22
+ HAS_SMAC = True
23
+ except ImportError:
24
+ HAS_SMAC = False
25
+
26
+
27
+ __all__ = [
28
+ "PymarlAdapter",
29
+ "Gym",
30
+ "make",
31
+ "PettingZoo",
32
+ "SMAC",
33
+ "HAS_GYM",
34
+ "HAS_PETTINGZOO",
35
+ "HAS_SMAC",
36
+ ]
@@ -3,7 +3,7 @@ from typing import Sequence
3
3
 
4
4
  import numpy as np
5
5
  import numpy.typing as npt
6
- from gymnasium import spaces # pettingzoo uses gymnasium spaces
6
+ from gymnasium import spaces
7
7
  from pettingzoo import ParallelEnv
8
8
 
9
9
  from marlenv.models import MARLEnv, Observation, State, Step, DiscreteSpace, ContinuousSpace, Space
@@ -3,7 +3,7 @@ from typing import overload
3
3
 
4
4
  import numpy as np
5
5
  import numpy.typing as npt
6
- from smac.env import StarCraft2Env # pyright: ignore[reportMissingImports]
6
+ from smacv2.env import StarCraft2Env
7
7
 
8
8
  from marlenv.models import MARLEnv, Observation, State, Step, MultiDiscreteSpace, DiscreteSpace
9
9
 
@@ -181,20 +181,7 @@ class SMAC(MARLEnv[MultiDiscreteSpace]):
181
181
 
182
182
  def step(self, action):
183
183
  reward, done, info = self._env.step(action)
184
- obs = Observation(
185
- self._env.get_obs(), # type: ignore
186
- self.available_actions(),
187
- )
188
- state = self.get_state()
189
- step = Step(
190
- obs,
191
- state,
192
- reward,
193
- done,
194
- False,
195
- info,
196
- )
197
- return step
184
+ return Step(self.get_observation(), self.get_state(), reward, done, False, info)
198
185
 
199
186
  def available_actions(self) -> npt.NDArray[np.bool]:
200
187
  return np.array(self._env.get_avail_actions()) == 1
@@ -1,10 +1,15 @@
1
- from marlenv.adapters import SMAC
2
1
  from .deepsea import DeepSea
3
2
  from .matrix_game import MatrixGame
4
3
  from .coordinated_grid import CoordinatedGrid
5
4
 
6
5
 
7
- __all__ = ["SMAC", "DeepSea", "lle", "overcooked", "MatrixGame", "connect_n", "CoordinatedGrid"]
6
+ __all__ = ["smac", "DeepSea", "lle", "overcooked", "MatrixGame", "connect_n", "CoordinatedGrid"]
7
+
8
+
9
+ def smac():
10
+ from marlenv.adapters import SMAC
11
+
12
+ return SMAC
8
13
 
9
14
 
10
15
  def lle():
@@ -92,7 +92,7 @@ class Observation:
92
92
  """
93
93
  Convert the observation to a tuple of tensors of shape (1, n_agents, <dim>).
94
94
  """
95
- import torch
95
+ import torch # pyright: ignore[reportMissingImports]
96
96
 
97
97
  data = torch.from_numpy(self.data).unsqueeze(0).to(device, non_blocking=True)
98
98
  extras = torch.from_numpy(self.extras).unsqueeze(0).to(device, non_blocking=True)
@@ -55,7 +55,7 @@ class State(Generic[StateType]):
55
55
 
56
56
  def as_tensors(self, device=None):
57
57
  """Convert the state to a tuple of tensors of shape (1, <dim>)."""
58
- import torch
58
+ import torch # pyright: ignore[reportMissingImports]
59
59
 
60
60
  data = torch.from_numpy(self.data).unsqueeze(0).to(device, non_blocking=True)
61
61
  extras = torch.from_numpy(self.extras).unsqueeze(0).to(device, non_blocking=True)
@@ -3,6 +3,8 @@ from types import SimpleNamespace
3
3
 
4
4
 
5
5
  def _raise_error(module_name: str, package_name: Optional[str] = None):
6
+ if package_name is None:
7
+ package_name = module_name
6
8
  raise ImportError(
7
9
  f"The optional dependency `{module_name}` is not installed.\nInstall the `{package_name}` package (e.g. pip install {package_name})."
8
10
  )
@@ -114,7 +114,7 @@ def _check_env_3m(env):
114
114
 
115
115
  @pytest.mark.skipif(skip_smac, reason="SMAC is not installed")
116
116
  def test_smac_from_class():
117
- from smac.env import StarCraft2Env # pyright: ignore[reportMissingImports]
117
+ from smacv2.env import StarCraft2Env # pyright: ignore[reportMissingImports]
118
118
  from marlenv.adapters import SMAC
119
119
 
120
120
  env = SMAC(StarCraft2Env("3m"))
@@ -130,6 +130,29 @@ def test_smac_render():
130
130
  env.render()
131
131
 
132
132
 
133
+ @pytest.mark.skipif(skip_smac, reason="SMAC is not installed")
134
+ def test_smac_obs():
135
+ from marlenv.adapters import SMAC
136
+
137
+ def check(obs: Observation, state: State):
138
+ assert isinstance(obs.data, np.ndarray)
139
+ assert isinstance(obs.extras, np.ndarray)
140
+ assert isinstance(obs.available_actions, np.ndarray)
141
+
142
+ assert isinstance(state.data, np.ndarray)
143
+ assert isinstance(state.extras, np.ndarray)
144
+
145
+ env = SMAC("3m")
146
+ obs, state = env.reset()
147
+ check(obs, state)
148
+
149
+ done = False
150
+ while not done:
151
+ step = env.random_step()
152
+ check(step.obs, step.state)
153
+ done = step.is_terminal
154
+
155
+
133
156
  def test_pymarl():
134
157
  LIMIT = 20
135
158
  N_AGENTS = 2
@@ -1,33 +0,0 @@
1
- from importlib.util import find_spec
2
- from .pymarl_adapter import PymarlAdapter
3
- from marlenv.utils import dummy_type, dummy_function
4
-
5
- HAS_GYM = find_spec("gymnasium") is not None
6
- if HAS_GYM:
7
- from .gym_adapter import Gym, make
8
- else:
9
- Gym = dummy_type("gymnasium")
10
- make = dummy_function("gymnasium")
11
-
12
- HAS_PETTINGZOO = find_spec("pettingzoo") is not None
13
- if HAS_PETTINGZOO:
14
- from .pettingzoo_adapter import PettingZoo
15
- else:
16
- PettingZoo = dummy_type("pettingzoo")
17
-
18
- HAS_SMAC = find_spec("smac") is not None
19
- if HAS_SMAC:
20
- from .smac_adapter import SMAC
21
- else:
22
- SMAC = dummy_type("smac", "https://github.com/oxwhirl/smac.git")
23
-
24
- __all__ = [
25
- "PymarlAdapter",
26
- "Gym",
27
- "make",
28
- "PettingZoo",
29
- "SMAC",
30
- "HAS_GYM",
31
- "HAS_PETTINGZOO",
32
- "HAS_SMAC",
33
- ]