giving speed info to brain
This commit is contained in:
4
brain.py
4
brain.py
@@ -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
2
car.py
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user