Esempio n. 1
0
 def change_properties(self):
     self.segment_number = Af.randint(5, 7)
     self.internal_beam_radius = 2 * self.segment_number
     self.external_beam_radius = Af.get_fibonacci(self.segment_number)
     self.frame = 0
     self.segments_coo = [self.starting_point_coo]
     self.last_segment_direction = Af.choice([-1, 1])
Esempio n. 2
0
 def __init__(self):
     self.internal_list = []
     self.first_parts = True
     self.choices = [20, 121, 240]
     self.y = Af.choice(self.choices)
     self.dist_between_parts = 5 + 44
     self.min_dist_between_blocs = 100
     self.max_dist_between_blocs = 200
     self.min_parts = 3
     self.max_parts = 7
Esempio n. 3
0
 def set_up_texts(self, first=False):
     self.text_name = Af.choice(Af.get_text_names())[:-4]  # chooses random text from existing texts
     self.text_to_write_image = Af.load_image(f"texts/{self.text_name}.png")  # loads the text's image
     lines = Af.read_file_content(f"texts/{self.text_name}.txt")  # loads the text's content
     self.text_to_write = [line.split(" ") for line in lines[1:]]  # sets the text in proper format
     self.screen.blit(self.text_to_write_image, (280, 320))
     image = Af.get_text_images("")  # turns written text into images to display
     self.written_text_images = [image, image, image, image, image, image, image, image]
     self.written_text = [[""]]
     self.line = 0  # sets current line to 0 (beginning)
     self.max_lines = int(lines[0])  # gets the number of lines that the chosen text has
Esempio n. 4
0
 def create_parts(self):
     dist_between_blocs = Af.randint(self.min_dist_between_blocs,
                                     self.max_dist_between_blocs)
     type_p = self.calculate_type_part()
     if self.first_parts:
         for i in range(Af.randint(self.min_parts, self.max_parts)):
             self.internal_list.append(
                 _part(
                     space_between_obstacles[-1] + dist_between_blocs +
                     i * self.dist_between_parts, type_p, self.y, i % 10))
         self.first_parts = False
         return 0
     if self.control_last():
         for i in range(Af.randint(self.min_parts, self.max_parts)):
             self.internal_list.append(
                 _part(
                     space_between_obstacles[-1] + dist_between_blocs +
                     i * self.dist_between_parts, type_p, self.y, i % 10))
         self.y = Af.choice(self.choices)
         return 0
Esempio n. 5
0
    def create_individual(self):
        hidden_1 = [[
            Af.random() * Af.choice([1, -1]) for _ in range(self.inputs)
        ] for _ in range(self.inputs)]
        hidden_2 = [[
            Af.random() * Af.choice([1, -1]) for _ in range(self.inputs)
        ] for _ in range(7)]
        output = [[Af.random() * Af.choice([1, -1]) for _ in range(7)]
                  for _ in range(3)]
        self.weights = [hidden_1, hidden_2, output]

        hidden_1 = [
            Af.random() * Af.choice([1, -1]) for _ in range(self.inputs)
        ]
        hidden_2 = [Af.random() * Af.choice([1, -1]) for _ in range(7)]
        output = [Af.random() * Af.choice([1, -1]) for _ in range(3)]
        self.bias = [hidden_1, hidden_2, output]
Esempio n. 6
0
 def calculate_type_part():
     return Af.choice([1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4,
                       5])  # random type (some are more rare than others)
Esempio n. 7
0
 def calculate_position_y(self, ultimo_y):
     if ultimo_y == 0:
         return Af.choice([20, 130, 240]) + self.adjust
     possibilities = {20: [130, 240], 130: [20, 240], 240: [130, 20]}
     return Af.choice(possibilities[ultimo_y - self.adjust]) + self.adjust