浏览代码

removing some dependencies

/develop/gym-wrapper
vincentpierre 5 年前
当前提交
69cafac9
共有 3 个文件被更改,包括 17 次插入13 次删除
  1. 7
      ml-agents-envs/mlagents_envs/gym_wrapper.py
  2. 18
      ml-agents-envs/mlagents_envs/tests/test_gym_wrapper.py
  3. 5
      ml-agents-envs/setup.py

7
ml-agents-envs/mlagents_envs/gym_wrapper.py


import numpy as np
import gym
try:
import gym
except ImportError:
raise ImportError("gym is not installed, gym required to use the GymToUnityWrapper")
class GymWrapper(BaseEnv):
class GymToUnityWrapper(BaseEnv):
_DEFAULT_BEHAVIOR_NAME = "gym_behavior_name"
_AGENT_ID = 1

18
ml-agents-envs/mlagents_envs/tests/test_gym_wrapper.py


from mlagents_envs.gym_wrapper import GymWrapper
from mlagents_envs.gym_wrapper import GymToUnityWrapper
import gym
try:
import gym
except ImportError:
raise ImportError(
"gym is not installed, please call `pip install gym` before running this test"
)
GYM_ENVS = ["CartPole-v1", "MountainCar-v0", "AirRaid-v0"]
GYM_ENVS = ["CartPole-v1", "MountainCar-v0"]
env = GymWrapper(gym.make(name), name)
env = GymToUnityWrapper(gym.make(name), name)
env.close()

env = GymWrapper(gym_env, name)
env = GymToUnityWrapper(gym_env, name)
assert env.get_behavior_names()[0] == name
if isinstance(gym_env.action_space, gym.spaces.Box):
assert env.get_behavior_spec(name).action_type == ActionType.CONTINUOUS

@pytest.mark.parametrize("name", GYM_ENVS, ids=GYM_ENVS)
def test_steps(name):
env = GymWrapper(gym.make(name), name)
env = GymToUnityWrapper(gym.make(name), name)
spec = env.get_behavior_spec(name)
env.reset()
for _ in range(200):

5
ml-agents-envs/setup.py


packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
zip_safe=False,
install_requires=[
"gym",
"cmake",
"atari-py",
"opencv-python",
"gym[atari]",
"cloudpickle",
"grpcio>=1.11.0",
"numpy>=1.14.1,<2.0",

正在加载...
取消
保存