add: horses can learn now

This commit is contained in:
KOSMOGOR
2025-04-10 14:04:56 +03:00
parent 46be023d9c
commit 010ccf313a
3 changed files with 11 additions and 22 deletions
+3 -1
View File
@@ -3,7 +3,7 @@ import sys
from gameobjects import *
from genetic_alg import GeneticAlgorithm
POPULATION_SIZE = 5
POPULATION_SIZE = 50
MUTATION_RATE = 0.5
POPULATION_BEST = 0.2
FRAME_RATE = 160 #TODO: FIX THE INCORRECT FRAME RATE CORRELATION
@@ -45,6 +45,7 @@ def init_game():
horse.set_vacceleration(0)
horse.set_vspeed(0)
horse.frame_counter = 0
horse.fitness = 0
spawner = Spawner("images/Barrier.png")
new_barrier = spawner.spawn()
barriers.append(new_barrier)
@@ -124,6 +125,7 @@ while True:
if all(horse.stopped for horse in horses):
UI.iteration_num += 1
genecticAlg.learn([x.fitness for x in horses])
init_game()
pygame.display.flip() # Update the display