diff --git a/src/p2lab/genetic/genetic.py b/src/p2lab/genetic/genetic.py index 6368284..f111bea 100644 --- a/src/p2lab/genetic/genetic.py +++ b/src/p2lab/genetic/genetic.py @@ -145,8 +145,9 @@ async def genetic_algorithm( # Only do this step if not mutating with fitness, as fitness scores become # invalid after crossover if doing so if not mutate_with_fitness: - new_teams = crossover_fn( + new_teams, new_fitness = crossover_fn( teams=new_teams, + fitness=new_fitness, num_teams=num_teams, num_pokemon=team_size, crossover_prob=crossover_prob, diff --git a/src/p2lab/genetic/operations.py b/src/p2lab/genetic/operations.py index 10bca47..0205caf 100644 --- a/src/p2lab/genetic/operations.py +++ b/src/p2lab/genetic/operations.py @@ -55,6 +55,7 @@ def build_crossover_fn( def crossover_fn( teams: list[Team], + fitness: np.ndarray, num_teams: int, num_pokemon: int, crossover_prob: float, @@ -117,8 +118,9 @@ def crossover_fn( # best to run an even number of teams lol if num_teams % 2 != 0: new_teams.pop() + fitness = fitness[:-1] - return new_teams + return new_teams, fitness return crossover_fn