There is a lot of curiosity about AI tools created to assist developers in creating software. GitHub’s Copilot and Amazon’s CodeWhisperer use deep-learning techniques initially developed to generate natural-language texts by modifying them to produce source code. This is the idea that developers can use these tools to create an auto-complete augmented with prompts with pieces of code that programmers can incorporate into their applications.
As I looked over these tools, I wondered: Can we go to the next level and remove the human programmers from the equation? Can a functioning program be developed and delivered at the click of a button?
At my job, I write embedded applications for microcontrollers. As such, I instantly considered a portable handheld device that could serve as a demonstration platform. A screen and a few buttons will allow users to interact and request essential AI-generated software. This was the beginning of the concept of infinite Pong.
I opted for Pong due to a variety of reasons. It is a simple game, famously explained on Atari’s 1972 original Pong arcade cabinet, most concisely: “Avoid missing ball for high score.” A button to up and a down button is all required to play. Like many classic Atari games developed in the 1980s and 1970s, Pong can be coded within a small amount of code and was implemented as a programming exercise numerous times. It is a result that the source code repository used to train the AI tools is full of Pong examples, which increases the chance of obtaining reliable results.
I used a US $7 Raspberry Pi Pico as the basis of my handheld device. Its built-in wireless lets you connect directly to cloud-based AI tools. In addition, I mounted a $19 Pico LCD 1.14 display module. Its 240 x 135-color pixels are plenty to play Pong, including two buttons and an axis-two micro joystick.
The preferred software language I could use for Pico was MicroPython since it’s the one I typically use. It is also an interpreted language that runs without a computer-based compiler. The AI programming tool I used is the OpenAI Codex. OpenAI Codex is a free tool that OpenAI Codex can be accessed through an API that responds to requests made using the web’s HTTP format and is simple to create and send by via it with the recommendations and the JSON libraries that are available for MicroPython. Utilizing the OpenAI Codex API is free during beta testing; however, registration is required. Additionally, requests are only 20 per minute – sufficient to satisfy even the most passionate player. Jockey.
Two hardware components are required-a Raspberry Pi Pico W [bottom left], which supplies computing power, and a plug-in board, which has basic controls and a display [top left[top left]. Other than that, all you need is the USB cable to power. JAMES PROVOSTNext, we had to develop an application that acts as a container. The program is responsible for determining when a push of a button can demand a new version of Pong and then transmits a request for OpenAI Codex. It then OpenAI Codex, receives the results and launches the game. The program that runs the container also creates a layer of abstraction on the hardware that handles connections between Pico and the control module and LCD.
The most crucial aspect of the entire endeavor was composing the prompt, sent through the OpenAI Codex every time we needed it to produce the latest variation of Pong. The prompt is a block of text with the bare skeleton of source code – a couple of lines that outline a typical structure to a lot of video games, such as the list of libraries we’d like us to use and a command to process certain events (such keys pressed) as well as a request to change the game’s state based on these events, and then a call to display the form that has been updated in the game’s screen.
The returned code generates a functional Pong game approximately 90% of the time.
What libraries to use and make the forms is left to the AI. The key to transforming this basic structure into an actual Pong game is the embedded comments, which are optional in the source code written by humans. They are handy for prompts. The statements provide the game’s gameplay in plain English, for example, “The game consists of the following classes…Ball The class that represents the ball. It has a location velocity, and debug attributesand a debug attribute. Pong is a class that embodies what the sport is. It is equipped with two paddles as well as an actual ball. It can tell when the game has ended.” (My containers and code for prompts can be found readily available at Hackaday.io) (Go to Hackaday.io to play the infinite variety of games.)g games using your Raspberry Pi Pico W; my prompt code and my container are available on the site.)
What is returned by the AI is approximately 300 lines of code. The first time I tried it, the program would not display the game because it was not compatible with the MicroPython framebuffer library that runs my module differs from the framebuffer library on which the OpenAI Codex was trained. My solution was to include explanations of the methods my library relies on in prompts, such as: “def rectangle(self, x, y, w, h, c).” Another problem was that many examples for training utilized global variables, while my initial prompt identified variables as attributes that were scoped to reside within specific courses, which was typically more appropriate. I ultimately had to abandon the idea and follow the flow declaring my variables global.