RuleSystem
:agenda
: Rule[]state
: anyfacts
: Map<string, number>addRuleExecutingAction
(predicate: Predicate$1, action: Action, salience?: number) => voidAdds a rule which runs an action if its predicate evaluates to true.
param
predicate- Predicate to evaluate. A function taking the system as parameter.
param
action- Action to execute. A function taking the system as parameter.
param
salience- Priority of the rule.
addRuleAssertingFact
(predicate: Predicate$1, fact: string, grade?: number, salience?: number) => voidAdd a rule which asserts a fact if its predicate evaluates to true.
param
predicate- Predicate to evaluate. A function taking the system as parameter.
param
fact- The fact to assert.
param
grade- The optional grade to use when asserting the fact.
param
salience- Priority of the rule.
addRuleRetractingFact
(predicate: Predicate$1, fact: string, grade?: number, salience?: number) => voidAdd a rule which retracts a fact if its predicate evaluates to true.
param
predicate- Predicate to evaluate. A function taking the system as parameter.
param
fact- The fact to retract.
param
grade- The optional grade to use when retracting the fact.
param
salience- Priority of the rule.
addRule
(rule: Rule) => voidAdd a custom rule.
param
rule- The rule to add.
removeAllRules
() => voidRemoves all rules.
execute
() => voidExecutes all rules for which the predicate evaluates to true.
assertFact
(fact: string, grade?: number) => voidAsserts a fact.
param
fact- The fact to assert.
param
grade- The optional grade to use.
retractFact
(fact: string, grade?: number) => voidRetracts a fact.
param
fact- The fact to retract.
param
grade- The optional grade to use.
gradeForFact
(fact: string) => numberReturns the grade for the specified fact.
param
fact- The fact to obtain the grade from.
returns
The grade for the fact.
minimumGradeForFacts
(facts: string[]) => numberReturns the minimum grade for the specified facts.
param
facts- The facts to obtain the minimum grade from.
returns
The minimum grade for the facts.
maximumGradeForFacts
(facts: string[]) => numberReturns the maximum grade for the specified facts.
param
facts- The facts to obtain the maximum grade from.
returns
The maximum grade for the facts.
reset
() => voidResets the facts.