Ejemplo n.º 1
0
def in_my_range(client, item):
    if not client.my_info.get('coordinates') or not item.get('coordinates'):
        return False

    distance = euclidean_distance(item['coordinates'],
                                  client.my_info['coordinates'])
    return distance - item['size'] / 2 <= client.my_info['firing_range']
Ejemplo n.º 2
0
    def ask_nearest_enemy(self):
        min_length = 1000
        nearest_enemy = None

        fighter = self.my_info

        for item in self.env_map_filter([MF.enemy]):
            length = euclidean_distance(item['coordinates'], fighter['coordinates'])

            if length < min_length:
                min_length = length
                nearest_enemy = item
        return self.ask_item_info(nearest_enemy['id']) if nearest_enemy else {}
Ejemplo n.º 3
0
    def ask_nearest_enemy(self):
        min_length = 1000
        nearest_enemy = None

        fighter = self.my_info

        for item in self.env_map_filter([MF.enemy]):
            length = euclidean_distance(item['coordinates'],
                                        fighter['coordinates'])

            if length < min_length:
                min_length = length
                nearest_enemy = item
        return self.ask_item_info(nearest_enemy['id']) if nearest_enemy else {}
Ejemplo n.º 4
0
    def ask_nearest_enemy(self, roles=None):
        min_length = 1000
        nearest_enemy = None
        fighter = self.my_info
        filters = [MF.enemy]

        if roles:
            filters.append(MF.roles(roles))
        for item in self.env_map_filter(filters):
            length = euclidean_distance(item['coordinates'], fighter['coordinates'])

            if length < min_length:
                min_length = length
                nearest_enemy = item
        return self.ask_item_info(nearest_enemy['id']) if nearest_enemy else {}
Ejemplo n.º 5
0
def in_my_range(client, item):
    distance = euclidean_distance(item['coordinates'],
                                  client.my_info['coordinates'])
    return distance - item['size'] / 2 <= client.my_info['firing_range']
Ejemplo n.º 6
0
def in_my_range(client, item):
    distance = euclidean_distance(item['coordinates'], client.my_info['coordinates'])
    return distance - item['size'] / 2 <= client.my_info['firing_range']