Skip to content

Commit

Permalink
Makes training updates weights on agent class
Browse files Browse the repository at this point in the history
  • Loading branch information
Rune Daugaard Harlyk authored and murrodroid committed Jan 10, 2024
1 parent b0960d1 commit f6451eb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions train_GeneticAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@

plot = ScatterPlot("Games", "Score", "Score per game | training")

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]
weight_score = [(weights, agent.get_fitness(env, weights)) for weights in agent.weights]
for i, (_, score) in enumerate(weight_score):
plot.add_point(i + gen * population_size, score, True)

Expand All @@ -50,9 +49,9 @@
if len(next_gen) % 2 == 1:
next_gen.append(child2)

population = next_gen
agent.weights = next_gen

print(f'Final best weights: {population[0]}')
print(f'Final best weights: {agent.weights[0]}')

plot.update()
plot.freeze()

0 comments on commit f6451eb

Please sign in to comment.