Tuesday, 23 May 2023

Budget-Friendly Revolution: AI's Impact on Game Development Efficiency

Overview

As a longstanding hobbyist and enthusiast of game development, I've gleaned a lot from utilizing AI for programming in my latest project, a topic I discussed in a previous blog post: https://contemplative-architect-journey.blogspot.com/2023/05/leveling-up-game-development-ai.html.


A recurring theme I encounter is the belief that "AI equals fully automated game generation," a notion swiftly countered with skepticism about AI's readiness to deliver on such a promise. This kind of binary thinking—believing AI is either a complete solution or irrelevant—is a misguided interpretation of the issue.


Looking ahead, a more probable trajectory sees AI tools being extensively employed to enhance productivity across the multitude of sub-domains that encompass game development. Games, along with all forms of interactive media, are in essence a complex tapestry of various artistic and entertainment sectors, with game development incorporating elements of many other fields.


Almost every sector has aspects that have already been enhanced by AI tools or have demonstrations of AI automation poised to become widespread in the next year. Granted, achieving the requisite robustness to deliver meaningful value in the short term may be challenging for some.


I anticipate the gradual integration of these AI tools into top-tier game engines like Unreal Engine and Unity, affording the many benefits that come with a comprehensive development environment supported by case-specific AI models.



Development Asset Categories


One key element common to all these use cases is that they don't demand perfection right out of the gate, making them well-suited for the inherently probabilistic AI assistance and generation. There's always the opportunity to generate a wide array of variations and evolve based on the most successful elements of earlier iterations.


Programming: Previously discussed in another post; a topic vast enough to merit its own focus.


2D Textures, Concepting and Art Generation: Tools such as Stable Diffusion, Midjourney, and Adobe Firefly (incorporated into the Adobe ecosystem) are continually expanding their capabilities, demonstrating the effectiveness of AI in this area.


3D Models: Techniques like NeRF scanning convert real-world objects into 3D models. Text generation allows for editing of NeRFs and creating new ones from scratch in a truly generative manner.


Animations: Text-based generative animations are being commercialized, and they can naturally be combined with AI-generated 3D models.


Game Design/Ideation/Mechanics/Story/Dialogue: Textual GPTs have proved to be excellent assistants in generating content for almost every part of the game development process. Specialized, productized tools are available for niche applications.


Level Design: Unity has announced AI integration, hinting at scene/level editing via textual input. Roblox already features some level of integration. Textual GPTs can assist with ideation, though not actual level design or scene population.


Music: Numerous productized music generation services provide consistent styles and themes, suitable for most smaller projects.


Voice and Narration: A variety of solutions offer natural-sounding voice synthesis and these have already been integrated along with GPTs to e.g. Skyrim to provide dynamic voiced NPC dialogue.


Sound Effects: Current tools primarily focus on automated search and matching, with generative models for creating effects from scratch emerging.


AI: Demonstrations of AI-driven NPCs exhibiting human-like interactions and emergent behaviors have been rated highly by evaluators. Tools for AI models to learn 3D environments and behave organically are increasingly being integrated into leading software.


QA: For unit tests, typical code tools apply. For functional level, AI bots can autonomously play the game, report anomalies, and provide valuable data for design improvements.


Marketing and Community: One of the earliest large-scale applications for GPT.


Project Management: Automated data collection, insight generation, and KPI tracking are becoming more commonplace. There are numerous sub-categories with more specific use cases.


Localization: Automated translation and voice synthesis tools are widely available.


Monetization: Machine learning and data analysis have been central to this category for quite some time.


Conclusion


AI's role in game development is not a matter of all-or-nothing automation but rather a testament to the gradual, potent enhancements AI can bring to diverse aspects of the creation process. From design to quality assurance, AI tools are already showing potential, and their integration into mainstream game engines is a realistic expectation. Despite the challenges in achieving robustness, the continuous advancement in AI technology promises a future where these hurdles can be overcome, thus enabling a transformation of the gaming landscape that will redefine our creative potential.


Monday, 22 May 2023

Leveling Up Game Development: An AI-Assisted Adventure

Overview

For the past half a year, a significant portion of my spare time has been devoted to a Diablo/Soulslike action RPG game development project. My productivity skyrocketed once I found my rhythm, and a notable contributor to this swift progress has been the programming assistant AI tools. In this post, I'll delve into the best practices that have helped maximize the benefits of these AI tools.



Tools Used


My game is based on the Unity engine and, of course, C#. I code primarily in Visual Studio, utilizing a few core assets as frameworks, tools or for inspiration, and program the game logic mainly by myself. However, I do borrow some logic from the existing Top Down Engine asset when appropriate.


While I source visual assets from traditional licensed outlets (the Unity asset store has been invaluable!), the programming is self-executed with the aid of ChatGPT premium and GitHub Copilot. Regarding ChatGPT, I've been using GPT4 exclusively as it far outperforms GPT3.5 for coding tasks due to reasons such as the increased token count, which allows for more contextual input, and the reduced error rate in smaller tasks.


For context, I'm quite adept with C#, able to craft high-quality code at a respectable pace, especially when the key design issues have been addressed. This proficiency significantly influences my usage of AI tools.


Approach


Recognizing the strengths and limitations of AI tools is crucial:

  • They're less proficient in creating meaningful structure and architecture – these, I must detail myself.
  • They struggle with large contexts, needing to ingest multiple custom classes or APIs accurately.
  • They excel at executing junior developer level tasks for a method or class of moderate size (100-200 lines max), assuming dependencies are limited to avoid exceeding GPT4 token limits.
  • They're adept at handling larger tasks that have seen frequent reiterations in the training data (complex A* pathfinding algorithms, sorting algorithms, etc.)

Understanding the AI output is also important. There's a growing trend (memes to be precise) of junior devs generating code via AI, which they don't fully comprehend, leading to lengthy debugging sessions. In my experience, having a clear vision of the task at hand, producing code that is easily understandable and refactorable, and then moving on has proven effective. Revisits to these AI-assisted implementations are rare except when the requirements change.


Initially, I leaned more on GPT4 but over time have started to use Copilot more frequently. The basic protocol is:

  • When the scope of a method or class is clear and likely around 50-150 lines (with few dependencies), I write the method signature and a number of TODOs outlining the functional or pseudo code stages. This is then copy-pasted into GPT4 for implementation.
  • More often, I start coding the class manually, letting Copilot suggest code snippets at a consistent pace. Copilot usually suggests 1-4 lines of code and occasionally an entire function. 

An indispensable aspect of using either AI tool is swiftly scanning the code generated by GPT or the suggestions put forth by Copilot. This quick evaluation allows me to determine whether they align with my needs, identify potential issues, and decide promptly whether to accept, modify, or reject them. This step is absolutely vital due to the fundamentally probabilistic nature of these AI tools, which often lack certain key context—some of which might only exist in my mind.


I cannot stress enough the importance of having a clear, focused intention for what you want to achieve at a specific juncture. That is, unless you're consciously employing the AI for brainstorming or finding an initial approach. The dichotomy between implementation mode and brainstorming mode should be well-defined in your workflow when using these tools. I highly recommend this explicit distinction for optimal results.


In addition to the general approach, there are more nuanced rules of thumb that can be difficult to articulate. For instance, Copilot's auto-complete feature works great when adding new member variables with a specific type of initialization logic.


Unit testing


Though Test-Driven Development (TDD) doesn't mesh well with my Unity workflow due to the pervasive influence of the Unity scene context, unit tests remain important for more complex algorithms. I've found GPT4's approach of generating a suite of unit tests based on an implementation of my class to be an excellent starting point. This creates a robust scaffold that I can refine with my specific edge cases meaning my mental focus can be concentrated on what is unique to this situation while automating all the boilerplate.


Where AI Shines


Frequently, I find myself in situations where I need to employ a particular Unity subsystem or API with which I'm unfamiliar, or that I've simply overlooked. In such instances, GPT-4 proves exceedingly beneficial. My typical approach involves providing the method signature and functional tasks as inputs, requesting GPT-4 to generate the implementation. Given its extensive training data, GPT-4 usually nails the API usage impeccably.


This approach substantially eases the subsequent manual adjustment process, as I often start from a base where APIs are already largely correctly employed. I then carry out the final tweaks, which usually entails asking GPT-4 for a few iterations to handle more significant, necessary alterations.


Future Prospects


I recently gained access to Copilot Chat, part of the Copilot X suite, which offers additional IDE-integrated capabilities. Consequently, I may lean more on Copilot variants and less on GPT4 for coding.


Models like Copilot hold immense potential. A significant increase in token limits, coupled with better integration with code structure search tools, could lead to sweeping refactorings, improved large-scale context understanding, and ultimately, a significant leap in the utility of AI coding assistants.


What an exciting time to get stuff done efficiently!

From Architecture to Game Development: A New Blog on Echoes of Myth

I’ve launched a new  Echoes of Myth Development Blog , documenting my journey into game development and sharing insights from my first comme...