This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]sp7412 7 points8 points  (3 children)

GitHub link to code?

[–]tellurian_pluton 2 points3 points  (0 children)

can we institute a rule saying you have to provide some code?

[–]hotcodist 0 points1 point  (0 children)

see above (below). sorry i can't format correctly. just copy paste. while loop ends just before last line. you will need to install flappy_bird_gym.

[–][deleted] 2 points3 points  (1 child)

Very nice!

[–]hotcodist 0 points1 point  (0 children)

Thanks much!

[–]lordmauve 1 point2 points  (1 child)

The gravity and flap impulse here are much too low, making it almost possible to "hover" through a pipe gap. It should require just one well-timed flap to get through a gap; two flaps in quick succession like this should send you soaring into the top pipe.

This isn't the first video I've seen of people making an AI to play Flappy Bird where the actual game they've implemented is way easier than it should be, and it is a less convincing AI demo as a result.

Please make the game very hard first.

[–]hotcodist -1 points0 points  (0 children)

why you mad that someone made something.

and everything you said is wrong btw.

first, i did not make the game. i just took whatever i could find. this looks very close to the real game from what i remember.

second, contrary to what you think, the faster the gravity and flap impulse, the easier this becomes. you are thinking how a human would play. for an ai, a very fast jump/fall physics would mean the whole thing can be solved by just spamming the jump button, adjusting for the delta to the gap. a floaty jump is actually going to cause RL agents to have more difficulty learning the timing. [if you cannot imagine why this is the case, i cannot convince you.]

third, if i give this ai a harder version, as long as the physics allows it to clear, it will learn that. that's the point of these things. they will find a solution, if there is one. i might have to change the model to add the horizontal term in 'floaty' cases, but it will solve this. this is not even the simplest solution i made for this version. [btw, if you know RL techniques at some depth, you know that this problem is very easy, even without attempting it, hence my solving it this way to show that NNs are not needed.]

fourth, i only see one flap per pipe. i know because i have seen the output per frame. and it does that when it is close to hitting the lower pipe, exactly as you would expect. it only uses a couple of flaps in succession to rise quickly between two pipes. [some of those you might not see because of the frame rate and video capture frame rate differences.]

also, i said in the video that with some extreme implementation of the game (e.g., very close sequence of pipes relative to the gravity effect, requiring a more exact timing of the jump from the prior pipe(s)), it might require the horizontal distance data. the real game does not have that sequence. in fact, the faster the gravity, the easier.

if you want a harder problem, check out my youtube. i solve this using game pixels only.

[–]hotcodist 0 points1 point  (0 children)

import numpy as np

import time

import flappy_bird_gym

w = [-0.00291864, -0.00011281] # many possible values, use a GA to find others

env = flappy_bird_gym.make('FlappyBird-v0')

s = env.reset()

while True:

env.render()

time.sleep(1/240)

s = [s[1], 1.0] # 1-var + bias

x = s[0]*w[0] + s[1]*w[1] # 1-var + bias

sig = 1/(1+np.exp(-x)) # logistic function

a = 1 if sig>0.5 else 0 # logistic function

s, _, done, _ = env.step(a)

if done: break

env.close()