Created
December 15, 2016 01:27
-
-
Save adpoe/6e52adb880071d903b72e76951d81bf0 to your computer and use it in GitHub Desktop.
State Representations for a Flappy Bird AI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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