Speed up your development with the help of AI and Automation

Tanim-ul Haque Khan
8 min readNov 8, 2023

As we began our next game project, I wanted to implement all the best practices I knew and didn’t know of. However, this meant spending a lot of time in making sure of it. And time is money. I was wondering how we can leverage tools at our disposal to power through the development process.

Goal: Write the best possible code following best practices as fast as possible.

And I believe I did. At least I’m quite satisfied with what I’ve done. And that’s what I’ll be sharing today. More like I’d be sharing the process so in case you are interested you can most certainly replicate it to speed up your development. Alright! Here we go.

Project Description

For the game we need to develop a Save System that will be published to OpenUPM so that we can install it via package manager. Okay what’s OpenUPM? And what’s Package Manager? Why are we doing it this way? That’s a discussion for another day. Let’s focus.

So, the Save System needs some features. What are they? Discussed with my team and asked what the public methods should be in a Save-System. And we discussed it on the high level, and I took down some bullet points.

  1. It should have a SAVE() method. [yes of course]
  2. It should have a LOAD() method. [I know right?]
  3. It Should have a Bundle() method.
  4. It needs to implement Steam Cloud as well.
  5. It needs to manage file and folder structures.
  6. It has to automatically save all the files by itself from one function call.
  7. Blah blah blah blah….

You get the point. I got a set of requirements at hand. Now need to plan it out.

Thought Process

First of all. I’m going to follow TDD (Test Driven Development) for this project. TDD suits well for projects that are data driven. So that means I need to write unit tests. Okay now I’m in a bit of trouble. I haven’t written test cases in ages. While I know it’s one of the best practices, I didn’t really feel like writing it myself. I had a bright idea!

Before I share my bright idea let me share other stuff first. Before any of this I need to setup my development environment and stuff. And as I mentioned before I’m going to make a package so that we can reuse it. You guessed it right making a package isn’t as easy as it sounds. You need to follow a specific guideline, folder-structure and manifest. Fortunately, one of my developers create a package that does all of these for me.

A Package System Generator: 📦 UPM Assistant

Used it to generate all the files and all. That saved me quite a while. I had planned out what would be the public methods and the class names. So, I opened up unity and wrote my class SAVESYSTEM.CS. Mhm…

This is going to be an awesome class library with SAVE and LOAD methods.

Which of course will manage steam cloud and Xbox cloud and other providers. Forgot to mention our game SILENT SCREAM is coming soon on XBOX platform. So yes, we need to prepare for porting it to XBOX Services. Anyway, No distraction. Need to finish writing.

So, the savesystem.cs file needs to have some content. The SAVE And Load method. But you know what I’m too lazy to write the methods following all the conventions. It’s too much work. Remember the bullet points I wrote down? I copied them and pasted into ChatGPT and asked it to write the class for me.

And woah! It really did write the class for me with all the private variables and stuff. I copied and pasted all of those stuff. And then modified them of course otherwise it won’t be my code. I have to edit. I made the private variables start with _(underscore) and small letter and public variables start with capital. Hmm… It looked pretty nice. However, I’m skeptical about AI generated code. It does look okay, but is it? Maybe. But we need to be sure that it is. And not only that. In the future when we make changes to the code, we need to make sure nothing broke. And it functions as it should be. And for that we need to write test cases. Unit Tests.

I copied my modified code to Sir ChatGPT and asked him to write test cases for me. Sir GPT did write test cases for me. Which I copied and pasted over, but it didn’t work. Of course. I mean it’s only a tool. However, it’s attempt were in the right direction logics were on point it's just the api calls were wrong or imaginary lol. In any case this gave me a starting point. I went ahead and fixed it with my experience. And prepared valid tests cases that would enable TDD process for me.

I carefully wrote and ensured the test cases covered my requirements properly. Because it will force me to write correct code later down the line. After that I went back to implement the actual Save system. I wrote all the subclasses, helper classes and etc. etc. Boring stuff...

However, I made sure of one thing. I carefully wrote XML documentation over every public method. Because you know…. Okay will show you in a moment.

In any case now that my Save System library is ready to be published in all its glory. I need to have it peer reviewed. Awesome as I may be. I still need my code to be reviewed so that I can show my team how good my coding skills are. So, I made a pull request to the main branch. (totally going to skip about git branching and maintaining stuff) And requested two of my devs to review the code. (Just so you know we kind of have a branch protection rule that doesn’t allow pushing to main branch without a pull request that has been approved by at least two reviewers who are randomly selected)

But wait. Before I ask my devs to review, wouldn’t it be nice if I could have some kind of AI or bot to check my code. I mean… It’s better to get your silly mistakes pointed out by a bot than your colleagues. I looked up and woah there are free tools that does it. I like this one. Take a look at what it does.

CodeRabbit: AI-powered Code Reviews

Hooked it up with my repo and got my first feedback. Not going to share what kind of lame mistakes I made. However, it did save my face. I went back and fixed some stuff. And made the Pull-Request again. Gladly nobody saw what I had pushed.

Anyway, now need to wait for my team to approve my code so that I can publish it. But wait… While I wait, I can do some stuff. I don’t need to manually do stuff. I can use GitHub Actions to do work for me.

So, I went back to ChatGPT and asked it to write a GitHub action file for me that creates a release with the version defined in the package.json file and create a new tag and a branch called upm that has some specific folders. (Why am I doing this? Well, these are some steps that needs to be done for package publishing) And bam! Sir GPT wrote the action file for me. It had some issues that I could resolve myself. After all I’m an experienced engineer. It’s not like I can’t write code.

I didn’t stop there. It’s a library. It needs proper documentation. And what do we tell documentation?

Writing documentation

Well, but we need to get it done somehow. So, I heard there’s this library that automatically generates documentation for us. Ain’t no AI but I’ll take it. So apparently, it’s called DocFX. Some dude even wrote a GitHub action for Unity Docs generation. I’m like oh nice. Couple of mins later I have myself another action that runs when main branch has new codes.

So basically, as soon as my pull requests gets approved my code gets updated to OpenUPM via black magic (They do it) and updates the documentation and hosts it to GitHub pages.

This is how it looks.

Documentation Page Screenshot

It nicely generated all that needs to be written for a public library. Well, my XML document helped filling up the human touch. Otherwise, the whole thing was pretty nice. If you are curious here’s the link to the docs.

In any case my team approved my code. Oh, did I mention CodeRabbit Generates a summary of the changes with its AI magic. And it’s quite decent if you ask me. Can pass as a good changelog.

After that there wasn’t much to do. I told everyone that now they can use this as a dependency to implement their file saving needs for the game. And they found lots of bugs as they tried to do that. I had to go back and fix a few codes and how TDD saved my life is a story for another time. However, I’m quite happy with how this library turned out. With the help of AI and some Tools I certainly feel like my development speed had increased. I think it took me around 16hours to get the whole thing done. Including the test case generation automation, the whole package. If you have any suggestions on how I can improve even further, I’m all ears.

In any case if you are interested into checking out the code here’s the repository. It’s under MIT license so you can do whatever you want.

GITHUB URL: Studio-23-xyz/SaveSystem

Or you can install and use it in your project too. It’s quite versatile. Should work for any type of unity game project. You can make a PR if you think you can improve on it.

Let me know if you would like to know about the process, we follow for game development. All the Automation and Quality Checks to make sure that we become better than yesterday.

--

--

Tanim-ul Haque Khan

Author — “How to Make A Game” / Apress, Springer Nature | Head Of Unity Department at Brain Station 23 Limited | Co-Founder of Capawcino Cat Cafe