@wonderyard/vivarium 0.1.3 → 0.1.5

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,7 +1,7 @@
1
1
  import { BaseBlueprint as r } from "./base-blueprint.js";
2
- import { R as n } from "../rule-blueprint-Df5BKApy.js";
2
+ import { R as n } from "../rule-blueprint-Dhi6aLUs.js";
3
3
  import { toRefIdOrPoint as p } from "./utils.js";
4
- import { A as u } from "../constants-Ry69vZz5.js";
4
+ import { A as u } from "../constants-CBz0gZS0.js";
5
5
  class o extends r {
6
6
  constructor(e, t) {
7
7
  super(), this.automaton = e, this.id = t.id, this.name = t.name, this.type = t.type;
@@ -8,8 +8,7 @@ export declare class RuleBlueprint extends BaseBlueprint {
8
8
  protected rule: Rule;
9
9
  constructor(context: BlueprintContext, automaton: Automaton, rule: Rule);
10
10
  private condition;
11
- count(refBlueprintOrNeighbor: RefBlueprint | AnyNeighbor, count: number[]): RuleBlueprintWithAccept;
12
- count(refBlueprintOrNeighbor: RefBlueprint | AnyNeighbor, ...count: number[]): RuleBlueprintWithAccept;
11
+ count(refBlueprintOrNeighbor: RefBlueprint | AnyNeighbor, ...count: (number | number[])[]): RuleBlueprintWithAccept;
13
12
  is(neighbor: AnyNeighbor, refBlueprintOrNeighbor: RefBlueprint | AnyNeighbor): RuleBlueprintWithAccept;
14
13
  chance(part: number, whole?: number): RuleBlueprintWithAccept;
15
14
  }
@@ -1,7 +1,7 @@
1
- import { R as m } from "../rule-blueprint-Df5BKApy.js";
1
+ import { R as m } from "../rule-blueprint-Dhi6aLUs.js";
2
2
  import "./base-blueprint.js";
3
3
  import "./utils.js";
4
- import "../constants-Ry69vZz5.js";
4
+ import "../constants-CBz0gZS0.js";
5
5
  export {
6
6
  m as RuleBlueprint
7
7
  };
@@ -1,4 +1,4 @@
1
- import { n as t } from "../constants-Ry69vZz5.js";
1
+ import { n as t } from "../constants-CBz0gZS0.js";
2
2
  const s = (o) => typeof o == "string" ? t[o] : o.id;
3
3
  export {
4
4
  s as toRefIdOrPoint
@@ -1,8 +1,8 @@
1
- import { n as o } from "../rule-blueprint-Df5BKApy.js";
1
+ import { n as o } from "../rule-blueprint-Dhi6aLUs.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";
5
- import { C as u, S as p } from "../constants-Ry69vZz5.js";
5
+ import { C as u, S as p } from "../constants-CBz0gZS0.js";
6
6
  class C extends n {
7
7
  constructor(t) {
8
8
  super(), this.neighborhoodName = t, this.helpers = new a(this.neighborhoodName), this.neighbor = this.neighborhoodName === "cross" ? u : p, this.automaton = {
@@ -1,4 +1,4 @@
1
- import { A as o, C as e, a5 as p, a1 as c, a2 as n, a6 as t, S as r, a4 as u, cf as i, a7 as G, n as d } from "../constants-Ry69vZz5.js";
1
+ import { A as o, C as e, b as p, G as c, a as n, O as t, S as r, T as u, cf as G, c as i, n as O } from "../constants-CBz0gZS0.js";
2
2
  export {
3
3
  o as Accept,
4
4
  e as Cross,
@@ -8,7 +8,7 @@ export {
8
8
  t as Opcode,
9
9
  r as Square,
10
10
  u as To,
11
- i as WORKGROUP_SIZE,
12
- G as acceptMap,
13
- d as neighborhoodPoints
11
+ G as WORKGROUP_SIZE,
12
+ i as acceptMap,
13
+ O as neighborhoodPoints
14
14
  };
@@ -1,53 +1,308 @@
1
- const u = (e) => {
1
+ const f = (e) => {
2
2
  switch (e.toLowerCase()) {
3
+ case "aliceblue":
4
+ return "#f0f8ff";
5
+ case "antiquewhite":
6
+ return "#faebd7";
7
+ case "aqua":
8
+ case "cyan":
9
+ return "#00ffff";
10
+ case "aquamarine":
11
+ return "#7fffd4";
12
+ case "azure":
13
+ return "#f0ffff";
14
+ case "beige":
15
+ return "#f5f5dc";
16
+ case "bisque":
17
+ return "#ffe4c4";
3
18
  case "black":
4
19
  return "#000000";
5
- case "silver":
6
- return "#c0c0c0";
7
- case "gray":
8
- return "#808080";
9
- case "white":
10
- return "#ffffff";
11
- case "maroon":
12
- return "#800000";
13
- case "red":
14
- return "#ff0000";
15
- case "purple":
16
- return "#800080";
20
+ case "blanchedalmond":
21
+ return "#ffebcd";
22
+ case "blue":
23
+ return "#0000ff";
24
+ case "blueviolet":
25
+ return "#8a2be2";
26
+ case "brown":
27
+ return "#a52a2a";
28
+ case "burlywood":
29
+ return "#deb887";
30
+ case "cadetblue":
31
+ return "#5f9ea0";
32
+ case "chartreuse":
33
+ return "#7fff00";
34
+ case "chocolate":
35
+ return "#d2691e";
36
+ case "coral":
37
+ return "#ff7f50";
38
+ case "cornflowerblue":
39
+ return "#6495ed";
40
+ case "cornsilk":
41
+ return "#fff8dc";
42
+ case "crimson":
43
+ return "#dc143c";
44
+ case "darkblue":
45
+ return "#00008b";
46
+ case "darkcyan":
47
+ return "#008b8b";
48
+ case "darkgoldenrod":
49
+ return "#b8860b";
50
+ case "darkgray":
51
+ case "darkgrey":
52
+ return "#a9a9a9";
53
+ case "darkgreen":
54
+ return "#006400";
55
+ case "darkkhaki":
56
+ return "#bdb76b";
57
+ case "darkmagenta":
58
+ return "#8b008b";
59
+ case "darkolivegreen":
60
+ return "#556b2f";
61
+ case "darkorange":
62
+ return "#ff8c00";
63
+ case "darkorchid":
64
+ return "#9932cc";
65
+ case "darkred":
66
+ return "#8b0000";
67
+ case "darksalmon":
68
+ return "#e9967a";
69
+ case "darkseagreen":
70
+ return "#8fbc8f";
71
+ case "darkslateblue":
72
+ return "#483d8b";
73
+ case "darkslategray":
74
+ case "darkslategrey":
75
+ return "#2f4f4f";
76
+ case "darkturquoise":
77
+ return "#00ced1";
78
+ case "darkviolet":
79
+ return "#9400d3";
80
+ case "deeppink":
81
+ return "#ff1493";
82
+ case "deepskyblue":
83
+ return "#00bfff";
84
+ case "dimgray":
85
+ case "dimgrey":
86
+ return "#696969";
87
+ case "dodgerblue":
88
+ return "#1e90ff";
89
+ case "firebrick":
90
+ return "#b22222";
91
+ case "floralwhite":
92
+ return "#fffaf0";
93
+ case "forestgreen":
94
+ return "#228b22";
17
95
  case "fuchsia":
96
+ case "magenta":
18
97
  return "#ff00ff";
98
+ case "gainsboro":
99
+ return "#dcdcdc";
100
+ case "ghostwhite":
101
+ return "#f8f8ff";
102
+ case "gold":
103
+ return "#ffd700";
104
+ case "goldenrod":
105
+ return "#daa520";
106
+ case "gray":
107
+ case "grey":
108
+ return "#808080";
19
109
  case "green":
20
110
  return "#008000";
111
+ case "greenyellow":
112
+ return "#adff2f";
113
+ case "honeydew":
114
+ return "#f0fff0";
115
+ case "hotpink":
116
+ return "#ff69b4";
117
+ case "indianred":
118
+ return "#cd5c5c";
119
+ case "indigo":
120
+ return "#4b0082";
121
+ case "ivory":
122
+ return "#fffff0";
123
+ case "khaki":
124
+ return "#f0e68c";
125
+ case "lavender":
126
+ return "#e6e6fa";
127
+ case "lavenderblush":
128
+ return "#fff0f5";
129
+ case "lawngreen":
130
+ return "#7cfc00";
131
+ case "lemonchiffon":
132
+ return "#fffacd";
133
+ case "lightblue":
134
+ return "#add8e6";
135
+ case "lightcoral":
136
+ return "#f08080";
137
+ case "lightcyan":
138
+ return "#e0ffff";
139
+ case "lightgoldenrodyellow":
140
+ return "#fafad2";
141
+ case "lightgray":
142
+ case "lightgrey":
143
+ return "#d3d3d3";
144
+ case "lightgreen":
145
+ return "#90ee90";
146
+ case "lightpink":
147
+ return "#ffb6c1";
148
+ case "lightsalmon":
149
+ return "#ffa07a";
150
+ case "lightseagreen":
151
+ return "#20b2aa";
152
+ case "lightskyblue":
153
+ return "#87cefa";
154
+ case "lightslategray":
155
+ case "lightslategrey":
156
+ return "#778899";
157
+ case "lightsteelblue":
158
+ return "#b0c4de";
159
+ case "lightyellow":
160
+ return "#ffffe0";
21
161
  case "lime":
22
162
  return "#00ff00";
23
- case "olive":
24
- return "#808000";
25
- case "yellow":
26
- return "#ffff00";
163
+ case "limegreen":
164
+ return "#32cd32";
165
+ case "linen":
166
+ return "#faf0e6";
167
+ case "maroon":
168
+ return "#800000";
169
+ case "mediumaquamarine":
170
+ return "#66cdaa";
171
+ case "mediumblue":
172
+ return "#0000cd";
173
+ case "mediumorchid":
174
+ return "#ba55d3";
175
+ case "mediumpurple":
176
+ return "#9370db";
177
+ case "mediumseagreen":
178
+ return "#3cb371";
179
+ case "mediumslateblue":
180
+ return "#7b68ee";
181
+ case "mediumspringgreen":
182
+ return "#00fa9a";
183
+ case "mediumturquoise":
184
+ return "#48d1cc";
185
+ case "mediumvioletred":
186
+ return "#c71585";
187
+ case "midnightblue":
188
+ return "#191970";
189
+ case "mintcream":
190
+ return "#f5fffa";
191
+ case "mistyrose":
192
+ return "#ffe4e1";
193
+ case "moccasin":
194
+ return "#ffe4b5";
195
+ case "navajowhite":
196
+ return "#ffdead";
27
197
  case "navy":
28
198
  return "#000080";
29
- case "blue":
30
- return "#0000ff";
199
+ case "oldlace":
200
+ return "#fdf5e6";
201
+ case "olive":
202
+ return "#808000";
203
+ case "olivedrab":
204
+ return "#6b8e23";
205
+ case "orange":
206
+ return "#ffa500";
207
+ case "orangered":
208
+ return "#ff4500";
209
+ case "orchid":
210
+ return "#da70d6";
211
+ case "palegoldenrod":
212
+ return "#eee8aa";
213
+ case "palegreen":
214
+ return "#98fb98";
215
+ case "paleturquoise":
216
+ return "#afeeee";
217
+ case "palevioletred":
218
+ return "#db7093";
219
+ case "papayawhip":
220
+ return "#ffefd5";
221
+ case "peachpuff":
222
+ return "#ffdab9";
223
+ case "peru":
224
+ return "#cd853f";
225
+ case "pink":
226
+ return "#ffc0cb";
227
+ case "plum":
228
+ return "#dda0dd";
229
+ case "powderblue":
230
+ return "#b0e0e6";
231
+ case "purple":
232
+ return "#800080";
233
+ case "rebeccapurple":
234
+ return "#663399";
235
+ case "red":
236
+ return "#ff0000";
237
+ case "rosybrown":
238
+ return "#bc8f8f";
239
+ case "royalblue":
240
+ return "#4169e1";
241
+ case "saddlebrown":
242
+ return "#8b4513";
243
+ case "salmon":
244
+ return "#fa8072";
245
+ case "sandybrown":
246
+ return "#f4a460";
247
+ case "seagreen":
248
+ return "#2e8b57";
249
+ case "seashell":
250
+ return "#fff5ee";
251
+ case "sienna":
252
+ return "#a0522d";
253
+ case "silver":
254
+ return "#c0c0c0";
255
+ case "skyblue":
256
+ return "#87ceeb";
257
+ case "slateblue":
258
+ return "#6a5acd";
259
+ case "slategray":
260
+ case "slategrey":
261
+ return "#708090";
262
+ case "snow":
263
+ return "#fffafa";
264
+ case "springgreen":
265
+ return "#00ff7f";
266
+ case "steelblue":
267
+ return "#4682b4";
268
+ case "tan":
269
+ return "#d2b48c";
31
270
  case "teal":
32
271
  return "#008080";
33
- case "aqua":
34
- return "#00ffff";
272
+ case "thistle":
273
+ return "#d8bfd8";
274
+ case "tomato":
275
+ return "#ff6347";
276
+ case "turquoise":
277
+ return "#40e0d0";
278
+ case "violet":
279
+ return "#ee82ee";
280
+ case "wheat":
281
+ return "#f5deb3";
282
+ case "white":
283
+ return "#ffffff";
284
+ case "whitesmoke":
285
+ return "#f5f5f5";
286
+ case "yellow":
287
+ return "#ffff00";
288
+ case "yellowgreen":
289
+ return "#9acd32";
35
290
  default:
36
291
  return e;
37
292
  }
38
- }, l = (e) => {
39
- e = u(e);
40
- const n = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
293
+ }, i = (e) => {
294
+ e = f(e);
295
+ const t = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
41
296
  e = e.replace(
42
- n,
43
- (d, a, t, f) => a + a + t + t + f + f
297
+ t,
298
+ (l, a, c, n) => a + a + c + c + n + n
44
299
  );
45
300
  const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
46
301
  if (!r)
47
302
  throw new Error("Bad color");
48
- const s = parseInt(r[1], 16), c = parseInt(r[2], 16);
49
- return 4278190080 | parseInt(r[3], 16) << 16 | c << 8 | s;
303
+ const s = parseInt(r[1], 16), u = parseInt(r[2], 16);
304
+ return 4278190080 | parseInt(r[3], 16) << 16 | u << 8 | s;
50
305
  };
51
306
  export {
52
- l as colorToABGR
307
+ i as colorToABGR
53
308
  };
@@ -2366,42 +2366,42 @@ const Hn = {
2366
2366
  export {
2367
2367
  O as $,
2368
2368
  Qi as A,
2369
- Ie as B,
2369
+ jn as B,
2370
2370
  qi as C,
2371
- jt as D,
2372
- w as E,
2373
- bh as F,
2374
- In as G,
2375
- Is as H,
2376
- Qs as I,
2371
+ Nn as D,
2372
+ J as E,
2373
+ dh as F,
2374
+ Dn as G,
2375
+ wh as H,
2376
+ Ie as I,
2377
2377
  Ks as J,
2378
- $n as K,
2379
- En as L,
2380
- es as M,
2381
- sh as N,
2382
- kn as O,
2383
- Bi as P,
2384
- si as Q,
2385
- Gt as R,
2378
+ Y as K,
2379
+ jt as L,
2380
+ w as M,
2381
+ En as N,
2382
+ Ji as O,
2383
+ bh as P,
2384
+ Bi as Q,
2385
+ In as R,
2386
2386
  Zi as S,
2387
- mh as T,
2388
- b as U,
2387
+ Xi as T,
2388
+ Is as U,
2389
2389
  z as V,
2390
2390
  Tn as W,
2391
- $ as X,
2391
+ Qs as X,
2392
2392
  On as Y,
2393
- re as Z,
2393
+ es as Z,
2394
2394
  Te as _,
2395
- ki as a,
2395
+ Wn as a,
2396
2396
  en as a$,
2397
- Ve as a0,
2398
- Dn as a1,
2399
- Wn as a2,
2400
- Y as a3,
2401
- Xi as a4,
2402
- Kn as a5,
2403
- Ji as a6,
2404
- Hn as a7,
2397
+ sh as a0,
2398
+ kn as a1,
2399
+ si as a2,
2400
+ Gt as a3,
2401
+ b as a4,
2402
+ $ as a5,
2403
+ re as a6,
2404
+ Ve as a7,
2405
2405
  xh as a8,
2406
2406
  F as a9,
2407
2407
  fn as aA,
@@ -2457,7 +2457,7 @@ export {
2457
2457
  Xh as ax,
2458
2458
  Jh as ay,
2459
2459
  Qh as az,
2460
- _h as b,
2460
+ Kn as b,
2461
2461
  Oh as b$,
2462
2462
  sn as b0,
2463
2463
  Rh as b1,
@@ -2522,7 +2522,7 @@ export {
2522
2522
  jh as bx,
2523
2523
  uh as by,
2524
2524
  Ui as bz,
2525
- $i as c,
2525
+ Hn as c,
2526
2526
  d as c0,
2527
2527
  Mn as c1,
2528
2528
  Pt as c2,
@@ -2539,27 +2539,27 @@ export {
2539
2539
  Cn as cd,
2540
2540
  Fn as ce,
2541
2541
  Zn as cf,
2542
- Ys as d,
2543
- Xe as e,
2542
+ mh as d,
2543
+ ki as e,
2544
2544
  qs as f,
2545
- Ce as g,
2545
+ _h as g,
2546
2546
  Ue as h,
2547
2547
  n as i,
2548
- Sn as j,
2549
- Pn as k,
2548
+ $i as j,
2549
+ Ys as k,
2550
2550
  Rs as l,
2551
2551
  zh as m,
2552
2552
  Bn as n,
2553
- a as o,
2553
+ Xe as o,
2554
2554
  Hs as p,
2555
- jn as q,
2556
- Nn as r,
2557
- J as s,
2555
+ Ce as q,
2556
+ $n as r,
2557
+ a as s,
2558
2558
  pt as t,
2559
2559
  Ls as u,
2560
- dh as v,
2560
+ Sn as v,
2561
2561
  Zs as w,
2562
- wh as x,
2562
+ Pn as x,
2563
2563
  Us as y,
2564
2564
  ph as z
2565
2565
  };
@@ -1,50 +1,51 @@
1
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";
2
+ import { toRefIdOrPoint as r } from "./blueprint/utils.js";
3
+ import { n as c, c as a } from "./constants-CBz0gZS0.js";
4
4
  const h = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
5
- let n = (i = 21) => {
5
+ let o = (i = 21) => {
6
6
  let t = "", e = crypto.getRandomValues(new Uint8Array(i |= 0));
7
7
  for (; i--; )
8
8
  t += h[e[i] & 63];
9
9
  return t;
10
10
  };
11
11
  class u extends s {
12
- constructor(t, e, r) {
13
- super(), this.context = t, this.automaton = e, this.rule = r;
12
+ constructor(t, e, n) {
13
+ super(), this.context = t, this.automaton = e, this.rule = n;
14
14
  }
15
15
  condition(t) {
16
- return this.assertNotCreated(), this.rule.when = [...this.rule.when, t], new d(this.context, this.automaton, this.rule);
16
+ return this.assertNotCreated(), this.rule.when = [...this.rule.when, t], new l(this.context, this.automaton, this.rule);
17
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({
18
+ count(t, ...e) {
19
+ let n = this.automaton.neighborhood === "cross" ? [1, 2, 3, 4] : [1, 2, 3, 4, 5, 6, 7, 8];
20
+ return e.length !== 0 && (n = e.flat()), this.condition({
20
21
  type: "count",
21
- id: n(),
22
- check: o(t),
23
- count: Array.isArray(e) ? e : [e]
22
+ id: o(),
23
+ check: r(t),
24
+ count: n
24
25
  });
25
26
  }
26
27
  is(t, e) {
27
28
  return this.condition({
28
29
  type: "is",
29
- id: n(),
30
- compare: a[t],
31
- with: o(e)
30
+ id: o(),
31
+ compare: c[t],
32
+ with: r(e)
32
33
  });
33
34
  }
34
35
  chance(t, e = 100) {
35
36
  return t < 0 && (t = 0), e <= 0 && (e = 1), t > e && (t = e), t = Math.floor(t), e = Math.floor(e), this.condition({
36
37
  type: "chance",
37
- id: n(),
38
+ id: o(),
38
39
  ratio: { part: t, whole: e }
39
40
  });
40
41
  }
41
42
  }
42
- class d extends u {
43
+ class l extends u {
43
44
  accept(t) {
44
- this.assertNotCreated(), this.rule.accept = c[t];
45
+ this.assertNotCreated(), this.rule.accept = a[t];
45
46
  }
46
47
  }
47
48
  export {
48
49
  u as R,
49
- n
50
+ o as n
50
51
  };
@@ -1,27 +1,14 @@
1
- import { TgpuRoot } from 'typegpu';
2
1
  import { Automaton } from '../automaton/types';
2
+ import { GpuCondition, GpuElement, GpuRule } from '../common/constants';
3
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;
4
+ type GpuRuleType = d.Infer<typeof GpuRule>;
5
+ type GpuElementType = d.Infer<typeof GpuElement>;
6
+ type GpuConditionType = d.Infer<typeof GpuCondition>;
7
+ export type GpuAutomaton = {
8
+ gpuNeighborhood: number;
9
+ gpuElements: GpuElementType[];
10
+ gpuRules: GpuRuleType[];
11
+ gpuConditions: GpuConditionType[];
27
12
  };
13
+ export declare const compileGpuAutomaton: (automaton: Automaton) => GpuAutomaton;
14
+ export {};