Let Machine Learning Code An Infinite Variety Of Pong Games

In a very real way, Pong started the video game revolution. You wouldn’t have thought so at the time, with its simple gameplay, rudimentary controls, some very low-end sounds, and a cannibalized TV for a display, but the legendarily stuffed coinboxes tell the tale. Fast forward 50 years or so, and Pong has been largely reduced to a programmer’s exercise to see how few lines of code can stand in for what [Ted Dabney] and [Allan Alcorn] accomplished. But now even that’s too much, as OpenAI Codex can generate a playable Pong from just a few prompts, at least most of the time.

This endless loop of Pong is the handiwork of [Jose Antonio Garcia Peiro], who wanted to explore the possibilities of on-the-fly AI-generated code. Pong seemed like a good choice, so he whipped up a handheld console with a Raspberry Pi Pico W and a 240×135-px LCD display. [Jose] chose MicroPython for the code, since an interpreted language means the output from the AI would be directly useable. To actually generate the code he chose OpenAI Codex, an API that’s designed to translate natural language to code.

All that was left was to come up with the prompt that will generate the code for the game. The prompt has the merest skeleton of code for the game, specifying things like the libraries needed and how to read the Pico’s buttons, along with comments that direct Codex on the classes needed for the basic game elements — ball, paddle, and a unifying Pong class. And that’s it, really — push a button, the AI generates about 300 new lines of code, and about 80% of the time, you get a playable game.

The point of all this isn’t to play a half-century-old video game, of course, but to see how AI can generate code. [Jose] has a detailed analysis of the various differences from run to run and what they mean. It seems like it would be fun to play with something like this, maybe taking it a little further into generative Tetris. Or, dare we ask: can it write DOOM?

[via IEEE Spectrum]

7 thoughts on “Let Machine Learning Code An Infinite Variety Of Pong Games

Leave a Reply to ShaysCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.