17class Snake():
18 snake, fruit = None, None
19
20 def __init__(self, s, genome): 21 self.genome = genome
22
23 self.s = s
32 self.fitness = 0.
33 self.last_dist = np.inf
34
35 def place_fruit(self, coord=None): 36 if coord:
37 self.fruit = np.array(coord)
38 return
34
35 def place_fruit(self, coord=None):
36 if coord:
37 self.fruit = np.array(coord) 38 return
39
40 while True:
35 def place_fruit(self, coord=None):
36 if coord:
37 self.fruit = np.array(coord)
38 return 39
40 while True:
41 x = random.randint(0, SCREEN_SIZE-1)
38 return
39
40 while True:
41 x = random.randint(0, SCREEN_SIZE-1) 42 y = random.randint(0, SCREEN_SIZE-1)
43 if list([x, y]) not in self.snake.tolist():
44 break
PEP8 recommends that Python code indentation be a multiple of four.