Skip to content

Commit

Permalink
fix evaluate_generation() being called twice
Browse files Browse the repository at this point in the history
  • Loading branch information
pastra98 committed Apr 16, 2021
1 parent 1363489 commit c091943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/demos/cars/car_main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ func _physics_process(delta) -> void:
# check if the best agent exceeded the fitness threshold
ga.evaluate_generation()
if ga.curr_best.fitness > fitness_threshold:
# either resume with next generation or switch to demo-choosing scene
end_car_demo()
else:
# go to the next gen
ga.next_generation()
place_bodies(ga.get_curr_bodies())
# every x gens, increase the generation_step
if ga.curr_generation % 2 == 0:
generation_step += 6
print("increased step to " + str(generation_step))
total_time = 0
# go to the next gen
ga.next_generation()
place_bodies(ga.get_curr_bodies())
# every x gens, increase the generation_step
if ga.curr_generation % 2 == 0:
generation_step += 6
print("increased step to " + str(generation_step))
total_time = 0


func place_bodies(bodies: Array) -> void:
Expand Down
7 changes: 3 additions & 4 deletions src/demos/xor/xor_main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ func _process(_delta):
# if the fittest network reached the fitness threshold, end this test
if ga.curr_best.fitness > fitness_threshold:
end_xor_test()
# else start a new generation
else:
ga.next_generation()
place_testers(ga.get_curr_bodies())
# start a new generation
ga.next_generation()
place_testers(ga.get_curr_bodies())


func place_testers(testers: Array) -> void:
Expand Down

0 comments on commit c091943

Please sign in to comment.