# Behavior utilities

The behavior utilities are a collection of signal procedures for creating, manipulating, and combining behaviors.

A behavior is represented as a group consisting of a motor-vector (what the behavior wants to do) and an activation-level (how badly it wants to do it).  If the activation level is a number, we will call it a graded activation behavior.  If its activation level is a Boolean, we call it a binary activation behavior.

## Constructor and accessors

(behavior activation-level  motor-vector)
Creates a behavior from component signals for the activation level and motor vector.
(activation-level behavior)
Returns the activation level signal for behavior.
(motor-vector behavior)
Returns the motor vector signal of behavior.

## Higher-order operators

(compose-activation f  behavior)
Returns a behavior identical to behavior, but whose activation level is the result of applying f to the activation level of behavior.
(compose-motor-vector f  behavior)
Returns a behavior identical to behavior, but whose motor vector is the result of applying f to the motor vector of behavior.

## Arbitration procedures

(behavior-+
The Arkin/Arbib motor schema combinator.  Returns a new behavior whose motor vector is the sum of the motor vectors of the argument behaviors, weighted by their activation levels.  Its activation level is activation-level, if specified, otherwise the sum of the activation levels of the behaviors.
This is the same as behavior-+, but only returns the motor vector, not a true behavior.
A variant of motor schema combination.  Returns a new behavior whose motor vector is the weighted average of the motor vectors of the argument behaviors, weighted by their activation levels.  Its activation level is new-activation-level, if specified, otherwise, it is the average of the activation levels of the behaviors.
The weighted average: the weighted sum divided by the sum of the weights
(behavior-max
The "Tinbergen combinator".  Returns the behavior with the highest activation level.  If activation-level is specified, it is used as the activation level of the result.

(behavior-or binary-activation-behavior ...)
(behavior-or
activation-level binary-activation-behavior ...)
A simplified version of the subsumption combinator.  Returns the leftmost argument that is active.  The activation level of the result is activation-level, if specified, otherwise the or of the activation levels of all the inputs.

(max-motor-vector behavior ...)
Returns the largest motor vector of the behaviors.

(suppress binary-suppressor  binary-suppressee)
(suppress binary-suppressor  binary-suppressee   time)
An approximation of the subsumption suppressor node.  Returns the suppressor, if its activation level is non-zero, else suppressee.  If the optional time argument is specified, the suppression continues for time milliseconds after the suppressor's activation level returns to zero.
(inhibit binary-inhibitor  binary-inhibitee)
(inhibit binary-inhibitor  binary-inhibitee   time)
An approximation of the subsumption inhibit node.  Returns a behavior with the motor vector of inhibitee, but which is active only when inhibitee is active but inhibitor is not.  If the optional time argument is specified, the inhibition continues for time milliseconds after the inhibitor goes inactive.