Skip to content

RuleBlueprint

Defined in: blueprint/rule-blueprint.ts:12

Blueprint for a rule. Provides methods to add conditions. Returned by element.to() or kind.to().

  • BaseBlueprint

N extends Neighborhood = Neighborhood

new RuleBlueprint<N>(context, automaton, rule): RuleBlueprint<N>

Defined in: blueprint/rule-blueprint.ts:13

BlueprintContext

Automaton

Rule

RuleBlueprint<N>

BaseBlueprint.constructor

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.

number

The numerator of the probability fraction, between 0 and whole.

number = 100

The denominator of the probability fraction, greater than 0. Defaults to 100.

RuleBlueprintWithAccept<N>

A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.

If whole is not greater than 0, or part is not between 0 and whole.


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.

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.

RuleBlueprintWithAccept<N>

A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.

If a count value is not a whole number between 0 and the neighborhood size.


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.

Neighbor<N>

The neighbor position to inspect (e.g. vi.neighbor.TOP).

RefBlueprint<Neighborhood> | Neighbor<N>

The element, kind, or neighbor position to compare against.

RuleBlueprintWithAccept<N>

A RuleBlueprintWithAccept for chaining more conditions or setting an accept strategy.