A robot coded this game in less than a minute. Play it now: Pong
In this installment of Ask AI, I test out the capabilities of GPT-3's code completion. I had intended to test out Codex (code-davinci-002 or code-cushman-001), but I forgot to switch the model from text-davinci-002 and it still did remarkably. I only needed a few commands:
1. Write the html and javascript code for the game Pong; make it a one-player game and add a scoreboard.
2. Initialize the variable showingWinScreen as false
- An error came up in the console onload because this variable didn't exist, so I initialized it
3. Center text horizontally on the Win Screen after game is over
- As you can see, this wasn't fully successful in getting the text centered, but that just makes it avant-garde
- To see the uncentered text, finish the game against the computer here (games are up to 3 points)
That third line leads well into some of the caveats:
- This specific string of commands was only found after some experimentation (about ten minutes worth)
- Pong could very well be part of the training data set for t-davs already - it didn't perform as well on things like creating functional flashcard or matching game apps
- One time, I entered this text: "Write the html and javascript code for the game Pong." and got back this! A fully functioning auto-complete drop down menu for selecting any country in the world. I was really trying to figure out what this could possibly do with Pong when it started getting typed on my screen: /*An array containing all the country names in the world:*/ var countries = ["Afghanistan","Albania",
"Algeria","Andorra", "Angola","Anguilla","Antigua & Barbuda", - Some semi-manual debugging was necessary to make the code functional (i.e. step 2 above). I initially tried to get it to work by stating things like "Correct this code", but at about 1,500 tokens (7 cents at current prices) a pop, I didn't do too many iterations
- The game doesn't really work well on mobile, so if you're on the phone, use your computer instead
- Sometimes centering some text on your webpage is still annoyingly hard
Overall, I was incredibly impressed once again with text-davinci-002. I'm in awe of its ability to create something fun to play so quickly. Especially in javascript, which doesn't seem to be Codex's absolute forte (it's python), but also that I didn't even use code-davinci-002 which is the actual model for code completion!
I urge you to play the final product: Pong
Below is the final html page that the AI wrote.
Published: Saturday, August 13, 2022
Comment Section