Wednesday, February 14, 2018

Tower Defense Starter Kit v2.2 Dev Log #2: Data Driven AI Design

In the previous dev log for the v2.2 update of Tower Defense Starter Kit, I talked about the new improvements to the wave spawning system, & in particular, the introduction of weighted spawn probabilities for different AI classes. If you're interested in knowing more about the same, you can get an in-depth read at Tower Defense Starter Kit Dev Log #1: Weighted Wave Spawning System. Getting back to the topic at hand, it was while working on the idea of weighted probability distributions that I decided to try out a data-driven approach to spawning AI bots. The tower spawning system had received a similar upgrade during the early stages of the toolkit and ever since then, I've occasionally had this thought cross my mind.

The introduction of a data-driven design ended up greatly streamlining the process of adding new features related to towers, and across a wide variety of scenarios. Most notable among these was that further changes to HUD systems required a far less hands-on approach as most of the associated UI elements were already being displayed dynamically based on the underlying data. And this drastically reduced the time required to release subsequent updates. However, all these advantages did not exactly warrant doing the same for the AI systems, as unlike towers, there were very few processes that were interlinked with them. Plus most of the updates were focused on other aspects of the toolkit. But that is about to change.

The primary focus of the next few updates is to improve the AI & Wave design elements of the toolkit. As mentioned in the previous dev log, I'd like to first create a foundational framework which facilitates the introduction of further customizations with ease. So as implemented in the case of tower spawning systems, I decided to make a small step towards taking a data-driven approach to AI design. No changes have been made to the core AI logic at this point. Instead, the basic attributes common to all AI classes, (like HP, Attack Damage, Vision Range, etc) have been migrated over to a new data table as shown below:

Over the course of new few updates, I would like to transfer more of the AI control parameters into the data table. For example, the Healer class AI has additional parameters that determine how often & by how much it can heal allied bots in the vicinity. A similar case can be said of the Tower Disabler bot as well, which can temporarily disable all nearby towers at periodic intervals. As of now, the variables that control these specialized functions still reside within their respective classes. In the future, I would like to have these unique parameters set through the data table as well. This could potentially allow us to have all data pertaining to the AI systems at a centralized & easily editable location, & also dynamically add special abilities like healing, based on the associated information.

Anyways I don't want to rush down that path without going over all the potential alternatives. So I'm taking it one step at a time right now. The v2.2 update will introduce the data-driven approach at a basic and limited level, with the wave spawning systems already synchronized with this design philosophy. I hope to develop it into a full-fledged system soon enough.