Beispiel #1
0
    def __init__(self, position, matrix):
        """
        Enemy constructor, defines the main attributes
        :param position: list -> initial position of the player
        :param matrix: Matrix -> matrix where the player moves
        """
        super().__init__(position, matrix)

        def define_stats():  # Randomly define the stats
            lives = LIVES
            evasion = random.randrange(2, 4)
            explosion_radius = random.randrange(2, 4)
            velocity = 14 - evasion - explosion_radius
            stats = [lives, velocity, explosion_radius, evasion]
            return stats

        enemy_stats = define_stats()
        self.lives = enemy_stats[0]
        self.velocity = enemy_stats[1] * 100
        self.explosion_radius = enemy_stats[2]
        self.evasion = enemy_stats[3]

        # Genetics
        self.genetics = GeneticAlgorithm.Genes(self)
        threading.Thread.__init__(self)