@its-not-rocket-science/ananke 0.1.13 → 0.1.15
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 +46 -0
- 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/campaign-layer.d.ts +1 -0
- package/dist/src/campaign-layer.js +1 -0
- package/dist/src/culture.d.ts +164 -0
- package/dist/src/culture.js +412 -0
- package/dist/src/wasm-kernel.d.ts +58 -0
- package/dist/src/wasm-kernel.js +96 -0
- package/package.json +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,10 +6,56 @@ Versioning follows [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [0.1.15] — 2026-03-25
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **CE-5 · WebAssembly Kernel** — shadow-mode WASM acceleration for push repulsion and
|
|
14
|
+
injury accumulation:
|
|
15
|
+
- `as/units.ts` — AssemblyScript port of `src/units.ts` (all 13 exports: SCALE constants,
|
|
16
|
+
`q()`, `clampQ()`, `qMul()`, `qDiv()`, `mulDiv()`, `sqrtQ()`, `cbrtQ()`, unit
|
|
17
|
+
converters). Compiled to `dist/as/units.wasm`.
|
|
18
|
+
- `as/push.ts` — pair-wise position repulsion kernel in flat WASM memory (64-entity
|
|
19
|
+
capacity, octagonal distance approximation, overflow-safe i64 arithmetic).
|
|
20
|
+
Compiled to `dist/as/push.wasm`.
|
|
21
|
+
- `as/injury.ts` — per-entity injury accumulation inner loop (clotting, bleed→fluid,
|
|
22
|
+
shock, consciousness, death check) matching `src/sim/step/injury.ts` constants exactly.
|
|
23
|
+
Compiled to `dist/as/injury.wasm`.
|
|
24
|
+
- `src/wasm-kernel.ts` — Node.js host bridge. `WasmKernel.shadowStep(world, tick)`
|
|
25
|
+
marshals entity state into WASM memory, runs both kernels, and returns a
|
|
26
|
+
`WasmStepReport` with per-entity velocity deltas and projected vitals. Shadow mode:
|
|
27
|
+
outputs are never applied to world state — used for validation and diagnostics only.
|
|
28
|
+
- `loadWasmKernel()` factory loads `push.wasm` + `injury.wasm` from `dist/as/` at
|
|
29
|
+
runtime via `import.meta.url` + `readFileSync`.
|
|
30
|
+
- Exported as `@its-not-rocket-science/ananke/wasm-kernel`.
|
|
31
|
+
- `dist/as/` (compiled WASM binaries) included in the published package.
|
|
32
|
+
- 61 WASM unit tests (`test/as/`) covering units, push repulsion, and injury
|
|
33
|
+
accumulation parity with the TypeScript reference implementation.
|
|
34
|
+
- Build scripts: `npm run build:wasm:all`, `npm run test:wasm`.
|
|
35
|
+
|
|
9
36
|
## [Unreleased]
|
|
10
37
|
|
|
11
38
|
### Added
|
|
12
39
|
|
|
40
|
+
- **Phase 71 · Cultural Generation & Evolution Framework** (`src/culture.ts`)
|
|
41
|
+
- Reverse WOAC method: derives culture bottom-up from five forces (`environment`,
|
|
42
|
+
`power`, `exchange`, `legacy`, `belief`) scored from simulation state.
|
|
43
|
+
- `generateCulture(polity, registry, myths, vassals?, biome?)` → `CultureProfile`
|
|
44
|
+
with 10 possible `CulturalValue` types, `CulturalContradiction` pairs, and
|
|
45
|
+
`CulturalCycle` practices (CYCLES audit).
|
|
46
|
+
- `stepCultureYear(profile, techPressure_Q, militaryOutcome_Q, myths, worldSeed, tick)`
|
|
47
|
+
→ `CultureYearResult { profile, schism? }`: tech diffusion pulls exchange force
|
|
48
|
+
upward; military outcomes shift power; new myths update legacy/belief; conservative
|
|
49
|
+
cultures with high tension fire deterministic `SchismEvent` (reform_movement,
|
|
50
|
+
heresy, or civil_unrest).
|
|
51
|
+
- `describeCulture(profile)` → `{ summary, values, contradictions, cycles }`:
|
|
52
|
+
human-readable output for writers and game designers.
|
|
53
|
+
- Query helpers: `getCulturalValue`, `getDominantValues`, `getSignificantContradictions`.
|
|
54
|
+
- Integrates with Phase 70 (vassal count → power force), Phase 66 (myths → legacy/belief),
|
|
55
|
+
Phase 68 (BiomeContext → environment harshness), Phase 23 dialogue and Phase 24
|
|
56
|
+
faction standing via exported profile queries.
|
|
57
|
+
- 45 tests in `test/culture.test.ts`; exported via `ananke/campaign` subpath.
|
|
58
|
+
|
|
13
59
|
- **Phase 70 · Stratified Political Simulation ("Vassal Web" Layer)** (`src/polity-vassals.ts`)
|
|
14
60
|
- `VassalNode` — intermediate layer between Entity and Polity with `territory_Q`,
|
|
15
61
|
`military_Q`, `treasury_cu`, and a `VassalLoyalty` block.
|
|
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
|