Greetings to you all,
I would like to create an AI capable of playing flappy bird, to do this I took the example of the bullet code video.
So I created my flappy bird game, and all I have to do is create the AI, but it needs input values. In the bullet code video it takes as input values the vertical distance between the bird and the top of the pipe, the same for the bottom of the pipe, the horizontal distance from the pipe and finally the horizontal velocity of the bird.
The only problem I have is that I don’t know how to get these values (knowing when once the bird passes through the first pipe, I need the values of the second pipe).
If you’ve got a trick for me, I’ll take it.
This is a huge multi-discipline endeavor if you’re looking for the general case. Your AI has to:
- figure out where it is (distance to next gap)
- figure out the gap position (position and height)
- know how much it will go up from a “tap”
- know the ballistic physics that will cause it to arc back downwards
- choose precisely when to execute that tap to get through.
If instead you are willing to “feed” the height and position of the next hole to your AI, then you might have an easier time of predicting when to tap. Ideally you could just make some tables of heuristics to apply to get it to be close to the gap. Once you have the correct values, the game would likely play perfectly, assuming the gaps and the gap-to-gap spacing are such that it CAN be done in the first place.
Try this as a starter: make an AI that just tries to keep the flappy bird at a particular altitude on a completely-empty horizontally-scrolling screen.
This simpel AI would watch the bird position and when it falls below its desired height, press tap. That’s it.
Watch how that goes and when you have that working, then you can make something that adjusts the desired height based on where you click onscreen. Now you can have it follow your clicks.
When you get that far, now you can start feeding the next gap height into the AI, and you should have at least something starting to look useful. Everything else will be fiddling with timing and distance-to-jump, etc.