2020-09-04 01:37:46 -04:00
|
|
|
from ray import tune
|
|
|
|
from ray.tune.registry import register_env
|
2021-01-19 10:09:39 +01:00
|
|
|
from ray.rllib.env.wrappers.pettingzoo_env import PettingZooEnv
|
2022-01-04 18:30:26 +01:00
|
|
|
from pettingzoo.sisl import waterworld_v3
|
2020-09-04 01:37:46 -04:00
|
|
|
|
|
|
|
# Based on code from github.com/parametersharingmadrl/parametersharingmadrl
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# RDQN - Rainbow DQN
|
|
|
|
# ADQN - Apex DQN
|
|
|
|
def env_creator(args):
|
2022-01-04 18:30:26 +01:00
|
|
|
return PettingZooEnv(waterworld_v3.env())
|
2020-09-04 01:37:46 -04:00
|
|
|
|
|
|
|
env = env_creator({})
|
|
|
|
register_env("waterworld", env_creator)
|
|
|
|
|
|
|
|
tune.run(
|
|
|
|
"APEX_DDPG",
|
|
|
|
stop={"episodes_total": 60000},
|
|
|
|
checkpoint_freq=10,
|
|
|
|
config={
|
|
|
|
# Enviroment specific
|
|
|
|
"env": "waterworld",
|
|
|
|
# General
|
|
|
|
"num_gpus": 1,
|
|
|
|
"num_workers": 2,
|
|
|
|
# Method specific
|
|
|
|
"multiagent": {
|
2021-07-15 05:51:24 -04:00
|
|
|
"policies": set(env.agents),
|
2021-06-21 13:46:01 +02:00
|
|
|
"policy_mapping_fn": (
|
|
|
|
lambda agent_id, episode, **kwargs: agent_id),
|
2020-09-04 01:37:46 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|