Exploring using ChatGPT as a Game Development Tool

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.

Meet Barry

In Order of Athanor, your party can be made up of 1-3 characters that you can freely swap control between, similar to the Mana series. Olivia’s dog Barry however is a unique case, as he is a package deal with Olivia, complementing her combat weaknesses. Although Olivia’s weapon is a pretty nifty ranged attack with a crossbow, it’s not particularly strong, and takes a moment to reload. Olivia excels more at support roles like using healing spells or items. Her defense and health are also rather low, so she is need of a bit of help. Enter Barry, her 10 year-old German Shephard and companion who has been with her since he was a pup.

Barry

Barry, being an older dog, also isn’t a very strong or aggressive fighter… unless an enemy gets too close to Olivia. Barry will then fearlessly defend his owner, providing some much needed defense for Olivia as she supports the rest of the party with alchemy spells or items.

Barry defends Olivia in a cutscene

On the technical side, Barry acts like any other party member, with his own health bar and own AI, but instead of following directly behind someone in the party like the other members, Barry prefers to sit right beside Olivia.

Barry happily following his owner

Last but not least, since Barry is such a good boy, you’ll be able to pet him at any time by holding down the action button for a brief moment when you’re near him:

Olivia petting Barry

Throwin’ Stuff in Order of Athanor

In order to make combat more flexible to different playstyles and simply more fun in general, players will be able to pick up and throw a bunch of different objects for an environment-specific ranged attack, but look out – some enemies will do the same!

BOX FIGHT!

In addition to picking up objects and throwing them at your enemies, you can also choose to place them down gently. This can be doubly used for puzzles involving floor switches or other situations where you want to place an object in a particular spot.

Currently I’ve just added boxes and bushes but there will be many more objects added, like rocks that hit enemies hard but don’t break on impact or bombs that explode. Here’s some classic bush-throwing, which will mostly be for fun as they don’t do a whole of damage:

Challenges

The biggest challenge from all of this has been the enemy ai scripting for throwing boxes. It’s a rather complex task, and involves logic like searching for the closest object to throw, pathfinding to it, how to walk to a spot that’s in-line with a player to throw it at them, and how to handle interruptions at different at different moments. For example enemies will put down objects when the player moves far enough away, or simply drop their object when hit with something. Having an enemy that can both throw things and also melee attack presents another challenge in choosing when to do what and creating a smart enemy that when close to the player will just attack them with a melee attack and not just run away for a far-off object to throw. There’s also moments with an enemy ai throwing objects that you don’t typically consider when controlling a player throwing things, like ensuring the enemy doesn’t just throw an object into an obstacle.

An experimental action-RPG is now in development!

It’s been a while since I’ve posted any development updates here but behind the scenes I’ve been hard at work on a new (currently unnamed) project that I’m happy to share today:

spiders and hurt animation are placeholder

an early jungle test map

There are some very unique key features planned for this game that will make the word “experimental” make more sense that I will share with future updates, when I have plenty of finalized screenshots and gifs to accompany those details. All I will say now regarding that is that the game will be released for Steam Early Access with the player community playing an immense, central role in the development of the game.

I’m happy to share some details on the foundational layer of the game today however! The gameplay is similar to several classic action-RPGs with the following features:

  • Three character party system like the Mana series, with local co-op available, and online co-op being a possibility later on depending on demand and reception.
  • An alchemy system where ingredients are used instead of MP/Mana to cast spells. This is the magic system of Secret of Evermore, a special favorite of mine which I haven’t seen any modern twists on.
  • A dynamic sandbox-like environment to allow for creative ways to fight enemies. Fire that spreads to other burnable objects, destroyable objects, throwable objects, spells and effects that burn, melt, freeze, or shock enemies and objects, friendly fire on some powerful attacks from both players and enemies, and smart enemy AI to use these features appropriately.
  • Puzzles spread throughout the world and in dungeons, with some being necessary to advance and other very difficult ones being for optional loot.

A lot of updates you’ll see in the near future will be new features for the dynamic combat and some puzzle design. When I have completed features finished for the experimental core mechanic, that will receive it’s own post, along with details on the characters and story.

During this game’s development I will be streaming dev work on Twitch at least once a week, with streams being a core feature of development after the initial release to Early Access. I’m excited to share more details as more work is completed, so stay tuned, and I’d love to hear your thoughts!

Watch the development on Twitch        Join the Discord Community