def render(self, mode='human'):
    from gym.envs.classic_control import rendering
    if (self.viewer is None):
        self.viewer = rendering.Viewer(VIEWPORT_W, VIEWPORT_H)
    self.viewer.set_bounds(self.scroll, ((VIEWPORT_W / SCALE) + self.scroll), 0, (VIEWPORT_H / SCALE))
    self.viewer.draw_polygon([(self.scroll, 0), ((self.scroll + (VIEWPORT_W / SCALE)), 0), ((self.scroll + (VIEWPORT_W / SCALE)), (VIEWPORT_H / SCALE)), (self.scroll, (VIEWPORT_H / SCALE))], color=(0.9, 0.9, 1.0))
    for (poly, x1, x2) in self.cloud_poly:
        if (x2 < (self.scroll / 2)):
            continue
        if (x1 > ((self.scroll / 2) + (VIEWPORT_W / SCALE))):
            continue
        self.viewer.draw_polygon([((p[0] + (self.scroll / 2)), p[1]) for p in poly], color=(1, 1, 1))
    for (poly, color) in self.terrain_poly:
        if (poly[1][0] < self.scroll):
            continue
        if (poly[0][0] > (self.scroll + (VIEWPORT_W / SCALE))):
            continue
        self.viewer.draw_polygon(poly, color=color)
    self.lidar_render = ((self.lidar_render + 1) % 100)
    i = self.lidar_render
    if (i < (2 * len(self.lidar))):
        l = (self.lidar[i] if (i < len(self.lidar)) else self.lidar[((len(self.lidar) - i) - 1)])
        self.viewer.draw_polyline([l.p1, l.p2], color=(1, 0, 0), linewidth=1)
    for obj in self.drawlist:
        for f in obj.fixtures:
            trans = f.body.transform
            if (type(f.shape) is circleShape):
                t = rendering.Transform(translation=(trans * f.shape.pos))
                self.viewer.draw_circle(f.shape.radius, 30, color=obj.color1).add_attr(t)
                self.viewer.draw_circle(f.shape.radius, 30, color=obj.color2, filled=False, linewidth=2).add_attr(t)
            else:
                path = [(trans * v) for v in f.shape.vertices]
                self.viewer.draw_polygon(path, color=obj.color1)
                path.append(path[0])
                self.viewer.draw_polyline(path, color=obj.color2, linewidth=2)
    flagy1 = TERRAIN_HEIGHT
    flagy2 = (flagy1 + (50 / SCALE))
    x = (TERRAIN_STEP * 3)
    self.viewer.draw_polyline([(x, flagy1), (x, flagy2)], color=(0, 0, 0), linewidth=2)
    f = [(x, flagy2), (x, (flagy2 - (10 / SCALE))), ((x + (25 / SCALE)), (flagy2 - (5 / SCALE)))]
    self.viewer.draw_polygon(f, color=(0.9, 0.2, 0))
    self.viewer.draw_polyline((f + [f[0]]), color=(0, 0, 0), linewidth=2)
    return self.viewer.render(return_rgb_array=(mode == 'rgb_array'))
def render(self, mode='human'):
    from gym.envs.classic_control import rendering
    if (self.viewer is None):
        self.viewer = rendering.Viewer(VIEWPORT_W, VIEWPORT_H)
    self.viewer.set_bounds(self.scroll, ((VIEWPORT_W / SCALE) + self.scroll), 0, (VIEWPORT_H / SCALE))
    self.viewer.draw_polygon([(self.scroll, 0), ((self.scroll + (VIEWPORT_W / SCALE)), 0), ((self.scroll + (VIEWPORT_W / SCALE)), (VIEWPORT_H / SCALE)), (self.scroll, (VIEWPORT_H / SCALE))], color=(0.9, 0.9, 1.0))
    for (poly, x1, x2) in self.cloud_poly:
        if (x2 < (self.scroll / 2)):
            continue
        if (x1 > ((self.scroll / 2) + (VIEWPORT_W / SCALE))):
            continue
        self.viewer.draw_polygon([((p[0] + (self.scroll / 2)), p[1]) for p in poly], color=(1, 1, 1))
    for (poly, color) in self.terrain_poly:
        if (poly[1][0] < self.scroll):
            continue
        if (poly[0][0] > (self.scroll + (VIEWPORT_W / SCALE))):
            continue
        self.viewer.draw_polygon(poly, color=color)
    self.lidar_render = ((self.lidar_render + 1) % 100)
    i = self.lidar_render
    if (i < (2 * len(self.lidar))):
        l = (self.lidar[i] if (i < len(self.lidar)) else self.lidar[((len(self.lidar) - i) - 1)])
        self.viewer.draw_polyline([l.p1, l.p2], color=(1, 0, 0), linewidth=1)
    for obj in self.drawlist:
        for f in obj.fixtures:
            trans = f.body.transform
            if (type(f.shape) is circleShape):
                t = rendering.Transform(translation=(trans * f.shape.pos))
                self.viewer.draw_circle(f.shape.radius, 30, color=obj.color1).add_attr(t)
                self.viewer.draw_circle(f.shape.radius, 30, color=obj.color2, filled=False, linewidth=2).add_attr(t)
            else:
                path = [(trans * v) for v in f.shape.vertices]
                self.viewer.draw_polygon(path, color=obj.color1)
                path.append(path[0])
                self.viewer.draw_polyline(path, color=obj.color2, linewidth=2)
    flagy1 = TERRAIN_HEIGHT
    flagy2 = (flagy1 + (50 / SCALE))
    x = (TERRAIN_STEP * 3)
    self.viewer.draw_polyline([(x, flagy1), (x, flagy2)], color=(0, 0, 0), linewidth=2)
    f = [(x, flagy2), (x, (flagy2 - (10 / SCALE))), ((x + (25 / SCALE)), (flagy2 - (5 / SCALE)))]
    self.viewer.draw_polygon(f, color=(0.9, 0.2, 0))
    self.viewer.draw_polyline((f + [f[0]]), color=(0, 0, 0), linewidth=2)
    return self.viewer.render(return_rgb_array=(mode == 'rgb_array'))