DEV Community

Cover image for Power of "Data-Driven Architecture" applies to game development as well
tomokat
tomokat

Posted on

Power of "Data-Driven Architecture" applies to game development as well

I thought I didn't write here for while but looks like I did write one article back in Jan 4th this year so maybe it's not that bad.

Table of Contents

I want to make sure I'm focusing on "development" topic when I write something here - as opposed to just give an update to my game development (honestly, who cares about that? lol) and since I started to establish my "development flow" which goes like this:

  • start with Chat GPT to refine my ask, make sure I'm clear on what I want
  • eventually Chat GPT generate "nice looking" (or "scary looking") super long, detailed prompt that I won't have patience to write
  • I then pass it to Antigravity
  • Check the work done, sometimes I need to chime in to fix few things here and there but for most part Chat GPT + Antigravity will make it happen in very few try

So ... yeah, I'm no longer "developing" code and hence I feel I don't have much to add value to dev.to community. I feel here, most people are fairly hardcore developers.

But today I feel I have a topic that I finally want to share and write bit about - and that is the power of "Data-Driven Architecture".

Bit of terminology

I need to look up if this is the real term (I think it was anyway) - yep, I was wrong (and glad I check it) Originally I thought it is "Data-Driven Development" but that term might be confusing with business term "Data-Driven" so Gemini suggested to change it to "Architecture" :) Anyway, just because I add a word "Architecture" won't all the sudden make me smart, so please bear with me if I said something bit off - goal of this post is to share my experiences and why I felt this approach make sense.

Motivation

Fist of all, let's state the obvious - "game development is time consuming activity". While AI can greatly reduce effort, we all know it won't be just magic box that you can throw whatever you want and it generates (well, maybe for fairly simple thing it can) So you want to reduce effort on your end when it comes to perform the cycle of:

  • developing a feature
  • testing a feature (manually)

The problem

This is especially true when you are solo developer - you have so many things you need to do and last thing you want to deal with, is bunch of hard-coded logic all over the place. Why? Because you can't quickly try slightly different thing - like what if I increase the HP of this boss monster, how does that impact the playability of my game? (I'm purposely trying to keep this to as generic as possible - so not talking too specific about what I'm building) If your logic is deeply hard-coded in the game itself you (or AI) will be

  • first locate the code/area where you need ot change value
  • (this might trigger process like compilation - depends on your setting/language/framework/game engine)
  • test your feature (manually)

This works, to some degree but eventually will drive you crazy. I can tell you this because when I built my old game with Android 0.6, I was doing this. I was using Static classes all over the place to trigger game logic and boy it was messy! Honestly I was young, inexperienced but had lots of time on my hand so I end up brute force this and (somehow) get to the point I release the app (really scary what passion can do - but in the end that's why I end up spending 3000+ hours on this)

A solution

I said "A solution" as I'm sure this is not the only way to solve this problem. I never used it myself but from what I see, this is exactly how "RPG (or Game) Maker" provide to its users. It provides ability to set various events (which is crucial for RPG game) and be able to trigger nicely. It also provide a way to quickly tweak monster parameters by changing values (stored in some form of DB?)

I honestly didn't know how exactly I can do this but I know what is my ideal state so I started to ask how I can extract game logic (whether it is to handle ADV game like conversation, to manage hotspots data in the town) I already wrote about these so I won't repeat myself here but that was best decision I made. Why? Because it game me ability to extend my game rapidly. I can keep adding new FX (of which I can simply define in my txt file, converted to CSV format and then let my game read and react to it)

I then keep applying this concept whenever I can - I need a logic to build "world" which I wanted to be super configurable but make many parameter random (yep, I want to build "rogue-light" game) and I just made a way to do this pretty much all things defined in JSON file and then be able to even add yet another hook from my txt file to call this with simple target id. I can't express the freedom this provide to me - I can now trigger this from pretty much any event scene (not that I have good reason to do that, but hey, you never know - I might want to do that at some later stage)

{
  "id": "WT_CALM",
  "name": "Calm",
  "tags": [
    "intro",
    "stable"
  ],
  "bgPool": [
    "bg_world_0"
  ],
  "rules": {
    "gridMin": 11,
    "gridMax": 11,
    "distortionGainPerStep": 0,
    "distortionGainPerBattle": 5,
    "monsterRate": 0.08,
    "npcRate": 0.03,
    "worldDistortionLimit": 100,
    "encounters": {
      "monster": {
        "mode": "count",
        "min": 7,
        "max": 9,
        "respawn": {
          "checkSteps": 7,
          "spawnMin": 2,
          "spawnMax": 3,
          "constraints": {
            "minDistFromCity": 3,
            "minDistFromPlayer": 5,
            "preferFog": true
          }
        }
      },
      "npc": {
        "mode": "count",
        "initial": 2
      },
      "elite": {
        "mode": "count",
        "initial": 1,
        "visible": true
      }
    }
  },
  "overrides": {
    "cities": [
      {
        "id": "first_town",
          "pos": {
            "x": 2,
            "y": 2
          },
          "hubId": "hub_1"
        }
      ],
      "dungeonGates": [
        {
          "id": "gate_intro_1",
          "pos": {
            "x": 8,
            "y": 8
          },
          "dungeon": {
            "type": "earth"
          },
          "gate": {
            "bgKey": "bg_gate_01",
            "titleKey": "gate.intro.title",
            "descKey": "gate.intro.desc"
          }
        }
      ],
    "disableRandomCities": true
  }
},
Enter fullscreen mode Exit fullscreen mode

please note: this game is under development and most likely this data format will change (also not everything described here are implemented - some are just placeholder still lol)

Conclusion

I feel "Data-Driven Architecture" is a way to go and anther benefit this approach provides in this AI era is that it seem to be easier for AI (both my brain partner Chat GPT and my amazing developer Antigravity) to understand what I want. I wonder why and then came to realize that you are essentially forced to bring potentially complex concepts if we were to explain all this through words but data format like this is lot easier for AI (or even for me) to make sense.

Bit of info about my game

Lastly, if you are interested, please check my itch.io site that I recently created - here, I plan to post more about my game progress (through development blog post feature) I plan to release Trial version of my game in sometime late February so please check it out!

https://w-ai.itch.io/para-logos-w-ai

Top comments (0)