Game Development Reference
In-Depth Information
Controlling groups of AI
In this recipe, we'll kill two birds with one stone and implement both an interface for group
AI management and look at weighted decision making.
In many ways, the architecture will be similar to the Decision making - Finite State
Machine recipe. It's recommended to have a look at it before making this recipe. The big
difference from the normal state machine is that instead of the states having definite out-
comes, an AI Manager will look at the current needs, and assign units to different tasks.
This recipe will also make use of an AIControl class. This is also an extension of the
AIControl that can be found in the Creating a reusable AI control class recipe.
As an example, we'll use resource gathering units in an RTS. In this simplified game, there
are two resources, wood and food. Food is consumed continuously by the workers and is
the driving force behind the decision. The AI Manager will try to keep the levels of the
food storage at a set minimum level, taking into account the current consumption rate. The
scarcer the food becomes, the more units will be assigned to gather it. Any unit not occu-
pied by food gathering will be assigned to wood gathering instead.
Search WWH ::




Custom Search