Merge branch 'emil'
This commit is contained in:
@@ -65,6 +65,7 @@ class Horse(GameObject):
|
|||||||
self.vspeed = 0
|
self.vspeed = 0
|
||||||
self.vacceleration = 0
|
self.vacceleration = 0
|
||||||
self.stopped = False
|
self.stopped = False
|
||||||
|
self.fitness = 0
|
||||||
self.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # Random color for the mark
|
self.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # Random color for the mark
|
||||||
self.ribbon_fill = GameObject("images/Ribbon_fill.png", self.x, self.y, (16, -1))
|
self.ribbon_fill = GameObject("images/Ribbon_fill.png", self.x, self.y, (16, -1))
|
||||||
self.ribbon_fill.recolor(self.color)
|
self.ribbon_fill.recolor(self.color)
|
||||||
@@ -102,6 +103,9 @@ class Horse(GameObject):
|
|||||||
self.frame_counter = 0
|
self.frame_counter = 0
|
||||||
self.current_frame = (self.current_frame + 1) % len(self.images)
|
self.current_frame = (self.current_frame + 1) % len(self.images)
|
||||||
self.image = self.images[self.current_frame]
|
self.image = self.images[self.current_frame]
|
||||||
|
def count_fitness(self):
|
||||||
|
if self.stopped == False:
|
||||||
|
self.fitness += 1
|
||||||
|
|
||||||
class Background(GameObject):
|
class Background(GameObject):
|
||||||
def __init__(self, image_path, x, y):
|
def __init__(self, image_path, x, y):
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ def get_features(horse):
|
|||||||
last_barrier.rect.bottomright[0], last_barrier.rect.bottomright[1],
|
last_barrier.rect.bottomright[0], last_barrier.rect.bottomright[1],
|
||||||
horse.rect.topleft[0], horse.rect.topleft[1],
|
horse.rect.topleft[0], horse.rect.topleft[1],
|
||||||
horse.rect.bottomright[0], horse.rect.bottomright[1],
|
horse.rect.bottomright[0], horse.rect.bottomright[1],
|
||||||
HEIGHT, BARRIER_SPEED]
|
HEIGHT, BARRIER_SPEED, 0]
|
||||||
return features
|
return features
|
||||||
|
|
||||||
genecticAlg = GeneticAlgorithm(POPULATION_SIZE, MUTATION_RATE, POPULATION_BEST, 10)
|
genecticAlg = GeneticAlgorithm(POPULATION_SIZE, MUTATION_RATE, POPULATION_BEST, 10)
|
||||||
@@ -91,6 +91,7 @@ while True:
|
|||||||
horse.stop() # Stop the horse
|
horse.stop() # Stop the horse
|
||||||
if horse.rect.colliderect(upper_bound_rect) or horse.rect.colliderect(lower_bound_rect):
|
if horse.rect.colliderect(upper_bound_rect) or horse.rect.colliderect(lower_bound_rect):
|
||||||
horse.stop()
|
horse.stop()
|
||||||
|
horse.count_fitness
|
||||||
|
|
||||||
|
|
||||||
for object in gameobjects:
|
for object in gameobjects:
|
||||||
|
|||||||
Reference in New Issue
Block a user