當前位置: 首頁>>代碼示例>>Python>>正文


Python rendering.Image方法代碼示例

本文整理匯總了Python中gym.envs.classic_control.rendering.Image方法的典型用法代碼示例。如果您正苦於以下問題:Python rendering.Image方法的具體用法?Python rendering.Image怎麽用?Python rendering.Image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gym.envs.classic_control.rendering的用法示例。


在下文中一共展示了rendering.Image方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: render

# 需要導入模塊: from gym.envs.classic_control import rendering [as 別名]
# 或者: from gym.envs.classic_control.rendering import Image [as 別名]
def render(self, mode='human'):

        if self.viewer is None:
            from gym.envs.classic_control import rendering
            self.viewer = rendering.Viewer(500,500)
            self.viewer.set_bounds(-2.2,2.2,-2.2,2.2)
            rod = rendering.make_capsule(1, .2)
            rod.set_color(.8, .3, .3)
            self.pole_transform = rendering.Transform()
            rod.add_attr(self.pole_transform)
            self.viewer.add_geom(rod)
            axle = rendering.make_circle(.05)
            axle.set_color(0,0,0)
            self.viewer.add_geom(axle)
            fname = path.join(path.dirname(__file__), "assets/clockwise.png")
            self.img = rendering.Image(fname, 1., 1.)
            self.imgtrans = rendering.Transform()
            self.img.add_attr(self.imgtrans)

        self.viewer.add_onetime(self.img)
        self.pole_transform.set_rotation(self.state[0] + np.pi/2)
        if self.last_u:
            self.imgtrans.scale = (-self.last_u/2, np.abs(self.last_u)/2)

        return self.viewer.render(return_rgb_array = mode=='rgb_array') 
開發者ID:ArztSamuel,項目名稱:DRL_DeliveryDuel,代碼行數:27,代碼來源:pendulum.py

示例2: render

# 需要導入模塊: from gym.envs.classic_control import rendering [as 別名]
# 或者: from gym.envs.classic_control.rendering import Image [as 別名]
def render(self, mode='human'):

        if self.viewer is None:
            from gym.envs.classic_control import rendering
            self.viewer = rendering.Viewer(500, 500)
            self.viewer.set_bounds(-2.2, 2.2, -2.2, 2.2)
            rod = rendering.make_capsule(1, .2)
            rod.set_color(.8, .3, .3)
            self.pole_transform = rendering.Transform()
            rod.add_attr(self.pole_transform)
            self.viewer.add_geom(rod)
            axle = rendering.make_circle(.05)
            axle.set_color(0, 0, 0)
            self.viewer.add_geom(axle)
            fname = path.join(path.dirname(__file__), "assets/clockwise.png")
            self.img = rendering.Image(fname, 1., 1.)
            self.imgtrans = rendering.Transform()
            self.img.add_attr(self.imgtrans)

        self.viewer.add_onetime(self.img)
        self.pole_transform.set_rotation(self.state[0] + np.pi/2)
        if self.last_u:
            self.imgtrans.scale = (-self.last_u/2, np.abs(self.last_u)/2)

        return self.viewer.render(return_rgb_array=mode == 'rgb_array') 
開發者ID:DeepX-inc,項目名稱:machina,代碼行數:27,代碼來源:env.py

示例3: render_goal

# 需要導入模塊: from gym.envs.classic_control import rendering [as 別名]
# 或者: from gym.envs.classic_control.rendering import Image [as 別名]
def render_goal(self, goal, end_goal, mode='human'):

        if self.viewer is None:
            from gym.envs.classic_control import rendering
            self.viewer = rendering.Viewer(500,500)
            self.viewer.set_bounds(-2.2,2.2,-2.2,2.2)
            
            rod = rendering.make_capsule(1, .2)
            rod.set_color(.8, .3, .3)
            self.pole_transform = rendering.Transform()
            rod.add_attr(self.pole_transform)
            self.viewer.add_geom(rod)
                   
            ################ goal ################
            rod1 = rendering.make_goal_circ(1, .1)
            rod1.set_color(.8, .8, .3)
            self.pole_transform1 = rendering.Transform()
            rod1.add_attr(self.pole_transform1)
            self.viewer.add_geom(rod1)
            ######################################
            
            ############## End Goal ##############
            rod2 = rendering.make_goal_circ(1, .1)
            rod2.set_color(.3, .3, .8)
            self.pole_transform2 = rendering.Transform()
            rod2.add_attr(self.pole_transform2)
            self.viewer.add_geom(rod2)
            ######################################
            
            axle = rendering.make_circle(.05)
            axle.set_color(0,0,0)
            self.viewer.add_geom(axle)
            fname = path.join(path.dirname(__file__), "assets/clockwise.png")
            self.img = rendering.Image(fname, 1., 1.)
            self.imgtrans = rendering.Transform()
            self.img.add_attr(self.imgtrans)

   #     self.viewer.add_onetime(self.img)
        self.pole_transform.set_rotation(self.state[0] + np.pi/2)
        
        self.pole_transform1.set_rotation(goal[0] + np.pi/2)
        
        self.pole_transform2.set_rotation(end_goal[0] + np.pi/2)
        
        if self.last_u:
            self.imgtrans.scale = (-self.last_u/2, np.abs(self.last_u)/2)

        return self.viewer.render(return_rgb_array = mode=='rgb_array') 
開發者ID:nikhilbarhate99,項目名稱:Hierarchical-Actor-Critic-HAC-PyTorch,代碼行數:50,代碼來源:pendulum.py


注:本文中的gym.envs.classic_control.rendering.Image方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。