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)
def _update_blue_robot_state(self, robot: Robot, blue_agent: blueAgent): blue_agent.pos = robot.get_pos() blue_agent.health = robot.get_health() blue_agent.angle = robot.get_angle()
def _update_red_robot_state(self, robot: Robot, red_agent: redAgent): red_agent.pos = robot.get_pos() red_agent.health = robot.get_health() red_agent.angle = robot.get_angle()
def _update_robot_state(self, robot: Robot, state: RobotState): state.pos = robot.get_pos() state.health = robot.get_health() state.angle = robot.get_angle() state.velocity = robot.get_velocity() state.angular = robot.get_angular()