-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
47 lines (36 loc) · 1.35 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
class Settings():
#settings shared between snakes
def __init__(self):
self.scale = 20
self.windowSize = 400
self.xyMaxValue = self.windowSize - self.scale
self.gridUnits = self.windowSize / self.scale
self.framerate = 100
self.neutalNetworkDimensions = {"input" : 24, "hidden" : 16, "output" : 4}
''' '''
self.debug = False
self.profiling = True
''' Settings for snakes '''
self.generation = 0
self.numberOfSnakes = 1000
self.numberOfSnakesAlive = self.numberOfSnakes
self.totalFitness = 0
self.mutationRate = .01
self.globalBestScore = 0
self.globalBestIndex = 0
self.globalBestTotal = 0
''' for saving brain '''
self.whi = None
self.whh = None
self.woh = None
self.spawnLocations = self.__generateRandomFoodList()
def reset(self):
self.numberOfSnakesAlive = self.numberOfSnakes
self.totalFitness = 0
def __generateRandomFoodList(self):
#make the food locations the same for all snakes
spawnLocations = []
for i in range(1,100):
spawnLocations.append([np.random.randint(self.gridUnits) * self.scale, np.random.randint(self.gridUnits) * self.scale])
return(spawnLocations)