Over the last few weeks, this tutorial series designed and implemented simple dog behaviors using random decisions structured within behavior trees. This article shows you the C++ source code of the game’s AI logic as it is today.
Also, it’s time for you to put your thinking hats on; you need to decide what features to implement next. The biggest thing missing in the AI is the ability to perceive information from the world. Here’s another chance for you to design behaviors to show off the dog’s perception abilities.
Behavior Tree Implementation
The source code for the AI is split into four files, two .h headers and two .cpp source files. These define a Dog entity, and build up a behavior tree using low-level actions — as discussed in the previous tutorials.
The documentation is formatted up using AsciiDoc. Feel free to browse it here:
As you can see, the bulk of the code is in the two implementation files, first to define the actions and then to build behavior trees out of them.
The next logical step for the AI is to start integrating it with information from the world instead of making random decisions. This requires using a simple sensory system for gathering information.
So here’s your chance to help design some simple doggy behaviors. Here are the requirements:
Behaviors must demonstrate awareness of the environment — whether objects, annotated areas, or other dogs.
The props and behaviors must be easy to implement, preferably within a few hours of work.
Only certain animations described in the start of this AI tutorial are available for use.
Otherwise, you’re free to let your scary ideas go wild. Thing about interaction with other dogs, or meaningful zones that are annotated in the code.
Post a comment below if you want to help out!