RuleBlueprint
Defined in: blueprint/rule-blueprint.ts:12
Blueprint for a rule. Provides methods to add conditions. Returned by element.to() or kind.to().
Extends
Section titled “Extends”BaseBlueprint
Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RuleBlueprint(
context,automaton,rule):RuleBlueprint
Defined in: blueprint/rule-blueprint.ts:13
Parameters
Section titled “Parameters”context
Section titled “context”BlueprintContext
automaton
Section titled “automaton”Automaton
Rule
Returns
Section titled “Returns”RuleBlueprint
Overrides
Section titled “Overrides”BaseBlueprint.constructor
Methods
Section titled “Methods”chance()
Section titled “chance()”chance(
part,whole?):RuleBlueprintWithAccept
Defined in: blueprint/rule-blueprint.ts:82
Adds a chance condition to the rule. The rule passes with a probability of part / whole.
Parameters
Section titled “Parameters”number
The numerator of the probability fraction.
whole?
Section titled “whole?”number = 100
The denominator of the probability fraction. Defaults to 100.
Returns
Section titled “Returns”A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.
count()
Section titled “count()”count(
refBlueprintOrNeighbor, …count):RuleBlueprintWithAccept
Defined in: blueprint/rule-blueprint.ts:37
Adds a count condition to the rule. The rule passes only if the number of matching neighbors equals one of the specified count values.
Parameters
Section titled “Parameters”refBlueprintOrNeighbor
Section titled “refBlueprintOrNeighbor”The element, kind, or neighbor reference to count.
AnyNeighbor | RefBlueprint
…(number | number[])[]
The accepted count values. Can be individual numbers or arrays. When omitted, matches any count from 1 to the neighborhood size.
Returns
Section titled “Returns”A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.
is(
neighbor,refBlueprintOrNeighbor):RuleBlueprintWithAccept
Defined in: blueprint/rule-blueprint.ts:63
Adds an is condition to the rule. Checks whether a specific neighbor position matches a given element, kind, or another neighbor position.
Parameters
Section titled “Parameters”neighbor
Section titled “neighbor”AnyNeighbor
The neighbor position to inspect (e.g. vi.neighbor.TOP).
refBlueprintOrNeighbor
Section titled “refBlueprintOrNeighbor”The element, kind, or neighbor position to compare against.
AnyNeighbor | RefBlueprint
Returns
Section titled “Returns”A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.