Beyond AI Pseudo-code and Towards Sensory Systems

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.

AI Logic Source CodeBehavior Tree Source CodeAI Actions Source CodeLow-Level AI Source Code


First Sensations

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:

  1. Behaviors must demonstrate awareness of the environment — whether objects, annotated areas, or other dogs.

  2. The props and behaviors must be easy to implement, preferably within a few hours of work.

  3. 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!

2 Comments ↓

#1 Bjoern Knafla on 11.22.07 at 5:47 am

I am new to this type of collaborative development and therefore my first participation might not fit the form needed here but I wanted to point to an interesting article of Richard Evans and Thomas Barnet Lamb about the AI model in Black and White ( http://www.gamasutra.com/features/20020424/evans_pfv.htm ).

Basically they say that agents (in this case the dogs) should be aware of activities other dogs and they themselves are involved in. Only then they know how to act and how to react to the behavior of another dog.

For example if the low level sensory system tells a dog about another dog in his neighborhood (via a spatial sensory system). Then another sensor might tell him (for example by inspecting the behavior animation or just by reading a symbolic behavior-description tag) that this other dog searches for another dog to play with him. Based on this knowledge he might decide to run to the other dog and start a “lets” play behavior with the associated animation.

Cheers,
Bjoern

#2 Mikkel on 11.22.07 at 2:18 pm

What about doing smell? Let scent accumulate over the time at a dogs position (in some relatively coarse-grained grid) in much the same manner as it does for pheromones in Ant Colony Optimization. Each cycle, all dogs deposits a fixed amount of smell at it’s current position, while smell either dissipates or disappears from all positions. This would have the strength of a particular scent depend on how fast dogs move through the environment. Also, peeing and pooping could leave larger “chunks” (?) of scent.

Support this with a tracking behaviour that, in the same vein as ACO (go in the direction where the concentration of scent is highest), has the dog following a trail of smell using a combination of the sniffing and sneaking animations. This behaviour could then be used either to simply track other dogs or in combination with peeing and pooping, such that the dog would mark it’s territory near concentrations of smell.

Leave a Comment

Game AI Character