I made flappy using the NEAT AI and the I finally got the game to run with NEAT. The problem is that with the 100 birds I made their either going diagonally up or down and not going through the pipes at all. in the part of my code where I define the outputs, I have the bird distance from the top, bottom, and middle of the pipe its closest to and currently looking at it I dont see what the problem is:
# FINDING THE INDEX OF THE PIPE THATS IN FRONT OF THE BIRD
pipe_ind = 0
if len(birds) > 0:
if len(pipes) > 1 and birds[0].x > pipes[0].pipe_bottom_rect.centerx + pipes[0].pipe_top.get_width():
pipe_ind = 1
else:
run == False
break
# GIVING THE NETWORK DISTANCE OF THE BIRD TO THE TOP BOTTOM AND MIDDLE OF THE PIPE
for x, bird in enumerate(birds):
bird.move()
ge[x].fitness += 0.1
output = nets[x].activate((bird.y, abs(bird.y - pipes[pipe_ind].height - 200), abs(bird.y - pipes[pipe_ind].height)))
if output[0] > 0.5:
bird.jump()
With 3 distances it should give the bird proper guidance to go through the pipes but it makes all my birds end up going in one of two directions. Is it because I'm using absolute values? I'm new to using neat so i'm still learning as I go along.
Full GitHub Repo: https://github.com/sharktankful/Flappy_Bird_AI