Esempio n. 1
0
 def __init__(self, fractal):
     self.fractal = fractal
     self.x = cfg.getfloat("Fractal", "origin_x")
     self.y = cfg.getfloat("Fractal", "origin_y")
     self.depth = 0
     self.dist_to_origin = 0
     self.parent_orientation = 0
     self.segment_count = 4
Esempio n. 2
0
    def mutate(self):
        mutate_count = 0

        # maybe delete a term
        if self.terms and random() > (1 - (cfg.getfloat('Function', 'term_deletion_chance') * len(self.terms))):
            self._delete_term()

        # potentially create a new term. always do so if there are none.
        if not self.terms or random() > (1 - cfg.getfloat('Function', 'term_creation_chance')):
            self._add_term()

        # modify some term constants
        if self.terms:
            while mutate_count < cfg.getint('Mutator', 'number_of_terms'):
                if random() > cfg.getfloat('Mutator', 'probability'):
                    t = choice(self.terms)
                    t.mutate()
                mutate_count += 1
Esempio n. 3
0
    def mutate(self):
        variability = cfg.getfloat('Mutator', 'variability')

        def nonzero_variation():
            while True:
                v = uniform(-variability, variability)
                if v != 0:
                    return v

        self.innerMultiplier += nonzero_variation()
        self.outerMultiplier += nonzero_variation()
        return self