Chris Elion
4 年前
当前提交
7f8258a8
共有 17 个文件被更改,包括 406 次插入 和 213 次删除
-
12.pre-commit-config.yaml
-
4.yamato/com.unity.ml-agents-pack.yml
-
2.yamato/com.unity.ml-agents-test.yml
-
20.yamato/gym-interface-test.yml
-
43.yamato/protobuf-generation-test.yml
-
27.yamato/python-ll-api-test.yml
-
40.yamato/standalone-build-test.yml
-
51.yamato/training-int-tests.yml
-
8Project/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs
-
3ml-agents-envs/mlagents_envs/environment.py
-
10ml-agents/tests/yamato/check_coverage_percent.py
-
8ml-agents/tests/yamato/scripts/run_gym.py
-
49ml-agents/tests/yamato/scripts/run_llapi.py
-
17ml-agents/tests/yamato/standalone_build_tests.py
-
130ml-agents/tests/yamato/training_int_tests.py
-
142ml-agents/tests/yamato/yamato_utils.py
-
53ml-agents/tests/yamato/scripts/run_compressed_sensor.py
|
|||
import argparse |
|||
import numpy as np |
|||
|
|||
from mlagents_envs.environment import UnityEnvironment |
|||
|
|||
EPSILON = 0.001 |
|||
|
|||
|
|||
def test_run_environment(env_name): |
|||
""" |
|||
Run the low-level API test of compressed sensors using the specified environment |
|||
:param env_name: Name of the Unity environment binary to launch |
|||
""" |
|||
env = UnityEnvironment( |
|||
file_name=env_name, no_graphics=True, additional_args=["-logFile", "-"] |
|||
) |
|||
|
|||
try: |
|||
# Reset the environment |
|||
env.reset() |
|||
|
|||
env.step() |
|||
|
|||
# Set the default brain to work with |
|||
group_name = list(env.behavior_specs.keys())[0] |
|||
|
|||
# Get the state of the agents |
|||
decision_steps, _ = env.get_steps(group_name) |
|||
|
|||
# One observation comes from compressed sensor while the other comes |
|||
# from an uncompressed sensor |
|||
obs_1 = decision_steps.obs[0][0, :, :, :] |
|||
obs_2 = decision_steps.obs[0][1, :, :, :] |
|||
|
|||
diff = np.abs(obs_1 - obs_2) |
|||
|
|||
# make sure both are identical |
|||
assert np.max(diff) < EPSILON |
|||
|
|||
# make sure an actual observation was collected |
|||
assert np.max(obs_1) > EPSILON |
|||
|
|||
print("Observations were identical") |
|||
|
|||
finally: |
|||
env.close() |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
parser = argparse.ArgumentParser() |
|||
parser.add_argument("--env", default="artifacts/testPlayer") |
|||
args = parser.parse_args() |
|||
test_run_environment(args.env) |
撰写
预览
正在加载...
取消
保存
Reference in new issue