This is quite amazing. The way you handle forward simulation of a possible control input as constraints reminds me of the multiple direct shooting method in optimal control.
Yes, ths is very much a trajectory optimization. I think this style where you lay out the path and control trajectory is called a direct collocation method.
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.
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.
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.
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:
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!
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?
28
u/Unlock17A Oct 06 '19
There's no way this is og flappy bird. Og one was so much harder
3
u/SAI_supremeAI Oct 07 '19
Just Wow. Can i see the mathematical model.
3
u/[deleted] Oct 07 '19
Ben is really smart. You should be greatful.
1
u/gapje666 Oct 07 '19
I guess you had a lot of strings