ChatGPT coded a game for me in seconds and I’m just amazed – and programmers should be very concerned
ChatGPT just blew my mind. Nearly two years after I first asked an early version of the generative AI chatbot to help me code a game, I returned to ChatGPT 4o with the exact same prompt, and the results blew my mind.
Since the advent of OpenAI’s generative AI platform, people have turned to the platform to perform tasks they would rather not do or, in some cases, to attempt things they themselves are not capable of. I can write, so I don’t usually ask ChatGPT to compose prose, and I’m a fine artist, so I only use generative image creation for entertainment. However, I am not a programmer. I’ve done some HTML, Javascript, and even BASIC coding in the past, but my skills are beyond rusty; they are calcified.
Last year I wrote that I asked ChatGPT to help me build a new game called Tic-Tac-Go. It’s like Tic-Tac-Toe, but on steroids. I imagined the playing field to be a 12×12 grid. To win, six “X” marks or six “O” marks in a row are required.
Here’s the original prompt:
I want to make a variation on the tic-tac-toe game, but it has to be more complex. So the grid must be 12 by 12. “x” and “o” must still be used. The rules mean that any player can block another player by placing their “x” or “o” in a box around the grid, as long as it is in one of the boxes directly next to the other player. They can also choose to place their “X” or “o” in any square to block future moves. The goal is to be the first to have at least six “x” or “o” in a row, column or diagonal before the other player. Remember that one player is “x” and the other is “o”. Please program this in simple HTML and JavaScript. Let’s call this game: Tic-Tac-Go.
I understand there’s no Wordle-level cleverness here, but my idea still requires nested tablets and browser interactivity, which is immediately beyond my skill set.
Things started off well on my first try, with ChatGPT providing CSS, JavaScript, HTML files, and plenty of explanations for almost every piece of code. However, most of what it gave me was incomplete due to a built-in character limit (4096). I kept asking ChatGPT to provide the rest of the code, but he kept losing track of what he was already telling me. I made a lot of mistakes, but also realized how ill-equipped ChatGPT 1.0 was to help me fill in the blanks. In the end, we never built the finished game, and after hours of trying, I gave up.
Return of the AI coder
In the intervening 20 months, ChatGPT has made huge leaps in capabilities. I recently started using the ChatGPT search and am impressed with how much more effective it is than Google at giving me useful answers. ChatGPT 4o has little or no problem with the limits I encountered in the first version. I started to wonder what else I could do. Separately, an office Slack conversation mentioned what some new AI-powered distributed computing platforms look like Oasis AIhelped programmers build games quickly. I didn’t think it would be useful, but it reminded me of my failed attempt at coding ChatGPT games. When I shared the post with a colleague, he wrote, “I wonder if it would be easier now with some of these new AI tools.”
It was a good thought. Could ChatGPT 4o succeed where the original ChatGPT and I failed?
Instead of polishing my prompt – and because I’m lazy – I simply copied and pasted the above prompt text into ChatGPT 4o.
It didn’t take me long to realize that this wasn’t even close to being my first ChatGPT coder. If ChatGPT 1 had primary school level intelligence, ChatGPT 4o is at least university level.
ChatGPT 4o started by summarizing my game idea into a more intelligent command:
Creating a complex variation of Tic-Tac-Toe, called “Tic-Tac-Go”, on a 12×12 grid, can be accomplished with HTML and JavaScript. In this game, players take turns placing their markers (“X” or “O”) to try to create a line of six markers in a row, column, or diagonal. The ability to block nearby movements adds an extra layer of strategy.
Then it quickly spit out the HTML and Javascript code, not just part of it. I have everything from the “html” at the top to the “/html” at the end. It looked complete. After the code, ChatGPT provided a four-point explanation of the game’s work and related features. In addition to HTML and JavaScript, there was a “copy code” button. I copied the code and asked ChatGPT how I would test it in a web browser, even though I pretty much knew how to do this, or at least I thought so.
It advised me to open a text editor like TextEdit on the Mac, paste the code and save it with the “.html” extension. I did this, but when I loaded the file in Chrome and Safari, it wasn’t the game, just a bunch of code and a “Restart the Game” button.
I mentioned this to ChatGPT and asked if I should separate the Javascript into a separate file. It told me no and reminded me to check if the file had the correct extension and disable RichText. It also gave me a few other suggestions, such as using developer tools to check if the JavaScript code worked.
I had another idea. I took a screenshot of the broken page and posted it to ChatGPT, asking if it could analyze the image. This multimodal use was not possible in the first ChatGPT, but it turned out to be a game changer.
“It looks like your file is showing up RTF (Rich Text format) formatting instead of HTML. This usually happens if the file is saved as an RTF document instead of plain text,” ChatGPT wrote, going on to explain why this happened and how to fix the problem.
I re-pasted the code, set TextEdit to PlainText and re-saved it as an HTML file. Then I opened the file with Chrome.
It worked. The game was exactly as I envisioned it, with 144 empty boxes and a two-player system for marking “X’s” and “O’s”
I realized that someone looking at this grid would have no idea how to proceed, so I asked ChatGPT if we could add rules below the game. ChatGPT spits out new code that includes the rules of the game.
In the first chat, when I asked GPT to re-execute some of the code, invariably something was lost in the process. Not this time though. There was a level of efficiency, clarity and recall that was missing twenty months ago.
Feeling bold and maybe a little like I could suddenly code, I asked for the next logical game update: the ability to play online. Sure, this was a web-based game, but the way it was designed, you could only play against someone sitting next to you. I wanted online competition.
“To turn it into an online multiplayer game, you’ll need to set up a server to manage game state and player interactions in real time. Here’s a high-level overview of the steps required and some code examples to get you started.”
ChatGPT gave me detailed instructions and all the necessary code for setting up servers. It called for things like Node.js and WebSockets, and as I read it I felt the water rising above my ears; I was way out of my depth. But not from ChatGPTs. It clearly knows what it’s doing and really doesn’t need my help to code. Yes, I came up with the idea, but ChatGPT 4o did everything else.
We’ve come a long way in a short time, AI. The future for AI-assisted coding looks bright, but I’m not sure the news is as good for human programmers.