Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411426 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 10:10:15 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Exploring using ChatGPT as a Game Development Tool
Pages: [1]
Print
Author Topic: Exploring using ChatGPT as a Game Development Tool  (Read 5641 times)
dustinaux
Level 0
***



View Profile WWW
« on: December 13, 2022, 02:30:56 PM »

I’ve been exploring using OpenAI’s chatbot ChatGPT as a gamedev tool a little bit and have come up with some mixed results. Sometimes it is very impressive but other times it only appears impressive but is actually incorrect. Most of the time for me it’s somewhere in the middle area of “That could sometimes be useful I guess.”

Code Optimization

The first thing I tried was asking it to optimize a bit of code that was a small, simple function that I just thought looked ugly when I went quickly looking for an example to give ChatGPT. It’s a function that takes a 2D point and quad parameters, and returns the minimum distance from the point to a point on the edge of the quad, or 0 if the point is already inside:



I was initially extremely impressed! This code looks nicer, and it says it’s more optimized. I was particularly impressed with how it has no definition for my custom TileNavMeshQuad class, nor was it explicitly told that the pos property of the quad corresponds to the top-left corner of the quad, but from my existing code it correctly guessed how everything is structured.

But wait – this is incorrect; this ignores diagonal distances to a corner of the quad for when the point is both beside and above/below the object. Let’s ask it to fix that. In thinking of how to word my request of what I wanted, I decided to just be pretty vague to see it if understood what I meant. Also as an aside I felt kind of weird being polite to a robot? Like I intentionally didn’t want to personify it. So I dropped the please from my request.



Awesome! It understood what I meant, and now includes diagonals. I was honestly kind of caught up in excitement at this point, thinking I was getting some nicer, optimized code. But I notice one more error, it doesn’t return 0 if the point is in the quad like my original function did so I tell it that and it fixes that problem:



Ok perfect! ChatGPT has rewritten my code to do the same thing but faster. So I go to test just how much faster…

And I find that it’s in fact about 5x SLOWER than my original code. So I tell it:



Cool, it adjusts the order of some checks to improve the performance. I do another test and this is faster, but still 1.5x slower than my original code. I didn’t want to just say “faster” again, maybe I should say “as fast as possible?”



Here ChatGPT stored some calculations in some variables once so that they don’t need to be calculated “every time,” but in this case they’re still only used once. So this basically does nothing. I tell it:



Some very general advice that doesn’t help here. It’s at this point I’m realizing none of this really helped me at all. I took another look at my original code and noticed it was in fact already very optimized. I know ChatGPT can optimize ugly code from seeing some examples from other people, but it doesn’t actually test out code. It seems to just confidently provide some code and tells you it’s optimized when the ideal response to my original prompt should be “I don’t know how to make that faster.”

Idea Brainstorming

I switch up tasks and think more about things that would actually help me in my current project. Maybe some brainstorming?



This was pretty cool. I had already thought of pretty much all of these things, except for pools of water and cobwebs, which are good ideas I may now consider. The drawback is it’s all fairly generic ideas, so you’ll still need some individual creativity if you want your game to stand out more, but perhaps this could be a handy time-saver for some tasks? The alternative is either googling or browsing various sites with collection of concept art or photos for inspiration.

I try another example:



A pretty extensive list of monsters, but they are of course fairly generic. It does provide some nice little explanations of why they are relevant to a desert.

I decide to do a little test. I decide on a new area for monsters, and first give myself one minute to brainstorm on my own to which compare to ChatGPT’s. I decide as an example a swamp environment, and in one minute came up with:

toads/frogs
witches
mosquitoes
giant bugs
giant birds
snakes
leaping fish
spiders
mud golems

I then ask ChatGPT to do the same:



Not bad. There is a bit of overlap in our ideas, but ideas like slimes, goblins/lizardfolk, the undeads that were trapped, and large predators are all pretty different than what I came up with. Nothing amazing, but for an instant response from just typing a response, it could be a nice springboard for ideas on a new area.

I feel like I’m not using ChatGPT to it’s full potential, which includes longer conversations, so I provide a more unique task and ask it to elaborate more on the swamp monsters:



Some possible fun ideas to consider! I like how it tries to explain the connection between the monsters and ruins, providing reasons for their existence and behaviors. This is something that my quick barebones list was lacking.

Pros and Cons

I’m still searching for ways I would actually use this and so far the brainstorming ideas seems to be the most helpful. I think tasks like that may work best since they are very open-ended and there is no one correct answer, unlike most coding problems, where ChatGPT may confidently give you an incorrect answer.

It is pretty helpful at explaining code, however, as well as spotting errors. These could be a nice use case. In one test I took this random reddit post of someone asking for help with a complex regex expression, copy and pasted their post verbatim to ChatGPT, and was given the same correct solution as the top commenter of that thread, which was impressive. ChatGPT could possibly drastically reduce the number of reddit and stackoverflow threads of “why isn’t this code working?”

There are a handful of cons as well, however. In some other attempts I asked for some help with a general issue I faced with some collisions in Unity, asking how I could achieve something, and ChatGPT explained a non existent feature of “conditional fields” for physics layers.

Sometimes people talk about ChatGPT as if someone without programming knowledge can use it to make a game which is far from the truth. You still need knowledge to test it’s answers, and tell it when it got things wrong. For me I was originally most interested in using it for coding tasks but that seems unlikely now, aside from very occasionally tasks.

It is also still limited in scope to what you give it. I keep an (embarrassingly long) todo list of tasks I need to do to fix things in my game, and went through it trying to find tasks that ChatGPT could help with and didn’t really find anything. I tried a few but didn’t have any luck getting something useful. The main problem is that for example my todo task of “fix game pausing issues during cutscenes” involves my cutscene system, entity movements, and other map updates spread through hundreds of lines of code across dozens of different classes and subclasses that’s needed just to understand the system enough to fix the problem. I’m sure it won’t be long until a bot can be given access to your entire project for this however.

ChatGPT is so open-ended on what it’s capable of that it’s kind of difficult to think of new use-cases, so I’m sure new ones will pop up as people continue to explore its capabilities and as the model is improved. It’s also worth mentioning that ChatGPT itself is a tool that can take some practice to efficiently use. Currently I don’t think it’s a perfect magic answer to any individual problem, although it does show promise with being helpful at some tasks.
Logged

Come see what I'm working on!

failbetter
Level 0
**



View Profile
« Reply #1 on: December 16, 2022, 12:15:55 PM »

How do you verify the generated code does what it says it does? Does it write unit tests, too? Like, if it writes a complicated algorithm that the developer might not fully grok, how do you ensure correctness? All that said, it's super crazy it can do all this. Scary to imagine how much it will advance over the next decade...
Logged

You may defeat me today but I will return stronger tomorrow.
dustinaux
Level 0
***



View Profile WWW
« Reply #2 on: December 17, 2022, 09:38:47 AM »

That's a big drawback of it currently, you still have to test out the code yourself because ChatGPT always responds with 100% confidence, even when it's wrong. I think it can be a useful tool in some cases but the idea that someone without programming knowledge can have it write code for them is false, you need to have the knowledge yourself to verify and check it's output.
Logged

Come see what I'm working on!

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #3 on: December 17, 2022, 05:06:25 PM »

If the algorithm does the coding and you have to do the testing it sounds like the algorithm is having all the fun :D

Although that does bring up a thought. I wonder if anyone has tried using ChatGPT to write tests (probably a bad idea haha)
Logged

coleModelo
Level 0
*



View Profile
« Reply #4 on: February 01, 2023, 01:30:43 PM »

Fascinating read, thanks for taking the time to write it all up!

The best use-case I've found for ChatGPT is asking questions I would otherwise be too embarrassed to ask a colleague lol

EDIT: Found a potential use-case for ChatGPT. Over the weekend, I revised my design doc and used Assistant to help better organize and reduce the bloat of the document. I'm very happy w/ the results and I think there is a use-case there as a technical writing assistant.
« Last Edit: February 07, 2023, 02:18:19 PM by coleModelo » Logged

Beyond the walls of intelligence, life is divine.
michaelplzno
Level 10
*****



View Profile WWW
« Reply #5 on: February 06, 2023, 11:34:30 AM »

I'm still a non AI believer: I wrote a bunch of threads here on tig about THE SOUL and it is my firm belief that humans just have some kind of magic goo in their brains that let them do things that AI cannot. Though I'm impressed AI has gotten this far. I've seen some good results of Stable Diffusion modifying my art to make it look a bit cleaner and prettier, I still think the human element is needed to give a work its soul. The way I think, I make leaps that are not algorithmically clear, and I doubt that a machine can do such a thing. Interesting test though.
Logged

Golds
Loves Juno
Level 10
*


Juno sucks


View Profile WWW
« Reply #6 on: February 07, 2023, 08:30:25 PM »

I'm still a non AI believer

I am, somewhat. I posted in the procedural resource dump yesterday about adapting the OpenAI API into writing dialogue for my characters in a game instead of myself, and it does a pretty decent job. And this is just one of the earliest Large Language Models. I believe, with time, their capabilities will continue to improve and probably at some point surpass humans at an ever increasing number of tasks. Maybe not the GPT architecture, but something.

I'm interested in expanding the model's role in my game. This topic is about using them to help you code, and I'm interested in prompting the model to creatively trigger events in my game in addition to just talking. I think there's a lot to mine there. I'm really happy OpenAI has an API to play with instead of keeping *everything* locked behind corporate walls.

Hopefully soon there will be some open source Large Language Models, or at least some competition for OpenAI on the API front. Keeping an eye on Open Assistant from LAION-AI right now.
Logged

@doomlaser, mark johns
mobilelast
Level 2
**


View Profile WWW
« Reply #7 on: February 11, 2023, 03:23:22 AM »

Currently AI excels in mostly concepting.

Results are rarely usable as such (also because of copyrights), but they are great for fresh ideas. As AI isn’t capable of proper reasoning, it comes up with things that humans would never think of; details that don’t make any sense, but can be extremely interesting. I think this works well with graphics and music, but less so with things that require faultlessness (like program code).
Logged

Avaruustaistelupeli (ATP) - a space combat game
- Free download from itch.io or IndieDB
- Dev diary here
flowerthief
Level 1
*


View Profile WWW
« Reply #8 on: February 11, 2023, 09:28:29 AM »

My dissatisfaction with ChatGPT began when I was asked for my phone # at signup. Why? So that the AI could call me on the phone? Of course I aborted. It perplexed me that other ppl didn't have this privacy concern.

I know it can do impressive things, and I use AI art in my own projects so who am I to complain right, but it all sort of saddens me. Once again things have gone the way of BIG and CORPORATE. Big money, big data, big computing power, big companies doing big things. There are other approaches to AI out there, but all we hear about are the big transformers big tech keeps making.

Not so long ago there were concerns about the ever-increasing cost and environmental impact of these enormous models. Now that ChatGPT is everyone's darling we don't hear about that any more, eh?

Also, you cannot trust anything ChatGPT tells you farther than you can throw a football stadium. It even warns you not to spread misinformation while it spreads misinformation.

The "train-it-on-the-entire-internet" approach almost feels like cheating. It's just the sort of thing GAFAM would do, and I despise GAFAM. I'm an indie AI dev so I have my biases.
« Last Edit: February 11, 2023, 09:34:23 AM by flowerthief » Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #9 on: February 11, 2023, 05:28:32 PM »

The corporate aspect is unfortunate, the tech bro philosophy isn't helping either. But I believe the tech will be accessible in the long term, we are kinda just stumbling on use case from research toys.

Given that most current ai can be compressed up to 95% by pruning weight, without losing significant performance loss, clue us that there is a lot of inefficiency and optimization to be had. If anything I see them as proof of concept, we will study and break apart the black box into something we can understood and use.

Also, even with the long training phases, I don't see the tech as out of reach of the average person, the tech itself is incredibly simple. The one thing would be the inherent impatience of the modern time, if we were to train such a model, we would want it done per tuesday. But I think time isn't such a big deal, we can just take the time, we do it with farming because nature impose its cycle onto us, but for some reason, we rage that tech would take multiple month of training on our puny computer vs week on corporate super computer. The result would be the same, and even if it's not, we can still reach good enough level for usability, we don't need all the fancy. You don't have to keep up with the jonesy.

Personally I'm interested in AI in how it can help us be more independent, like not about making game, but helping us farm for example, I wouldn't need a job if I can feed myself. I wouldn't care if my game don't sell. AI is free labor, it can take your job, but it can also work for you, and also you never hear CEO talking about how ai will take their jobs, it absolutely can, they don't go there because it's about leverage of power, not skills.

And ai don't need a souls to do impactful stuff, just like plane don't need to flap their wings to fly, and car don't need leg to travel. Ai might never be like human, it won't ever need to be if the result are the same or better.
Logged

Action Tad
Level 0
**



View Profile WWW
« Reply #10 on: February 12, 2023, 01:39:38 PM »

Very interesting, I wonder what it would have responded with if the first question was 'Can you make this code run faster?'
It seems it initially understood 'optimize' as basically to make the code cleaner.
Logged
J-Snake
Level 10
*****


A fool with a tool is still a fool.


View Profile WWW
« Reply #11 on: June 24, 2023, 02:42:26 PM »

This AI wouldn't be beneficial for my research since I'm doing new things that require new ideas and theories. But we have already a guy in the company who heavily relies on ChatGPT to write code. Looks like a convenient assistant for common tasks, including debugging.

As with everything in life, keep in mind that a fool with a tool is still a fool. The greatest power is inside your head.
« Last Edit: June 24, 2023, 03:09:57 PM by J-Snake » Logged

Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality.<br /><br />Trap Them: http://store.steampowered.com/app/375930
mobilelast
Level 2
**


View Profile WWW
« Reply #12 on: June 30, 2023, 12:02:23 AM »

AI is a great tool. I consider it a highly enhanced search engine or, alternatively, a more polite version of Stack Overflow.

But there are still problems. For instance, I’ve been toying with the newest Unity URP, and ChatGPT keeps offering outdated information with great confidence. It takes lots of (correct) information to train the AI, and as the gaming industry progresses fast, this may cause problems for machine learning algorithms.
Logged

Avaruustaistelupeli (ATP) - a space combat game
- Free download from itch.io or IndieDB
- Dev diary here
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic