浏览代码

fix proto test, revert gym and llapi tests

/r2v-yamato-linux
Chris Elion 4 年前
当前提交
25a495d8
共有 3 个文件被更改,包括 33 次插入27 次删除
  1. 3
      .yamato/protobuf-generation-test.yml
  2. 8
      ml-agents/tests/yamato/scripts/run_gym.py
  3. 49
      ml-agents/tests/yamato/scripts/run_llapi.py

3
.yamato/protobuf-generation-test.yml


test_linux_protobuf_generation:
- test_linux_protobuf_generation:
name: Protobuf Generation Tests
agent:
type: Unity::VM

8
ml-agents/tests/yamato/scripts/run_gym.py


:param env_name: Name of the Unity environment binary to launch
"""
u_env = UnityEnvironment(env_name, worker_id=1, no_graphics=True)
env = UnityToGymWrapper(u_env)
env = UnityToGymWrapper(u_env, use_visual=False)
try:
# Examine environment parameters

try:
env1 = UnityToGymWrapper(
UnityEnvironment(env_name, worker_id=1, no_graphics=True)
UnityEnvironment(env_name, worker_id=1, no_graphics=True), use_visual=False
UnityEnvironment(env_name, worker_id=1, no_graphics=True)
UnityEnvironment(env_name, worker_id=1, no_graphics=True), use_visual=False
UnityEnvironment(env_name, worker_id=2, no_graphics=True)
UnityEnvironment(env_name, worker_id=2, no_graphics=True), use_visual=False
)
env2.reset()
finally:

49
ml-agents/tests/yamato/scripts/run_llapi.py


import argparse
import numpy as np
from mlagents_envs.environment import UnityEnvironment
from mlagents_envs.side_channel.engine_configuration_channel import (

file_name=env_name,
side_channels=[engine_configuration_channel],
no_graphics=True,
additional_args=["-logFile", "-"],
args=["-logFile", "-"],
)
try:

# Set the default brain to work with
group_name = list(env.behavior_specs.keys())[0]
group_spec = env.behavior_specs[group_name]
group_name = env.get_behavior_names()[0]
group_spec = env.get_behavior_spec(group_name)
# Set the time scale of the engine
engine_configuration_channel.set_configuration_parameters(time_scale=3.0)

# Examine the number of observations per Agent
print("Number of observations : ", len(group_spec.observation_specs))
print("Number of observations : ", len(group_spec.observation_shapes))
vis_obs = any(
len(obs_spec.shape) == 3 for obs_spec in group_spec.observation_specs
)
vis_obs = any(len(shape) == 3 for shape in group_spec.observation_shapes)
print("Is there a visual observation ?", vis_obs)
# Examine the state space for the first observation for the first agent

episode_rewards = 0
tracked_agent = -1
while not done:
action_tuple = group_spec.action_spec.random_action(len(decision_steps))
if group_spec.is_action_continuous():
action = np.random.randn(
len(decision_steps), group_spec.action_size
)
elif group_spec.is_action_discrete():
branch_size = group_spec.discrete_action_branches
action = np.column_stack(
[
np.random.randint(
0, branch_size[i], size=(len(decision_steps))
)
for i in range(len(branch_size))
]
)
else:
# Should never happen
action = None
env.set_actions(group_name, action_tuple)
env.set_actions(group_name, action)
env.step()
decision_steps, terminal_steps = env.get_steps(group_name)
done = False

"""
try:
env1 = UnityEnvironment(
file_name=env_name,
base_port=5006,
no_graphics=True,
additional_args=["-logFile", "-"],
file_name=env_name, base_port=5006, no_graphics=True, args=["-logFile", "-"]
file_name=env_name,
base_port=5006,
no_graphics=True,
additional_args=["-logFile", "-"],
file_name=env_name, base_port=5006, no_graphics=True, args=["-logFile", "-"]
file_name=env_name,
base_port=5007,
no_graphics=True,
additional_args=["-logFile", "-"],
file_name=env_name, base_port=5007, no_graphics=True, args=["-logFile", "-"]
)
env2.reset()
finally:

正在加载...
取消
保存