goku
goku game engine_en
goku game engine_en
  • Chapter 1: Introduction to SDL2, Rust, and goku
  • Chapter2: The Base Structure: SpriteSheet
  • Chapter 3: Animated Textures
  • Chapter 4: Handling Textures: TextureManager
  • Chapter 5: Bringing Textures to Life: GameObject
  • Chapter 6: The Foundation: Tile System
  • Chapter 7: Moving the View: Camera
  • Chapter 8: Particle System
  • Chapter 9: The User Interface Layer
  • Chapter 10: The Button Element
  • Chapter 11: The Text Box Element
  • Chapter 12: The Checkbox Element
  • Chapter 13: The Slider Element
  • Chapter 14: The Audio System
  • Chapter 15: The AI System
  • Chapter 16: The Window System
  • Chapter 17: User Input Handling
  • Chapter 18: Rendering a Parallax Background
  • Chapter 19: Timing and Frame Rate Management
  • Chapter 20: Conclusion
Powered by GitBook
On this page

Chapter 15: The AI System

The AI system is implemented using a behavior tree. A behavior tree is a model of the decision process of an agent in a game. It represents a set of decisions, which take the form of nodes in a tree structure. These nodes are of two types: leaf nodes (Action) and internal nodes (Selector and Sequence).

Leaf nodes represent actions, the basic building blocks of behavior. Each action returns a BehaviourTreeResult, which can be either Success, Failure, or Running.

Internal nodes, Selector and Sequence, each contain a vector of other nodes. They decide which of their child nodes will be processed and in what order. A Selector node will return immediately with a Success result as soon as one of its child nodes returns Success. On the other hand, a Sequence node will stop processing and return Failure as soon as one of its child nodes fails.

The tick method is called to process the behavior tree. It executes the action, selector, or sequence based on the node type, thus driving the AI's decision-making process.

PreviousChapter 14: The Audio SystemNextChapter 16: The Window System

Last updated 1 year ago