What Are Modular Behaviors

Alex J. Champandard on May 29, 2007

In a game, each actor is defined by a set of behaviors that are active over time. These behaviors can take effect for any reason, and remain active for a certain duration of time. For example, “waving to somebody” or “saying a few words” are behaviors.

Generally speaking, such a behavior is modular if it:

  1. Requires minimal number of dependencies to other elements within the game’s engine and data.

  2. Conforms to a pre-established specification when applied to an actor.

Behaviors are a composed of their own computation and memory. So, both must have the fewest possible dependencies and conform to a standard interface.

Modular Computation

To reduce the dependencies of your behaviors’ computation, they should be allowed as much as possible to:

  • Run independently from other behaviors.

  • Execute in parallel with other non-conflicting behaviors.

  • Disassociate themselves from the rest of the engine code.

This provides a great deal of flexibility, and it opens the door for parallelism of behaviors. Of course to make this really modular, you also need to think about their data too…

Modular Memory

Similar principles apply to the memory used by your behaviors if you want them to be modular:

  • Should be able to function with only the necessary data components of an actor.

  • Optionally use private memory, and be responsible for it.

  • Use a minimal of memory from other behaviors, preferably none.

As you’ll see in the next part, there are two opposite strategies for deciding exactly how to implement this.

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!