The Agent-Role Pattern

An interesting elaboration of the Actor-Role Pattern is the Agent-Role Pattern. The basic idea is borrowed from sociology, where an organization or society consists of agents (people and subsidiary organizations) playing roles (also called behaviors):

An agent has a schedule (list) of roles that it plays. New roles can be added to the schedule. The agent perpetually cycles through its schedule, executing each role. (Note that agents are active objects.)

A role may need to be executed several times before it is finished. When it is finished, the hosting agent removes it from the schedule. When its schedule is empty, an agent terminates.

A role can add new roles to its host's schedule. A role can also send messages to other agents and receive messages from other agents.

See Agent-Based Systems for a full treatment of this pattern.