State Representations for a Flappy Bird AI
# first value in state tuple | |
height_category = 0 | |
dist_to_pipe_bottom = pipe_bottom - bird.y | |
if dist_to_pipe_bottom < 8: # very close | |
height_category = 0 | |
elif dist_to_pipe_bottom < 20: # close | |
height_category = 1 | |
elif dist_to_pipe_bottom < 125: #mid | |
height_category = 2 | |
elif dist_to_pipe_bottom < 250: # far | |
height_category = 3 | |
else: | |
height_category = 4 | |
# second value in state tuple | |
dist_category = 0 | |
dist_to_pipe_horz = pp.x - bird.x | |
if dist_to_pipe_horz < 8: # very close | |
dist_category = 0 | |
elif dist_to_pipe_horz < 20: # close | |
dist_category = 1 | |
elif dist_to_pipe_horz < 125: # mid | |
dist_category = 2 | |
elif dist_to_pipe_horz < 250: # far | |
dist_category = 3 | |
else: | |
dist_category = 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment