<commit_before>from tota.utils import closest, distance, sort_by_distance, possible_moves
from tota import settings


def create():
    def simple_hero_logic(self, things, t):
        # some useful data about the enemies I can see in the map
        enemy_team = settings.ENEMY_TEAMS[self.team]
        enemies = [thing for thing in things.values()
                   if thing.team == enemy_team]
        closest_enemy = closest(self, enemies)
        closest_enemy_distance = distance(self, closest_enemy)

        if self.life < self.max_life and self.can('heal', t):
            # if I'm hurt and can heal, heal
            return 'heal', self.position
        else:
            # else, try to attack
            if closest_enemy:
                # there is an enemy
                if closest_enemy_distance < settings.STUN_DISTANCE and self.can('stun', t):
                    # try to stun him
                    return 'stun', closest_enemy.position
                elif closest_enemy_distance < settings.FIREBALL_DISTANCE and self.can('fireball', t):
                    # else try to fireball him
                    return 'firebal', closest_enemy.position
                elif closest_enemy_distance < settings.HERO_ATTACK_DISTANCE:
                    # else try to attack him
                    return 'attack', closest_enemy.position
                else:
                    # of finally just move to him
                    moves = sort_by_distance(closest_enemy,<commit_msg>Simple doesn't fireball himself anymore<commit_after>from tota.utils import closest, distance, sort_by_distance, possible_moves
from tota import settings


def create():
    def simple_hero_logic(self, things, t):
        # some useful data about the enemies I can see in the map
        enemy_team = settings.ENEMY_TEAMS[self.team]
        enemies = [thing for thing in things.values()
                   if thing.team == enemy_team]
        closest_enemy = closest(self, enemies)
        closest_enemy_distance = distance(self, closest_enemy)

        if self.life < self.max_life and self.can('heal', t):
            # if I'm hurt and can heal, heal
            return 'heal', self.position
        else:
            # else, try to attack
            if closest_enemy:
                # there is an enemy
                if closest_enemy_distance < settings.STUN_DISTANCE and self.can('stun', t):
                    # try to stun him
                    return 'stun', closest_enemy.position
                elif closest_enemy_distance < settings.FIREBALL_DISTANCE and self.can('fireball', t) and closest_enemy_distance > settings.FIREBALL_RADIUS:
                    # else try to fireball him, but only if I'm not in range
                    return 'firebal', closest_enemy.position
                elif closest_enemy_distance < settings.HERO_ATTACK_DISTANCE:
                    # else try to attack him
                    return 'attack', closest_enemy.position
                else:
                    # of finally just move to him
                    moves = sort_by_distance(closest_enemy,
{'fraction_non_alphanumeric': 0.06686046511627906, 'fraction_numerical': 0.0, 'mean_word_length': 1.907981220657277, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5357540', 'n_tokens_mistral': 850, 'n_tokens_neox': 810, 'n_words': 253}