[Question] Specify policies for the simple_tag 2 sides
Yuxin916 opened this issue · 2 comments
Question
Hi,
I am trying to train a multiagent competitive scenario with simple_tag. 3 predators 1 prey. I am wondering how to specifify policies for predator team and prey team accordingly. for example, MADDPG for predators and DDPG for prey (similar to the original MPE paper, where should i specify the good-policy and adv-policy in OpenAI MPE code)
Thank you
Each agent's name identifies the team it is on, so for example if I run the env with default parameters you can see that there are three adversary agents and one regular agent:
>>> from pettingzoo.mpe import simple_tag_v3
>>> env = simple_tag_v3.env(render_mode="human")
>>> env.reset()
>> env.agents
['adversary_0', 'adversary_1', 'adversary_2', 'agent_0']
You would then do a conditional statement based on the string value of the current agent, in order to tell if they are an adversary or not. Following the starter code shown on our documentation website https://pettingzoo.farama.org/main/environments/mpe/simple_tag/#aec), and we defined the different models separately, we would have:
from pettingzoo.mpe import simple_tag_v3
env = simple_tag_v3.env(render_mode="human")
env.reset(seed=42)
for agent in env.agent_iter():
observation, reward, termination, truncation, info = env.last()
# NEW: check which agent type it is
if "adversary" in agent:
action = MADDPG(observation, agent)
else:
action = DDPG(observation)
if termination or truncation:
action = None
else:
# this is where you would insert your policy
action = env.action_space(agent).sample()
env.step(action)
env.close()
Thank you for your reply!