Live data from Hacker News

Hacking Flappy Bird with Machine Learning

sarvagyavaish.github.io

41–50 of 56 posts

Re: Hacking Flappy Bird with Machine Learning

#41
post #18
post #14

I really want to build a Lego Mindstorms robot (or similar) that watches my phone with a webcam, holds a stylus, and plays Flappy Bird. I have played enough (high score 194) that I am pretty sure I know the right strategy, I just want to take human error out of the equation. Are there open source vision libraries that are low-latency enough to play this in real time? Assuming the robot could keep up with some regular…

Someone made a robot that played Angry Birds: https://us.pycon.org/2012/schedule/presentation/470/ I was wondering if this would work for Flappy birds. Due to the speed of the game, I think it is going to be quite a challenge. P.S. If you are interested in the mindstorms robot part, I'll put a shameless plug for a robot I built some time ago (based on some work by David Singleton). Code is on github but here is a pyc…

Ohai! (I presented that Angry Birds bot at PyCon.) My bot is now called "Tapster" and I continue to make improvements. It's completely open-source; I'd love to expand the community of game-playing bot fans. (http://tapsterbot.com) I even created a 3d-printable LEGO Technic-compatible building material to make the bot. (http://bitbeam.org)

I'm working on training Tapster to play Flappy Bird. I'm going down the route of webcam + OpenCV.

Re: Hacking Flappy Bird with Machine Learning

#42

Earlier quoted context omitted.

If you play the game, it's actually quite trivial to program deterministically. :-) Flapping is not implemented as an impulse. It's more like jumping in Mario - it instantaneously fires a canned "flap" movement that is always the same. Set flap_height = bottom of next pipe + constant. If bird height Done!

It also looks like you'd want to avoid flapping into the top of the pipe.

Perhaps I should have said "threshold_height".

    threshold_height = bottom_of_pipe_height + 10 pixels; // or something

    if (current_height 
If you never flap when above the threshold, you will not hit the top.

Re: Hacking Flappy Bird with Machine Learning

#45
post #33

Earlier quoted context omitted.

holy shit you sound like a crack addict (only with flappy bird) - they say it's addictive but you're taking this to another level. "Man I need to do a Lego Mindstorms robot with a webcam and stylus and OpenCV - I've gotten to 194 but I NEED more. I need to take the human element out of this equation...."

A worrying amount of serious CS effort was put into the problem of Sudoku solving after it became a big hit.

Logical Conclusion: All computer scientists are crack addicts.

Re: Hacking Flappy Bird with Machine Learning

#46
post #14

I really want to build a Lego Mindstorms robot (or similar) that watches my phone with a webcam, holds a stylus, and plays Flappy Bird. I have played enough (high score 194) that I am pretty sure I know the right strategy, I just want to take human error out of the equation. Are there open source vision libraries that are low-latency enough to play this in real time? Assuming the robot could keep up with some regular…

holy shit you sound like a crack addict (only with flappy bird) - they say it's addictive but you're taking this to another level. "Man I need to do a Lego Mindstorms robot with a webcam and stylus and OpenCV - I've gotten to 194 but I NEED more. I need to take the human element out of this equation...."

It's a joke guys. I left it at +4 if I saw the downvotes I would have deleted it.

Re: Hacking Flappy Bird with Machine Learning

#47

Neat. You could also probably do this with a genetic algorithm. Thinking out loud here: - Have a neural network with 6 inputs for: - player x - player y - acceleration speed - acceleration direction - next pipe mid-point x - next pipe mid-point y - Two outputs of 0 or 1 for click or no-click The fitness score would be how close the player is to the pipe mid-point. Hopefully, this would cause the bird to stay as close…

I'm curious, I've thought about using genetic algorithms for training neural nets before, but haven't seen it mentioned much. I imagine PSO could work as well. What is the general concensus on using algorithms other than back propagation for neural net learning? When is it appropriate / not appropriate?

Re: Hacking Flappy Bird with Machine Learning

#48

Neat. You could also probably do this with a genetic algorithm. Thinking out loud here: - Have a neural network with 6 inputs for: - player x - player y - acceleration speed - acceleration direction - next pipe mid-point x - next pipe mid-point y - Two outputs of 0 or 1 for click or no-click The fitness score would be how close the player is to the pipe mid-point. Hopefully, this would cause the bird to stay as close…

I'm curious, I've thought about using genetic algorithms for training neural nets before, but haven't seen it mentioned much. I imagine PSO could work as well. What is the general concensus on using algorithms other than back propagation for neural net learning? When is it appropriate / not appropriate?

Some people frown upon training neural networks with genetic algorithms, just because gen algs are so random and hard to dissect. I think it's silly to discard anything that is a potential solution to a problem.

I go by a rule of thumb like this:

- If you are able to collect lots of training data (inputs and valid outputs) then use back-propagation. It's faster and you might get better results.

- If you don't know the outputs for inputs or if there are simply too many possible combinations (such as in the case of a game), then use a genetic algorithm. It's effectively a search engine that finds the best solution within the problem space (the solution being the optimal weights for the neural network).

Using Neural Networks and Genetic Algorithms http://primaryobjects.com/CMS/Article105.aspx

Re: Hacking Flappy Bird with Machine Learning

#49
post #14

I really want to build a Lego Mindstorms robot (or similar) that watches my phone with a webcam, holds a stylus, and plays Flappy Bird. I have played enough (high score 194) that I am pretty sure I know the right strategy, I just want to take human error out of the equation. Are there open source vision libraries that are low-latency enough to play this in real time? Assuming the robot could keep up with some regular…

What do you mean strategy? I only played on http://flapmmo.com but it seemed like it was only a game of reflex (I got to level 12).

I mean as far as when I should tap based on height and distance to the next obstacle. I try to be consistent but obviously a robot would be better.

Re: Hacking Flappy Bird with Machine Learning

#50

Very cool! It's remarkable that you can get a good score with effectively only two features: vertical distance from the lower pipe and horizontal distance from the next pair of pipes. I suspect you could cut the training time by an order of magnitude with a different optimization algorithm, or just by varying alpha. For example, have you considered trying something like a line search? http://en.wikipedia.org/wiki/Lin…

reenforcement learning is not an optimization algorithm, and his times are consistent with an off the shelf Q-learning approach. reenforcement learning is trying to find the optimal policy of action from a given position in the discrete state space. The policy is roughly a map between state -> action. But it understands the temporal nature of the world. It will start knowing nothing, then discover hitting a pipe is r…

You could set up a cost function to account for closeness to being hit (a.k.a. decision theory approach)
Post reply on HN