def render(self, mode='human'):
    screen_width = 600
    screen_height = 400
    world_width = (self.x_threshold * 2)
    scale = (screen_width / world_width)
    carty = 100
    polewidth = 10.0
    polelen = (scale * (2 * self.length))
    cartwidth = 50.0
    cartheight = 30.0
    if (self.viewer is None):
        from gym.envs.classic_control import rendering
        self.viewer = rendering.Viewer(screen_width, screen_height)
        (l, r, t, b) = (((- cartwidth) / 2), (cartwidth / 2), (cartheight / 2), ((- cartheight) / 2))
        axleoffset = (cartheight / 4.0)
        cart = rendering.FilledPolygon([(l, b), (l, t), (r, t), (r, b)])
        self.carttrans = rendering.Transform()
        cart.add_attr(self.carttrans)
        self.viewer.add_geom(cart)
        (l, r, t, b) = (((- polewidth) / 2), (polewidth / 2), (polelen - (polewidth / 2)), ((- polewidth) / 2))
        pole = rendering.FilledPolygon([(l, b), (l, t), (r, t), (r, b)])
        pole.set_color(0.8, 0.6, 0.4)
        self.poletrans = rendering.Transform(translation=(0, axleoffset))
        pole.add_attr(self.poletrans)
        pole.add_attr(self.carttrans)
        self.viewer.add_geom(pole)
        self.axle = rendering.make_circle((polewidth / 2))
        self.axle.add_attr(self.poletrans)
        self.axle.add_attr(self.carttrans)
        self.axle.set_color(0.5, 0.5, 0.8)
        self.viewer.add_geom(self.axle)
        self.track = rendering.Line((0, carty), (screen_width, carty))
        self.track.set_color(0, 0, 0)
        self.viewer.add_geom(self.track)
        self._pole_geom = pole
    if (self.state is None):
        return None
    pole = self._pole_geom
    (l, r, t, b) = (((- polewidth) / 2), (polewidth / 2), (polelen - (polewidth / 2)), ((- polewidth) / 2))
    pole.v = [(l, b), (l, t), (r, t), (r, b)]
    x = self.state
    cartx = ((x[0] * scale) + (screen_width / 2.0))
    self.carttrans.set_translation(cartx, carty)
    self.poletrans.set_rotation((- x[2]))
    return self.viewer.render(return_rgb_array=(mode == 'rgb_array'))
def render(self, mode='human'):
    screen_width = 600
    screen_height = 400
    world_width = (self.x_threshold * 2)
    scale = (screen_width / world_width)
    carty = 100
    polewidth = 10.0
    polelen = (scale * (2 * self.length))
    cartwidth = 50.0
    cartheight = 30.0
    if (self.viewer is None):
        from gym.envs.classic_control import rendering
        self.viewer = rendering.Viewer(screen_width, screen_height)
        (l, r, t, b) = (((- cartwidth) / 2), (cartwidth / 2), (cartheight / 2), ((- cartheight) / 2))
        axleoffset = (cartheight / 4.0)
        cart = rendering.FilledPolygon([(l, b), (l, t), (r, t), (r, b)])
        self.carttrans = rendering.Transform()
        cart.add_attr(self.carttrans)
        self.viewer.add_geom(cart)
        (l, r, t, b) = (((- polewidth) / 2), (polewidth / 2), (polelen - (polewidth / 2)), ((- polewidth) / 2))
        pole = rendering.FilledPolygon([(l, b), (l, t), (r, t), (r, b)])
        pole.set_color(0.8, 0.6, 0.4)
        self.poletrans = rendering.Transform(translation=(0, axleoffset))
        pole.add_attr(self.poletrans)
        pole.add_attr(self.carttrans)
        self.viewer.add_geom(pole)
        self.axle = rendering.make_circle((polewidth / 2))
        self.axle.add_attr(self.poletrans)
        self.axle.add_attr(self.carttrans)
        self.axle.set_color(0.5, 0.5, 0.8)
        self.viewer.add_geom(self.axle)
        self.track = rendering.Line((0, carty), (screen_width, carty))
        self.track.set_color(0, 0, 0)
        self.viewer.add_geom(self.track)
        self._pole_geom = pole
    if (self.state is None):
        return None
    pole = self._pole_geom
    (l, r, t, b) = (((- polewidth) / 2), (polewidth / 2), (polelen - (polewidth / 2)), ((- polewidth) / 2))
    pole.v = [(l, b), (l, t), (r, t), (r, b)]
    x = self.state
    cartx = ((x[0] * scale) + (screen_width / 2.0))
    self.carttrans.set_translation(cartx, carty)
    self.poletrans.set_rotation((- x[2]))
    return self.viewer.render(return_rgb_array=(mode == 'rgb_array'))