def SetResolution(target_resolution):
class SetResolutionWrapper(gym.Wrapper):
"""
Doom wrapper to change screen resolution
"""
def __init__(self, env):
super(SetResolutionWrapper, self).__init__(env)
if target_resolution not in resolutions:
raise gym.error.Error('Error - The specified resolution "{}" is not supported by Vizdoom.'.format(target_resolution))
parts = target_resolution.lower().split('x')
width = int(parts[0])
height = int(parts[1])
screen_res = __import__('doom_py')
screen_res = getattr(screen_res, 'ScreenResolution')
screen_res = getattr(screen_res, 'RES_{}X{}'.format(width, height))
self.screen_width, self.screen_height, self.unwrapped.screen_resolution = width, height, screen_res
self.unwrapped.observation_space = gym.spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
self.observation_space = self.unwrapped.observation_space
return SetResolutionWrapper
评论列表
文章目录