A Development Overview of a Complex AI Character Project
AI characters have generally been developed using behavioral trees – a simple, if-this-then-that logical model. While this system is straightforward and effective for basic actions, I felt it didn’t fully capture the nuances needed for more human-like, complex AI behavior.
Brain-like Processing Structure
My approach drew inspiration from the human brain and how we acquire, process, and react to information. Unlike binary code that works with discrete values, our brain operates fluidly and continuously. I aimed to mimic this in my character’s structure through a three-tiered processing system: Primitive, Emotional, and Complex Processing. Each processing ‘Tick’ deals with different types of information.
- Primitive Processing: The first and fastest level is triggered every 0.2 seconds. It’s responsible for reflexive, instinctual actions and automatic information intake – akin to recognizing an object without active thought, a regular brain function.
- Emotional Processing: The next tier activates every 0.5 to 0.6 seconds, processing emotional reactions and memory. This layer governs how the character reacts to significant events and recalls experiences, mirroring our brain’s tendency to remember emotionally charged events more vividly.
- Complex Processing: The final and slowest tier ticks every 1.2 seconds, handling strategic thinking and decision-making. This part is the most cognitively demanding, akin to planning actions or solving complex problems in our own minds.
The tick rate is malleable and could be modified by character stats like intelligence, reaction speed, empathy, and more.
Decisions and Actions
The character’s decision-making process involves four stages – Goals, Strategies, Decisions, and Actions.
- Goals: The character sets a broad goal, such as winning a game. It can choose a defensive or offensive approach based on its role (healer, archer, etc.). The goal starts generally and gets more specific, like: Win -> Defensive -> Assist Ally for a healer.
- Strategies: To achieve its goal, the character needs a plan. For instance, it could decide to heal an ally while maintaining distance from enemies or wear down the enemy with arrows, moving in for a melee attack to finish them off. Each goal can be achieved through multiple strategies.
- Decisions: The character decides the sequence of actions for executing its strategy. If it opts for a close attack, it will need to run towards the enemy, pull out a dagger, and engage in combat.
- Actions: The character executes specific actions as per the decided sequence. For example, using the navigation mesh to find the best path to the enemy, running, pulling out a dagger, and attacking.
Multiple Actions, Multiple Body Parts
To create a more dynamic character, I developed a system where the character can perform multiple actions simultaneously. This was achieved by assigning separate actions to different body parts – lower legs, left arm, right arm, and head. While running (a lower leg action), the character can simultaneously pull out a dagger (a right arm action). Instead of dealing with almost infinite combinations of actions (run, run & heal, run & equip, etc.), we can stack them together. A crucial consideration is the conditions for actions to break or how disruptive events are handled.
This is merely a basic overview of the system. The intricacies and complexity go far beyond this when developing a system like this.
For the brain processing and logic system, I am using a new state tree feature, which appears to be a good fit despite some initial hiccups. Goals are determined using gameplay tags, providing a desirable level of granularity from general to specific goals. Strategies are segregated into data assets that house a list of necessary actions for execution. Actions, also data assets, reference a specific component that houses the rules for executing that action.
The Animation Blueprint is complicated, given the different body parts that all need to synchronize. The current setup includes different anim graphs for the head, legs, body, pelvis, left arm, and right arm, allowing for plugging in appropriate animations. The separation of the pelvis might be unnecessary, as it usually moves in tandem with the legs.