コード例 #1
0
def init_environment(env_path, docker_target_name, no_graphics, worker_id,
                     seed):
    if env_path is not None:
        # Strip out executable extensions if passed
        env_path = (env_path.strip().replace('.app', '').replace(
            '.exe', '').replace('.x86_64', '').replace('.x86', ''))
    docker_training = docker_target_name is not None

    return UnityEnvironment(n_arenas=1,
                            file_name=env_path,
                            worker_id=worker_id,
                            seed=seed,
                            docker_training=docker_training,
                            play=True)
コード例 #2
0
def debug_confirm_arena_config(env_path, arena_config):
    env_path = (env_path.strip().replace('.app', '').replace(
        '.exe', '').replace('.x86_64', '').replace('.x86', ''))

    from animalai.envs.environment import UnityEnvironment

    env = UnityEnvironment(n_arenas=16,
                           file_name=env_path,
                           worker_id=1,
                           seed=0,
                           docker_training=False,
                           play=True)
    env.reset(arenas_configurations=arena_config)

    try:
        while True:
            continue
    except KeyboardInterrupt:
        env.close()
コード例 #3
0
def main(args):
    docker_training = docker_target_name is not None

    env = UnityEnvironment(
        n_arenas=args.n_arenas,
        file_name=env_path,
        worker_id=worker_id,
        seed=seed,
        docker_training=docker_training,
        play=False,
        resolution=resolution
    )

    arena_config_in = ArenaConfig('configs/3-Obstacles.yaml')
    env.reset(arenas_configurations=arena_config_in)

    start_time = time.time()
    for i in range(args.frames):
        res = env.step(np.random.randint(0, 3, size=2 * args.n_arenas))

    elapsed_time = time.time() - start_time
    fps = float(args.frames) / elapsed_time
    print("n_arenas={0}, fps={1:.3f}".format(args.n_arenas, fps))
    env.close()
コード例 #4
0
resolution = 84
n_channels = 3
dim_actions = 2
sample_size_per_task = 30

# set up the testing env
np.random.seed(seed)
if env_path is not None:
    env_path = (env_path.strip().replace('.app', '').replace(
        '.exe', '').replace('.x86_64', '').replace('.x86', ''))
docker_training = docker_target_name is not None

env = UnityEnvironment(n_arenas=n_arenas,
                       file_name=env_path,
                       worker_id=worker_id,
                       seed=seed,
                       docker_training=docker_training,
                       play=False,
                       resolution=resolution)

# The Agent to test
agent = Agent()

# visualization
plt.ion()
fig, ax = plt.subplots(ncols=1, nrows=1)
image = ax.imshow(np.zeros(
    (resolution, resolution, 3)))  # visual input for the agent
line, = ax.plot(
    [], [])  # the direction that the agent want to go given the visual input
sca = ax.scatter([], [], s=5, c="yellow")  # the path to the target(food)
コード例 #5
0
ファイル: env.py プロジェクト: ironbar/orangutan
 def __init__(self, *args, **kwargs):
     '''
     Check UnityEnvironment parameters
     '''
     self._env = UnityEnvironment(*args, **kwargs)
     self._arenas_configurations = None
コード例 #6
0
from animalai.envs.environment import UnityEnvironment
from animalai.envs.arena_config import ArenaConfig
import time
import random

worker_id = random.randint(0, 100)

env = UnityEnvironment(n_arenas=1,
                       file_name='../env_modified/AnimalAILinux',
                       worker_id=worker_id,
                       seed=0,
                       docker_training=False,
                       inference=True)

arena_config_in = ArenaConfig('configs/empty.yaml')
env.reset(arenas_configurations=arena_config_in)
total_distance = 0
# step_time_length = 0.0595
try:
    while True:
        step = 0
        direction = input()
        if direction == "w":
            action = [1, 0]
        if direction == "s":
            action = [2, 0]
        if direction == "d":
            action = [0, 1]
        if direction == "a":
            action = [0, 2]
        while step < 1.0: