from corekit.utils import get_debug_logger
import numpy as np
_logger = get_debug_logger()
""""规则智能体模型"""
class Policy:
    def __init__(self):
        self.policy_name = None



class AttackPolicy(Policy):
    def __init__(self):
        super().__init__()
        self.policy_name = 'attack'


    def run_(self, agent, env_info):
        _logger.info(
            f"智能体{agent.agent_name}采用专家策略")
        agent_action_dict: dict = {}
        course_list: list = []
        manevuer_action = 1
        for aircraft_name, aircraft_info in env_info.aircrafts.items():
            if agent.agent_name == aircraft_info.Name:
                current_lat, current_lon, current_height = aircraft_info.Lat, aircraft_info.Lon, aircraft_info.Alt
                contact_id, contact_info = agent._get_nearest_contact(
                    current_course=(current_lat, current_lon, current_height),
                    env_obs=env_info
                    )
                break
        next_course, weapon_id, mount_id, height = agent._get_next_course(course_action=manevuer_action,
                                                                         current_course=(
                                                                         current_lat, current_lon, current_height),
                                                                         env_obs=env_info,
                                                                         agent_info=aircraft_info)

        course_list.append(next_course)
        agent_action_dict["course"] = course_list
        agent_action_dict["height"] = height
        agent_action_dict["weapon"]: dict = {}
        agent_action_dict["weapon"]["contact_id"] = contact_id
        agent_action_dict["weapon"]["mount_id"] = mount_id
        agent_action_dict["weapon"]["weapon_id"] = weapon_id

        # 雷达规则
        radar_action = 1
        radar_switch = True if radar_action else False
        agent_action_dict["radar"] = radar_switch
        # 电子干扰规则
        disturb_action = 1
        disturb_switch = True if disturb_action else False
        agent_action_dict["disturb"] = disturb_switch

        return agent_action_dict



class DefendPolicy(Policy):
    pass