本文整理汇总了Python中multiagent.environment.MultiAgentEnv方法的典型用法代码示例。如果您正苦于以下问题:Python environment.MultiAgentEnv方法的具体用法?Python environment.MultiAgentEnv怎么用?Python environment.MultiAgentEnv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiagent.environment
的用法示例。
在下文中一共展示了environment.MultiAgentEnv方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, arglist, benchmark=False):
from multiagent.environment import MultiAgentEnv
import multiagent.scenarios as scenarios
# load scenario from script
scenario = scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
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
示例2: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, benchmark=False):
'''
Creates a MultiAgentEnv object as env. This can be used similar to a gym
environment by calling env.reset() and env.step().
Use env.render() to view the environment on the screen.
Input:
scenario_name : name of the scenario from ./scenarios/ to be Returns
(without the .py extension)
benchmark : whether you want to produce benchmarking data
(usually only done during evaluation)
Some useful env properties (see environment.py):
.observation_space : Returns the observation space for each agent
.action_space : Returns the action space for each agent
.n : Returns the number of Agents
'''
from multiagent.environment import MultiAgentEnv
import multiagent.scenarios as scenarios
# load scenario from script
scenario = scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
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
示例3: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, benchmark=False):
'''
Creates a MultiAgentEnv object as env. This can be used similar to a gym
environment by calling env.reset() and env.step().
Use env.render() to view the environment on the screen.
Input:
scenario_name : name of the scenario from ./scenarios/ to be Returns
(without the .py extension)
benchmark : whether you want to produce benchmarking data
(usually only done during evaluation)
Some useful env properties (see environment.py):
.observation_space : Returns the observation space for each agent
.action_space : Returns the action space for each agent
.n : Returns the number of Agents
'''
from multiagent.environment import MultiAgentEnv
import multiagent.scenarios as scenarios
# load scenario from script
scenario = scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
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,
done_callback=scenario.done)
return env
示例4: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, benchmark=False):
# load scenario from script
scenario = scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
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
示例5: make_multiagent_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_multiagent_env(env_id, num_agents, dist_threshold, arena_size, identity_size):
scenario = scenarios.load(env_id+".py").Scenario(num_agents=num_agents, dist_threshold=dist_threshold,
arena_size=arena_size, identity_size=identity_size)
world = scenario.make_world()
env = MultiAgentEnv(world=world,
reset_callback=scenario.reset_world,
reward_callback=scenario.reward,
observation_callback=scenario.observation,
info_callback=scenario.info if hasattr(scenario, 'info') else None,
discrete_action=True,
done_callback=scenario.done,
cam_range=arena_size
)
return env
示例6: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, benchmark=False):
'''
Creates a MultiAgentEnv object as env. This can be used similar to a gym
environment by calling env.reset() and env.step().
Use env.render() to view the environment on the screen.
Input:
scenario_name : name of the scenario from ./scenarios/ to be Returns
(without the .py extension)
benchmark : whether you want to produce benchmarking data
(usually only done during evaluation)
Some useful env properties (see environment.py):
.observation_space : Returns the observation space for each agent
.action_space : Returns the action space for each agent
.n : Returns the number of Agents
'''
from multiagent.environment import MultiAgentEnv
import multiagent.scenarios as scenarios
# load scenario from script
scenario = scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
if benchmark:
env = MultiAgentEnv(world, scenario.reset_world, scenario.reward, scenario.observation, scenario.benchmark_data, done_callback = scenario.done)
else:
env = MultiAgentEnv(world, scenario.reset_world, scenario.reward, scenario.observation, done_callback = scenario.done)
return env
示例7: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, benchmark=False, discrete_action=False):
'''
Creates a MultiAgentEnv object as env. This can be used similar to a gym
environment by calling env.reset() and env.step().
Use env.render() to view the environment on the screen.
Input:
scenario_name : name of the scenario from ./scenarios/ to be Returns
(without the .py extension)
benchmark : whether you want to produce benchmarking data
(usually only done during evaluation)
Some useful env properties (see environment.py):
.observation_space : Returns the observation space for each agent
.action_space : Returns the action space for each agent
.n : Returns the number of Agents
'''
from multiagent.environment import MultiAgentEnv
import multiagent.scenarios as scenarios
# load scenario from script
scenario = scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
if benchmark:
env = MultiAgentEnv(world, scenario.reset_world, scenario.reward,
scenario.observation, scenario.benchmark_data,
discrete_action=discrete_action)
else:
env = MultiAgentEnv(world, scenario.reset_world, scenario.reward,
scenario.observation,
discrete_action=discrete_action)
return env
示例8: make_env
# 需要导入模块: from multiagent import environment [as 别名]
# 或者: from multiagent.environment import MultiAgentEnv [as 别名]
def make_env(scenario_name, benchmark=False, discrete_action=False):
'''
Creates a MultiAgentEnv object as env. This can be used similar to a gym
environment by calling env.reset() and env.step().
Use env.render() to view the environment on the screen.
Input:
scenario_name : name of the scenario from ./scenarios/ to be Returns
(without the .py extension)
benchmark : whether you want to produce benchmarking data
(usually only done during evaluation)
Some useful env properties (see environment.py):
.observation_space : Returns the observation space for each agent
.action_space : Returns the action space for each agent
.n : Returns the number of Agents
'''
from multiagent.environment import MultiAgentEnv
import multiagent.scenarios as old_scenarios
import envs.mpe_scenarios as new_scenarios
# load scenario from script
try:
scenario = old_scenarios.load(scenario_name + ".py").Scenario()
except:
scenario = new_scenarios.load(scenario_name + ".py").Scenario()
# create world
world = scenario.make_world()
# create multiagent environment
if hasattr(scenario, 'post_step'):
post_step = scenario.post_step
else:
post_step = None
if benchmark:
env = MultiAgentEnv(world, reset_callback=scenario.reset_world,
reward_callback=scenario.reward,
observation_callback=scenario.observation,
post_step_callback=post_step,
info_callback=scenario.benchmark_data,
discrete_action=discrete_action)
else:
env = MultiAgentEnv(world, reset_callback=scenario.reset_world,
reward_callback=scenario.reward,
observation_callback=scenario.observation,
post_step_callback=post_step,
discrete_action=discrete_action)
return env