nucleation 0.7.0 → 0.9.1

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.
@@ -0,0 +1,312 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { Schematic } from "./Schematic.mjs"
4
+ import type { TickSettleMode } from "./TickSettleMode.mjs"
5
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
6
+
7
+
8
+
9
+ /**
10
+ * A headless, vanilla-accurate tick simulation of one structure.
11
+ */
12
+ export class TickSimulation {
13
+ /** @internal */
14
+ get ffiValue(): pointer;
15
+ /** @internal */
16
+ constructor();
17
+
18
+
19
+ /**
20
+ * Why the last constructor on this thread failed, in words.
21
+ *
22
+ * The enum cannot carry a message, and "Simulation" is useless to
23
+ * someone holding a door that will not load: the engine already knows
24
+ * it is `minecraft:waxed_copper_bulb` at (4,2,1) and says so here.
25
+ * Empty when the last construction succeeded.
26
+ */
27
+ static lastErrorDetail(): string;
28
+
29
+ /**
30
+ * Largest build this will attempt, in cells.
31
+ *
32
+ * A 500x379x442 "door" is a saved world, and loading one exhausts the
33
+ * wasm heap — after which every later call on that instance traps,
34
+ * not just the one that overflowed. Refused up front instead.
35
+ */
36
+ static maxVolume(): number;
37
+
38
+ /**
39
+ * Load from Java structure SNBT text.
40
+ *
41
+ * `extra_states`: semicolon-separated block-state descriptors that
42
+ * later `place_block` calls may write (behaviours bind at
43
+ * construction). `minecraft:redstone_block` is always available.
44
+ * `origin_*`: where the build's (0,0,0) sits in world coordinates —
45
+ * wire update order hashes absolute positions.
46
+ *
47
+ * The text's own `DataVersion` selects `Entity.load` Motion semantics,
48
+ * exactly as {@link TickSimulation::from_schematic} uses the schematic's —
49
+ * so `gametest_snbt` → `from_snbt` keeps a nan-cart build's NaN
50
+ * velocities instead of quietly sanitising them. A text with no
51
+ * `DataVersion` gets the engine default (the modern, NaN-dropping
52
+ * rule); read {@link TickSimulation::motion_semantics} to see which
53
+ * applied.
54
+ */
55
+ static fromSnbt(snbt: string, settle: TickSettleMode, originX: number, originY: number, originZ: number, extraStates: string): TickSimulation;
56
+
57
+ /**
58
+ * Load from a schematic (any format nucleation can read), rendered
59
+ * to gametest-flavor structure SNBT for mc-tick's parser.
60
+ */
61
+ static fromSchematic(schematic: Schematic, settle: TickSettleMode, originX: number, originY: number, originZ: number, extraStates: string): TickSimulation;
62
+
63
+ /**
64
+ * GA fast path: construct from a flat genome-cell array — no SNBT
65
+ * text built or parsed. Corridor layout matches the flying-ga app:
66
+ * machine at `x_off`, world size `[bx + travel, by + 2, bz + 2]`,
67
+ * cells flattened `((y * bz) + z) * bx + x`, `air_index` = empty
68
+ * cell. `palette` is the run's alphabet, semicolon-separated; every
69
+ * entry is pre-interned so behaviours bind exactly as the SNBT
70
+ * path's EXTRA_STATES did.
71
+ */
72
+ static fromBlocks(bx: number, by: number, bz: number, travel: number, xOff: number, palette: string, cells: Array<number>, airIndex: number, settle: TickSettleMode, originX: number, originY: number, originZ: number): TickSimulation;
73
+
74
+ /**
75
+ * Evaluate a whole batch of kicked flights inside the engine — one
76
+ * wasm call per generation chunk instead of a dozen boundary calls
77
+ * per machine. `cells` holds N genomes concatenated (each
78
+ * `bx*by*bz` entries), `kicks` N structure-space `[x,y,z]` triples.
79
+ * The flight protocol, probe schedule and gait detection mirror the
80
+ * app's evalCore exactly; `early_exit` stops provably-frozen
81
+ * machines at tick 40 without changing any reported value. Writes
82
+ * JSON rows `[n0, startCom, startMinX, startMaxX, comAtMoveCheck |
83
+ * null, comAtMid, period, n1, endCom, endMinX, endMaxX]`.
84
+ */
85
+ static evalFlightBatch(bx: number, by: number, bz: number, travel: number, xOff: number, palette: string, cells: Array<number>, airIndex: number, kicks: Array<number>, evalTicks: number, seed: bigint, mustMoveByTick: number, needPeriod: boolean, earlyExit: boolean): string;
86
+
87
+ /**
88
+ * Seed the vanilla random source (`java.util.Random`'s LCG,
89
+ * bit-for-bit). Unseeded, jittering behaviours use each
90
+ * distribution's mean — fully deterministic, no noise.
91
+ */
92
+ setRngSeed(seed: bigint): void;
93
+
94
+ /**
95
+ * Advance one game tick.
96
+ */
97
+ step(): void;
98
+
99
+ /**
100
+ * Advance `ticks` game ticks.
101
+ */
102
+ run(ticks: number): void;
103
+
104
+ /**
105
+ * Run until nothing is scheduled or `budget` ticks pass. Returns
106
+ * whether the world went quiet.
107
+ */
108
+ runUntilQuiescent(budget: number): boolean;
109
+
110
+ /**
111
+ * Game ticks elapsed since settle.
112
+ */
113
+ tickCount(): number;
114
+
115
+ /**
116
+ * Whether nothing is scheduled or queued.
117
+ */
118
+ isQuiescent(): boolean;
119
+
120
+ /**
121
+ * Right-click a block with an empty hand (lever, button, note block).
122
+ */
123
+ useBlock(x: number, y: number, z: number): void;
124
+
125
+ /**
126
+ * Write a block state (`minecraft:air` breaks). The state must be in
127
+ * the structure, in `extra_states`, or `minecraft:redstone_block`.
128
+ */
129
+ placeBlock(x: number, y: number, z: number, state: string): void;
130
+
131
+ /**
132
+ * The block state descriptor at a position (`minecraft:air` for empty).
133
+ */
134
+ getBlock(x: number, y: number, z: number): string;
135
+
136
+ /**
137
+ * Snapshot the entire simulation; returns a checkpoint id.
138
+ */
139
+ checkpoint(): number;
140
+
141
+ /**
142
+ * Restore a checkpoint taken earlier on this simulation.
143
+ */
144
+ restore(id: number): void;
145
+
146
+ /**
147
+ * Render a schematic as gametest-flavor structure SNBT — the text
148
+ * `from_snbt` and the corpus/render tooling consume. Lets hosts hand
149
+ * a converted `.litematic`/`.schem` to the video renderer.
150
+ */
151
+ static gametestSnbt(schematic: Schematic): string;
152
+
153
+ /**
154
+ * Report blocks whose behaviour is defined by block-entity data the
155
+ * file does not carry.
156
+ *
157
+ * Some exporters write the blocks and drop the block entities. The
158
+ * build then loads clean and simulates *wrongly but plausibly*: a
159
+ * comparator with no `OutputSignal` reads 0, a barrel holding the
160
+ * item that latched a repeater reads empty, and the door quietly
161
+ * fails to reset. Two files with identical block arrays get
162
+ * different verdicts and nothing says why. `0.45_4x4_funnel.schem`
163
+ * is exactly this — 4 comparators, 2 furnaces, `BlockEntities` of
164
+ * length 0, while its `.litematic` twin carries all 9.
165
+ *
166
+ * This does not refuse the build; it names the doubt so a host can.
167
+ * JSON: `{"present":N,"missing_total":N,"missing":[{"name":..,
168
+ * "count":N}],"summary":"..."}` — `summary` is empty when nothing
169
+ * is missing, and otherwise a sentence fit to show as-is.
170
+ */
171
+ static blockEntityAuditJson(schematic: Schematic): string;
172
+
173
+ /**
174
+ * Start (or stop) recording every delivered redstone update.
175
+ *
176
+ * Off by default and much larger than the block-change log — a door's
177
+ * cycle runs several updates per change — so a propagation view asks
178
+ * for it explicitly and pages with
179
+ * {@link TickSimulation::updates_json_between}.
180
+ *
181
+ * Switching it off keeps what was recorded; use
182
+ * {@link TickSimulation::clear_updates} to free it.
183
+ */
184
+ recordUpdates(on: boolean): void;
185
+
186
+ /**
187
+ * Drop the recorded updates without changing whether recording is on.
188
+ *
189
+ * A cycle of a 6x6 door is tens of megabytes of log, so a page that
190
+ * certifies several builds on one instance needs to release one
191
+ * before recording the next.
192
+ */
193
+ clearUpdates(): void;
194
+
195
+ /**
196
+ * How many updates have been recorded — page before pulling them.
197
+ */
198
+ updatesCount(): number;
199
+
200
+ /**
201
+ * Every recorded update, in delivery order.
202
+ *
203
+ * `seq` counts from 0 within each tick: that is the sub-tick axis, and
204
+ * `(tick, seq)` is the order the engine actually delivered them in.
205
+ * `state` is the block as it stood **at dispatch time**, which is what
206
+ * makes intra-tick order legible — a snapshot cannot show it.
207
+ */
208
+ updatesJson(): string;
209
+
210
+ /**
211
+ * The recorded updates for ticks in `[from_tick, to_tick)`.
212
+ *
213
+ * The whole log for a 6x6 door's cycle is megabytes; a scrubber only
214
+ * ever shows one tick, so it should ask for one tick.
215
+ */
216
+ updatesJsonBetween(fromTick: number, toTick: number): string;
217
+
218
+ /**
219
+ * Per-tick, per-cell update counts for ticks in `[from_tick, to_tick)`.
220
+ *
221
+ * The resolution playback should run at: `{phases, ticks:[{tick, total,
222
+ * cells:[{p:[x,y,z], n, nb, sh, ph:[…]}]}]}`, where `nb`/`sh` split
223
+ * neighbour from shape and `ph` indexes the `phases` legend. Collapses
224
+ * a tick's tens of thousands of updates into a few hundred cells.
225
+ */
226
+ updatesHeatJson(fromTick: number, toTick: number): string;
227
+
228
+ /**
229
+ * One tick's updates in delivery order, as parallel arrays.
230
+ *
231
+ * For stepping *within* a tick: `seq` is the array index, `pos` is flat
232
+ * x,y,z triples, `kind`/`phase`/`from` are integer codes with legends
233
+ * in the payload, and `state` indexes a deduplicated `states` table.
234
+ */
235
+ updatesWaveJson(tick: number): string;
236
+
237
+ changesJson(): string;
238
+
239
+ /**
240
+ * Live item entities and minecarts, as JSON:
241
+ * `{"items":[{"id":N,"item":"...","count":N,"pos":[..],"vel":[..],
242
+ * "on_ground":bool,"contents":[{"id":"...","count":N}]}],
243
+ * "minecarts":[{"id":N,"kind":"...","pos":[..],"vel":[..]}]}`.
244
+ */
245
+ itemEntitiesJson(): string;
246
+
247
+ /**
248
+ * Which `Entity.load` Motion semantics this run uses:
249
+ * `"clamp_abs_ten"` (DataVersion <= 4556 — NaN survives a cold load)
250
+ * or `"drop_non_finite"` (>= 4671 — it does not).
251
+ *
252
+ * Exposed because a door built on nan carts is a *different machine*
253
+ * under the two, and a caller that cannot tell them apart cannot
254
+ * report why it came apart.
255
+ */
256
+ motionSemantics(): string;
257
+
258
+ /**
259
+ * How many times an entity stood in a **retracting** piston's sweep
260
+ * that the engine could not reproduce.
261
+ *
262
+ * A tripwire from when retraction was unmodelled — extension
263
+ * displacement was measured and implemented while
264
+ * `tools/gametest/captures/piston_pull.entities.log`'s sub-0.03
265
+ * movements, not uniformly backwards, had no model here. All three
266
+ * retraction geometries are implemented now, so this reports **0**,
267
+ * including on the record 3x3 door, which used to name six. It is kept
268
+ * because the next geometry that turns out not to be covered should be
269
+ * reported rather than guessed at: non-zero means this run leaned on
270
+ * behaviour we do not reproduce and its result is not trustworthy.
271
+ */
272
+ pistonRetractContacts(): number;
273
+
274
+ /**
275
+ * Per-tick aggregates over the recorded changes, as JSON:
276
+ * `[{"tick":N,"changes":N,"piston":N,"redstone":N}]` — `piston`
277
+ * counts changes touching piston blocks (base, head, moving), and
278
+ * `redstone` changes touching wire/torch/repeater/comparator/
279
+ * observer/lamp/lever/button/pressure-plate states.
280
+ */
281
+ eventsSummaryJson(): string;
282
+
283
+ /**
284
+ * Every non-air block, as JSON:
285
+ * `[{"pos":[x,y,z],"state":"..."}]`.
286
+ * How many non-air blocks stand in the world right now.
287
+ */
288
+ nonAirCount(): number;
289
+
290
+ /**
291
+ * Center of mass (x) of every non-air block — the GA's displacement
292
+ * metric without a JSON round-trip. NaN when the world is empty.
293
+ */
294
+ nonAirCenterX(): number;
295
+
296
+ /**
297
+ * Smallest x holding a non-air block; `i32::MAX` when empty.
298
+ */
299
+ nonAirMinX(): number;
300
+
301
+ /**
302
+ * Largest x holding a non-air block; `i32::MIN` when empty.
303
+ */
304
+ nonAirMaxX(): number;
305
+
306
+ /**
307
+ * How many block changes recording has captured so far.
308
+ */
309
+ changesCount(): number;
310
+
311
+ worldSnapshotJson(): string;
312
+ }