@its-not-rocket-science/ananke 0.1.14 → 0.1.16
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/CHANGELOG.md +44 -1
- package/dist/as/injury.wasm +0 -0
- package/dist/as/injury.wat +382 -0
- package/dist/as/push.wasm +0 -0
- package/dist/as/push.wat +326 -0
- package/dist/as/units.wasm +0 -0
- package/dist/as/units.wat +290 -0
- package/dist/src/battle-bridge.d.ts +94 -0
- package/dist/src/battle-bridge.js +126 -0
- package/dist/src/wasm-kernel.d.ts +58 -0
- package/dist/src/wasm-kernel.js +96 -0
- package/package.json +15 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,50 @@ Versioning follows [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
## [
|
|
9
|
+
## [0.1.16] — 2026-03-25
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **CE-5 · Persistent World Server** — campaign ↔ combat battle bridge:
|
|
14
|
+
- src/battle-bridge.ts: pure functions translating polity state to
|
|
15
|
+
BattleConfig and BattleOutcome back to PolityImpact[]. Covers
|
|
16
|
+
tech-era→loadout mapping, military-strength→team-size scaling,
|
|
17
|
+
deterministic battle seed, morale/stability/population impact.
|
|
18
|
+
27 tests in test/battle-bridge.test.ts.
|
|
19
|
+
- tools/persistent-world.ts: integrated server running polity tick +
|
|
20
|
+
synchronous tactical battles every 7 days per active war. Battle
|
|
21
|
+
outcomes mutate polity morale, stability, and population. Full
|
|
22
|
+
checkpoint/resume, WebSocket push, HTTP war/peace/save/reset/battles
|
|
23
|
+
endpoints. Run with: npm run persistent-world
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## [0.1.15] — 2026-03-25
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **CE-5 · WebAssembly Kernel** — shadow-mode WASM acceleration for push repulsion and
|
|
32
|
+
injury accumulation:
|
|
33
|
+
- `as/units.ts` — AssemblyScript port of `src/units.ts` (all 13 exports: SCALE constants,
|
|
34
|
+
`q()`, `clampQ()`, `qMul()`, `qDiv()`, `mulDiv()`, `sqrtQ()`, `cbrtQ()`, unit
|
|
35
|
+
converters). Compiled to `dist/as/units.wasm`.
|
|
36
|
+
- `as/push.ts` — pair-wise position repulsion kernel in flat WASM memory (64-entity
|
|
37
|
+
capacity, octagonal distance approximation, overflow-safe i64 arithmetic).
|
|
38
|
+
Compiled to `dist/as/push.wasm`.
|
|
39
|
+
- `as/injury.ts` — per-entity injury accumulation inner loop (clotting, bleed→fluid,
|
|
40
|
+
shock, consciousness, death check) matching `src/sim/step/injury.ts` constants exactly.
|
|
41
|
+
Compiled to `dist/as/injury.wasm`.
|
|
42
|
+
- `src/wasm-kernel.ts` — Node.js host bridge. `WasmKernel.shadowStep(world, tick)`
|
|
43
|
+
marshals entity state into WASM memory, runs both kernels, and returns a
|
|
44
|
+
`WasmStepReport` with per-entity velocity deltas and projected vitals. Shadow mode:
|
|
45
|
+
outputs are never applied to world state — used for validation and diagnostics only.
|
|
46
|
+
- `loadWasmKernel()` factory loads `push.wasm` + `injury.wasm` from `dist/as/` at
|
|
47
|
+
runtime via `import.meta.url` + `readFileSync`.
|
|
48
|
+
- Exported as `@its-not-rocket-science/ananke/wasm-kernel`.
|
|
49
|
+
- `dist/as/` (compiled WASM binaries) included in the published package.
|
|
50
|
+
- 61 WASM unit tests (`test/as/`) covering units, push repulsion, and injury
|
|
51
|
+
accumulation parity with the TypeScript reference implementation.
|
|
52
|
+
- Build scripts: `npm run build:wasm:all`, `npm run test:wasm`.
|
|
10
53
|
|
|
11
54
|
### Added
|
|
12
55
|
|
|
Binary file
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
(module
|
|
2
|
+
(type $0 (func (param i32) (result i32)))
|
|
3
|
+
(type $1 (func (param i32 i32 i32 i32 i32 i32 i32)))
|
|
4
|
+
(type $2 (func (param i32 i32 i32 i32 i32 i32)))
|
|
5
|
+
(type $3 (func (param i32 i32) (result i32)))
|
|
6
|
+
(type $4 (func (param i32)))
|
|
7
|
+
(global $as/injury/SHOCK_FROM_FLUID i32 (i32.const 40))
|
|
8
|
+
(global $as/injury/SHOCK_FROM_INTERNAL i32 (i32.const 20))
|
|
9
|
+
(global $as/injury/CONSC_LOSS_FROM_SHOCK i32 (i32.const 100))
|
|
10
|
+
(global $as/injury/CONSC_LOSS_FROM_SUFF i32 (i32.const 200))
|
|
11
|
+
(global $as/injury/FATAL_FLUID_LOSS i32 (i32.const 8000))
|
|
12
|
+
(global $as/injury/CLOT_RATE_PER_TICK i32 (i32.const 2))
|
|
13
|
+
(global $as/injury/MAX_ENTITIES i32 (i32.const 64))
|
|
14
|
+
(global $as/injury/N_REGIONS i32 (i32.const 6))
|
|
15
|
+
(global $as/injury/ENTITY_STRIDE i32 (i32.const 120))
|
|
16
|
+
(memory $0 1)
|
|
17
|
+
(export "SHOCK_FROM_FLUID" (global $as/injury/SHOCK_FROM_FLUID))
|
|
18
|
+
(export "SHOCK_FROM_INTERNAL" (global $as/injury/SHOCK_FROM_INTERNAL))
|
|
19
|
+
(export "CONSC_LOSS_FROM_SHOCK" (global $as/injury/CONSC_LOSS_FROM_SHOCK))
|
|
20
|
+
(export "CONSC_LOSS_FROM_SUFF" (global $as/injury/CONSC_LOSS_FROM_SUFF))
|
|
21
|
+
(export "FATAL_FLUID_LOSS" (global $as/injury/FATAL_FLUID_LOSS))
|
|
22
|
+
(export "CLOT_RATE_PER_TICK" (global $as/injury/CLOT_RATE_PER_TICK))
|
|
23
|
+
(export "MAX_ENTITIES" (global $as/injury/MAX_ENTITIES))
|
|
24
|
+
(export "N_REGIONS" (global $as/injury/N_REGIONS))
|
|
25
|
+
(export "ENTITY_STRIDE" (global $as/injury/ENTITY_STRIDE))
|
|
26
|
+
(export "writeVitals" (func $as/injury/writeVitals))
|
|
27
|
+
(export "writeRegion" (func $as/injury/writeRegion))
|
|
28
|
+
(export "readFluidLoss" (func $as/injury/readFluidLoss))
|
|
29
|
+
(export "readShock" (func $as/injury/readShock))
|
|
30
|
+
(export "readConsciousness" (func $as/injury/readConsciousness))
|
|
31
|
+
(export "readDead" (func $as/injury/readDead))
|
|
32
|
+
(export "readBleedingRate" (func $as/injury/readBleedingRate))
|
|
33
|
+
(export "stepBleedAndShock" (func $as/injury/stepBleedAndShock))
|
|
34
|
+
(export "memory" (memory $0))
|
|
35
|
+
(func $as/injury/writeVitals (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) (param $6 i32)
|
|
36
|
+
local.get $0
|
|
37
|
+
i32.const 120
|
|
38
|
+
i32.mul
|
|
39
|
+
local.tee $0
|
|
40
|
+
local.get $1
|
|
41
|
+
i32.store
|
|
42
|
+
local.get $0
|
|
43
|
+
local.get $2
|
|
44
|
+
i32.store offset=4
|
|
45
|
+
local.get $0
|
|
46
|
+
local.get $3
|
|
47
|
+
i32.store offset=8
|
|
48
|
+
local.get $0
|
|
49
|
+
local.get $4
|
|
50
|
+
i32.store offset=12
|
|
51
|
+
local.get $0
|
|
52
|
+
local.get $5
|
|
53
|
+
i32.store offset=16
|
|
54
|
+
local.get $0
|
|
55
|
+
local.get $6
|
|
56
|
+
i32.store offset=20
|
|
57
|
+
)
|
|
58
|
+
(func $as/injury/writeRegion (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32)
|
|
59
|
+
local.get $0
|
|
60
|
+
i32.const 120
|
|
61
|
+
i32.mul
|
|
62
|
+
local.tee $0
|
|
63
|
+
local.get $1
|
|
64
|
+
i32.const 2
|
|
65
|
+
i32.shl
|
|
66
|
+
local.tee $1
|
|
67
|
+
i32.const 6
|
|
68
|
+
i32.add
|
|
69
|
+
i32.const 2
|
|
70
|
+
i32.shl
|
|
71
|
+
i32.add
|
|
72
|
+
local.get $2
|
|
73
|
+
i32.store
|
|
74
|
+
local.get $0
|
|
75
|
+
local.get $1
|
|
76
|
+
i32.const 7
|
|
77
|
+
i32.add
|
|
78
|
+
i32.const 2
|
|
79
|
+
i32.shl
|
|
80
|
+
i32.add
|
|
81
|
+
local.get $3
|
|
82
|
+
i32.store
|
|
83
|
+
local.get $0
|
|
84
|
+
local.get $1
|
|
85
|
+
i32.const 8
|
|
86
|
+
i32.add
|
|
87
|
+
i32.const 2
|
|
88
|
+
i32.shl
|
|
89
|
+
i32.add
|
|
90
|
+
local.get $4
|
|
91
|
+
i32.store
|
|
92
|
+
local.get $0
|
|
93
|
+
local.get $1
|
|
94
|
+
i32.const 9
|
|
95
|
+
i32.add
|
|
96
|
+
i32.const 2
|
|
97
|
+
i32.shl
|
|
98
|
+
i32.add
|
|
99
|
+
local.get $5
|
|
100
|
+
i32.store
|
|
101
|
+
)
|
|
102
|
+
(func $as/injury/readFluidLoss (param $0 i32) (result i32)
|
|
103
|
+
local.get $0
|
|
104
|
+
i32.const 120
|
|
105
|
+
i32.mul
|
|
106
|
+
i32.load
|
|
107
|
+
)
|
|
108
|
+
(func $as/injury/readShock (param $0 i32) (result i32)
|
|
109
|
+
local.get $0
|
|
110
|
+
i32.const 120
|
|
111
|
+
i32.mul
|
|
112
|
+
i32.load offset=4
|
|
113
|
+
)
|
|
114
|
+
(func $as/injury/readConsciousness (param $0 i32) (result i32)
|
|
115
|
+
local.get $0
|
|
116
|
+
i32.const 120
|
|
117
|
+
i32.mul
|
|
118
|
+
i32.load offset=8
|
|
119
|
+
)
|
|
120
|
+
(func $as/injury/readDead (param $0 i32) (result i32)
|
|
121
|
+
local.get $0
|
|
122
|
+
i32.const 120
|
|
123
|
+
i32.mul
|
|
124
|
+
i32.load offset=12
|
|
125
|
+
)
|
|
126
|
+
(func $as/injury/readBleedingRate (param $0 i32) (param $1 i32) (result i32)
|
|
127
|
+
local.get $0
|
|
128
|
+
i32.const 120
|
|
129
|
+
i32.mul
|
|
130
|
+
local.get $1
|
|
131
|
+
i32.const 2
|
|
132
|
+
i32.shl
|
|
133
|
+
i32.const 6
|
|
134
|
+
i32.add
|
|
135
|
+
i32.const 2
|
|
136
|
+
i32.shl
|
|
137
|
+
i32.add
|
|
138
|
+
i32.load
|
|
139
|
+
)
|
|
140
|
+
(func $as/injury/stepBleedAndShock (param $0 i32)
|
|
141
|
+
(local $1 i32)
|
|
142
|
+
(local $2 i32)
|
|
143
|
+
(local $3 i32)
|
|
144
|
+
(local $4 i32)
|
|
145
|
+
(local $5 i32)
|
|
146
|
+
(local $6 i32)
|
|
147
|
+
(local $7 i32)
|
|
148
|
+
loop $for-loop|0
|
|
149
|
+
local.get $0
|
|
150
|
+
local.get $4
|
|
151
|
+
i32.gt_s
|
|
152
|
+
if
|
|
153
|
+
local.get $4
|
|
154
|
+
i32.const 120
|
|
155
|
+
i32.mul
|
|
156
|
+
i32.load offset=12
|
|
157
|
+
i32.eqz
|
|
158
|
+
if
|
|
159
|
+
i32.const 0
|
|
160
|
+
local.set $3
|
|
161
|
+
i32.const 0
|
|
162
|
+
local.set $2
|
|
163
|
+
loop $for-loop|1
|
|
164
|
+
local.get $2
|
|
165
|
+
i32.const 6
|
|
166
|
+
i32.lt_s
|
|
167
|
+
if
|
|
168
|
+
local.get $4
|
|
169
|
+
i32.const 120
|
|
170
|
+
i32.mul
|
|
171
|
+
local.tee $5
|
|
172
|
+
local.get $2
|
|
173
|
+
i32.const 2
|
|
174
|
+
i32.shl
|
|
175
|
+
local.tee $6
|
|
176
|
+
i32.const 6
|
|
177
|
+
i32.add
|
|
178
|
+
i32.const 2
|
|
179
|
+
i32.shl
|
|
180
|
+
i32.add
|
|
181
|
+
local.tee $7
|
|
182
|
+
i32.load
|
|
183
|
+
local.tee $1
|
|
184
|
+
i32.const 0
|
|
185
|
+
i32.gt_s
|
|
186
|
+
if
|
|
187
|
+
local.get $7
|
|
188
|
+
i32.const 10000
|
|
189
|
+
local.get $1
|
|
190
|
+
i32.const 10000
|
|
191
|
+
i32.const 10000
|
|
192
|
+
local.get $5
|
|
193
|
+
local.get $6
|
|
194
|
+
i32.const 7
|
|
195
|
+
i32.add
|
|
196
|
+
i32.const 2
|
|
197
|
+
i32.shl
|
|
198
|
+
i32.add
|
|
199
|
+
i32.load
|
|
200
|
+
i32.sub
|
|
201
|
+
local.tee $1
|
|
202
|
+
local.get $1
|
|
203
|
+
i32.const 10000
|
|
204
|
+
i32.gt_s
|
|
205
|
+
select
|
|
206
|
+
local.tee $1
|
|
207
|
+
i32.const 0
|
|
208
|
+
local.get $1
|
|
209
|
+
i32.const 0
|
|
210
|
+
i32.ge_s
|
|
211
|
+
select
|
|
212
|
+
i64.extend_i32_s
|
|
213
|
+
i64.const 1
|
|
214
|
+
i64.shl
|
|
215
|
+
i64.const 10000
|
|
216
|
+
i64.div_s
|
|
217
|
+
i32.wrap_i64
|
|
218
|
+
i32.sub
|
|
219
|
+
local.tee $1
|
|
220
|
+
local.get $1
|
|
221
|
+
i32.const 10000
|
|
222
|
+
i32.gt_s
|
|
223
|
+
select
|
|
224
|
+
local.tee $1
|
|
225
|
+
i32.const 0
|
|
226
|
+
local.get $1
|
|
227
|
+
i32.const 0
|
|
228
|
+
i32.ge_s
|
|
229
|
+
select
|
|
230
|
+
local.tee $1
|
|
231
|
+
i32.store
|
|
232
|
+
end
|
|
233
|
+
local.get $1
|
|
234
|
+
local.get $3
|
|
235
|
+
i32.add
|
|
236
|
+
local.set $3
|
|
237
|
+
local.get $2
|
|
238
|
+
i32.const 1
|
|
239
|
+
i32.add
|
|
240
|
+
local.set $2
|
|
241
|
+
br $for-loop|1
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
i32.const 10000
|
|
245
|
+
local.get $4
|
|
246
|
+
i32.const 120
|
|
247
|
+
i32.mul
|
|
248
|
+
local.tee $1
|
|
249
|
+
i32.load
|
|
250
|
+
local.get $3
|
|
251
|
+
i64.extend_i32_s
|
|
252
|
+
i64.const 500
|
|
253
|
+
i64.mul
|
|
254
|
+
i64.const 10000
|
|
255
|
+
i64.div_s
|
|
256
|
+
i32.wrap_i64
|
|
257
|
+
i32.add
|
|
258
|
+
local.tee $2
|
|
259
|
+
local.get $2
|
|
260
|
+
i32.const 10000
|
|
261
|
+
i32.gt_s
|
|
262
|
+
select
|
|
263
|
+
local.tee $2
|
|
264
|
+
i32.const 0
|
|
265
|
+
local.get $2
|
|
266
|
+
i32.const 0
|
|
267
|
+
i32.ge_s
|
|
268
|
+
select
|
|
269
|
+
local.set $2
|
|
270
|
+
local.get $1
|
|
271
|
+
local.get $2
|
|
272
|
+
i32.store
|
|
273
|
+
local.get $1
|
|
274
|
+
i32.const 10000
|
|
275
|
+
local.get $1
|
|
276
|
+
i64.load32_s offset=48
|
|
277
|
+
i64.const 20
|
|
278
|
+
i64.mul
|
|
279
|
+
i64.const 10000
|
|
280
|
+
i64.div_s
|
|
281
|
+
i32.wrap_i64
|
|
282
|
+
local.get $1
|
|
283
|
+
i32.const 4
|
|
284
|
+
i32.add
|
|
285
|
+
i32.load
|
|
286
|
+
local.get $2
|
|
287
|
+
i64.extend_i32_s
|
|
288
|
+
i64.const 40
|
|
289
|
+
i64.mul
|
|
290
|
+
i64.const 10000
|
|
291
|
+
i64.div_s
|
|
292
|
+
i32.wrap_i64
|
|
293
|
+
i32.add
|
|
294
|
+
i32.add
|
|
295
|
+
local.tee $3
|
|
296
|
+
local.get $3
|
|
297
|
+
i32.const 10000
|
|
298
|
+
i32.gt_s
|
|
299
|
+
select
|
|
300
|
+
local.tee $3
|
|
301
|
+
i32.const 0
|
|
302
|
+
local.get $3
|
|
303
|
+
i32.const 0
|
|
304
|
+
i32.ge_s
|
|
305
|
+
select
|
|
306
|
+
local.tee $3
|
|
307
|
+
i32.store offset=4
|
|
308
|
+
local.get $1
|
|
309
|
+
i32.const 10000
|
|
310
|
+
local.get $1
|
|
311
|
+
i32.const 8
|
|
312
|
+
i32.add
|
|
313
|
+
i32.load
|
|
314
|
+
i32.const 10000
|
|
315
|
+
local.get $3
|
|
316
|
+
i64.extend_i32_s
|
|
317
|
+
i64.const 100
|
|
318
|
+
i64.mul
|
|
319
|
+
i64.const 10000
|
|
320
|
+
i64.div_s
|
|
321
|
+
i32.wrap_i64
|
|
322
|
+
local.get $1
|
|
323
|
+
i64.load32_s offset=20
|
|
324
|
+
i64.const 200
|
|
325
|
+
i64.mul
|
|
326
|
+
i64.const 10000
|
|
327
|
+
i64.div_s
|
|
328
|
+
i32.wrap_i64
|
|
329
|
+
i32.add
|
|
330
|
+
local.tee $5
|
|
331
|
+
local.get $5
|
|
332
|
+
i32.const 10000
|
|
333
|
+
i32.gt_s
|
|
334
|
+
select
|
|
335
|
+
local.tee $5
|
|
336
|
+
i32.const 0
|
|
337
|
+
local.get $5
|
|
338
|
+
i32.const 0
|
|
339
|
+
i32.ge_s
|
|
340
|
+
select
|
|
341
|
+
i32.sub
|
|
342
|
+
local.tee $5
|
|
343
|
+
local.get $5
|
|
344
|
+
i32.const 10000
|
|
345
|
+
i32.gt_s
|
|
346
|
+
select
|
|
347
|
+
local.tee $5
|
|
348
|
+
i32.const 0
|
|
349
|
+
local.get $5
|
|
350
|
+
i32.const 0
|
|
351
|
+
i32.ge_s
|
|
352
|
+
select
|
|
353
|
+
local.tee $5
|
|
354
|
+
i32.store offset=8
|
|
355
|
+
local.get $5
|
|
356
|
+
i32.eqz
|
|
357
|
+
local.get $3
|
|
358
|
+
i32.const 10000
|
|
359
|
+
i32.ge_s
|
|
360
|
+
local.get $2
|
|
361
|
+
i32.const 8000
|
|
362
|
+
i32.ge_s
|
|
363
|
+
i32.or
|
|
364
|
+
i32.or
|
|
365
|
+
if
|
|
366
|
+
local.get $1
|
|
367
|
+
i32.const 1
|
|
368
|
+
i32.store offset=12
|
|
369
|
+
local.get $1
|
|
370
|
+
i32.const 0
|
|
371
|
+
i32.store offset=8
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
local.get $4
|
|
375
|
+
i32.const 1
|
|
376
|
+
i32.add
|
|
377
|
+
local.set $4
|
|
378
|
+
br $for-loop|0
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
)
|
|
382
|
+
)
|
|
Binary file
|