@wonderyard/vivarium 0.1.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.
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { vivarium } from './vivarium/vivarium';
2
+ export { setup } from './webgpu/setup';
package/dist/main.js ADDED
@@ -0,0 +1,6 @@
1
+ import { vivarium as e } from "./vivarium/vivarium.js";
2
+ import { setup as p } from "./webgpu/setup.js";
3
+ export {
4
+ p as setup,
5
+ e as vivarium
6
+ };
@@ -0,0 +1,50 @@
1
+ import { BaseBlueprint as s } from "./blueprint/base-blueprint.js";
2
+ import { toRefIdOrPoint as o } from "./blueprint/utils.js";
3
+ import { n as a, a7 as c } from "./constants-Ry69vZz5.js";
4
+ const h = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
5
+ let n = (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 s {
12
+ constructor(t, e, r) {
13
+ super(), this.context = t, this.automaton = e, this.rule = r;
14
+ }
15
+ condition(t) {
16
+ return this.assertNotCreated(), this.rule.when = [...this.rule.when, t], new d(this.context, this.automaton, this.rule);
17
+ }
18
+ count(t, e = this.automaton.neighborhood === "cross" ? [1, 2, 3, 4] : [1, 2, 3, 4, 5, 6, 7, 8]) {
19
+ return this.condition({
20
+ type: "count",
21
+ id: n(),
22
+ check: o(t),
23
+ count: Array.isArray(e) ? e : [e]
24
+ });
25
+ }
26
+ is(t, e) {
27
+ return this.condition({
28
+ type: "is",
29
+ id: n(),
30
+ compare: a[t],
31
+ with: o(e)
32
+ });
33
+ }
34
+ chance(t, e = 100) {
35
+ return t < 0 && (t = 0), e <= 0 && (e = 1), t > e && (t = e), t = Math.floor(t), e = Math.floor(e), this.condition({
36
+ type: "chance",
37
+ id: n(),
38
+ ratio: { part: t, whole: e }
39
+ });
40
+ }
41
+ }
42
+ class d extends u {
43
+ accept(t) {
44
+ this.assertNotCreated(), this.rule.accept = c[t];
45
+ }
46
+ }
47
+ export {
48
+ u as R,
49
+ n
50
+ };
@@ -0,0 +1,3 @@
1
+ import { Neighborhood } from '../automaton/types';
2
+ import { VivariumBlueprint } from '../blueprint/vivarium-blueprint';
3
+ export declare function vivarium<N extends Neighborhood = "square">(neighborhoodName?: N): VivariumBlueprint<N>;
@@ -0,0 +1,7 @@
1
+ import { VivariumBlueprint as i } from "../blueprint/vivarium-blueprint.js";
2
+ function t(r) {
3
+ return new i(r);
4
+ }
5
+ export {
6
+ t as vivarium
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { TgpuRoot } from 'typegpu';
2
+ import { Automaton } from '../automaton/types';
3
+ import * as d from "typegpu/data";
4
+ export declare const compileGpuAutomaton: (root: TgpuRoot, automaton: Automaton) => {
5
+ neighborhood: import('typegpu').TgpuBuffer<d.U32> & import('typegpu').UniformFlag;
6
+ elements: import('typegpu').TgpuBuffer<d.WgslArray<d.WgslStruct<{
7
+ color: d.U32;
8
+ ruleStart: d.U32;
9
+ ruleEnd: d.U32;
10
+ }>>> & import('typegpu').StorageFlag;
11
+ rules: import('typegpu').TgpuBuffer<d.WgslArray<d.WgslStruct<{
12
+ toType: d.U32;
13
+ toId: d.U32;
14
+ toNeighbor: d.Vec2u;
15
+ accept: d.U32;
16
+ conditionsStart: d.U32;
17
+ conditionsEnd: d.U32;
18
+ }>>> & import('typegpu').StorageFlag;
19
+ conditions: import('typegpu').TgpuBuffer<d.WgslArray<d.WgslStruct<{
20
+ opcode: d.U32;
21
+ checkId: d.U32;
22
+ countOrWithId: d.U32;
23
+ checkPointOrComparePoint: d.Vec2u;
24
+ withPoint: d.Vec2u;
25
+ chance: d.F32;
26
+ }>>> & import('typegpu').StorageFlag;
27
+ };
@@ -0,0 +1,6 @@
1
+ import "../constants-Ry69vZz5.js";
2
+ import "../common/utils.js";
3
+ import { g as r } from "../compiler-CEYR17Vv.js";
4
+ export {
5
+ r as compileGpuAutomaton
6
+ };
@@ -0,0 +1,11 @@
1
+ import { Automaton } from '../automaton/types';
2
+ export declare const setup: ({ canvas, automaton, }: {
3
+ canvas: HTMLCanvasElement;
4
+ automaton: Automaton;
5
+ }) => {
6
+ evolve: () => Promise<void>;
7
+ setAutomaton: ({ automaton }: {
8
+ automaton: Automaton;
9
+ }) => void;
10
+ tgpuRoot: import('typegpu').TgpuRoot;
11
+ };