https://github.com/deepmind/lab/blob/master/docs/users/python_api.md
参数
deepmind_lab.Lab(level, observations, config={}, renderer='software', level_cache=None)
level
observations
width (Default 320) and height (Default 180)
Name | Type/Shape |
---|---|
RGB_INTERLEAVED | Bytes (height, width, 3) |
RGBD_INTERLEAVED | Bytes (height, width, 4) |
RGB | Bytes (3, height, width) |
RGBD | Bytes (4, height, width) |
BGR_INTERLEAVED | Bytes (height, width, 3) |
BGRD_INTERLEAVED | Bytes (height, width, 4) |
FRAMES_REMAINING_AT_60 | Doubles (1) |
config={}
config={'width':'320, 'height':'240', 'fps':60, 'levelDirectory':'', 'appendCommand':'', 'mixerSeed':'0'}
renderer
--define graphics=osmesa_or_egl
( renderer='software',osmesa; renderer='hardware',egl)
--define graphics=osmesa_or_glx
(renderer='software',osmesa;renderer='hardware',glx)
--define graphics=sdl
level_cache
bool fetch(self, key, pk3_path),path→pk3_path
write(self, key, pk3_path),pk3_path→path
import os.path
import shutil
class LevelCache(object):
def __init__(self, cache_dir):
self._cache_dir = cache_dir
def fetch(self, key, pk3_path):
path = os.path.join(self._cache_dir, key)
if os.path.isfile(path):
# Copy the cached file to the path expected by DeepMind Lab.
shutil.copyfile(path, pk3_path)
return True
return False
def write(self, key, pk3_path):
path = os.path.join(self._cache_dir, key)
if not os.path.isfile(path):
# Copy the cached file DeepMind Lab has written to the cache directory.
shutil.copyfile(pk3_path, path)
方法
env=deepmind_lab.Lab()
env.reset(episode=-1,seed=None)
env.observations()
返回一个dict
obs = env.observations()
obs={'RGBD':int64}
env.observation_spec()
# Outputs:
[{'dtype': , 'name': 'RGB_INTERLEAVED', 'shape': (180, 320, 3)},
{'dtype': , 'name': 'RGBD_INTERLEAVED', 'shape': (180, 320, 4)},
{'dtype': , 'name': 'RGB', 'shape': (3, 180, 320)},
{'dtype': , 'name': 'RGBD', 'shape': (4, 180, 320)},
{'dtype': , 'name': 'BGR_INTERLEAVED', 'shape': (180, 320, 3)},
{'dtype': , 'name': 'BGRD_INTERLEAVED', 'shape': (180, 320, 4)},
{'dtype': , 'name': 'MAP_FRAME_NUMBER', 'shape': (1,)},
{'dtype': , 'name': 'VEL.TRANS', 'shape': (3,)},
{'dtype': , 'name': 'VEL.ROT', 'shape': (3,)},
{'dtype': , 'name': 'INSTR', 'shape': ()},
{'dtype': , 'name': 'DEBUG.POS.TRANS', 'shape': (3,)},
{'dtype': , 'name': 'DEBUG.POS.ROT', 'shape': (3,)},
{'dtype': , 'name': 'DEBUG.PLAYER_ID', 'shape': (1,)},
# etc...
env.action_spec()
返回dict
# Outputs:
[{'max': 512, 'min': -512, 'name': 'LOOK_LEFT_RIGHT_PIXELS_PER_FRAME'},
{'max': 512, 'min': -512, 'name': 'LOOK_DOWN_UP_PIXELS_PER_FRAME'},
{'max': 1, 'min': -1, 'name': 'STRAFE_LEFT_RIGHT'},
{'max': 1, 'min': -1, 'name': 'MOVE_BACK_FORWARD'},
{'max': 1, 'min': 0, 'name': 'FIRE'},
{'max': 1, 'min': 0, 'name': 'JUMP'},
{'max': 1, 'min': 0, 'name': 'CROUCH'}]
env.num_steps()
重置后帧的个数
env.step(action, num_steps=1)
env.events()
返回一个list,Each event is a tuple of a name, and a list of observations
env.is_running()
True or False
env.fps()
每秒帧数
env.close()
关闭is_running()