Thank you for your comments
It freaked me out a bit after a while of just running in circle it took me down super easily.
Very 'it reads my mind'/'it knows the future' feeling with 'I must think and do random things to confuse it' element to it.
Very fun thing to do for few minutes.
In the first few seconds, the ball is just plain stupid and is basically following you so you make a few moves so it can start learning your movements. Passed that, the real thing begins.
I could make it a little less dumb (make it assume in the beginning that you will continue in your current trajectory), but that would make the beginning of the game much harder, which would be really discouraging. It is better to let the player hope things will be easy for a few seconds
Interesting gameplay... How does the AI work? Did you implement the learning from scratch or did you employ established AI techniques?
I don't know if it's an established technique. Basically, I have an enum "Orientation" storing all possible movements (nothing, up, up-left, up-right, left, down-left, down, ...) and an array Orientation [4096]. Each game cycle I store the player's current movement in the table.
Then, in order to predict, I just take the player's last 256 orientations and try to match them with some other 256 contiguous orientations in the past (recorded in the array). Once I find the best match, the idea is just to assume that what you will do next is what you did next in the past after doing nearly the same moves. I wrote some documentation in french
here, but I don't think it is clearer.
It works well, but it is extremely computation-extensive (complexity O(256 * Number of cycles spent in game)). In fact, the main reason the game will only last for 67s is because on my netbook (reference low-end machine), more will make the game start frameskipping. Second reason is because I think 67s really is enough for this kind of game
The source code is kinda messy. I consider this game as finished so I will only work on bugfixes, but if I had to redo it a lot of things would be different.
The eye animation when losing is also nice
By the way, you should probably forbid resizing the window, or map the mouse input correctly when resizing. And document that F enables fullscreen
Nice catch for the window resize
I corrected it in the repository (and, in the same time, added a small README documenting the F key).