AI with a Behavior Decision System
Something I found very interesting about the AI of the companions in Dragon Age: Inquisition is how the player is able to select what abilities the companions can use and how frequently they would like the companions to use them.
I decided to look into how this was implemented and try doing something similar in Unity. I discovered that it uses an original system created for the game dubbed The Behavior Decision System, which functions like a traditional decision tree, however it uses a priority queue to come to each leaf on the tree, rather than a large tree which can become unwieldy and expensive in complex systems.
The code for the project is available under the MIT license at this Github link.
Below is an in-engine demonstration of the AI in action.
(N.B. there are no elements which the user can interact with at this time).
Planning of UX/UI
To demonstrate what the AI was doing I felt it would be important to display the factors the AI agents were considering when they made their decisions, especially showing what task they were currently thinking of, and any sub-tasks which came from it.
To better show where each character was, I felt that keeping a live camera following each character would be really helpful in quickly navigating between the UI and the game play.
On the left is an example of a "Behavior Snippet" that serves as a "leaf" which the Behavior Decision System may end up using as the behavior for an agent. The key, required functions for every behavior snippet are:
HandleSleep (the constructor)
This constructor sets the name of the current goal, which is displayed in the UI as the smaller italicized text, it also sets up any other relevant stats for this derived class.
This is an update that occurs once this is a valid snippet for the agent to use, even if it is not the snippet that the player will use. It is almost always used exclusively to update the "actionValue" of the snippet (in this case, increasing it as the agent gets more exhausted).
This is the update that occurs if, and only if, this is the "current" behavior snippet has the highest actionValue of all the snippets available to the agent. This is where the actual actions that this snippet makes the player do take place (in this case ).