我无法为多智能体健身房环境选择随机动作。
def make_env(scenario_name, 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
env = make_env('simple_tag')
env.reset()
for i in range(100):
env.render()
actions = [action_space.sample() for action_space in env.action_space]
env.step(actions)
上面的代码抛出这个错误:
Traceback (most recent call last):
File "hello.py", line 22, in <module>
env.step(actions)
File "c:\multiagent-particle-envs\multiagent\environment.py", line 88, in step
self._set_action(action_n[i], agent, self.action_space[i])
File "c:\multiagent-particle-envs\multiagent\environment.py", line 174, in _set_action
agent.action.u[0] += action[0][1] - action[0][2]
TypeError: 'int' object is not subscriptable
我找不到解决办法,因为关于这些多代理环境的讨论还不够多。
MM们
相关分类