TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Hacking Flappy Bird with Machine Learning

243 pointsby sarvagyavaishover 11 years ago

22 comments

habosaover 11 years ago
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.<p>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 servos. Would be a very interesting project.<p>Edit: I&#x27;m thinking I could run an Android emulator, and then use MonkeyRunner with Python OpenCV processing my monitor to do the work. Anyone who has any relevant experience please reply, I&#x27;d love to hear if this is feasible.
评论 #7246079 未加载
评论 #7246599 未加载
评论 #7246373 未加载
评论 #7265384 未加载
评论 #7246117 未加载
dwetterauover 11 years ago
Neat AI approach to play it. When this first blew up 5 or so days ago I threw together a simple javascript bookmarklet that played the game at: <a href="http://www.mrspeaker.net/dev/game/flappy/" rel="nofollow">http:&#x2F;&#x2F;www.mrspeaker.net&#x2F;dev&#x2F;game&#x2F;flappy&#x2F;</a><p>It&#x27;s really poorly formatted and has unused code in it but it was fun to automate and watch. <a href="http://pastebin.com/yTmdWgfC" rel="nofollow">http:&#x2F;&#x2F;pastebin.com&#x2F;yTmdWgfC</a><p>To use it just install the bookmarklet, click on it and then start the game. Press space to make it die.
brandonbover 11 years ago
Very cool! It&#x27;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.<p>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? <a href="http://en.wikipedia.org/wiki/Line_search" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Line_search</a>
评论 #7246064 未加载
potashover 11 years ago
How hard would it be to solve this deterministically?<p>Can someone comment on the game&#x27;s physics? I am assuming:<p><pre><code> - constant horizontal velocity - gravity - flapping implemented via impulse - collisions are handled with bounding boxes </code></pre> Maybe someone who knows something about optimal control (ODE) say whether this is analytically solvable? Of course there&#x27;s still the practical stuff (numerical integration, I&#x2F;O lag) to deal with but I&#x27;m optimistic.
评论 #7246274 未加载
评论 #7249452 未加载
Blahahover 11 years ago
By far the most interesting &#x27;flappy bird&#x27; post so far.
primaryobjectsover 11 years ago
Neat. You could also probably do this with a genetic algorithm. Thinking out loud here:<p>- Have a neural network with 6 inputs for:<p><pre><code> - player x - player y - acceleration speed - acceleration direction - next pipe mid-point x - next pipe mid-point y</code></pre> - Two outputs of 0 or 1 for click or no-click<p>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 as possible to fly between the pipes. The genetic algorithm would select the best neural network that knows when to flap based on the current input state.
评论 #7247663 未加载
评论 #7246482 未加载
foglemanover 11 years ago
I&#x27;d like to see a two-dimensional chart that plots Click vs Do Nothing for the two input parameters. (Vertical distance from lower pipe and Horizontal distance from next pair of pipes)
评论 #7246123 未加载
piloochover 11 years ago
Reinforcement learning (RL) is the future of real-world AI. Bear my words ;) RL has been around for a long time, it is the mix of optimal (in the optimization sense) decision making along with machine learning (ML). It does benefit of most recent advances in ML. As such it is likely to power the next batch of &#x27;intelligent&#x27; applications and services.
foglemanover 11 years ago
The GIF shown on this page makes it look like the input space could simply be pipe height and bird height.<p><a href="https://github.com/zachhuff386/flapbot" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zachhuff386&#x2F;flapbot</a>
mrtksnover 11 years ago
I was waiting for something like this, but I expected somebody to build a flappy bird playing robot :)<p>Do you know some good literature for machine learning 101? Where to start?
评论 #7246002 未加载
评论 #7246053 未加载
ronaldxover 11 years ago
The video seems jerky in a way which suggests the engine is taking longer to make decisions at certain points in the cycle.<p>Is that plausible? Or just my imagination?
bjdover 11 years ago
How funny is it that I find this post by searching for monkeyrunner and opencv? When I was looking into this for the same silly reason.
shurcooLover 11 years ago
This reminds me (vaguely) of the AI I made for a worm-in-tunnel game long ago.<p><a href="https://dl.dropboxusercontent.com/u/8554242/available-for-2-weeks/wormFX_2003.swf" rel="nofollow">https:&#x2F;&#x2F;dl.dropboxusercontent.com&#x2F;u&#x2F;8554242&#x2F;available-for-2-...</a><p>(It&#x27;s there in the background of the main menu.)
bamosover 11 years ago
Cool post! Minor typo: Monekyrunner -&gt; monkeyrunner
judkover 11 years ago
If you learn that all actions `a` from state `s_i` have very low reward, does that propagatet backward to `s_j,a` that feed into `s_i`?
FlyingLawnmowerover 11 years ago
Beating the unbeatable with science. I like it.
nathan_f77over 11 years ago
Had the same idea when I first played the game, but didn&#x27;t do anything about it. Well done for doing it!
vinchucoover 11 years ago
good job! now you have to do it with <a href="http://corpsmoderne.itch.io/flappy-space-program" rel="nofollow">http:&#x2F;&#x2F;corpsmoderne.itch.io&#x2F;flappy-space-program</a> and deal with the complications
kookiekrakover 11 years ago
can you build one for this? <a href="http://kookiekrak.itch.io/flappy-pipes" rel="nofollow">http:&#x2F;&#x2F;kookiekrak.itch.io&#x2F;flappy-pipes</a>
评论 #7246283 未加载
geek90over 11 years ago
Awesome work!
kevoncover 11 years ago
impressive work man!
dpanahover 11 years ago
Tre sweet