Skip to content

Instantly share code, notes, and snippets.

@adpoe
Created December 15, 2016 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adpoe/6e52adb880071d903b72e76951d81bf0 to your computer and use it in GitHub Desktop.
Save adpoe/6e52adb880071d903b72e76951d81bf0 to your computer and use it in GitHub Desktop.
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