Rules & Conditions¶
The tokens on the Blackboard are processed by rules and conditions. The conditions determine when something is processed and the rule determines how it is processed.
The figure below visualizes the control flow of conditions and rules. Each rule needs to have a condition that defines which tokens trigger the rule. Condition 1 in this example matches red tokens. The color of the tokens could, for example, represent the token type. The blackboard streams the currently active tokens to the condition and the condition returns the tokens that match. In this example, token 1 matches but token 2 not. A condition can match single tokens (for basic dialog rules) or combinations of tokens (e.g. for fusion rules). The matching tokens are then fed into the rule that the condition belongs to (here: Rule 1), which can perform some action based on the token (e.g. say hello to the user).
Currently, the following types of rules and conditions are available:
- SimpleRule: Basic dialog rule that is recommended to be used with the PatternCondition. For more information, refer to the section Simple Rule.
- PatternCondition: Matches tokens of a certain form defined by a pattern (e.g. a certain type). For more information, refer to the section Pattern Condition.
- DeclarativeTypeBasedFusionRule: Rule that fuses two input tokens together and thereby creates a new token with information from both input tokens. For more information, refer to the section Declarative Type Based Fusion.
Guarantee
For the rules and conditions mentioned above, it is ensured that the same rule is never called twice with the same combination of tokens.
Rules have priorities that determine which rules are executed first. The highest priority is 0. If two rules have the same priority, the one that was added to the blackboard first is executed first. When creating one of the rules mentioned above, their priority is automatically set to a priority in the corresponding range but can be overridden by a manual priority if desired.
Priority ranges:
- 0 - 999 : reserved
- 1000-1999 : reducing component
- 2000-2999 : reserved
- 3000-3999 : resolution
- 4000-4999 : reserved
- 5000-5999 : fusion
- 6000-9999 : reserved
- 10000-99999 : user rules
- 100000-... : reserved