Skip to content

Commit

Permalink
Changes print of data
Browse files Browse the repository at this point in the history
  • Loading branch information
murrodroid committed Jan 10, 2024
1 parent 06c43a3 commit b0960d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions train_GeneticAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

population = agent.weights
total_scores = []

print(f'|==== # of generations: {num_gens}\t| Max steps: {max_steps}\t| Pop. size: {population_size}\t| # of elite/parents: {elite}/{num_parents} ====|')
for gen in range(agent.num_gens):
weight_score = [(weights, agent.get_fitness(env, weights)) for weights in population]
for i, (_, score) in enumerate(weight_score):
Expand All @@ -32,7 +34,7 @@
weights = [weight for weight, _ in weight_score]

total_scores += scores
print(f'| Generation: {gen+1:0{len(str(num_gens))}d}\t| Max steps: {agent.max_steps}\t| Pop. size: {agent.population_size}\t| High score: {np.max(scores)}\t| Mean score [Gen {gen+1}]: {np.round(np.mean(scores),2)}\t| Mean score [overall]: {np.round(np.mean(total_scores),2)}\t|')
print(f'| Generation: {gen+1:0{len(str(num_gens))}d}\t| Min./Mean/Max. [Gen {gen+1}]: {np.min(scores)} / {np.round(np.mean(scores),2)} / {np.max(scores)}\t| Min./Mean/Max. [Overall]: {np.min(total_scores)} / {np.round(np.mean(total_scores),2)} / {np.max(total_scores)}\t|')

next_gen = weights[:agent.elite]
parents = weights[:agent.num_parents]
Expand All @@ -43,8 +45,8 @@
child1, child2 = agent.breed(parent1, parent2)
else:
child1, child2 = parent1, parent2

next_gen.append(child1)

if len(next_gen) % 2 == 1:
next_gen.append(child2)

Expand Down

0 comments on commit b0960d1

Please sign in to comment.