浏览代码

Merge branch 'develop-hybrid-actions' of https://github.com/Unity-Technologies/ml-agents into develop-hybrid-actions

/develop/actionmodel-csharp
Andrew Cohen 4 年前
当前提交
53176dc0
共有 1 个文件被更改,包括 19 次插入2 次删除
  1. 21
      ml-agents/mlagents/trainers/tests/simple_test_envs.py

21
ml-agents/mlagents/trainers/tests/simple_test_envs.py


vec_obs_size=OBS_SIZE,
action_size=1,
):
super().__init__(brain_names, False)
self.continuous_env = SimpleEnvironment(
brain_names,
False,

self.discrete_action = {}
def step(self) -> None:
self.continuous_env.step()
self.discrete_env.step()
assert all(action is not None for action in self.continuous_env.action.values())
assert all(action is not None for action in self.discrete_env.action.values())
for name in self.names:
cont_done = self.continuous_env._take_action(name)
cont_reward = self.continuous_env._compute_reward(name, cont_done)
self.rewards[name] += cont_reward / 2
disc_done = self.discrete_env._take_action(name)
disc_reward = self.discrete_env._compute_reward(name, disc_done)
self.rewards[name] += disc_reward / 2
all_done = cont_done and disc_done
self.step_result[name] = self._make_batched_step(
name, all_done, cont_reward + disc_reward
)
self.reset()
self.continuous_env.goal = self.goal
self.discrete_env.goal = self.goal
def set_actions(self, behavior_name: BehaviorName, action: HybridAction) -> None:
self.continuous_env.set_actions(action.continuous)

正在加载...
取消
保存