Skip to main content
Log in

Behavior Trees for Modelling Artificial Intelligence in Games: A Tutorial

  • Published:
The Computer Games Journal

Abstract

We provide a tutorial introduction to behavior trees, which are a useful way of structuring artificial intelligence in games. A behavior tree is a model of plan execution that is graphically represented as a tree. A node in a tree either encapsulates an action to be performed or acts as a control flow component that directs traversal over the tree. Behavior trees are appropriate for specifying the behavior of non-player characters and other entities because of their maintainability, scalability, reusability, and extensibility. We describe the main features of behavior trees, show an example of how to create a behavior tree, and briefly survey existing packages for editing behavior trees. We recommend that behavior trees be used when some game designers are not programmers, the conditions governing the behavior are complex, and the NPCs have aspects of behavior in common.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6

Similar content being viewed by others

References

  • Bates, J. (1994). The role of emotion in believable agents. Communications of the ACM, 37(7), 122–125.

    Article  Google Scholar 

  • Bohm, C., & Jacopini, G. (1966). Flow diagrams, turing machines and languages with only two formation rules. Communications of the ACM, 9(5), 366–371.

    Article  MATH  Google Scholar 

  • Brainiac Designer. (2009, November 23). Retrieved June 11, 2016, from CodePlex: https://brainiac.codeplex.com/.

  • Bungie Studios. (2004). Halo 2, video game, Xbox, Microsoft.

  • Champandard, A. J. (2008). Getting started with decision making and control systems. In S. Rabin (Ed.), AI Game programming wisdom (Vol. 4, pp. 257–264). Boston: Charles River Media.

    Google Scholar 

  • Colledanchise, M., & Ogren, P. (2014). How behavior trees modularize robustness and safety in hybrid systems. IEEE/RSJ International Conference on Intelligent Robots and Systems (pp. 1482–1488). Chicago: IEEE.

  • Epic Games. (n.d.). Behavior Trees. Retrieved June 18, 2016, from Unreal Engine Documentation: https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/index.html.

  • Flórez-Puga, G., Gómez-Martín, M. A., Gómez-Martín, P. P., Díaz-Agudo, B., & González-Calero, P. A. (2009). Query-enabled behavior trees. IEEE Transactions on Computational Intelligence and AI in Games, 1(4), 298–308.

    Article  Google Scholar 

  • Humphreys, T. (2014). Exploring HTN planners through example. In S. Rabin (Ed.), Game AI pro: Collected wisdom of game AI professionals (pp. 149–167). Boca Raton: CRC Press.

    Google Scholar 

  • Isla, D. (2005). Handling complexity in the Halo 2 AI. Retrieved January 15, 2014, from http://www.gamasutra.com/view/feature/130663/gdc_2005_proceeding_handling_.php.

  • Isla, D. (2008). Building a better battle: The Halo 3 AI objectives system. Retrieved February 8, 2017, from https://web.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/halo3.pdf.

  • Johansen, E. (2016). The Behave project. Retrieved June 15, 2016, from AngryAnt: http://angryant.com/behave/.

  • Johansson, A., & Dell’Acqua, P. (2012). Emotional behavior trees. IEEE Conference on Computational Intelligence and Games (pp. 355-362). Granada, Spain: IEEE Xplore.

  • Khoo, A. (2006). An Introduction to behaviour-based systems for games. In S. Rabin (Ed.), AI Game programming wisdom (Vol. 3, pp. 351–364). Boston: Charles River Media.

    Google Scholar 

  • Lim, C.-U., Baumgarten, R., & Colton, S. (2010). Evolving behaviour trees for the commercial game DEFCON. Applications of Evolutionary Computation (pp. 110–110).

  • Llopis, N. (2010). Game architecture. In S. Rabin (Ed.), Introduction to Game Development (pp. 235–270). Boston: Charles River Media.

    Google Scholar 

  • Marcotte, R. (2017). Modelling artificial intelligence in games using MindSet behavior trees. Regina: Department of Computer Science, University of Regina.

    Google Scholar 

  • Marzinotto, A., Colledanchise, M., Smith, C., & Ogren, P. (2014). Towards a unified behavior trees framework for robot control. IEEE International Conference on Robotics and Automation (pp. 5420–5427). Hong Kong: IEEE.

  • Mateas, M. (2002). Interactive drama, art, and artificial intelligence. Technical report CMU-CS-02-206, Carnegie Mellon University, School of Computer Science, Pittsburgh.

  • Mateas, M., & Stern, A. (2005). Structuring Content in the Facade Interactive Drama Architecture. In Proceedings of Artificial Intelligence and Interactive Digital Entertainment (AIIDE 2005). Marina del Rey, CA.

  • Merrill, B. (2013). Building utility decisions into your existing behavior tree. In S. Rabin (Ed.), Game AI Pro (pp. 127–136). Boston: Charles River Media.

    Google Scholar 

  • Millington, I. (2009). Artificial intelligence for games (2nd ed.). San Francisco: Morgan Kaufmann.

    Google Scholar 

  • Mosiman, J., & Watson, S. (2014, February 10). Behavior Designer—behavior trees for everyone | Unity Community. Retrieved June 17, 2016, from Unity3D Forums: http://forum.unity3d.com/threads/behavior-designer-behavior-trees-for-everyone.227497/.

  • Pereira, R. (2015, June 24). GitHub—behavior3/behavior3editor. Retrieved June 14, 2016, from GitHub https://github.com/behavior3/behavior3editor.

  • Pillosu, R. (2009). Coordinating agents with behavior trees. Paris Game AI Conference ‘09. Paris, France. Retrieved from https://aigamedev.com/premium/presentations/coordination-behavior-trees/.

  • Pousman, Z., Mateas, M., & Wolff, M. (2009, July 21). ABL (A Behavior Language), Tutorial v01. Retrieved 05 28, 2017, from http://www.cc.gatech.edu/~simpkins/research/afabl/ABL_Tutorial.pdf.

  • Rabin, S. (2010). Artificial intelligence: Agents, architecture, and techniques. In S. Rabin (Ed.), Introduction to game development (2nd ed., pp. 521–557). Boston: Charles River Media.

    Google Scholar 

  • Rasmussen, J. (2016, April 27). Are behavior trees a thing of the past? Retrieved August 2, 2016, from Gamasutra: http://www.gamasutra.com/blogs/JakobRasmussen/20160427/271188/Are_Behavior_Trees_a_Thing_of_the_Past.php.

  • Schenk, K., Lari, A., Church, M., Graves, E., Duncan, J., Miller, R., & Schaeffer, J. (2013). ScriptEase II: Platform independent story creation using high-level patterns. Proceedings of the Ninth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment (AIIDE) (pp. 170–176). Boston: AIIDE.

  • Shoulson, A., Garcia, F., Jones, M., Mead, R., & Badler, N. (2011). Parameterizing behavior trees. Motion in Games, 2011, 144–155.

    Article  Google Scholar 

  • Weiss, M. A. (2013). Data structures and algorithm analysis in C ++ (4th ed.). Upper Saddle River: Pearson.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Howard J. Hamilton.

Appendix: Pseudo-Code and Icons for Decorator Components

Appendix: Pseudo-Code and Icons for Decorator Components

See Figs. 7, 8, 9, 10, 11, 12 and 13.

Fig. 7
figure 7

The succeeder decorator

Fig. 8
figure 8

The failer decorator

Fig. 9
figure 9

The basic repeater decorator

Fig. 10
figure 10

The repeat-until-success decorator

Fig. 11
figure 11

The repeat-until-failure decorator

Fig. 12
figure 12

The count-based limit decorator

Fig. 13
figure 13

The timer-based limit decorator

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Marcotte, R., Hamilton, H.J. Behavior Trees for Modelling Artificial Intelligence in Games: A Tutorial. Comput Game J 6, 171–184 (2017). https://doi.org/10.1007/s40869-017-0040-9

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s40869-017-0040-9

Keywords

Navigation