A simple Ai created with C++ and OpenCV for Breakout
For a longer preview you can watch this video
Usage:
- open the Atari 2600 emulator Stella
- load a legal copy of Breakout
- Tab out of the emulator
- Start the Ai
- Focus Stella by clicking the window
- Press f2, and then space, to start the game. watch the magic.
Disclaimer: The ai isn't close to perfect, and results may vary.
I'm using the Windows API to read the game display. The gamestate is parsed from the resulting image stream with OpenCV, which is then used to drive the ai. I extracted the position of the ball from which I could calculate its trajectory. From there, I estimate where the ball will be when it approaches the paddle. With this information I generate the necessary inputs to position the paddle to meet with the falling ball.