Exemple #1
0
 def _step_action(self, robot: Robot, action: Action):
     # gas, rotate, transverse, rotate cloud terrance, shoot
     robot.move_ahead_back(action.v_t)
     robot.turn_left_right(action.angular)
     robot.move_left_right(action.v_n)
     if int(self.t * FPS) % (60 * FPS) == 0:
         robot.refresh_supply_oppotunity()
     if action.supply > 0.99:
         action.supply = 0.0
         if robot.if_supply_available():
             robot.use_supply_oppotunity()
             if self.__area_supply.if_in_area(robot):
                 robot.supply()
     if action.shoot > 0.99 and int(self.t * FPS) % (FPS / 5) == 1:
         if (robot.if_left_projectile()):
             angle, pos = robot.get_gun_angle_pos()
             robot.shoot()
             self.__projectile.shoot(angle, pos)
 def _step_action(self, robot: Robot, action: Action):
     # gas, rotate, transverse, rotate cloud terrance, shoot
     robot.move_ahead_back(action.v_t)
     robot.turn_left_right(action.angular)
     robot.move_left_right(action.v_n)
     # if int(self.t * FPS) % (60 * FPS) == 0:
     #     robot.refresh_supply_oppotunity()
     # if action.supply > 0.99:
     #     action.supply = 0.0
     #     if robot.if_supply_available():
     #         robot.use_supply_oppotunity()
     #         if self.__area_supply.if_in_area(robot):
     #             robot.supply()
     if action.shoot > 0.99 and int(self.t * FPS) % (FPS / 5) == 1:
         if (robot.if_left_projectile() > 0) and robot.get_health() > 0:
             # print("shoot")
             # FIXME 下面这行条件只允许红方发射子弹
             if robot.robot_id % 2 == ID_R1:
                 angle, pos = robot.get_gun_angle_pos()
                 robot.shoot()
                 self.__projectile.shoot(angle, pos, robot.robot_id)