Many algorithms work in the parallel setting — especially all the algorithms with the CTDE approach (the majority).
Please insert the example of the parallel execution. It was hard to find out how to do it properly.
My suggestion:
# uncomment the required environment
# from magent2.environments.adversarial_pursuit import parallel_env
# from magent2.environments.battle import parallel_env
# from magent2.environments.battlefield import parallel_env
# from magent2.environments.combined_arms import parallel_env
# from magent2.environments.gather import parallel_env, raw_env
from magent2.environments.tiger_deer import parallel_env
import time
# to render or not to render
render_mode='human'
# render_mode=None
env = parallel_env(render_mode=render_mode, max_cycles=200)
observations, infos = env.reset()
i_step = 0
while env.agents:
# this is where you would insert your policy
actions = {agent: env.action_space(agent).sample() for agent in env.agents}
observations, rewards, terminations, truncations, infos = env.step(actions)
i_step += 1
print(f'{i_step}')
# time.sleep(0.1) # for slower rendering
env.close()
Many algorithms work in the parallel setting — especially all the algorithms with the CTDE approach (the majority).
Please insert the example of the parallel execution. It was hard to find out how to do it properly.
My suggestion: