r/Python • u/The_Regent • Oct 06 '19
Playing Flappy Bird with Mixed Integer Programming
3
u/appsplaah Oct 07 '19
Awesome! I am a newbie to python, but wont be for much long.
Do you mind telling me how did you do it? Might help newbies like me.
The way i think is you took the flappy bird ios/android app and then "by some way" you integrated your Python algorithm(correct me if i am wrong).
Just curious about it :p Thanks for the Inspiration!
3
u/The_Regent Oct 07 '19
Nope. We used a python flappy bird clone written in pygame (that we did not write) as a starting point. So the whole thing is in python. The hack you're suggesting would be significantly harder.
The original: https://github.com/sourabhv/FlapPyBird
Our modified fork: https://github.com/philzook58/FlapPyBird-MPC
4
14
u/davidwolf995 Oct 07 '19
It's guys like you that motivate me to keep learn python. This is amazing.
2
u/MaesterCrow Oct 07 '19
So basically your controlling the birds future?
8
3
u/ishmandoo Oct 07 '19
Basically! We predict into the future in order to correctly plan the next step.
28
u/Unlock17A Oct 06 '19
There's no way this is og flappy bird. Og one was so much harder
38
4
3
5
u/fenom500 Oct 07 '19
It really wasn’t though, at least not at lower numbers like this. I was easily getting to 200 so with a computer playing, it looks even easier
11
u/Ph0X Oct 07 '19
I'm not saying the original was impossible but it was still harder than this. The bounces were basically the same height as the distance between pipes or more, so to pass through, you needed to press space lower than the bottom pipe. Here, the bird is doing lots of tiny bounces that are 1/3 the height of the entrance. This is nowhere near the real difficulty...
This implementation is the one posted on this sub a month ago. It's not the real game, but a remake in python, and it definitely does not have the same parameters when it comes to jump height and pipe distance.
4
u/ishmandoo Oct 07 '19
You're definitely right that this isn't the original implementation and I think you're right about the jump height too. I'll make the jump height bigger tonight and see how it runs. Feel free to clone the the repo and play with the parameters.
3
u/SAI_supremeAI Oct 07 '19
Just Wow. Can i see the mathematical model.
4
3
1
84
u/The_Regent Oct 06 '19
My friend Ben and I wrote up a controller for flappy bird. cvxpy for the win!
Code here: https://github.com/philzook58/FlapPyBird-MPC
and our blog posts here:
http://www.philipzucker.com/flappy-bird-as-a-mixed-integer-program/
http://blog.benwiener.com/programming/2019/10/06/flappy-bird-mpc.html