@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/LICENSE +21 -0
- package/README.md +28 -0
- package/README.md.local +93 -0
- package/dist/automaton/types.d.ts +56 -0
- package/dist/automaton/types.js +1 -0
- package/dist/blueprint/base-blueprint.d.ts +10 -0
- package/dist/blueprint/base-blueprint.js +29 -0
- package/dist/blueprint/helpers.d.ts +9 -0
- package/dist/blueprint/helpers.js +32 -0
- package/dist/blueprint/ref-blueprint.d.ts +24 -0
- package/dist/blueprint/ref-blueprint.js +42 -0
- package/dist/blueprint/rule-blueprint.d.ts +18 -0
- package/dist/blueprint/rule-blueprint.js +7 -0
- package/dist/blueprint/types.d.ts +8 -0
- package/dist/blueprint/types.js +1 -0
- package/dist/blueprint/utils.d.ts +4 -0
- package/dist/blueprint/utils.js +5 -0
- package/dist/blueprint/vivarium-blueprint.d.ts +18 -0
- package/dist/blueprint/vivarium-blueprint.js +47 -0
- package/dist/common/constants.d.ts +64 -0
- package/dist/common/constants.js +14 -0
- package/dist/common/utils.d.ts +1 -0
- package/dist/common/utils.js +53 -0
- package/dist/compiler-CEYR17Vv.js +527 -0
- package/dist/constants-Ry69vZz5.js +2565 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +6 -0
- package/dist/rule-blueprint-Df5BKApy.js +50 -0
- package/dist/vivarium/vivarium.d.ts +3 -0
- package/dist/vivarium/vivarium.js +7 -0
- package/dist/vivarium/vivarium.test.d.ts +1 -0
- package/dist/webgpu/compiler.d.ts +27 -0
- package/dist/webgpu/compiler.js +6 -0
- package/dist/webgpu/setup.d.ts +11 -0
- package/dist/webgpu/setup.js +4348 -0
- package/package.json +40 -0
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -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 @@
|
|
|
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,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
|
+
};
|