observation_space.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:gym-doom 作者: ppaquette 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号