def mutate(self, dna_draw): if (Tools.will_mutate(Settings.add_point_mutation_rate)): self.add_point() dna_draw.set_dirty() if (Tools.will_mutate(Settings.remove_point_mutation_rate)): self.remove_point() dna_draw.set_dirty() self.brush = self.brush.mutate(dna_draw) for index in range(len(self.points)): p = self.points[index] self.points[index] = p.mutate(dna_draw) return self
def mutate(self): if (Tools.will_mutate(Settings.add_polygon_mutation_rate)): self.add_polygon() self.set_dirty() if (Tools.will_mutate(Settings.remove_polygon_mutation_rate)): self.remove_polygon() self.set_dirty() if (Tools.will_mutate(Settings.move_polygon_mutation_rate)): self.move_polygon() self.set_dirty() for index in range(len(self.polygons)): self.polygons[index] = self.polygons[index].mutate(self) return self
def mutate(self, dna_draw): if (Tools.will_mutate(Settings.move_point_max_mutation_rate)): self.x = np.random.randint(0, Settings.max_width) self.y = np.random.randint(0, Settings.max_height) print "point mutation max" dna_draw.set_dirty() if (Tools.will_mutate(Settings.move_point_mid_mutation_rate)): self.x = min( max( 0, self.x + np.random.randint(-Settings.move_point_range_mid, Settings.move_point_range_mid)), Settings.max_width) self.y = min( max( 0, self.y + np.random.randint(-Settings.move_point_range_mid, Settings.move_point_range_mid)), Settings.max_height) print "point mutation mid" dna_draw.set_dirty() if (Tools.will_mutate(Settings.move_point_min_mutation_rate)): self.x = min( max( 0, self.x + np.random.randint(-Settings.move_point_range_min, Settings.move_point_range_min)), Settings.max_width) self.y = min( max( 0, self.y + np.random.randint(-Settings.move_point_range_min, Settings.move_point_range_min)), Settings.max_height) print "point mutation min" dna_draw.set_dirty() return self
def mutate(self,dna_draw): if (Tools.will_mutate(Settings.red_mutation_rate)): self.red = Tools.get_random_color() dna_draw.set_dirty() print "color mutation" if (Tools.will_mutate(Settings.green_mutation_rate)): self.green = Tools.get_random_color() dna_draw.set_dirty() print "color mutation" if (Tools.will_mutate(Settings.blue_mutation_rate)): self.blue = Tools.get_random_color() dna_draw.set_dirty() print "color mutation" if (Tools.will_mutate(Settings.alpha_mutation_rate)): self.alpha = Tools.get_random_alpha() dna_draw.set_dirty() print "color mutation" return self