def multi_agent_make_env(scenario_name, benchmark=False): from multiagent import scenarios from multiagent.environment import MultiAgentEnv scenario = scenarios.load(scenario_name + '.py').Scenario() world = scenarios.make_world() if benchmark: env = MultiAgentEnv(world, scenario.reset_world, scenario.reward, scenario.observation, scenario.benchmark_data) else: env = MultiAgentEnv(world, scenario.reset_world, scenario.reward, scenario.observation) return env
'''define the model name''' model_name = 'independent_ddpg' '''define the scenario name''' scenario_name = 'simple_spread' '''define the special property''' # independentArgs = namedtuple( 'independentArgs', [] ) aux_args = AuxArgs[model_name]() alias = '_new_6' '''load scenario from script''' scenario = scenario.load(scenario_name+".py").Scenario() '''create world''' world = scenario.make_world() '''create multiagent environment''' env = MultiAgentEnv(world, scenario.reset_world, scenario.reward, scenario.observation, info_callback=None, shared_viewer=True) env = GymWrapper(env) MergeArgs = namedtuple('MergeArgs', Args._fields+AuxArgs[model_name]._fields) # under offline trainer if set batch_size=replay_buffer_size=update_freq -> epoch update args = Args(model_name=model_name, agent_num=env.get_num_of_agents(), hid_size=32, obs_size=np.max(env.get_shape_of_obs()), continuous=False, action_dim=np.max(env.get_output_shape_of_act()), init_std=0.1,