Czytaj

arrow pointing down

How to quickly create a simple game using AI? Claude Sonnet 3.5

Learn how to program a simple game with AI using the Claude 3.5 model. Watch the instructions and download the ready-made project!

This entry is a transcription of a video we published on our Beyond AI channel. Visit it for more content like this!

Watch this material on YouTube:

How to program and run a simple game with the help of AI?

Today will be very simple. We are just taking Claude, which has the Sonnet 3.5 model, and entering a prompt:

"Program a simple game and run it. Use whatever libraries you want"

Let's see what it makes for us. Well, it created a game but didn't run it, so we will ask it to run it in an artifact.

Okay, it created a game where we move a square around. I don't know exactly what the point is yet, but something is happening here, something is moving. If the red one falls on me, do I lose? No, nothing like that is happening.

First corrections after the first run

Okay, it is a game where we move a square and red things fall from the sky. Of course, if we wanted to, we could still improve it. Let's try to do that.

Make it so that the red squares end the game upon contact with the black one.

Let's see what happens this time: Game over, we lost. Great!

Make a number guessing game, use React

As we can see, to make a simple game in Claude, literally a minute is enough and we have it all ready. Especially since it came up with it itself; we didn't tell it what it should look like, etc.

Interestingly, every time before this, it has come up with a number guessing game. So let's make one of those too.

We have a finished number guessing game. We can enter a number here and guess from 1 to 100. I guessed it in seven tries. Claude immediately added additional functions that tell us how many attempts it took to guess the number.

Creating our own 2048 game

The game 2048 was very popular once, so we can ask it: "Create a 2048 game." And we will ask for the game to be in purple and blue colors, because that fits our channel. Let's see how long it takes.

Okay, we already have a finished game. There are purple and blue hues. However, as for its operation, it's just average. Something is happening, it's controlled by arrows, but I think it's not exactly as it should be yet. I'll ask it to fix it, meaning I say:

"Please fix the game, the tiles do not move after clicking the arrows. Check exactly what the rules of the game are."

Let's see what it does now.

Okay, we have another version of the game and we can check if it works this time. Indeed, the tiles move just like in the original version of the game and we can control them.

Great, there you go! So you see how mega simple it is. You don't need any knowledge of programming, you just write "Create a game, run the game."

We see this is called an artifact in the code and we can ask it to run this thing in an artifact. We can also ask for a version so that you can download the file and run it as HTML, simply in a browser, or possibly send it to someone else.

I decided to share this project with you – click – and modify it a little bit more. You can test it, click it, see how it works, and also remix this artifact, meaning click here and continue using it, making further iterations of it.

Thanks a lot for being here, see you at Beyond AI!

Czy wiesz, że... ...subskrybenci Beyond AI są o 50% bardziej odporni na zagubienie się w rozmowach o AI? Bądź tym, który wie, o co chodzi – kliknij "subskrybuj" na naszym kanale

FAQ

1. Do I need advanced programming knowledge to create a game using AI?

No, thanks to tools like Claude with the Sonnet 3.5 model, a simple prompt is enough to create and run a simple game. The whole process can take just a few minutes.

2. How can I run a game created by Claude?

You can ask Claude to run the game in an artifact, and also to prepare a version that can be downloaded and run in a browser as an HTML file.

3. Can I modify the game after it has been created by Claude?

Yes, you can make corrections and modifications to the game, for example by changing the game rules or the appearance of the interface.

4. Can I share the created games with other people?

Yes, after creating a game, you can share it with others, allowing them to run it in a browser or further modify and develop the project.

Glossary

  • Claude – an AI-based language model capable of generating text and creating simple programs, including games
  • Prompt – a text signal or command entered into an AI model that instructs it on what to do, for example, create a game or write a piece of code
  • Artifact – in the context of programming, the result of a code or program that can be run, modified, or shared with others
  • 2048 – a popular puzzle game where the goal is to slide tiles on a board so that they combine into pairs, summing their values to reach the number 2048
  • HTML – a markup language used to create websites. Games created in HTML can be run directly in a web browser.

See more!

If you are interested in how to create games and programs using artificial intelligence, be sure to visit our Beyond AI YouTube channel! You will find many inspiring videos and practical tips there that will help you fully exploit the potential of AI in your daily projects. Your guide to the dynamic world of AI is waiting for you!

Visit Beyond AI on YouTube

The Beyond AI channel is created by specialists from WEBSENSA, a company that has been providing AI solutions to leading representatives of various industries since 2011.

Inne wpisy z tej serii

How AI helps you publish videos on YouTube

Learn how artificial intelligence can help you unlock YouTube’s full potential and make video publishing easier and more efficient.

How to Choose the Perfect Gift? We Tested GPT!

Discover how AI can help you pick the perfect present — from personalised recommendations to analysing YouTube reviews and saving time with intelligent suggestions.