def reset(self):
    self._destroy()
    self.world.contactListener_bug_workaround = ContactDetector(self)
    self.world.contactListener = self.world.contactListener_bug_workaround
    self.game_over = False
    self.prev_shaping = None
    self.scroll = 0.0
    self.lidar_render = 0
    W = (VIEWPORT_W / SCALE)
    H = (VIEWPORT_H / SCALE)
    self._generate_terrain(self.hardcore)
    self._generate_clouds()
    init_x = ((TERRAIN_STEP * TERRAIN_STARTPAD) / 2)
    init_y = (TERRAIN_HEIGHT + (2 * LEG_H))
    self.hull = self.world.CreateDynamicBody(position=(init_x, init_y), fixtures=HULL_FD)
    self.hull.color1 = (0.5, 0.4, 0.9)
    self.hull.color2 = (0.3, 0.3, 0.5)
    self.hull.ApplyForceToCenter((self.np_random.uniform((- INITIAL_RANDOM), INITIAL_RANDOM), 0), True)
    self.legs = []
    self.joints = []
    for i in [(- 1), (+ 1)]:
        leg = self.world.CreateDynamicBody(position=(init_x, ((init_y - (LEG_H / 2)) - LEG_DOWN)), angle=(i * 0.05), fixtures=LEG_FD)
        leg.color1 = ((0.6 - (i / 10.0)), (0.3 - (i / 10.0)), (0.5 - (i / 10.0)))
        leg.color2 = ((0.4 - (i / 10.0)), (0.2 - (i / 10.0)), (0.3 - (i / 10.0)))
        rjd = revoluteJointDef(bodyA=self.hull, bodyB=leg, localAnchorA=(0, LEG_DOWN), localAnchorB=(0, (LEG_H / 2)), enableMotor=True, enableLimit=True, maxMotorTorque=MOTORS_TORQUE, motorSpeed=i, lowerAngle=(- 0.8), upperAngle=1.1)
        self.legs.append(leg)
        self.joints.append(self.world.CreateJoint(rjd))
        lower = self.world.CreateDynamicBody(position=(init_x, ((init_y - ((LEG_H * 3) / 2)) - LEG_DOWN)), angle=(i * 0.05), fixtures=LOWER_FD)
        lower.color1 = ((0.6 - (i / 10.0)), (0.3 - (i / 10.0)), (0.5 - (i / 10.0)))
        lower.color2 = ((0.4 - (i / 10.0)), (0.2 - (i / 10.0)), (0.3 - (i / 10.0)))
        rjd = revoluteJointDef(bodyA=leg, bodyB=lower, localAnchorA=(0, ((- LEG_H) / 2)), localAnchorB=(0, (LEG_H / 2)), enableMotor=True, enableLimit=True, maxMotorTorque=MOTORS_TORQUE, motorSpeed=1, lowerAngle=(- 1.6), upperAngle=(- 0.1))
        lower.ground_contact = False
        self.legs.append(lower)
        self.joints.append(self.world.CreateJoint(rjd))
    self.drawlist = ((self.terrain + self.legs) + [self.hull])

    class LidarCallback(Box2D.b2.rayCastCallback):

        def ReportFixture(self, fixture, point, normal, fraction):
            if ((fixture.filterData.categoryBits & 1) == 0):
                return 1
            self.p2 = point
            self.fraction = fraction
            return 0
    self.lidar = [LidarCallback() for _ in range(10)]
    return self.step(np.array([0, 0, 0, 0]))[0]
def reset(self):
    self._destroy()
    self.world.contactListener_bug_workaround = ContactDetector(self)
    self.world.contactListener = self.world.contactListener_bug_workaround
    self.game_over = False
    self.prev_shaping = None
    self.scroll = 0.0
    self.lidar_render = 0
    W = (VIEWPORT_W / SCALE)
    H = (VIEWPORT_H / SCALE)
    self._generate_terrain(self.hardcore)
    self._generate_clouds()
    init_x = ((TERRAIN_STEP * TERRAIN_STARTPAD) / 2)
    init_y = (TERRAIN_HEIGHT + (2 * LEG_H))
    self.hull = self.world.CreateDynamicBody(position=(init_x, init_y), fixtures=HULL_FD)
    self.hull.color1 = (0.5, 0.4, 0.9)
    self.hull.color2 = (0.3, 0.3, 0.5)
    self.hull.ApplyForceToCenter((self.np_random.uniform((- INITIAL_RANDOM), INITIAL_RANDOM), 0), True)
    self.legs = []
    self.joints = []
    for i in [(- 1), (+ 1)]:
        leg = self.world.CreateDynamicBody(position=(init_x, ((init_y - (LEG_H / 2)) - LEG_DOWN)), angle=(i * 0.05), fixtures=LEG_FD)
        leg.color1 = ((0.6 - (i / 10.0)), (0.3 - (i / 10.0)), (0.5 - (i / 10.0)))
        leg.color2 = ((0.4 - (i / 10.0)), (0.2 - (i / 10.0)), (0.3 - (i / 10.0)))
        rjd = revoluteJointDef(bodyA=self.hull, bodyB=leg, localAnchorA=(0, LEG_DOWN), localAnchorB=(0, (LEG_H / 2)), enableMotor=True, enableLimit=True, maxMotorTorque=MOTORS_TORQUE, motorSpeed=i, lowerAngle=(- 0.8), upperAngle=1.1)
        self.legs.append(leg)
        self.joints.append(self.world.CreateJoint(rjd))
        lower = self.world.CreateDynamicBody(position=(init_x, ((init_y - ((LEG_H * 3) / 2)) - LEG_DOWN)), angle=(i * 0.05), fixtures=LOWER_FD)
        lower.color1 = ((0.6 - (i / 10.0)), (0.3 - (i / 10.0)), (0.5 - (i / 10.0)))
        lower.color2 = ((0.4 - (i / 10.0)), (0.2 - (i / 10.0)), (0.3 - (i / 10.0)))
        rjd = revoluteJointDef(bodyA=leg, bodyB=lower, localAnchorA=(0, ((- LEG_H) / 2)), localAnchorB=(0, (LEG_H / 2)), enableMotor=True, enableLimit=True, maxMotorTorque=MOTORS_TORQUE, motorSpeed=1, lowerAngle=(- 1.6), upperAngle=(- 0.1))
        lower.ground_contact = False
        self.legs.append(lower)
        self.joints.append(self.world.CreateJoint(rjd))
    self.drawlist = ((self.terrain + self.legs) + [self.hull])

    class LidarCallback(Box2D.b2.rayCastCallback):

        def ReportFixture(self, fixture, point, normal, fraction):
            if ((fixture.filterData.categoryBits & 1) == 0):
                return 1
            self.p2 = point
            self.fraction = fraction
            return 0
    self.lidar = [LidarCallback() for _ in range(10)]
    return self.step(np.array([0, 0, 0, 0]))[0]