# I created a snake game and fitted the NEAT algorithm and there's issues

Below are my Inputs Outputs and fitness function. The snake is learning at a slow rate, and seems to be stagnant, additionally when the snake collides with the food, it gets deleted from the genome, which doesn't make any sense because that's not specified in the collision. Any input would be greatly appreciated

for x, s in enumerate(snakes):
# inserting new snake head and deleting the tale for movement

# inputs
snake_length = len(s.snake_position)
snakefoodDistEuclidean = math.sqrt((s.x - food.x) ** 2 + (s.y - food.y) ** 2)
snakefoodDisManhattan = abs(s.x - food.x) + abs(s.y - food.y)
xdis = s.Xdis()
ydis = s.Ydis()
s.dis_list1.append(snakefoodDistEuclidean)
s.dis_list2.append(snakefoodDisManhattan)
s.dis_list3.append(s.Xdis())
s.dis_list4.append(s.Ydis())
s.hunger_list.append(s.hunger)
#print('Euclidean: ', dis_list1[-1])
#print('Manhattan: ', dis_list2[-1])
#print('X distance from Wall: ', dis_list3[-1])
#print('Y distance from Wall: ', dis_list4[-1])

output = nets[snakes.index(s)].activate((s.hunger, s.x, s.y, food.x, food.y, snakeheadBottomDis,
snakefoodDisManhattan, snakefoodDistEuclidean,s.dis_list1[-1],s.dis_list1[-2],
s.dis_list2[-1],s.dis_list2[-2],s.dis_list3[-1],s.dis_list3[-2],
s.dis_list4[-1],s.dis_list4[-2],s.hunger_list[-1],s.hunger_list[-2]))

#snake moving animation
s.snake_position.pop()
s.hunger -= 1

# Checking distance Euclidean and Manhattan current and last
if s.dis_list1[-1] > s.dis_list1[-2]:
ge[x].fitness -= 1

if s.dis_list1[-1] < s.dis_list1[-2]:
ge[x].fitness += 0.5

if s.dis_list1[-1] > s.dis_list2[-2]:
ge[x].fitness -= 1

if s.dis_list1[-1] < s.dis_list2[-2]:
ge[x].fitness += 0.5

#checking hunger number and if its decreasing
if s.hunger_list[-1] < s.hunger_list[-2]:
ge[x].fitness -= 0.1

# move right
if output[0] >= 0 and output[1] < 0 and output[2] < 0 and output[
3] < 0:
#and s.x < win_w - s.width and s.y > 0 + s.height:
# ge[x].fitness += 0.5
s.move_right()

# move left
if output[1] >= 0 and output[0] < 0 and output[2] < 0 and output[
3] < 0:
#and s.x < 500 - s.width and s.y > 0 + s.height:
#ge[x].fitness += 0.5
s.move_left()

# move down
if output[2] >= 0 and output[1] < 0 and output[0] < 0 and output[
3] < 0:
#and s.x < 500 - s.width and s.y > 0 + s.height:
# ge[x].fitness += 0.5
s.move_down()

# move up
if output[3] >= 0 and output[1] < 0 and output[2] < 0 and output[
3] < 0:
#and s.x < 500 - s.width and s.y > 0 + s.height:
# ge[x].fitness += 0.5
s.move_up()

#adding more fitness if axis aligns
ge[x].fitness += 0.1
ge[x].fitness += 0.1

# checking the activation function tanh
# print ('output 0: ', output[0])
# print('output 1: ', output[1])
# print ('output 2: ', output[1])
# print ('output 3: ', output[1])

# snake poping on other side of screen if screen limit reached
if s.snake_head[0] >= win_w - s.width:
if s.snake_head[0] <= 11 + s.width:
s.snake_head[0] = win_w - s.width - 1
if s.snake_head[1] >= win_h - s.height:
if s.snake_head[1] <= 11 + s.height:
s.snake_head[1] = win_h - s.height - 1

#s.x < 0 + s.width or s.x > win_w - s.width or s.y < 0 + s.height or \
#s.y > win_h - s.height or

#if run into self you die
ge[x].fitness -= 10
snakes.pop(x)
nets.pop(x)
ge.pop(x)

#if hunger reaches 0 you die
if s.hunger == 0:
ge[x].fitness -= 5
snakes.pop(x)
nets.pop(x)
ge.pop(x)

#if snake collides with food award fitness
if s.getRec().colliderect(food.getRec()):
ge[x].fitness += 100
s.hunger = 100
score += 1
food.y = random.randint(0 + 24, 500 - 24)
food.x = random.randint(0 + 24, 500 - 24)

# print(s.hunger)


So, I suggest you to try giving fitness only when your snake is eating food, and maybe remove some as time passes (because of hunger). Your fitness could even be just the time a snake survived, since to survive your snakes have to eat, and avoid touching themselves! Definitely try this: just giving fitness as time passes!
The snake doesn't need to know his position, he just need to know the distance between him and the food, and the angle between the direction of the snake (him) and the food.