RuleBlueprintWithAccept
Defined in: blueprint/rule-blueprint.ts:103
Extended rule blueprint that additionally exposes the accept method for choosing how multiple conditions are evaluated.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”N extends Neighborhood = Neighborhood
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RuleBlueprintWithAccept<
N>(context,automaton,rule):RuleBlueprintWithAccept<N>
Defined in: blueprint/rule-blueprint.ts:13
Parameters
Section titled “Parameters”context
Section titled “context”BlueprintContext
automaton
Section titled “automaton”Returns
Section titled “Returns”RuleBlueprintWithAccept<N>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”accept()
Section titled “accept()”accept(
strategy):void
Defined in: blueprint/rule-blueprint.ts:116
Sets the acceptance strategy for multiple conditions on this rule.
"all"(default) — every condition must pass."any"— at least one condition must pass."one"— exactly one condition must pass."none"— no condition must pass (negation).
Parameters
Section titled “Parameters”strategy
Section titled “strategy”The acceptance strategy.
Returns
Section titled “Returns”void
chance()
Section titled “chance()”chance(
part,whole?):RuleBlueprintWithAccept<N>
Defined in: blueprint/rule-blueprint.ts:83
Adds a chance condition to the rule. The condition passes with a probability of part / whole.
Parameters
Section titled “Parameters”number
The numerator of the probability fraction, between 0 and whole.
whole?
Section titled “whole?”number = 100
The denominator of the probability fraction, greater than 0. Defaults to 100.
Returns
Section titled “Returns”RuleBlueprintWithAccept<N>
A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.
Throws
Section titled “Throws”If whole is not greater than 0, or part is not between 0 and whole.
Inherited from
Section titled “Inherited from”count()
Section titled “count()”count(
refBlueprintOrNeighbor, …count):RuleBlueprintWithAccept<N>
Defined in: blueprint/rule-blueprint.ts:38
Adds a count condition to the rule. The condition passes only if the number of matching neighbors equals one of the specified count values.
Parameters
Section titled “Parameters”refBlueprintOrNeighbor
Section titled “refBlueprintOrNeighbor”RefBlueprint<Neighborhood> | Neighbor<N>
The element, kind, or neighbor reference to count.
…(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”RuleBlueprintWithAccept<N>
A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.
Throws
Section titled “Throws”If a count value is not a whole number between 0 and the neighborhood size.
Inherited from
Section titled “Inherited from”is(
neighbor,refBlueprintOrNeighbor):RuleBlueprintWithAccept<N>
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”Neighbor<N>
The neighbor position to inspect (e.g. vi.neighbor.TOP).
refBlueprintOrNeighbor
Section titled “refBlueprintOrNeighbor”RefBlueprint<Neighborhood> | Neighbor<N>
The element, kind, or neighbor position to compare against.
Returns
Section titled “Returns”RuleBlueprintWithAccept<N>
A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.
