Example #1
0
def pipe_worker(pipe, params, is_train, idx=0):
    env = DoomEnvironment(params,
                          idx=idx,
                          is_train=is_train,
                          use_shaping=params.use_shaping)
    while True:
        action = pipe.recv()
        if action is None:
            break
        elif action == 'reset':
            pipe.send(env.reset())

        elif action == 'depth_trim':
            pipe.send(env.get_depth()[2:-2, 2:-2])

        elif action == 'depth':
            pipe.send(env.get_depth())

        elif action == 'ego_depth':
            pipe.send(env.get_ego_depth())

        elif action == 'ego_depth_trim':
            pipe.send(env.get_ego_depth()[2:-2, 2:-2])

        elif action == 'deltas':
            pipe.send(env.get_player_deltas())

        elif action == 'positions':
            pipe.send(env.get_player_position())

        elif action == 'origins':
            pipe.send(env.get_player_origins())

        elif action == 'pos_deltas_origins':
            pipe.send(env.get_player_pos_delta_origin())

        elif action == 'loops':
            pipe.send(env.get_loop())
        else:
            obs, reward, done, info = env.step(action)
            pipe.send((obs, reward, done, info))
Example #2
0
def worker(in_queue, out_queue, params, is_train, idx=0):
    env = DoomEnvironment(params,
                          idx=idx,
                          is_train=is_train,
                          use_shaping=params.use_shaping)
    while True:
        action = in_queue.get()
        if action is None:
            break
        elif action == 'reset':
            out_queue.put(env.reset())

        elif action == 'depth_trim':
            out_queue.put(env.get_depth()[2:-2, 2:-2])

        elif action == 'depth':
            out_queue.put(env.get_depth())

        elif action == 'ego_depth':
            out_queue.put(env.get_ego_depth())

        elif action == 'ego_depth_trim':
            out_queue.put(env.get_ego_depth()[2:-2, 2:-2])

        elif action == 'deltas':
            out_queue.put(env.get_player_deltas())

        elif action == 'positions':
            out_queue.put(env.get_player_position())

        elif action == 'origins':
            out_queue.put(env.get_player_origins())

        elif action == 'pos_deltas_origins':
            out_queue.put(env.get_player_pos_delta_origin())

        else:
            obs, reward, done, info = env.step(action)
            out_queue.put((obs, reward, done, info))