@wonderyard/vivarium 0.1.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,36 @@
1
1
  import { Neighborhood } from '../automaton/types';
2
+ /**
3
+ * Helper functions for constructing count arrays used in conditions.
4
+ * Accessed via `vi.helpers`.
5
+ */
2
6
  export declare class Helpers {
3
7
  private neighborhoodName?;
4
8
  constructor(neighborhoodName?: Neighborhood | undefined);
9
+ /**
10
+ * Returns every valid count value except the ones specified.
11
+ *
12
+ * @param value - A number or array of numbers to exclude.
13
+ * @returns An array of all valid count values minus the excluded ones.
14
+ */
5
15
  not(value: number | number[]): number[];
16
+ /**
17
+ * Generates a range of whole numbers from `min` to `max` (inclusive).
18
+ *
19
+ * @param min - The start of the range (must be ≥ 0).
20
+ * @param max - The end of the range (must be ≤ 8 and greater than `min`). For cross neighborhoods, should not exceed 4.
21
+ * @returns An array of numbers from `min` to `max`.
22
+ */
6
23
  between(min: number, max: number): number[];
24
+ /**
25
+ * Returns all even count values (zero included) for the current neighborhood type.
26
+ *
27
+ * @returns `[0, 2, 4, 6, 8]` for square, `[0, 2, 4]` for cross.
28
+ */
7
29
  even(): number[];
30
+ /**
31
+ * Returns all odd count values for the current neighborhood type.
32
+ *
33
+ * @returns `[1, 3, 5, 7]` for square, `[1, 3]` for cross.
34
+ */
8
35
  odd(): number[];
9
36
  }
@@ -2,12 +2,25 @@ class s {
2
2
  constructor(r) {
3
3
  this.neighborhoodName = r;
4
4
  }
5
+ /**
6
+ * Returns every valid count value except the ones specified.
7
+ *
8
+ * @param value - A number or array of numbers to exclude.
9
+ * @returns An array of all valid count values minus the excluded ones.
10
+ */
5
11
  not(r) {
6
12
  const e = this.neighborhoodName === "cross" ? /* @__PURE__ */ new Set([0, 1, 2, 3, 4]) : /* @__PURE__ */ new Set([0, 1, 2, 3, 4, 5, 6, 7, 8]);
7
13
  return typeof r == "number" ? e.delete(r) : Array.isArray(r) && r.forEach((o) => {
8
14
  e.delete(o);
9
15
  }), Array.from(e);
10
16
  }
17
+ /**
18
+ * Generates a range of whole numbers from `min` to `max` (inclusive).
19
+ *
20
+ * @param min - The start of the range (must be ≥ 0).
21
+ * @param max - The end of the range (must be ≤ 8 and greater than `min`). For cross neighborhoods, should not exceed 4.
22
+ * @returns An array of numbers from `min` to `max`.
23
+ */
11
24
  between(r, e) {
12
25
  if (r < 0)
13
26
  throw new Error("min cannot be less than 0");
@@ -20,9 +33,19 @@ class s {
20
33
  o.push(n);
21
34
  return o;
22
35
  }
36
+ /**
37
+ * Returns all even count values (zero included) for the current neighborhood type.
38
+ *
39
+ * @returns `[0, 2, 4, 6, 8]` for square, `[0, 2, 4]` for cross.
40
+ */
23
41
  even() {
24
42
  return this.neighborhoodName === "cross" ? [0, 2, 4] : [0, 2, 4, 6, 8];
25
43
  }
44
+ /**
45
+ * Returns all odd count values for the current neighborhood type.
46
+ *
47
+ * @returns `[1, 3, 5, 7]` for square, `[1, 3]` for cross.
48
+ */
26
49
  odd() {
27
50
  return this.neighborhoodName === "cross" ? [1, 3] : [1, 3, 5, 7];
28
51
  }
@@ -2,20 +2,37 @@ import { Automaton, Element, Kind, RefType } from '../automaton/types';
2
2
  import { BaseBlueprint } from './base-blueprint';
3
3
  import { RuleBlueprint } from './rule-blueprint';
4
4
  import { AnyNeighbor, BlueprintContext } from './types';
5
+ /**
6
+ * Base class for element and kind blueprints. Provides the {@link RefBlueprint.to | to} method for defining rules.
7
+ */
5
8
  export declare abstract class RefBlueprint extends BaseBlueprint {
6
9
  protected automaton: Automaton;
7
10
  id: string;
8
11
  name: string;
9
12
  type: RefType;
10
13
  constructor(automaton: Automaton, ref: Element | Kind);
14
+ /**
15
+ * Creates a new rule that transitions cells of this element (or kind) to another element or neighbor reference.
16
+ *
17
+ * @param elementBlueprintOrNeighbor - The target element, or a neighbor position reference (e.g. `vi.neighbor.TOP`).
18
+ * @returns A {@link RuleBlueprint} for chaining conditions.
19
+ */
11
20
  to(elementBlueprintOrNeighbor: ElementBlueprint | AnyNeighbor): RuleBlueprint;
12
21
  }
22
+ /**
23
+ * Blueprint for an element. Returned by {@link VivariumBlueprint.element | vivarium().element()}.
24
+ * Use {@link RefBlueprint.to | to()} to define rules on this element.
25
+ */
13
26
  export declare class ElementBlueprint extends RefBlueprint {
14
27
  protected context: BlueprintContext;
15
28
  type: "element";
16
29
  id: string;
17
30
  constructor(context: BlueprintContext, automaton: Automaton, element: Element);
18
31
  }
32
+ /**
33
+ * Blueprint for a kind. Returned by {@link VivariumBlueprint.kind | vivarium().kind()}.
34
+ * Use {@link RefBlueprint.to | to()} to define shared rules for all elements extending this kind.
35
+ */
19
36
  export declare class KindBlueprint extends RefBlueprint {
20
37
  protected context: BlueprintContext;
21
38
  type: "kind";
@@ -1,5 +1,5 @@
1
1
  import { BaseBlueprint as r } from "./base-blueprint.js";
2
- import { R as n } from "../rule-blueprint--dHAjnu3.js";
2
+ import { R as n } from "../rule-blueprint-DGODv9IV.js";
3
3
  import { toRefIdOrPoint as p } from "./utils.js";
4
4
  import { A as u } from "../constants-D4GX9YB2.js";
5
5
  class o extends r {
@@ -9,6 +9,12 @@ class o extends r {
9
9
  id;
10
10
  name;
11
11
  type;
12
+ /**
13
+ * Creates a new rule that transitions cells of this element (or kind) to another element or neighbor reference.
14
+ *
15
+ * @param elementBlueprintOrNeighbor - The target element, or a neighbor position reference (e.g. `vi.neighbor.TOP`).
16
+ * @returns A {@link RuleBlueprint} for chaining conditions.
17
+ */
12
18
  to(e) {
13
19
  this.assertNotCreated();
14
20
  const t = {
@@ -2,17 +2,55 @@ import { Automaton, Rule, Strategy } from '../automaton/types';
2
2
  import { BaseBlueprint } from './base-blueprint';
3
3
  import { RefBlueprint } from './ref-blueprint';
4
4
  import { AnyNeighbor, BlueprintContext } from './types';
5
+ /**
6
+ * Blueprint for a rule. Provides methods to add conditions. Returned by {@link RefBlueprint.to | element.to()} or {@link RefBlueprint.to | kind.to()}.
7
+ */
5
8
  export declare class RuleBlueprint extends BaseBlueprint {
6
9
  protected context: BlueprintContext;
7
10
  protected automaton: Automaton;
8
11
  protected rule: Rule;
9
12
  constructor(context: BlueprintContext, automaton: Automaton, rule: Rule);
10
13
  private condition;
14
+ /**
15
+ * Adds a count condition to the rule. The rule passes only if the number of matching neighbors
16
+ * equals one of the specified count values.
17
+ *
18
+ * @param refBlueprintOrNeighbor - The element, kind, or neighbor reference to count.
19
+ * @param count - The accepted count values. Can be individual numbers or arrays. When omitted, matches any count from 1 to the neighborhood size.
20
+ * @returns A {@link RuleBlueprintWithAccept} for chaining more conditions or setting an accept strategy.
21
+ */
11
22
  count(refBlueprintOrNeighbor: RefBlueprint | AnyNeighbor, ...count: (number | number[])[]): RuleBlueprintWithAccept;
23
+ /**
24
+ * Adds an `is` condition to the rule. Checks whether a specific neighbor position matches a given element, kind, or another neighbor position.
25
+ *
26
+ * @param neighbor - The neighbor position to inspect (e.g. `vi.neighbor.TOP`).
27
+ * @param refBlueprintOrNeighbor - The element, kind, or neighbor position to compare against.
28
+ * @returns A {@link RuleBlueprintWithAccept} for chaining more conditions or setting an accept strategy.
29
+ */
12
30
  is(neighbor: AnyNeighbor, refBlueprintOrNeighbor: RefBlueprint | AnyNeighbor): RuleBlueprintWithAccept;
31
+ /**
32
+ * Adds a chance condition to the rule. The rule passes with a probability of `part / whole`.
33
+ *
34
+ * @param part - The numerator of the probability fraction.
35
+ * @param whole - The denominator of the probability fraction. Defaults to `100`.
36
+ * @returns A {@link RuleBlueprintWithAccept} for chaining more conditions or setting an accept strategy.
37
+ */
13
38
  chance(part: number, whole?: number): RuleBlueprintWithAccept;
14
39
  }
15
- declare class RuleBlueprintWithAccept extends RuleBlueprint {
40
+ /**
41
+ * Extended rule blueprint that additionally exposes the {@link RuleBlueprintWithAccept.accept | accept} method
42
+ * for choosing how multiple conditions are evaluated.
43
+ */
44
+ export declare class RuleBlueprintWithAccept extends RuleBlueprint {
45
+ /**
46
+ * Sets the acceptance strategy for multiple conditions on this rule.
47
+ *
48
+ * - `"all"` (default) — every condition must pass.
49
+ * - `"any"` — at least one condition must pass.
50
+ * - `"one"` — exactly one condition must pass.
51
+ * - `"none"` — no condition must pass (negation).
52
+ *
53
+ * @param strategy - The acceptance strategy.
54
+ */
16
55
  accept(strategy: Strategy): void;
17
56
  }
18
- export {};
@@ -1,7 +1,8 @@
1
- import { R as m } from "../rule-blueprint--dHAjnu3.js";
1
+ import { R as o, a as l } from "../rule-blueprint-DGODv9IV.js";
2
2
  import "./base-blueprint.js";
3
3
  import "./utils.js";
4
4
  import "../constants-D4GX9YB2.js";
5
5
  export {
6
- m as RuleBlueprint
6
+ o as RuleBlueprint,
7
+ l as RuleBlueprintWithAccept
7
8
  };
@@ -3,16 +3,52 @@ import { BaseBlueprint } from './base-blueprint';
3
3
  import { Helpers } from './helpers';
4
4
  import { ElementBlueprint, KindBlueprint } from './ref-blueprint';
5
5
  import { Cross, Square } from '../common/constants';
6
+ /**
7
+ * The main builder for defining a vivarium. Use it to create elements, kinds, and rules,
8
+ * then call {@link VivariumBlueprint.create | create} to produce an {@link Automaton} that can be passed to {@link setup}.
9
+ */
6
10
  export declare class VivariumBlueprint<N extends Neighborhood = "square"> extends BaseBlueprint {
7
11
  private neighborhoodName?;
8
12
  protected automaton: Automaton;
9
13
  protected context: {
10
14
  created: boolean;
11
15
  };
16
+ /**
17
+ * Named constants for referring to specific positions in the neighborhood.
18
+ * Available positions depend on the neighborhood type.
19
+ *
20
+ * For `"square"`: `TOP_LEFT`, `TOP`, `TOP_RIGHT`, `LEFT`, `SELF`, `RIGHT`, `BOTTOM_LEFT`, `BOTTOM`, `BOTTOM_RIGHT`.
21
+ *
22
+ * For `"cross"`: `TOP`, `LEFT`, `SELF`, `RIGHT`, `BOTTOM`.
23
+ */
12
24
  neighbor: N extends "cross" ? typeof Cross : typeof Square;
25
+ /**
26
+ * Helper functions for constructing count arrays used in conditions.
27
+ * Includes {@link Helpers.not | not}, {@link Helpers.between | between}, {@link Helpers.even | even}, and {@link Helpers.odd | odd}.
28
+ */
13
29
  helpers: Helpers;
14
30
  constructor(neighborhoodName?: N | undefined);
31
+ /**
32
+ * Defines a new element in the vivarium.
33
+ *
34
+ * @param name - A unique name identifying this element.
35
+ * @param color - A unique color used to draw this element. Accepts CSS named colors or hex values (e.g. `"green"`, `"#FF7A45"`).
36
+ * @param extensions - An optional array of kinds this element extends.
37
+ * @returns An {@link ElementBlueprint} that can be used to define rules.
38
+ */
15
39
  element(name: string, color: Color, extensions?: KindBlueprint[]): ElementBlueprint;
40
+ /**
41
+ * Defines a new kind in the vivarium. A kind groups elements that share common behavior.
42
+ *
43
+ * @param name - A unique name identifying this kind.
44
+ * @returns A {@link KindBlueprint} that can be used to define shared rules.
45
+ */
16
46
  kind(name: string): KindBlueprint;
47
+ /**
48
+ * Finalizes the vivarium and produces an {@link Automaton} object. After calling this method,
49
+ * no further elements, kinds, or rules can be added.
50
+ *
51
+ * @returns The compiled {@link Automaton} to pass to {@link setup}.
52
+ */
17
53
  create(): Automaton;
18
54
  }
@@ -1,4 +1,4 @@
1
- import { n as o } from "../rule-blueprint--dHAjnu3.js";
1
+ import { n as o } from "../rule-blueprint-DGODv9IV.js";
2
2
  import { BaseBlueprint as n } from "./base-blueprint.js";
3
3
  import { Helpers as a } from "./helpers.js";
4
4
  import { ElementBlueprint as h, KindBlueprint as m } from "./ref-blueprint.js";
@@ -14,8 +14,28 @@ class C extends n {
14
14
  }
15
15
  automaton;
16
16
  context = { created: !1 };
17
+ /**
18
+ * Named constants for referring to specific positions in the neighborhood.
19
+ * Available positions depend on the neighborhood type.
20
+ *
21
+ * For `"square"`: `TOP_LEFT`, `TOP`, `TOP_RIGHT`, `LEFT`, `SELF`, `RIGHT`, `BOTTOM_LEFT`, `BOTTOM`, `BOTTOM_RIGHT`.
22
+ *
23
+ * For `"cross"`: `TOP`, `LEFT`, `SELF`, `RIGHT`, `BOTTOM`.
24
+ */
17
25
  neighbor;
26
+ /**
27
+ * Helper functions for constructing count arrays used in conditions.
28
+ * Includes {@link Helpers.not | not}, {@link Helpers.between | between}, {@link Helpers.even | even}, and {@link Helpers.odd | odd}.
29
+ */
18
30
  helpers;
31
+ /**
32
+ * Defines a new element in the vivarium.
33
+ *
34
+ * @param name - A unique name identifying this element.
35
+ * @param color - A unique color used to draw this element. Accepts CSS named colors or hex values (e.g. `"green"`, `"#FF7A45"`).
36
+ * @param extensions - An optional array of kinds this element extends.
37
+ * @returns An {@link ElementBlueprint} that can be used to define rules.
38
+ */
19
39
  element(t, e, r = []) {
20
40
  this.assertNotCreated(), this.assertUniqueName(t), this.assertUniqueColor(e);
21
41
  const s = {
@@ -27,6 +47,12 @@ class C extends n {
27
47
  };
28
48
  return this.automaton.elements.push(s), new h(this.context, this.automaton, s);
29
49
  }
50
+ /**
51
+ * Defines a new kind in the vivarium. A kind groups elements that share common behavior.
52
+ *
53
+ * @param name - A unique name identifying this kind.
54
+ * @returns A {@link KindBlueprint} that can be used to define shared rules.
55
+ */
30
56
  kind(t) {
31
57
  this.assertNotCreated(), this.assertUniqueName(t);
32
58
  const e = {
@@ -36,6 +62,12 @@ class C extends n {
36
62
  };
37
63
  return this.automaton.kinds.push(e), new m(this.context, this.automaton, e);
38
64
  }
65
+ /**
66
+ * Finalizes the vivarium and produces an {@link Automaton} object. After calling this method,
67
+ * no further elements, kinds, or rules can be added.
68
+ *
69
+ * @returns The compiled {@link Automaton} to pass to {@link setup}.
70
+ */
39
71
  create() {
40
72
  this.assertNotCreated(), this.assertNotEmpty();
41
73
  const t = this.automaton;
package/dist/main.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  export { vivarium } from './vivarium/vivarium';
2
2
  export { setup } from './webgpu/setup';
3
+ export { VivariumBlueprint } from './blueprint/vivarium-blueprint';
4
+ export { RefBlueprint, ElementBlueprint, KindBlueprint, } from './blueprint/ref-blueprint';
5
+ export { RuleBlueprint, RuleBlueprintWithAccept, } from './blueprint/rule-blueprint';
6
+ export { Helpers } from './blueprint/helpers';
package/dist/main.js CHANGED
@@ -1,6 +1,17 @@
1
- import { vivarium as e } from "./vivarium/vivarium.js";
2
- import { setup as p } from "./webgpu/setup.js";
1
+ import { vivarium as t } from "./vivarium/vivarium.js";
2
+ import { setup as i } from "./webgpu/setup.js";
3
+ import { VivariumBlueprint as u } from "./blueprint/vivarium-blueprint.js";
4
+ import { ElementBlueprint as m, KindBlueprint as n, RefBlueprint as f } from "./blueprint/ref-blueprint.js";
5
+ import { R as B, a } from "./rule-blueprint-DGODv9IV.js";
6
+ import { Helpers as R } from "./blueprint/helpers.js";
3
7
  export {
4
- p as setup,
5
- e as vivarium
8
+ m as ElementBlueprint,
9
+ R as Helpers,
10
+ n as KindBlueprint,
11
+ f as RefBlueprint,
12
+ B as RuleBlueprint,
13
+ a as RuleBlueprintWithAccept,
14
+ u as VivariumBlueprint,
15
+ i as setup,
16
+ t as vivarium
6
17
  };
@@ -0,0 +1,84 @@
1
+ import { BaseBlueprint as r } from "./blueprint/base-blueprint.js";
2
+ import { toRefIdOrPoint as s } from "./blueprint/utils.js";
3
+ import { n as c, c as a } from "./constants-D4GX9YB2.js";
4
+ const h = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
5
+ let o = (i = 21) => {
6
+ let t = "", e = crypto.getRandomValues(new Uint8Array(i |= 0));
7
+ for (; i--; )
8
+ t += h[e[i] & 63];
9
+ return t;
10
+ };
11
+ class u extends r {
12
+ constructor(t, e, n) {
13
+ super(), this.context = t, this.automaton = e, this.rule = n;
14
+ }
15
+ condition(t) {
16
+ return this.assertNotCreated(), this.rule.when = [...this.rule.when, t], new l(this.context, this.automaton, this.rule);
17
+ }
18
+ /**
19
+ * Adds a count condition to the rule. The rule passes only if the number of matching neighbors
20
+ * equals one of the specified count values.
21
+ *
22
+ * @param refBlueprintOrNeighbor - The element, kind, or neighbor reference to count.
23
+ * @param count - The accepted count values. Can be individual numbers or arrays. When omitted, matches any count from 1 to the neighborhood size.
24
+ * @returns A {@link RuleBlueprintWithAccept} for chaining more conditions or setting an accept strategy.
25
+ */
26
+ count(t, ...e) {
27
+ let n = this.automaton.neighborhood === "cross" ? [1, 2, 3, 4] : [1, 2, 3, 4, 5, 6, 7, 8];
28
+ return e.length !== 0 && (n = e.flat()), this.condition({
29
+ type: "count",
30
+ id: o(),
31
+ check: s(t),
32
+ count: n
33
+ });
34
+ }
35
+ /**
36
+ * Adds an `is` condition to the rule. Checks whether a specific neighbor position matches a given element, kind, or another neighbor position.
37
+ *
38
+ * @param neighbor - The neighbor position to inspect (e.g. `vi.neighbor.TOP`).
39
+ * @param refBlueprintOrNeighbor - The element, kind, or neighbor position to compare against.
40
+ * @returns A {@link RuleBlueprintWithAccept} for chaining more conditions or setting an accept strategy.
41
+ */
42
+ is(t, e) {
43
+ return this.condition({
44
+ type: "is",
45
+ id: o(),
46
+ compare: c[t],
47
+ with: s(e)
48
+ });
49
+ }
50
+ /**
51
+ * Adds a chance condition to the rule. The rule passes with a probability of `part / whole`.
52
+ *
53
+ * @param part - The numerator of the probability fraction.
54
+ * @param whole - The denominator of the probability fraction. Defaults to `100`.
55
+ * @returns A {@link RuleBlueprintWithAccept} for chaining more conditions or setting an accept strategy.
56
+ */
57
+ chance(t, e = 100) {
58
+ return t < 0 && (t = 0), e <= 0 && (e = 1), t > e && (t = e), t = Math.floor(t), e = Math.floor(e), this.condition({
59
+ type: "chance",
60
+ id: o(),
61
+ ratio: { part: t, whole: e }
62
+ });
63
+ }
64
+ }
65
+ class l extends u {
66
+ /**
67
+ * Sets the acceptance strategy for multiple conditions on this rule.
68
+ *
69
+ * - `"all"` (default) — every condition must pass.
70
+ * - `"any"` — at least one condition must pass.
71
+ * - `"one"` — exactly one condition must pass.
72
+ * - `"none"` — no condition must pass (negation).
73
+ *
74
+ * @param strategy - The acceptance strategy.
75
+ */
76
+ accept(t) {
77
+ this.assertNotCreated(), this.rule.accept = a[t];
78
+ }
79
+ }
80
+ export {
81
+ u as R,
82
+ l as a,
83
+ o as n
84
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,9 @@
1
1
  import { Neighborhood } from '../automaton/types';
2
2
  import { VivariumBlueprint } from '../blueprint/vivarium-blueprint';
3
+ /**
4
+ * Creates a new vivarium builder used to define elements, kinds, and rules.
5
+ *
6
+ * @param neighborhoodName - The neighborhood type to use. Defaults to `"square"` (Moore neighborhood, 8 neighbors). Use `"cross"` for a von Neumann neighborhood (4 neighbors).
7
+ * @returns A {@link VivariumBlueprint} instance.
8
+ */
3
9
  export declare function vivarium<N extends Neighborhood = "square">(neighborhoodName?: N): VivariumBlueprint<N>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,75 @@
1
+ import { TgpuUniform } from 'typegpu';
1
2
  import { Automaton } from '../automaton/types';
3
+ import * as d from "typegpu/data";
4
+ export declare const setSeed: (s: TgpuUniform<d.F32>) => void;
5
+ export declare const gridLayout: import('typegpu').TgpuBindGroupLayout<{
6
+ dimensions: {
7
+ uniform: d.Vec2u;
8
+ };
9
+ colors: {
10
+ storage: (elementCount: number) => d.WgslArray<d.U32>;
11
+ access: "mutable";
12
+ };
13
+ newColors: {
14
+ storage: (elementCount: number) => d.WgslArray<d.U32>;
15
+ access: "mutable";
16
+ };
17
+ ids: {
18
+ storage: (elementCount: number) => d.WgslArray<d.U32>;
19
+ access: "mutable";
20
+ };
21
+ newIds: {
22
+ storage: (elementCount: number) => d.WgslArray<d.U32>;
23
+ access: "mutable";
24
+ };
25
+ }>;
26
+ export declare const automatonLayout: import('typegpu').TgpuBindGroupLayout<{
27
+ neighborhood: {
28
+ uniform: d.U32;
29
+ };
30
+ elements: {
31
+ storage: (elementCount: number) => d.WgslArray<d.WgslStruct<{
32
+ color: d.U32;
33
+ ruleStart: d.U32;
34
+ ruleEnd: d.U32;
35
+ }>>;
36
+ access: "readonly";
37
+ };
38
+ rules: {
39
+ storage: (elementCount: number) => d.WgslArray<d.WgslStruct<{
40
+ toType: d.U32;
41
+ toId: d.U32;
42
+ toNeighbor: d.Vec2u;
43
+ accept: d.U32;
44
+ conditionsStart: d.U32;
45
+ conditionsEnd: d.U32;
46
+ }>>;
47
+ access: "readonly";
48
+ };
49
+ conditions: {
50
+ storage: (elementCount: number) => d.WgslArray<d.WgslStruct<{
51
+ opcode: d.U32;
52
+ checkId: d.U32;
53
+ countOrWithId: d.U32;
54
+ checkPointOrComparePoint: d.Vec2u;
55
+ withPoint: d.Vec2u;
56
+ chance: d.F32;
57
+ }>>;
58
+ access: "readonly";
59
+ };
60
+ }>;
61
+ export declare const mainCompute: import('typegpu').TgpuComputeFn<{
62
+ pos: d.BuiltinGlobalInvocationId;
63
+ }>;
64
+ /**
65
+ * Initializes the WebGPU simulation for a given canvas and automaton. The grid is randomly initialized
66
+ * with the defined elements.
67
+ *
68
+ * @param options - An object containing the `canvas` element and the compiled `automaton`.
69
+ * @param options.canvas - The HTML canvas element. Its `width` and `height` define the grid dimensions.
70
+ * @param options.automaton - The compiled automaton produced by {@link VivariumBlueprint.create | vivarium().create()}.
71
+ * @returns An object with an `evolve` function that advances the simulation by one step, a `setAutomaton` function to update the automaton, and the underlying `tgpuRoot`.
72
+ */
2
73
  export declare const setup: ({ canvas, automaton, }: {
3
74
  canvas: HTMLCanvasElement;
4
75
  automaton: Automaton;