-

Chaos Dev Diaries Episode 2:

-
 
Invest in Popularium
 

Chapter 1: The Philosophy of Chaos (Agents)

 

“Wait, why did my Agent just run past that Shard without collecting it?”,

“Oh no, you , don’t go after that guy, go after THAT gal who’s at 5 HP!”,

And the always popular “No! Not that way you moron, you’re supposed to be SURVIVING, not running into the grand melee of 4 Agents annihilating each other, and now you…and there goes our hard-fought Shardmaster win.”

Why do our Chaos Agents do what they do? It’s a question that you have asked yourself, at least once. Well, wonder no more, as this is your first glorious opportunity to take a journey deep into the mind of a Chaos Agent.

Welcome to Episode 2 of the Chaos Dev Diaries, where we give you an in-depth look into how a Chaos Agent’s AI works, as of v1.8.6.

With Chaos Agents‘ AI, our philosophy is to be predictable and flexible:

1. Predictable, so players can learn how to predict how their Agent will behave under various conditions.

2. Flexible enough for Skills to have a meaningful impact on the Agent’s behavior. For example, ensure that the Agent’s AI is flexible enough for a “Bloodthirsty’ Skill that, if purchased, lets the Agent select the Enemy Agent in Vision Range with lowest health as its Attack Target instead of the nearest Enemy Agent.

3. Flexible enough for AI Strategy decisions that the player makes to have meaningful impact, while leaving enough scope for the Agent’s decisions, when interacting with the decisions of several other Agents, to create interesting scenarios that require real-time problem solving, as opposed to memorizing and regurgitating a predefined strategy during a match.  

With the release of Chaos Agents v1.8.6, we believe that the Agent AI is in a state where it is stable enough to achieve the above goals to a reasonable degree.

The updates in the “SURVIVE” AI Strategy, specifically in how an Agent calculates its “Escape Vector”, are a key step towards getting the Agent AI to this state.

As a result, we wanted to give our Chaos Agents community a closer look at how their Agent’s AI works, so that they can make more informed decisions during upcoming matches and Tournaments with a deeper understanding of the Agents’ decision-making process and logic in any given scenario.

Having said the above, the Agent AI for Chaos Agents will forever evolve, and we should expect the Agent AI described below to evolve in the future. Take a look at the “Chapter 4: Future of Chaos Agents AI” section for a look into how your Agents’ AI might evolve in the future, and the role you can play in it.  

Enjoy this deep dive into the digital brain of your Chaos Agent!

 

Chapter 2: Basic Concepts

   

Before we start our journey into the brain of your Chaos Agent, it’s important to understand few basic concepts about the game engine driving Chaos Agents:  

1. What is a Location on the map?

A Location is simply the (x,y) coordinate of an Agent (or another entity) on the Chaos Agents map (or “Game Board”).

2. What is a Tick?

A Tick is the smallest unit of time measurable by a Chaos Agent within a match.. The Chaos Engine allows any length of actual time to be set as a Tick. As of v1.8.6, a Tick is equal to 0.1s of real time (and this has been stable since v1, so it’s unlikely to change.)   3. What is an Agent Action?

While Chaos Agents appears to be a real-time game, it’s a “pseudo real-time game”, which means that under the hood it functions more like a turn-based game akin to a board game. In this board game, all Agents take their turns simultaneously, and then the game “resolves’ the actions taken by the various Agents to determine the actual outcome. For example, an Agent might decide to move from point X to point Y during their turn, but maybe they take damage from another Agent that causes them to get knocked out before getting to point Y– the computer helps resolve these types of “conflicting actions” for multiple Agents. An Agent Action (or “Game Unit Action”) is an atomic action that an Agent takes during a Tick–that is, over 0.1s of real time. An Agent Action can be a Movement Action, an Attack Action, a Collect Shard Action or a few other types (such as a “Stay Action” which means the Agent can’t do anything else during that Action).

4. What is a Tick Batch?

An Agent makes decisions not for each Tick, but for a predetermined number of Ticks at a time, and that number is called the Tick Batch. In v1.8.6 a Tick Batch is 10, so the Agent makes decisions for 10 Ticks at a time. Since a Tick is 0.1s, this means that the Agent calculates the next set of Actions that it takes every 1 second. This means that the Agent makes decisions for 10 Ticks – that is, it calculates 10 Agent Actions at a time.  

5. What is a Tick Batch Agent Action List for a Chaos Agent?

The Tick Batch Agent Action list for a Chaos Agent is the list of Actions that it takes during a Tick Batch. That is, these are the 10 Actions that it takes over 1 second, with each Action lasting 1 Tick (or 0.1s). Once an Agent calculates its next Tick Batch worth of Actions, it’s “locked into” performing that set of Actions. This means that the Agent can only take in additional inputs and “change its mind” after 1s worth of Actions.

So, the goal of the Chaos Agent’s AI algorithm is to generate the “best possible” next Tick Batch worth of Actions (10 Actions as of v1.8.6) based on the various input and conditions that the Agent has the consider, for example the current “AI Strategy” based on its current health, and other inputs from the player.

 

Chapter 3: How a Chaos Agent’s AI works

   

The first state that the Agent checks for is the “AI Strategy” that it is currently set to.The AI Strategy is determined by the “Health Tolerance Threshold” that is set by the Player during the Power-up Phase.  If the Agent’s Health is above the “Health Tolerance Threshold” then the Agent is on the “PURSUE OBJECTIVE” or “OBJECTIVE” AI Strategy. If the Agent’s Health is below the “Health Tolerance Threshold” then the Agent is on the “SURVIVE” AI Strategy.

3.1 "PURSUE OBJECTIVE" AI Strategy Logic - Attack or Collect

 

If the Agent is on “PURSUE OBJECTIVE” AI Strategy, it then checks for what its current Objective is, based on the objective prioritized by the player:

  • Prioritize Collect or “COLLECT” AI Strategy: The objective is to maximize Shard collection.

  • Prioritize Attack or “ATTACK” AI Strategy: The objective is to maximize Attacking other Agents.

If the Agent is on “ATTACK” AI Strategy:

  • The Agent checks to see if it has an Enemy Agent in its Vision Range.

  • If yes, then the Agent selects the nearest Enemy Agent as its Target Enemy Agent.

  • The Agent checks to see if it has an Attack available – that is not on Cooldown — that can cause Damage to the Target Enemy Agent. For v1.8.6, the default Cooldown Period for Melee Attacks is 1s, and for Ranged Attacks is 3s (these can and will change.)

  • If there is more than 1 type of Attack available that can cause Damage to the Target Enemy Agent, pick the “most preferred” Attack type out of these. Each Agent has a “stack” of Attack Types ordered by which Attack Type they prefer - Melee or Ranged Single Target Attacks for now, more Attack Types such as AoE Attacks will be introduced in the future. Typically the Agent will prefer Attacks that do higher amount of Damage, if more than 1 Attack Type is available.

  • The Agent then generates “Attack Actions” of the appropriate Attack Type and adds these Actions to its “TickBatch Actions List”.

  • However, if the Agent does not have an available Attack Type (not on Cooldown) that can Damage the Target Enemy Unit, then it generates “Movement Actions” towards the Target Enemy Unit.

  • If the Agent does not have an Enemy in its Vision Range, then it checks to determine if there is a Shard available to Collect in its Vision Range. If a Shard is available in its Vision Range, then the Agent jumps to the “COLLECT” AI Strategy logic flow, as described below, and tries to move towards and collect the Shard. The “COLLECT” AI Strategy logic flow is described by the “GCMA” Flowchart (Generate Collect and Movement Actions).

If the Agent does not have an Enemy Agent nor a Shard for Collection in its Vision Range, then it picks a new Destination Location on the Map to go to look for Enemy Agents. The “Attack and Movement” flowchart below goes into more detail.

If the Agent is on “COLLECT AI Strategy”:

  • The Agent checks to see if it has a Shard in its Vision Range.

  • If yes, then the Agent checks to see if the Shard is within its “Collect Range” (the maximum distance at which the Agent can Collect the Shard) and if the Collect Action is not on Cooldown.

  • If the Shard is within the Agent’s “Collect Range”, then it generates “Collect Actions” for the minimum duration that it needs to collect a Shard “Collect Period” (0.5s by default for v1.8.6).

  • If the Shard is outside of the Agent’s “Collect Range”, then the Agent generates “Movement Actions” towards the Shard.  

  • If the Agent does not have a Shard within its Vision Range OR if the Agent’s Collect Action is on Cooldown, then it checks to see if it has an Enemy Agent in Vision Range. If yes, then the Agent’s logic jumps to the “ATTACK” AI Strategy flow.  If no, then the Agent picks a new Destination Location on the map to move to look for more Shards to Collect. The flowchart below goes into more detail.

3.2 "SURVIVE" AI Strategy Logic

 

If the Agent’s Health is at or below the “Health Tolerance Threshold”, then the Agent goes to the “SURVIVE” AI Strategy logic flow. In the “SURVIVE” AI Strategy, the Agent first checks to see if there are any Enemy Agents in its Vision Radius. If so, then the Agent calculates a “Escape Destination Location” on the map where it thinks it can be safe from Enemy Agents. The Agent calculates this “Escape Destination” by noting the Locations on the map of all the Enemy Agents in its Vision Range, and calculating an “Escape Vector”. The “Escape Vector” is calculated by taking the average angle of the vectors between your Agent and each Enemy Agent, and reversing the direction of this average vector.  

“Fun but Frustrating” Trivia! Why oh why did Agents (prior to v1.8.6) calculate “Escape Vectors” that would take them right into danger zones, sometimes with multiple Enemy Agents?

The reason for this was that we wanted the initial Agent AI kit to be as simple as possible, to aid predictability, testing, and debugging. To keep things simple, the SURVIVE Agent AI calculated the Escape Vector for an Agent taking into account only the nearest Enemy Agent, not all Enemy Agents in its Vision Radius. The unfortunate result of this method of calculating the Escape Vector is that the Agent does not take into account the Locations of any Enemy Agents other than the nearest Agent, and can therefore calculate an Escape Vector that takes the Agent right into the path of another Enemy Agent, or worse, into a cluster of Enemy Agents engaged in fighting each other. This behavior is now avoided from v1.8.6 onward by having the Agent take into account all Enemy Agents in Vision Range, instead of just the nearest Enemy Agent, when calculating the Escape Vector.

 

 Chapter 4: The Future of Chaos Agents AI

     

With the way that the Chaos Agents AI framework is architected, we can easily swap modules in and out for:

  • ATTACK AI logic flows

  • COLLECT AI logic flows

  • SURVIVE AI logic flows  

As a result, we can and will experiment with different types of ATTACK, COLLECT, and SURVIVE logic flows based on the Agent AI behavior observed during the Pre-Alpha and Alpha phases of development. So, while we expect the Agent AI to behave as written in this Dev Diary paper for v1.8.6 and beyond, we will keep tweaking the logic flows to best serve the evolution of Chaos Agents’ gameplay, which for example, will change considerably with the introduction of Skill Maps in a future Chaos Agents version. We have very early plans to make the ATTACK, COLLECT, and SURVIVE Agent AI API available for the more technically-inclined members of the Chaos Agents community, so stay tuned!