Skip to content

Commit

Permalink
fix: fix bug with visualizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hako2807 committed Oct 22, 2024
1 parent f7137fc commit 86ed4ec
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gui_with_pygame.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def load_genomes(self):
genome_object = pickle.load(file)

# Append the loaded genome object to the list
self.genomes.append(genome_object)
self.genomes.append((genome_object, int(str(file_path).split("_")[-1][:-4])))
print(genome_object)

def get_genomes(self):
"""
Expand Down Expand Up @@ -194,24 +195,27 @@ def __init__(self, genomes, font, text_color, bg_color, selected_color):
def populate_genomes(self):
self.items.clear()
y_position = 50
for genome in self.genomes:
for genome, file_path in self.genomes:
genome_id = genome.id
fitness = genome.fitness_value
item = SelectableListItem(100, y_position, 400, 50, genome_id, fitness, self.font, self.text_color, self.bg_color, self.selected_color)
self.items.append(item)
self.items.append((item, file_path))
y_position += 60

def draw(self, screen):
for item in self.items:
item = item[0]
print(item)
item.draw(screen)

def handle_event(self, event):
for item in self.items:
item = item[0]
item.handle_event(event)

def get_selected_genomes(self):
# Return a list of selected genome IDs
return [item.id for item in self.items if item.selected]
return [item[1] for item in self.items if item[0].selected]


class Button:
Expand Down

0 comments on commit 86ed4ec

Please sign in to comment.