Skip to content

Commit

Permalink
Merge pull request #50 from Unity-Technologies/develop-1.2
Browse files Browse the repository at this point in the history
Add timeout_wait and realtime_mode to interface
  • Loading branch information
awjuliani committed Feb 14, 2019
2 parents 888b370 + 8984d1a commit dada2ba
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -38,9 +38,9 @@ Python dependencies (also in [setup.py](https://github.com/Unity-Technologies/ob

| *Platform* | *Download Link* |
| --- | --- |
| Linux (x86_64) | https://storage.googleapis.com/obstacle-tower-build/v1.1/obstacletower_v1.1_linux.zip |
| Linux (x86_64) | https://storage.googleapis.com/obstacle-tower-build/v1.1/obstacletower_v1.1.2_linux.zip |
| Mac OS X | https://storage.googleapis.com/obstacle-tower-build/v1.1/obstacletower_v1.1_osx.zip |
| Windows | https://storage.googleapis.com/obstacle-tower-build/v1.1/obstacletower_v1.1_windows.zip |
| Windows | https://storage.googleapis.com/obstacle-tower-build/v1.1/obstacletower_v1.1.2_windows.zip |

For checksums on these files, see [here](https://storage.googleapis.com/obstacle-tower-build/v1.1/obe-v1.1-checksums.txt).

Expand Down
24 changes: 14 additions & 10 deletions examples/basic_usage.ipynb

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions obstacle_tower_env.py
Expand Up @@ -22,7 +22,8 @@ class UnityGymException(error.Error):
class ObstacleTowerEnv(gym.Env):
ALLOWED_VERSIONS = ['1', '1.1']

def __init__(self, environment_filename=None, docker_training=False, worker_id=0, retro=True):
def __init__(self, environment_filename=None, docker_training=False, worker_id=0, retro=True,
timeout_wait=30, realtime_mode=False):
"""
Arguments:
environment_filename: The file path to the Unity executable. Does not require the extension.
Expand All @@ -31,12 +32,17 @@ def __init__(self, environment_filename=None, docker_training=False, worker_id=0
worker_id: The index of the worker in the case where multiple environments are running. Each
environment reserves port (5005 + worker_id) for communication with the Unity executable.
retro: Resize visual observation to 84x84 (int8) and flattens action space.
timeout_wait: Time for python interface to wait for environment to connect.
realtime_mode: Whether to render the environment window image and run environment at realtime.
"""
if self.is_grading():
environment_filename = None
docker_training = True

self._env = UnityEnvironment(environment_filename, worker_id, docker_training=docker_training)
self._env = UnityEnvironment(environment_filename,
worker_id,
docker_training=docker_training,
timeout_wait=timeout_wait)

split_name = self._env.academy_name.split('-v')
if len(split_name) == 2 and split_name[0] == "ObstacleTower":
Expand All @@ -48,8 +54,8 @@ def __init__(self, environment_filename=None, docker_training=False, worker_id=0

if self.version not in self.ALLOWED_VERSIONS:
raise UnityGymException(
"Invalid Obstacle Tower version. Your build is v" + self.version + \
" but only the following versions are compatible with this gym: " + \
"Invalid Obstacle Tower version. Your build is v" + self.version +
" but only the following versions are compatible with this gym: " +
str(self.ALLOWED_VERSIONS)
)

Expand All @@ -60,6 +66,7 @@ def __init__(self, environment_filename=None, docker_training=False, worker_id=0
self._flattener = None
self._seed = None
self._floor = None
self.realtime_mode = realtime_mode
self.game_over = False # Hidden flag used by Atari environments to determine if the game is over
self.retro = retro

Expand All @@ -84,7 +91,7 @@ def __init__(self, environment_filename=None, docker_training=False, worker_id=0
"Please note that only the first will be provided in the observation.")

# Check for number of agents in scene.
initial_info = self._env.reset()[self.brain_name]
initial_info = self._env.reset(train_mode=not self.realtime_mode)[self.brain_name]
self._check_agents(len(initial_info.agents))

# Set observation and action spaces
Expand Down Expand Up @@ -144,7 +151,8 @@ def reset(self):
if self._seed is not None:
reset_params['tower-seed'] = self._seed

info = self._env.reset(config=reset_params)[self.brain_name]
info = self._env.reset(config=reset_params,
train_mode=not self.realtime_mode)[self.brain_name]
n_agents = len(info.agents)
self._check_agents(n_agents)
self.game_over = False
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -5,12 +5,12 @@

setup(
name='obstacle_tower_env',
version='1.1',
version='1.2',
author='Unity Technologies',
url='https://github.com/Unity-Technologies/obstacle-tower-env',
py_modules=["obstacle_tower_env"],
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=['mlagents_envs>=0.6.1,<0.7',
install_requires=['mlagents_envs>=0.6.2,<0.7',
'gym']
)

0 comments on commit dada2ba

Please sign in to comment.