Behavior Tree Framework

For Cornell University Game Library

Read-Only Tree Structures

The behavior tree in this project is designed as a read-only structure, enabling multiple instances to operate on a single shared tree object. This approach eliminates the need to duplicate the tree for each entity, significantly reducing memory usage and improving runtime efficiency. At compile time, the tree's logic is pre-validated and optimized, ensuring predictable behavior and avoiding costly runtime errors. This design streamlines execution and allows for scalable AI systems, where many entities can simultaneously exhibit complex, coordinated behaviors with minimal overhead.

Instance initialization with reference to Tree

Multiple instances share a single read-only behavior tree, passed as a parameter during initialization. Each instance manages its own NodeDataVector for unique execution data like random seeds, ensuring independent behaviors. This design reduces memory overhead, enhances runtime efficiency, and simplifies instance creation without duplicating the tree's logic.

User-Custom Behaviors

We dynamically retrieve and run the user-defined function stored in the instances' NodeDataVector, ensuring flexibility and adaptability in node behavior. By allowing custom logic at the leaf level, this design provides a powerful way to tailor AI behaviors while maintaining the efficiency and structure of the shared behavior tree. It ensures extensibility without compromising the tree's core logic.