Skip to content

Commit

Permalink
feat: Switched from custom smac wrapper to pz smac wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
KaleabTessera committed Nov 22, 2021
1 parent 670f021 commit 12022a2
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 465 deletions.
5 changes: 2 additions & 3 deletions Dockerfile.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ RUN AutoROM -v
##########################################################
# SMAC image
FROM tf-core AS sc2
## Install SC2 game
RUN apt-get install -y wget
## Install smac environment
RUN apt-get -y install git
RUN pip install .[sc2]
RUN ./bash_scripts/install_sc2.sh
# We use the pz wrapper for smac
RUN pip install .[pz]
ENV SC2PATH /home/app/mava/3rdparty/StarCraftII
##########################################################

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif
IMAGE = $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
# make file commands
build:
DOCKER_BUILDKIT=1 docker build --tag $(IMAGE) -f Dockerfile.tf --target $(DOCKER_IMAGE_TAG) --build-arg record=$(record) --progress=plain .
DOCKER_BUILDKIT=1 docker build --tag $(IMAGE) -f Dockerfile.tf --target $(DOCKER_IMAGE_TAG) --build-arg record=$(record) .

run:
$(DOCKER_RUN) python $(example) --base_dir /home/app/mava/logs/
Expand All @@ -62,6 +62,9 @@ run-tests:
run-integration-tests:
$(DOCKER_RUN) /bin/bash bash_scripts/tests.sh true

run-checks:
$(DOCKER_RUN) /bin/bash bash_scripts/check_format.sh

push:
docker login
-docker push $(IMAGE)
Expand Down
4 changes: 2 additions & 2 deletions bash_scripts/install_sc2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ echo 'SC2PATH is set to '$SC2PATH

if [ ! -d $SC2PATH ]; then
echo 'StarCraftII is not installed. Installing now ...';
wget http://blzdistsc2-a.akamaihd.net/Linux/SC2.4.10.zip --progress=dot -e dotbytes=100M
unzip -qq iagreetotheeula SC2.4.10.zip
wget http://blzdistsc2-a.akamaihd.net/Linux/SC2.4.10.zip --progress=dot -e dotbytes=50M
unzip -P iagreetotheeula SC2.4.10.zip
rm -rf SC2.4.10.zip
else
echo 'StarCraftII is already installed.'
Expand Down
7 changes: 3 additions & 4 deletions examples/smac/feedforward/decentralised/run_madqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example running MADQN on multi-agent Starcraft 2 (SMAC) environment."""

import functools
from datetime import datetime
Expand All @@ -28,7 +27,7 @@
)
from mava.systems.tf import madqn
from mava.utils import lp_utils
from mava.utils.environments import smac_utils
from mava.utils.environments import pettingzoo_utils
from mava.utils.loggers import logger_utils

FLAGS = flags.FLAGS
Expand All @@ -47,10 +46,10 @@


def main(_: Any) -> None:

"""Example running MADQN on multi-agent Starcraft 2 (SMAC) environment."""
# environment
environment_factory = functools.partial(
smac_utils.make_environment, map_name=FLAGS.map_name
pettingzoo_utils.make_environment, env_class="smac", env_name=FLAGS.map_name
)

# Networks.
Expand Down
7 changes: 4 additions & 3 deletions examples/smac/feedforward/decentralised/run_qmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example running QMIX on SMAC environments."""

import functools
from datetime import datetime
from typing import Any
Expand All @@ -25,7 +25,7 @@
from mava.components.tf.modules.exploration import LinearExplorationTimestepScheduler
from mava.systems.tf import qmix
from mava.utils import lp_utils
from mava.utils.environments import smac_utils
from mava.utils.environments import pettingzoo_utils
from mava.utils.loggers import logger_utils

FLAGS = flags.FLAGS
Expand All @@ -44,9 +44,10 @@


def main(_: Any) -> None:
"""Example running QMIX on SMAC environments."""
# Environment.
environment_factory = functools.partial(
smac_utils.make_environment, map_name=FLAGS.map_name
pettingzoo_utils.make_environment, env_class="smac", env_name=FLAGS.map_name
)

# Networks.
Expand Down
7 changes: 3 additions & 4 deletions examples/smac/feedforward/decentralised/run_vdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example running VDN on multi-agent Starcraft 2 (SMAC) environment."""

import functools
from datetime import datetime
Expand All @@ -26,7 +25,7 @@
from mava.components.tf.modules.exploration import LinearExplorationTimestepScheduler
from mava.systems.tf import vdn
from mava.utils import lp_utils
from mava.utils.environments import smac_utils
from mava.utils.environments import pettingzoo_utils
from mava.utils.loggers import logger_utils

FLAGS = flags.FLAGS
Expand All @@ -45,10 +44,10 @@


def main(_: Any) -> None:

"""Example running VDN on multi-agent Starcraft 2 (SMAC) environment."""
# environment
environment_factory = functools.partial(
smac_utils.make_environment, map_name=FLAGS.map_name
pettingzoo_utils.make_environment, env_class="smac", env_name=FLAGS.map_name
)

# Networks.
Expand Down
10 changes: 3 additions & 7 deletions examples/smac/feedforward/decentralised/run_vdn_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Example running VDN on multi-agent Starcraft 2 (SMAC) environment,
while recording agents.
"""

import functools
from datetime import datetime
Expand All @@ -29,7 +25,7 @@
from mava.components.tf.modules.exploration import LinearExplorationTimestepScheduler
from mava.systems.tf import vdn
from mava.utils import lp_utils
from mava.utils.environments import smac_utils
from mava.utils.environments import pettingzoo_utils
from mava.utils.loggers import logger_utils
from mava.wrappers.environment_loop_wrappers import MonitorParallelEnvironmentLoop

Expand All @@ -49,10 +45,10 @@


def main(_: Any) -> None:

"""Example running VDN on SMAC,while recording agents."""
# environment
environment_factory = functools.partial(
smac_utils.make_environment, map_name=FLAGS.map_name
pettingzoo_utils.make_environment, env_class="smac", env_name=FLAGS.map_name
)

# Networks.
Expand Down
7 changes: 3 additions & 4 deletions examples/smac/recurrent/decentralised/run_madqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example running recurrent MADQN on multi-agent Starcraft 2 (SMAC) environment."""

import functools
from datetime import datetime
Expand All @@ -33,7 +32,7 @@
from mava.components.tf.networks.epsilon_greedy import EpsilonGreedy
from mava.systems.tf import madqn
from mava.utils import lp_utils
from mava.utils.environments import smac_utils
from mava.utils.environments import pettingzoo_utils
from mava.utils.loggers import logger_utils

FLAGS = flags.FLAGS
Expand Down Expand Up @@ -96,10 +95,10 @@ def custom_recurrent_network(


def main(_: Any) -> None:

"""Example running recurrent MADQN on multi-agent Starcraft 2 (SMAC) environment."""
# environment
environment_factory = functools.partial(
smac_utils.make_environment, map_name=FLAGS.map_name
pettingzoo_utils.make_environment, env_class="smac", env_name=FLAGS.map_name
)

# Networks.
Expand Down
66 changes: 0 additions & 66 deletions mava/utils/environments/smac_utils.py

This file was deleted.

6 changes: 0 additions & 6 deletions mava/wrappers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
PettingZooParallelEnvWrapper,
)
from mava.wrappers.robocup import RoboCupWrapper
from mava.wrappers.smac import SMACEnvWrapper

try:
from smac.env import StarCraft2Env
except ModuleNotFoundError:
pass
from mava.wrappers.system_trainer_statistics import (
DetailedTrainerStatistics,
NetworkStatisticsActorCritic,
Expand Down
Loading

0 comments on commit 12022a2

Please sign in to comment.