Commit 999c42e6 authored by Benjamin Beyret's avatar Benjamin Beyret
Browse files

add custom resolution

parent f0912659
......@@ -33,7 +33,8 @@ class UnityEnvironment(object):
n_arenas=1,
play=False,
arenas_configurations=None,
inference=False):
inference=False,
resolution=None):
"""
Starts a new unity environment and establishes a connection with the environment.
Notice: Currently communication between Unity and Python takes place over an open socket without authentication.
......@@ -49,6 +50,7 @@ class UnityEnvironment(object):
self.n_arenas = n_arenas
self.play = play
self.inference = inference
self.resolution = resolution
self.port = base_port + worker_id
self._buffer_size = 12000
self._version_ = "0.6"
......@@ -79,7 +81,7 @@ class UnityEnvironment(object):
"There is a version mismatch between the Python API and Unity executable.\n"
"Python API : {0}, Unity executable : {1}.\n"
"Please go to https://github.com/beyretb/AnimalAI-Olympics to download the latest version "
.format(self._version_, self._unity_version))
.format(self._version_, self._unity_version))
self._n_agents = {}
self._global_done = None
self._academy_name = aca_params.name
......@@ -187,8 +189,13 @@ class UnityEnvironment(object):
self.proc1 = subprocess.Popen(
[launch_string, '--port', str(self.port), '--inference'])
else:
self.proc1 = subprocess.Popen(
[launch_string, '--port', str(self.port), '--nArenas', str(self.n_arenas)])
if self.resolution:
self.proc1 = subprocess.Popen(
[launch_string, '--port', str(self.port), '--resolution', str(self.resolution), '--nArenas',
str(self.n_arenas)])
else:
self.proc1 = subprocess.Popen(
[launch_string, '--port', str(self.port), '--nArenas', str(self.n_arenas)])
else:
"""
......
......@@ -32,7 +32,8 @@ class AnimalAIEnv(gym.Env):
n_arenas=1,
arenas_configurations=None,
greyscale=False,
retro=True):
retro=True,
resolution=None):
"""
Environment initialization
:param environment_filename: The UnityEnvironment path or file to be wrapped in the gym.
......@@ -49,9 +50,11 @@ class AnimalAIEnv(gym.Env):
worker_id=worker_id,
docker_training=docker_training,
n_arenas=n_arenas,
arenas_configurations=arenas_configurations)
arenas_configurations=arenas_configurations,
resolution=resolution)
# self.name = self._env.academy_name
self.vector_obs = None
self.resolution = resolution
self._current_state = None
self._n_agents = None
self._flattener = None
......
......@@ -2,7 +2,7 @@ from setuptools import setup
setup(
name='animalai',
version='0.6.0',
version='1.0.0',
description='Animal AI competition interface',
url='https://github.com/beyretb/AnimalAI-Olympics',
author='Benjamin Beyret',
......
......@@ -2,7 +2,7 @@ from setuptools import setup
setup(
name='animalai_train',
version='0.6.1',
version='1.0.0',
description='Animal AI competition training library',
url='https://github.com/beyretb/AnimalAI-Olympics',
author='Benjamin Beyret',
......@@ -20,7 +20,7 @@ setup(
zip_safe=False,
install_requires=[
'animalai>=0.6.0',
'animalai>=1.0.0',
'dopamine-rl',
'tensorflow==1.12.2',
'matplotlib',
......
......@@ -10,17 +10,23 @@ arenas:
t: 100
blackouts: [-40]
items:
- !Item
name: Wall
- !Item
name: GoodGoal
2: !Arena
t: 100
blackouts: [50, 55, 75, 80, 100, 105, 125]
items:
- !Item
name: WallTranparent
- !Item
name: GoodGoal
3: !Arena
t: 100
blackouts: [25, 30, 50, 55, 75]
items:
- !Item
name: CylinderTunnel
- !Item
name: GoodGoal
......@@ -8,7 +8,7 @@ import random
env_path = '../env/AnimalAI'
worker_id = random.randint(1, 100)
arena_config_in = ArenaConfig('configs/justFood.yaml')
arena_config_in = ArenaConfig('configs/1-Food.yaml')
base_dir = 'models/dopamine'
gin_files = ['configs/rainbow.gin']
......
......@@ -16,6 +16,7 @@ run_seed = 1
docker_target_name = None
no_graphics = False
n_arenas = 4
resolution = 32
if env_path is not None:
env_path = (env_path.strip()
......@@ -31,10 +32,11 @@ env = UnityEnvironment(
worker_id=worker_id,
seed=seed,
docker_training=docker_training,
play=False
play=False,
resolution=resolution
)
arena_config_in = ArenaConfig('configs/lightsOff.yaml')
arena_config_in = ArenaConfig('configs/7-InternalMemory.yaml')
env.reset(arenas_configurations=arena_config_in)
fig, axes = plt.subplots(2, 2)
imshows = []
......@@ -42,12 +44,12 @@ for i in range(2):
for j in range(2):
axes[i, j].set_title('Arena ' + str(i * 2 + j))
axes[i, j].axis('off')
imshows.append(axes[i, j].imshow(np.zeros((84, 84, 3))))
imshows.append(axes[i, j].imshow(np.zeros((resolution, resolution, 3))))
def initialize_animation():
for i in range(4):
imshows[i].set_data(np.zeros((84, 84, 3)))
imshows[i].set_data(np.zeros((resolution, resolution, 3)))
def run_step_imshow(step):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment