ALGORITHMS AND METHODS OF ADAPTIVE BEHAVIOR OF NON-PLAYER CHARACTERS IN COMPUTER GAMES
Abstract
The article is devoted to a comprehensive study of the Behavior Tree model as a tool for implementing artificial intelligence of Non-Player Characters (NPCs; Agents) in modern computer games. The relevance of applying hierarchical decision-making architectures is substantiated in the context of increasing demands for interactivity, adaptability, and realism in NPC behavior. It is demonstrated that the structured behavior tree model ensures logical organization of an agent’s actions, a transparent prioritization mechanism, and the possibility of system scalability without loss of manageability. The paper proposes a formalized architecture of a behavior tree, distinguishing composite nodes such as Selector and Sequence, as well as leaf nodes that implement specific actions (pursuit, attack, patrol, idle/wait). The tri-state execution model (Success, Failure, Running) and the tick-based evaluation principle are analyzed in detail, ensuring real-time system reactivity. Particular attention is given to constructing a priority hierarchy of behaviors, in which combat scenarios have higher significance, while alternative states serve as background or fallback actions. The practical implementation of the model was carried out in the Unity environment using the C# programming language. The uniqueness of the proposed algorithm implementations lies in the adaptability of the code for other engines based on C++. Examples of programmatic implementation of the base node class, composite structures, and tree initialization are presented, demonstrating the correspondence between theoretical principles and real software implementation. It is shown that the proposed architecture is modular, extensible, and suitable for integration into game projects of varying complexity. The obtained results confirm that behavior trees allow combining algorithmic rigor with game design flexibility, ensuring predictable yet dynamic agent behavior. The proposed approach can be used in educational prototypes, indie projects, and commercial developments, and can also serve as a foundation for further research related to Behavior Trees.
References
2. Champandard A. Behavior Trees for Next-Gen Game AI // Game Developers Conference (GDC). URL: https://www.gdcvault.com/play/1018040/Behavior-Trees-for-Next-Gen
3. Colledanchise M., Ögren P. Behavior Trees in Robotics and AI: An Introduction. Boca Raton: CRC Press, 2018. DOI: 10.1201/9780429489105
4. Cui Y. The exploring of AI applications in game development. 2025. DOI: 10.54254/2755-2721/2025.TJ23324
5. Iovino M., Scukins E., Styrud J., Ögren P., Smith C. A survey of Behavior Trees in robotics and AI. Robotics and Autonomous Systems. 2022. DOI: 10.1016/j.robot.2022.104096
6. Kacprzyk S., Hutsenko V. Comparison of artificial intelligence models used in computer games on the Unity platform. Journal of Computer Sciences Institute. 2023. DOI: 10.35784/jcsi.6471
7. Millington I., Funge J. Artificial Intelligence for Games. 2nd ed. Boca Raton: CRC Press, 2009. URL: https://www.routledge.com/Artificial-Intelligence-for-Games/Millington-Funge/p/book/9780123747310
8. Rabin S. (Ed.). Game AI Pro: Collected Wisdom of Game AI Professionals. Boca Raton: CRC Press, 2013. URL: https://www.routledge.com/Game-AI-Pro-Collected-Wisdom-of-Game-AI-Professionals/Rabin/p/book/9781466565975
9. Rabin S. (Ed.). Game AI Pro 2: Collected Wisdom of Game AI Professionals. Boca Raton: CRC Press, 2015. URL: https://www.routledge.com/Game-AI-Pro-2-Collected-Wisdom-of-Game-AI-Professionals/Rabin/p/book/9781482254792
10. Świechowski M., Lewiński D., Tyl R. Combining Utility AI and MCTS towards creating intelligent agents in video games // Proc. IEEE Symposium Series on Computational Intelligence (SSCI). 2021. DOI: 10.1109/SSCI50451.2021.9660170
ISSN 


