GameBaba Universe

How To Create Snake Game With GPT-4 In Minutes

GPT-4 feature image
GPT-4 succeeded ChatGPT-3.5 (Photo credit Gearrice)
GPT-4 succeeded ChatGPT-3.5 (Photo credit: Gearrice)

GPT-4, the highly awaited replacement to OpenAI’s ChatGPT already promises huge disruptions in the technology world. There has been a mixed reception ever since the launch of ChatGPT. An increasing number of jobs are now at risk of being automated.

A new study by the University of Pennsylvania, Open Research, and Open AI identified the potential of exposure of various jobs to large language models. Exposure here is a term used to determine whether the use of GPT or GPT-powered systems can cut down the time humans will need to do a job by half.

ALSO READ: How To Build A Gaming Laptop The Right Way—7 Steps

According to the study, higher-paying jobs are more at risk of being automated than lower-paying jobs. Also, professions that need critical or scientific thinking skills are less prone to automation. Jobs that require proficiency in writing and programming are more prone to being automated.

The study titled “GPTs are GPTs: An Early Look at the Labor Market Impact potential of Large Language Models” identified jobs at a high risk of automation. They include Writers, Tax Preparers, Blockchain Engineers, Web and Digital Interface Designers, and so on. Well, that is a story for another day.

How GPT-4 differs from its predecessor

GPT-4 comes with some major upgrades that make it far superior to its predecessor including the ability to process up to 25,000 words (8 times more than ChatGPT-3.5 as well as the ability to respond to image queries.

In a demonstration, OpenAI showed that a user can draw a simple website design on a sheet of paper and ask the AI to write code to bring the website to reality. The company behind the technology also said that the software can behave like a tutor. Rather than just providing answers, the bot can teach the human chat participant how to solve an equation. However, OpenAI had a note of warning to users.

“Great care should be taken when using language model outputs, particularly in high-stakes contexts, with the exact protocol (such as human review, grounding with additional context, or avoiding high-stakes uses altogether) matching the needs of a specific use-case,” OpenAI said.

GPT-4 has its limitations. One of the most dizzying is that the system can make up facts as well as make reasoning errors. Unlike its predecessor, you will need a subscription to use GPT-4. However, OpenAI said that may change.

“Depending on the traffic patterns we see, we may introduce a new subscription level for higher-volume GPT-4 usage. We also hope at some point to offer some amount of free GPT-4 queries so those without a subscription can try it too.”

Early experiences with the chatbot

Ammaar Reshi recently took to Twitter to share how he developed a classic game using GPT-4. An action like this is a reminder not to focus too much on the disruptions that GPT-4 is going to bring. Rather, we should look for ways to maximize their potential to enhance production.

The chatbot was released on Tuesday 14 March 2023 as a successor to ChatGPT. Soon after the unveiling of GPT-4, a lot of people decided to put it to the test. One of them was Reshi, a digital designer.

Reshi decided to use the artificial intelligence tool to recreate ‘Snake’, a classic game that evolved with Nokia phones “in less than 20 minutes”. Reshi shared the game online and could not stop talking about the potential of GPT-4.

“The potential is so exciting. Anyone can make their own games just by describing them,” Reshi wrote.

Another Twitter user, Pietro Schirano asked the chatbot to “build a pong-like game”. GPT-4 responded by providing the coding language to use as well as the script that can be used to create the game. Schirano was excited about the outcome

“I don’t care that it’s not AGI, GPT-4 is an incredible and transformative technology. I recreated the game of pong in under 60 seconds. It was my first try. Things will never be the same,” he wrote.

How to create classic games with GPT-4 in minutes

If, like Reshi, you are curious about what GPT-4 can do or simply want to create your own classic game, below is a step-by-step guide outlined by Reshi on how he created his ‘Snake’ game. To start the trend, Reshi wrote;

“Can GPT-4 code an entire game for you? Yes, yes it can. Here’s how I created a snake game that runs in your browser using Chat GPT-4 and @Replit, with ZERO knowledge of Javascript all in less than 20 minutes.”

Firstly, Reshi asked “GPT-4 to provide code for a Snake game, with the relevant HTML, CSS, and Javascript required to make it run”. Surprisingly, the chatbot was able to provide Reshi with all he asked for. It took multiple responses for the bot to provide all of it. However, all Reshi had to do was say “continue” each time it stopped.

First response (Photo credit: @ammaarTwitter)
First response (Photo credit: @ammaar/Twitter)

ALSO READ: Dead Space’s Secret Ending Is Terrifying. Here Is How To Find 12 Marker Fragments To Unlock It

Once Reshi had all the required codes for the Snake game, he went over to @Replit and created an account. There, he began a new HTML, CSS, and JS project. Interestingly, all these can be done using a browser.

Working on Replit (Photo credit: @ammaarTwitter)
Working on Replit (Photo credit: @ammaar/Twitter)

The next step was to copy the codes generated by GPT-4 and paste them into the relevant files within Replit and hit run. Reshi was able to play the game using the arrow keys.

Run game (Photo credit @ammaarTwitter)
Run game (Photo credit: @ammaar/Twitter)

However, Reshi discovered two issues with the game. “The snake would die after its first bite instead of growing, and it kept adding the score in increments of 2 instead of 1.” Reshi went back to GPT-4 and asked it to make the tweaks and it did.

Tweaks to snake game (Photo credit: @ammaar/Twitter)
Tweaks to snake game (Photo credit: @ammaar/Twitter)

Instead of just providing what Reshi asked for, GPT-4 followed it up with explanations. “I love that it followed up with explanations too—what a wonderful way to learn to code and actually understand why it’s doing the things it’s doing. GPT-4 is a decent teacher,” Reshi said.

Finally, Reshi was able to add a high score counter to the game to make it more competitive by asking GPT-4. Again, the chatbot was able to provide the required codes.

A day after the initial posting, Reshi was able to add sound to his game to make it more engaging. He said he intends to push further to see how much more he could do with GPT-4.

Conclusion

As Reshi pointed out, GPT-4 may likely not totally replace the need to learn how to code. Rather, it will supplement it. Having basic CSS knowledge is still paramount for programmers. GPT-4 will only make it easier for users to implement what they already know.

For example, Reshi knew that to create a snake game that would run on a browser he needed CSS, HTML, and JS codes. If he didn’t know the codes that he needed, he would still not be able to create a game using the chatbot.

Another lesson that can be gleaned from Reshi’s experience is that GPT-4 may not get what you want exactly the way you want it the first time. However, you can always go back and ask it to keep tweaking until you get the desired result.

Now that you know how to create games with GPT-4, which game will you attempt to create? Let us know in the comment box below.

Remember to share and bookmark this website to stay up to date on all the hottest news in the gaming industry.