def draw_current_population(self): # center text: # (x, y, width_X, length_Y) (textbox) row_pitch = C.row_pitch max_length = self.width // 4 - 2 * row_pitch center_pos = [7 * self.width // 8, 0] sample = ''.join(self.pop.population[0].genes) size = Textbox.shift_size(sample, C.pop_size, C.font, max_length) font = pygame.font.SysFont(C.font, size) n = 0 for individual in self.pop.population: string = ''.join(individual.genes) txt = font.render(string, True, C.text_color) center_pos[1] += +size * (n + 1) + row_pitch txt_rect = txt.get_rect(center=center_pos) if center_pos[1] < self.height - row_pitch - txt.get_rect()[3]: self.game_display.blit(txt, txt_rect)