USING OF THE UTILITY SYSTEMS WITH BEHAVIOR TREES
12.10.2021 23:07
[1. Інформаційні системи і технології]
Автор: Vash Y., postgraduate, department assistant, Department of software systems, Uzhhorod National University, Uzhhorod;
Rol M., assistant, Department of software systems, Uzhhorod National University, Uzhhorod
The concept of utility-based systems [6] has been developed primary for mathematically depended areas such as economics. Through time utility concepts also impact other areas. In past years was explored by AI programmers primally in the game development area. By nature, utility systems are easy to map on behavior patterns. Basic idea behind utility systems is rather making complicated preconstructed task selection logic with manually determined priorities the developers are going to specify set of tasks and conditions (a.k.a. considerations [3]) for picking most suitable task depend on the AI agent and world properties. Every condition provides normalized float value from 0 to 1. The task with larger weight will be selected. For example, we can specify custom attack enemy task that will depend on a few conditions:
1. Do we have a weapon?
2. Do we have enough ammo?
3. How much health do we have?
Each of those conditions return normalized value, each value multiplied to provide single weight for task. The system which will pick most preferable task called – Reasoner. The reasoner can be implemented as class which contains list of tasks and additional info about priorities. Reasoners main purpose is to determine task to execute.
Most AI systems have their own pros and cons. For example, behavior trees by their nature are more static and require from the developer to specify priorities in sequence to check certain conditions. When it comes to large scale behavior trees with separated variative logic it can be tricky to configure. Most of the modern games try to avoid predictable AI agent behaviors. Here comes utility-based ai systems. It can help to improve behavior selection so the ai agent will behave less predictable. Most often behavior trees and utility systems are going along side by side. Combining those architectures bring developers to systems with the pros from both behavior trees and utility.
One of the commonly used way to combine those architecture is to make custom selector systems based on utility ai while rest logic is done using behavior tree. For example, game engines like Unreal Engine 4 provides powerful support of behavior trees [1] where users can specify their own services, decorators or even make custom engine modification to create game-specific sequence or selector nodes. Despite behavior tree system Unreal Engine 4 [2] provides tools for curve editing which can be used to make custom curves for utility ai score evaluations.
Implementation of utility ai integrated into behavior tree can be different depend on the project and requirements of the software. Most of the systems contains few common abstractions: tasks, conditions, reasoner. Applying utility ai to behavior tree developers can operate without task abstractions and create hybrid approach based on behavior tree services. For example, reasoner can be separated as standalone class which determine generic task id which has the highest priority. It means that we can abstract from direct involvement into the agent behavior logic and write more generic code.
Reasoner operates with enumerations rather task objects. Each enumeration can be casted to uint8 data type. This allow us to reuse same reasoning logic across different behavior tree leaves. This class can be used inside behavior tree service to determine enumeration variable that can be used by behavior tree selector to switch between different tasks. Also, reasoner can support minimal score value as a threshold. When evaluation return value that is not completely satisfying our needs, we can pick the default action instead.
To make reasoner to pick more unpredictable actions we can use weighted randomization based on action scores. Reasoner can be placed inside behavior tree service to determine next action. Here is example of behavior tree service written in blueprints using Unreal Engine 4:
Pic 1. Usage of reasoner inside behavior tree service
Reasoner can be placed inside behavior tree service to determine next action. Here is example of behavior tree service written in blueprints inside behavior tree:
Pic 2. Example of behavior tree using utility ai
Utility AI provides nice way to describe variable behavior for tree-based AI architectures. Utility systems are easy to write, easy to debug and easy to integrate with behavior tree services or AI controllers.
References:
1. Behaviour Tree Overview – [Electronic Resource] – Access Mode: https://docs.unrealengine.com/en-US/InteractiveExperiences/ArtificialIntelligence/BehaviorTrees/BehaviorTreesOverview/index.html
2. Unreal Engine 4 Documentation – [Electronic Resource] – Access Mode: https://docs.unrealengine.com/en-US/index.html
3. LEWIS, Mike. Choosing effective utility-based considerations. In: Game AI Pro 360. CRC Press, 2019. p. 361-372.
4. MERRILL, Bill. Building utility decisions into your existing behavior tree. In: Game AI Pro 360. CRC Press, 2019. p. 81-90.
5. HANLON, Sebastian; WATTS, Cody. Behavior Decision System: Dragon Age Inquisition’s Utility Scoring Architecture. In: Game AI Pro 360. CRC Press, 2019. p. 73-82.
6. MARK, Dave; DILL, Kevin. Improving ai decision modeling through utility theory. In: Game Developers Conference. 2010.