-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.py
43 lines (29 loc) · 928 Bytes
/
sketch.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
from p5 import *
from snake import Snake
from food import Food
from settings import Settings
from inputs import Inputs
from NeuralNetwork import NeuralNetwork
from population import Population
settings = Settings()
#create Popluation object with settings
P = Population(settings)
def setup():
size(settings.windowSize, settings.windowSize)
no_stroke()
background(0)
#setup population
P.setup()
def draw():
background(0)
#run population
P.run()
text("Generation: {}".format(settings.generation), (0,100), wrap_at=None)
text("Highest number of eats: {}".format(settings.globalBestTotal), (0, 120), wrap_at=None)
text("Mutation rate: {}".format(settings.mutationRate), (0, 140), wrap_at=None)
def key_pressed(event):
if(key == 'h'):
settings.mutationRate /= 2
if(key == 'd'):
settings.mutationRate *= 2
run(frame_rate = settings.framerate)