giving speed info to brain

This commit is contained in:
2019-10-29 11:39:07 +01:00
parent 5c27c3c72f
commit 545ffd21ac
2 changed files with 3 additions and 3 deletions

View File

@@ -13,9 +13,9 @@ class Neural_Network(object):
# inspired from https://enlight.nyc/projects/neural-network/ # inspired from https://enlight.nyc/projects/neural-network/
def __init__(self, W1=None, W2=None): def __init__(self, W1=None, W2=None):
# parameters # parameters
self.inputSize = 3 self.inputSize = 4
self.outputSize = 2 self.outputSize = 2
self.hiddenSize = 3 self.hiddenSize = 4
self.fitness = 0 self.fitness = 0
# weights # weights

2
car.py
View File

@@ -139,7 +139,7 @@ class Car(pygame.sprite.Sprite):
# print(self.probes) # print(self.probes)
def probe_brain(self): def probe_brain(self):
res = self.brain.predict(np.array(self.probes)) res = self.brain.predict(np.array(self.probes + [self.speed]))
self.heading_change = res[0] * 30 self.heading_change = res[0] * 30
self.throttle = res[1] * 5 self.throttle = res[1] * 5