diff --git a/.gitignore b/.gitignore
index 4fce1fd..d60327e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
#.idea/
.DS_Store
*.pyc
+__pycache__/
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8c3805b..a3ab11b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,6 +3,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -12,20 +29,25 @@
+
+
+
-
+
+
-
+
+
@@ -40,11 +62,12 @@
+
-
+
diff --git a/README.md b/README.md
index d414293..0086557 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,12 @@
```diff
-+ New Addition: Multi-Agent Mujoco now supports Scenarios with Coupled Robots (using Tendons).
-+ Check out instructions below.
+- PLEASE NOTE: To use the legacy version of Multiagent Mujoco please check out tag v1.0
+```
+
+```diff
++ New Version: Multi-Agent MuJoCo is now at Version 1.1.0. Changes and added features are as follows:
++ Fixed a bug in action mapping in the step function (thanks go to Paul Barde). This fixes several unphysical mappings found in previous versions.
++ Multi-Agent MuJoCo can now be installed as a PIP package.
++ I am in the process of establishing comprehensive benchmarks of all Multi-Agent MuJoCO scenarios across a variety of RL algorithms.
```
```diff
@@ -17,20 +23,20 @@ Described in the paper [Deep Multi-Agent Reinforcement Learning for Decentralize
# Installation
-**Note: You require OpenAI Gym Version 0.10.8 and Mujoco 2.0**
+**Note: You require OpenAI Gym Version 0.10.8 and Mujoco 2.1**
Simply clone this repository and put ./src on your PYTHONPATH.
To render, please also set the following environment variables:
```
-LD_LIBRARY_PATH=${HOME}/.mujoco/mujoco200/bin;
+LD_LIBRARY_PATH=${HOME}/.mujoco/mujoco210/bin;
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
```
# Example
```python
-from src.multiagent_mujoco.mujoco_multi import MujocoMulti
+from multiagent_mujoco.mujoco_multi import MujocoMulti
import numpy as np
import time
diff --git a/src/multiagent_mujoco/__init__.py b/multiagent_mujoco/__init__.py
similarity index 100%
rename from src/multiagent_mujoco/__init__.py
rename to multiagent_mujoco/__init__.py
diff --git a/src/multiagent_mujoco/assets/.gitignore b/multiagent_mujoco/assets/.gitignore
similarity index 100%
rename from src/multiagent_mujoco/assets/.gitignore
rename to multiagent_mujoco/assets/.gitignore
diff --git a/src/__init__.py b/multiagent_mujoco/assets/__init__.py
similarity index 100%
rename from src/__init__.py
rename to multiagent_mujoco/assets/__init__.py
diff --git a/src/multiagent_mujoco/assets/coupled_half_cheetah.xml b/multiagent_mujoco/assets/coupled_half_cheetah.xml
similarity index 100%
rename from src/multiagent_mujoco/assets/coupled_half_cheetah.xml
rename to multiagent_mujoco/assets/coupled_half_cheetah.xml
diff --git a/src/multiagent_mujoco/assets/manyagent_ant.xml b/multiagent_mujoco/assets/manyagent_ant.xml
similarity index 100%
rename from src/multiagent_mujoco/assets/manyagent_ant.xml
rename to multiagent_mujoco/assets/manyagent_ant.xml
diff --git a/src/multiagent_mujoco/assets/manyagent_ant.xml.template b/multiagent_mujoco/assets/manyagent_ant.xml.template
similarity index 100%
rename from src/multiagent_mujoco/assets/manyagent_ant.xml.template
rename to multiagent_mujoco/assets/manyagent_ant.xml.template
diff --git a/src/multiagent_mujoco/assets/manyagent_ant__stage1.xml b/multiagent_mujoco/assets/manyagent_ant__stage1.xml
similarity index 100%
rename from src/multiagent_mujoco/assets/manyagent_ant__stage1.xml
rename to multiagent_mujoco/assets/manyagent_ant__stage1.xml
diff --git a/src/multiagent_mujoco/assets/manyagent_swimmer.xml.template b/multiagent_mujoco/assets/manyagent_swimmer.xml.template
similarity index 100%
rename from src/multiagent_mujoco/assets/manyagent_swimmer.xml.template
rename to multiagent_mujoco/assets/manyagent_swimmer.xml.template
diff --git a/src/multiagent_mujoco/assets/manyagent_swimmer__bckp2.xml b/multiagent_mujoco/assets/manyagent_swimmer__bckp2.xml
similarity index 100%
rename from src/multiagent_mujoco/assets/manyagent_swimmer__bckp2.xml
rename to multiagent_mujoco/assets/manyagent_swimmer__bckp2.xml
diff --git a/src/multiagent_mujoco/assets/manyagent_swimmer_bckp.xml b/multiagent_mujoco/assets/manyagent_swimmer_bckp.xml
similarity index 100%
rename from src/multiagent_mujoco/assets/manyagent_swimmer_bckp.xml
rename to multiagent_mujoco/assets/manyagent_swimmer_bckp.xml
diff --git a/src/multiagent_mujoco/coupled_half_cheetah.py b/multiagent_mujoco/coupled_half_cheetah.py
similarity index 100%
rename from src/multiagent_mujoco/coupled_half_cheetah.py
rename to multiagent_mujoco/coupled_half_cheetah.py
diff --git a/src/multiagent_mujoco/manyagent_ant.py b/multiagent_mujoco/manyagent_ant.py
similarity index 100%
rename from src/multiagent_mujoco/manyagent_ant.py
rename to multiagent_mujoco/manyagent_ant.py
diff --git a/src/multiagent_mujoco/manyagent_swimmer.py b/multiagent_mujoco/manyagent_swimmer.py
similarity index 100%
rename from src/multiagent_mujoco/manyagent_swimmer.py
rename to multiagent_mujoco/manyagent_swimmer.py
diff --git a/src/multiagent_mujoco/mujoco_multi.py b/multiagent_mujoco/mujoco_multi.py
similarity index 90%
rename from src/multiagent_mujoco/mujoco_multi.py
rename to multiagent_mujoco/mujoco_multi.py
index b556c02..3dc7d57 100755
--- a/src/multiagent_mujoco/mujoco_multi.py
+++ b/multiagent_mujoco/mujoco_multi.py
@@ -30,10 +30,10 @@ class MujocoMulti(MultiAgentEnv):
def __init__(self, batch_size=None, **kwargs):
super().__init__(batch_size, **kwargs)
- self.scenario = kwargs["env_args"]["scenario"] # e.g. Ant-v2
- self.agent_conf = kwargs["env_args"]["agent_conf"] # e.g. '2x3'
+ self.scenario = kwargs["env_args"]["scenario"] # e.g. Ant-v2
+ self.agent_conf = kwargs["env_args"]["agent_conf"] # e.g. '2x3'
- self.agent_partitions, self.mujoco_edges, self.mujoco_globals = get_parts_and_edges(self.scenario,
+ self.agent_partitions, self.mujoco_edges, self.mujoco_globals = get_parts_and_edges(self.scenario,
self.agent_conf)
self.n_agents = len(self.agent_partitions)
@@ -107,9 +107,18 @@ def __init__(self, batch_size=None, **kwargs):
def step(self, actions):
- # need to remove dummy actions that arise due to unequal action vector sizes across agents
- flat_actions = np.concatenate([actions[i][:self.action_space[i].low.shape[0]] for i in range(self.n_agents)])
- obs_n, reward_n, done_n, info_n = self.wrapped_env.step(flat_actions)
+ # we need to map actions back into MuJoCo action space
+ env_actions = np.zeros((sum([self.action_space[i].low.shape[0] for i in range(self.n_agents)]),)) + np.nan
+ for a, partition in enumerate(self.agent_partitions):
+ for i, body_part in enumerate(partition):
+ if env_actions[body_part.act_ids] == env_actions[body_part.act_ids]:
+ raise Exception("FATAL: At least one env action is doubly defined!")
+ env_actions[body_part.act_ids] = actions[a][i]
+
+ if np.isnan(env_actions).any():
+ raise Exception("FATAL: At least one env action is undefined!")
+
+ obs_n, reward_n, done_n, info_n = self.wrapped_env.step(env_actions)
self.steps += 1
info = {}
diff --git a/src/multiagent_mujoco/multiagentenv.py b/multiagent_mujoco/multiagentenv.py
similarity index 100%
rename from src/multiagent_mujoco/multiagentenv.py
rename to multiagent_mujoco/multiagentenv.py
diff --git a/src/multiagent_mujoco/obsk.py b/multiagent_mujoco/obsk.py
similarity index 100%
rename from src/multiagent_mujoco/obsk.py
rename to multiagent_mujoco/obsk.py
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..0226c57
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,50 @@
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+from setuptools import setup
+
+description = """MAMuJoCo - Multi-Agent MuJoCo
+
+Benchmark for Continuous Multi-Agent Robotic Control, based on OpenAI's Mujoco Gym environments.
+Described in the paper Deep Multi-Agent Reinforcement Learning for Decentralized Continuous Cooperative Control
+by Christian Schroeder de Witt, Bei Peng, Pierre-Alexandre Kamienny, Philip Torr, Wendelin Böhmer and Shimon Whiteson,
+Torr Vision Group and Whiteson Research Lab, University of Oxford, 2020
+
+Contact CSDW at cs@robots.ox.ac.uk
+"""
+
+extras_deps = {
+ "dev": [
+ "pre-commit>=2.0.1",
+ "black>=19.10b0",
+ "flake8>=3.7",
+ "flake8-bugbear>=20.1",
+ ],
+}
+
+setup(
+ name="MAMujoco",
+ version="1.1.0",
+ description="MAMuJoCo - Multi-Agent MuJoCo.",
+ long_description=description,
+ author="Christian Schroeder de Witt",
+ author_email="cs@robots.ox.ac.uk",
+ license="Apache 2.0 License",
+ keywords="Robotics, MuJoCo, Multi-Agent Reinforcement Learning",
+ url="https://github.com/schroederdewitt/multiagent_mujoco",
+ packages=[
+ "multiagent_mujoco",
+ "multiagent_mujoco.assets",
+ ],
+ extras_require=extras_deps,
+ install_requires=[
+ "numpy>=1.22.3",
+ "gym==0.10.8",
+ "mujoco-py>=2.1.2.14",
+ "scipy>=1.8.0",
+ "Jinja2>=3.0.3",
+ "glfw>=2.5.1",
+ "Cython>=0.29.28"
+ ],
+)
\ No newline at end of file
diff --git a/src/multiagent_mujoco/__pycache__/__init__.cpython-36.pyc b/src/multiagent_mujoco/__pycache__/__init__.cpython-36.pyc
deleted file mode 100644
index f09f7b8..0000000
Binary files a/src/multiagent_mujoco/__pycache__/__init__.cpython-36.pyc and /dev/null differ
diff --git a/src/multiagent_mujoco/__pycache__/coupled_half_cheetah.cpython-36.pyc b/src/multiagent_mujoco/__pycache__/coupled_half_cheetah.cpython-36.pyc
deleted file mode 100644
index 7f43ad9..0000000
Binary files a/src/multiagent_mujoco/__pycache__/coupled_half_cheetah.cpython-36.pyc and /dev/null differ
diff --git a/src/multiagent_mujoco/__pycache__/mujoco_multi.cpython-36.pyc b/src/multiagent_mujoco/__pycache__/mujoco_multi.cpython-36.pyc
deleted file mode 100644
index 98d4022..0000000
Binary files a/src/multiagent_mujoco/__pycache__/mujoco_multi.cpython-36.pyc and /dev/null differ
diff --git a/src/multiagent_mujoco/__pycache__/multiagentenv.cpython-36.pyc b/src/multiagent_mujoco/__pycache__/multiagentenv.cpython-36.pyc
deleted file mode 100644
index cc2a027..0000000
Binary files a/src/multiagent_mujoco/__pycache__/multiagentenv.cpython-36.pyc and /dev/null differ
diff --git a/src/multiagent_mujoco/__pycache__/obsk.cpython-36.pyc b/src/multiagent_mujoco/__pycache__/obsk.cpython-36.pyc
deleted file mode 100644
index ff1387d..0000000
Binary files a/src/multiagent_mujoco/__pycache__/obsk.cpython-36.pyc and /dev/null differ
diff --git a/src/multiagent_mujoco/assets/__init__.py b/src/multiagent_mujoco/assets/__init__.py
deleted file mode 100644
index e69de29..0000000