Skip to content

Commit

Permalink
refactor: convert to if-else one-liner
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFredrikJohnsen committed Nov 5, 2024
1 parent c2baf27 commit 35276fb
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def playback_genome(from_gen: int, to_gen: int, neat_name: str, environment: int
fitness = run_game_playback(env, state, genome, neat_name)
print(fitness)



def collect_fitnesses(genomes, generation, min_fitnesses, avg_fitnesses, best_fitnesses, neat_name):
fitnesses = [genome.fitness_value for genome in genomes]

Expand All @@ -76,7 +74,6 @@ def collect_fitnesses(genomes, generation, min_fitnesses, avg_fitnesses, best_fi

print(f"Generation: {generation} - Best: {max_fitness} - Avg: {avg_fitness} - Min: {min_fitness}")


def main(args):
neat_name = args.neat_name
print("\nTraining NEAT with name: ", neat_name)
Expand All @@ -89,10 +86,7 @@ def main(args):
neat = load_neat(neat_name)
if neat is not None: # TODO: Add option to insert new config into NEAT object.
generation_nums, best_fitnesses, avg_fitnesses, min_fitnesses = read_fitness_file(neat_name)
if len(generation_nums) == 0:
from_generation = 0
else:
from_generation = generation_nums[-1] + 1
from_generation = generation_nums[-1] + 1 if generation_nums else 0
neat.config = config_instance
else:
neat = NEAT(config_instance)
Expand Down

0 comments on commit 35276fb

Please sign in to comment.