Advice for Making Useful Modular Behaviours

Alex J. Champandard on May 31, 2007

1) Keep behaviors as simple as possible

Complexity quickly grows when you’re building a control system, so it’s important to keep the basic building blocks as simple as you can make them. This also makes actors much easier to test, either interactively or automatically.

2) Make them as generic as the game engine allows

When making behaviors, don’t go out of your way to limit their use to the purpose you intended. In some cases, it’s easier to make behaviors more general purpose. This will give more flexibility to your designers when combining the behaviors together.

3) Define few types of module

When you have different kinds of modules, they don’t plug together very easily. You end up with artificial restrictions for what you can do based on the types, and the code complexity goes up. For example, many AI engines have separate types of behaviors to represent actions (which do something in the world) and conditions (which simply check for information). If you can implement one as a special case of the other, then you’re better off!

4) Think about return statuses, success or failure

One of the most important aspects of computation is that it can either fail or succeed. It’s important to consider how this information is passed to other dependent behaviors, as they may rely on this to complete successfully. Two return status codes are not uncommon, but it can also be useful to distinguish between a clean failure (as an anticipated refusal to run), or an error (which indicates that something has gone wrong unexpectedly.)

Discussion 0 Comments

If you'd like to add a comment or question on this page, simply log-in to the site. You can create an account from the sign-up page if necessary... It takes less than a minute!