honse-sim 0.1.0 → 0.1.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.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "honse-sim",
3
3
  "type": "module",
4
- "description": "WebAssembly adapter for the uma-sim race simulation engines (contested + vacuum).",
5
- "version": "0.1.0",
4
+ "description": "WebAssembly adapter for the honse-sim race simulation engine.",
5
+ "version": "0.1.1",
6
6
  "license": "GPL-3.0-only",
7
7
  "repository": {
8
8
  "type": "git",
@@ -11,11 +11,12 @@
11
11
  "files": [
12
12
  "uma_sim_wasm_bg.wasm",
13
13
  "uma_sim_wasm.js",
14
- "uma_sim_wasm.d.ts"
14
+ "uma_sim_wasm.d.ts",
15
+ "snippets"
15
16
  ],
16
17
  "main": "uma_sim_wasm.js",
17
18
  "types": "uma_sim_wasm.d.ts",
18
19
  "sideEffects": [
19
20
  "./snippets/*"
20
21
  ]
21
- }
22
+ }
package/uma_sim_wasm.d.ts CHANGED
@@ -43,17 +43,38 @@ export class WasmRaceSimulator {
43
43
  setOnRunnerFinished(cb: Function): void;
44
44
  }
45
45
 
46
+ /**
47
+ * The late-race HP consumption multiplier for a guts stat.
48
+ *
49
+ * See [`honse_sim::readouts::guts_hp_burn_multiplier`].
50
+ */
51
+ export function gutsHpBurnMultiplier(guts: number): number;
52
+
53
+ /**
54
+ * Stamina's HP conversion coefficient for a strategy id (1-5).
55
+ *
56
+ * See [`honse_sim::readouts::hp_strategy_coefficient`].
57
+ */
58
+ export function hpStrategyCoefficient(strategy: number): number;
59
+
46
60
  /**
47
61
  * All condition tokens the Rust engine's catalog recognizes.
48
62
  *
49
- * Exposed so the TS-side simulatability gate (ADR-0003, driven by the TS
50
- * `knownConditionTokens` vocabulary) can be cross-checked against the engine
51
- * that actually runs the sim, closing the dual-parser drift risk (ADR-0004):
52
- * any token the UI treats as simulatable must be resolvable by this engine.
63
+ * Exposed so an external consumer can cross-check its simulatability gate
64
+ * against the engine that runs the simulation. Any token a consumer treats as
65
+ * simulatable must be resolvable by this engine.
53
66
  * Returned as a sorted JS string array.
54
67
  */
55
68
  export function knownConditionTokens(): string[];
56
69
 
70
+ /**
71
+ * The HP a runner starts a race with, from stamina, strategy id, and course
72
+ * distance in meters.
73
+ *
74
+ * See [`honse_sim::readouts::max_hp`].
75
+ */
76
+ export function maxHp(stamina: number, strategy: number, distance: number): number;
77
+
57
78
  /**
58
79
  * Run a batch compare-family simulation and return the serialized result.
59
80
  *
@@ -80,12 +101,21 @@ export function runContestedCompare(params: any): any;
80
101
  */
81
102
  export function runRaceSim(params: any): any;
82
103
 
104
+ /**
105
+ * The pre-race wisdom check pass rate, as a percentage, for a base wit stat.
106
+ *
107
+ * See [`honse_sim::readouts::skill_activation_percent`].
108
+ */
109
+ export function skillActivationPercent(base_wit: number): number;
110
+
83
111
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
84
112
 
85
113
  export interface InitOutput {
86
114
  readonly memory: WebAssembly.Memory;
87
115
  readonly __wbg_wasmracesimulator_free: (a: number, b: number) => void;
116
+ readonly hpStrategyCoefficient: (a: number) => [number, number, number];
88
117
  readonly knownConditionTokens: () => [number, number];
118
+ readonly maxHp: (a: number, b: number, c: number) => [number, number, number];
89
119
  readonly runCompare: (a: any) => [number, number, number];
90
120
  readonly runContestedCompare: (a: any) => [number, number, number];
91
121
  readonly runRaceSim: (a: any) => [number, number, number];
@@ -96,14 +126,16 @@ export interface InitOutput {
96
126
  readonly wasmracesimulator_setOnRoundEnd: (a: number, b: any) => void;
97
127
  readonly wasmracesimulator_setOnRoundStart: (a: number, b: any) => void;
98
128
  readonly wasmracesimulator_setOnRunnerFinished: (a: number, b: any) => void;
129
+ readonly gutsHpBurnMultiplier: (a: number) => number;
130
+ readonly skillActivationPercent: (a: number) => number;
99
131
  readonly __wbindgen_malloc: (a: number, b: number) => number;
100
132
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
101
133
  readonly __wbindgen_exn_store: (a: number) => void;
102
134
  readonly __externref_table_alloc: () => number;
103
135
  readonly __wbindgen_externrefs: WebAssembly.Table;
136
+ readonly __externref_table_dealloc: (a: number) => void;
104
137
  readonly __externref_drop_slice: (a: number, b: number) => void;
105
138
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
106
- readonly __externref_table_dealloc: (a: number) => void;
107
139
  readonly __wbindgen_start: () => void;
108
140
  }
109
141
 
package/uma_sim_wasm.js CHANGED
@@ -83,23 +83,67 @@ export class WasmRaceSimulator {
83
83
  }
84
84
  if (Symbol.dispose) WasmRaceSimulator.prototype[Symbol.dispose] = WasmRaceSimulator.prototype.free;
85
85
 
86
+ /**
87
+ * The late-race HP consumption multiplier for a guts stat.
88
+ *
89
+ * See [`honse_sim::readouts::guts_hp_burn_multiplier`].
90
+ * @param {number} guts
91
+ * @returns {number}
92
+ */
93
+ export function gutsHpBurnMultiplier(guts) {
94
+ const ret = wasm.gutsHpBurnMultiplier(guts);
95
+ return ret;
96
+ }
97
+
98
+ /**
99
+ * Stamina's HP conversion coefficient for a strategy id (1-5).
100
+ *
101
+ * See [`honse_sim::readouts::hp_strategy_coefficient`].
102
+ * @param {number} strategy
103
+ * @returns {number}
104
+ */
105
+ export function hpStrategyCoefficient(strategy) {
106
+ const ret = wasm.hpStrategyCoefficient(strategy);
107
+ if (ret[2]) {
108
+ throw takeFromExternrefTable0(ret[1]);
109
+ }
110
+ return ret[0];
111
+ }
112
+
86
113
  /**
87
114
  * All condition tokens the Rust engine's catalog recognizes.
88
115
  *
89
- * Exposed so the TS-side simulatability gate (ADR-0003, driven by the TS
90
- * `knownConditionTokens` vocabulary) can be cross-checked against the engine
91
- * that actually runs the sim, closing the dual-parser drift risk (ADR-0004):
92
- * any token the UI treats as simulatable must be resolvable by this engine.
116
+ * Exposed so an external consumer can cross-check its simulatability gate
117
+ * against the engine that runs the simulation. Any token a consumer treats as
118
+ * simulatable must be resolvable by this engine.
93
119
  * Returned as a sorted JS string array.
94
120
  * @returns {string[]}
95
121
  */
96
122
  export function knownConditionTokens() {
97
123
  const ret = wasm.knownConditionTokens();
98
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
124
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
99
125
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
100
126
  return v1;
101
127
  }
102
128
 
129
+ /**
130
+ * The HP a runner starts a race with, from stamina, strategy id, and course
131
+ * distance in meters.
132
+ *
133
+ * See [`honse_sim::readouts::max_hp`].
134
+ * @param {number} stamina
135
+ * @param {number} strategy
136
+ * @param {number} distance
137
+ * @returns {number}
138
+ */
139
+ export function maxHp(stamina, strategy, distance) {
140
+ const ret = wasm.maxHp(stamina, strategy, distance);
141
+ if (ret[2]) {
142
+ throw takeFromExternrefTable0(ret[1]);
143
+ }
144
+ return ret[0];
145
+ }
146
+
103
147
  /**
104
148
  * Run a batch compare-family simulation and return the serialized result.
105
149
  *
@@ -149,14 +193,26 @@ export function runRaceSim(params) {
149
193
  }
150
194
  return takeFromExternrefTable0(ret[0]);
151
195
  }
196
+
197
+ /**
198
+ * The pre-race wisdom check pass rate, as a percentage, for a base wit stat.
199
+ *
200
+ * See [`honse_sim::readouts::skill_activation_percent`].
201
+ * @param {number} base_wit
202
+ * @returns {number}
203
+ */
204
+ export function skillActivationPercent(base_wit) {
205
+ const ret = wasm.skillActivationPercent(base_wit);
206
+ return ret;
207
+ }
152
208
  function __wbg_get_imports() {
153
209
  const import0 = {
154
210
  __proto__: null,
155
- __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
211
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
156
212
  const ret = Error(getStringFromWasm0(arg0, arg1));
157
213
  return ret;
158
214
  },
159
- __wbg_Number_6b506e6536831eaa: function(arg0) {
215
+ __wbg_Number_3890faa6d3ff057d: function(arg0) {
160
216
  const ret = Number(arg0);
161
217
  return ret;
162
218
  },
@@ -167,64 +223,64 @@ function __wbg_get_imports() {
167
223
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
168
224
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
169
225
  },
170
- __wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
226
+ __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721: function(arg0, arg1) {
171
227
  const v = arg1;
172
228
  const ret = typeof(v) === 'bigint' ? v : undefined;
173
229
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
174
230
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
175
231
  },
176
- __wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
232
+ __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
177
233
  const v = arg0;
178
234
  const ret = typeof(v) === 'boolean' ? v : undefined;
179
235
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
180
236
  },
181
- __wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
237
+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
182
238
  const ret = debugString(arg1);
183
239
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
184
240
  const len1 = WASM_VECTOR_LEN;
185
241
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
186
242
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
187
243
  },
188
- __wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
244
+ __wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
189
245
  const ret = arg0 in arg1;
190
246
  return ret;
191
247
  },
192
- __wbg___wbindgen_is_bigint_6ffd6468a9bc44b9: function(arg0) {
248
+ __wbg___wbindgen_is_bigint_8ffbbef442139384: function(arg0) {
193
249
  const ret = typeof(arg0) === 'bigint';
194
250
  return ret;
195
251
  },
196
- __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
252
+ __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
197
253
  const ret = typeof(arg0) === 'function';
198
254
  return ret;
199
255
  },
200
- __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
256
+ __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
201
257
  const val = arg0;
202
258
  const ret = typeof(val) === 'object' && val !== null;
203
259
  return ret;
204
260
  },
205
- __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
261
+ __wbg___wbindgen_is_string_e6f02f0ea5f20a32: function(arg0) {
206
262
  const ret = typeof(arg0) === 'string';
207
263
  return ret;
208
264
  },
209
- __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
265
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
210
266
  const ret = arg0 === undefined;
211
267
  return ret;
212
268
  },
213
- __wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
269
+ __wbg___wbindgen_jsval_eq_0a18949a61670320: function(arg0, arg1) {
214
270
  const ret = arg0 === arg1;
215
271
  return ret;
216
272
  },
217
- __wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
273
+ __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
218
274
  const ret = arg0 == arg1;
219
275
  return ret;
220
276
  },
221
- __wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
277
+ __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
222
278
  const obj = arg1;
223
279
  const ret = typeof(obj) === 'number' ? obj : undefined;
224
280
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
225
281
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
226
282
  },
227
- __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
283
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
228
284
  const obj = arg1;
229
285
  const ret = typeof(obj) === 'string' ? obj : undefined;
230
286
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -232,34 +288,34 @@ function __wbg_get_imports() {
232
288
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
233
289
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
234
290
  },
235
- __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
291
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
236
292
  throw new Error(getStringFromWasm0(arg0, arg1));
237
293
  },
238
- __wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
294
+ __wbg_call_1c5886ab9c57d1c7: function() { return handleError(function (arg0, arg1) {
239
295
  const ret = arg0.call(arg1);
240
296
  return ret;
241
297
  }, arguments); },
242
- __wbg_call_9c758de292015997: function() { return handleError(function (arg0, arg1, arg2) {
298
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
243
299
  const ret = arg0.call(arg1, arg2);
244
300
  return ret;
245
301
  }, arguments); },
246
- __wbg_done_60cf307fcc680536: function(arg0) {
302
+ __wbg_done_669171204c3dcae2: function(arg0) {
247
303
  const ret = arg0.done;
248
304
  return ret;
249
305
  },
250
- __wbg_entries_04b37a02507f1713: function(arg0) {
306
+ __wbg_entries_7774d489e1da5f4f: function(arg0) {
251
307
  const ret = Object.entries(arg0);
252
308
  return ret;
253
309
  },
254
- __wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
255
- const ret = Reflect.get(arg0, arg1);
256
- return ret;
257
- }, arguments); },
258
- __wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
310
+ __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
259
311
  const ret = arg0[arg1 >>> 0];
260
312
  return ret;
261
313
  },
262
- __wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
314
+ __wbg_get_d173c0308df22d37: function() { return handleError(function (arg0, arg1) {
315
+ const ret = Reflect.get(arg0, arg1);
316
+ return ret;
317
+ }, arguments); },
318
+ __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
263
319
  const ret = arg0[arg1 >>> 0];
264
320
  return ret;
265
321
  },
@@ -267,7 +323,7 @@ function __wbg_get_imports() {
267
323
  const ret = arg0[arg1];
268
324
  return ret;
269
325
  },
270
- __wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
326
+ __wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
271
327
  let result;
272
328
  try {
273
329
  result = arg0 instanceof ArrayBuffer;
@@ -277,7 +333,7 @@ function __wbg_get_imports() {
277
333
  const ret = result;
278
334
  return ret;
279
335
  },
280
- __wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
336
+ __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
281
337
  let result;
282
338
  try {
283
339
  result = arg0 instanceof Uint8Array;
@@ -287,64 +343,64 @@ function __wbg_get_imports() {
287
343
  const ret = result;
288
344
  return ret;
289
345
  },
290
- __wbg_isArray_67c2c9c4313f4448: function(arg0) {
346
+ __wbg_isArray_6339f732981044bf: function(arg0) {
291
347
  const ret = Array.isArray(arg0);
292
348
  return ret;
293
349
  },
294
- __wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
350
+ __wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
295
351
  const ret = Number.isSafeInteger(arg0);
296
352
  return ret;
297
353
  },
298
- __wbg_iterator_8732428d309e270e: function() {
354
+ __wbg_iterator_5cebbb86e33c6dd6: function() {
299
355
  const ret = Symbol.iterator;
300
356
  return ret;
301
357
  },
302
- __wbg_length_4a591ecaa01354d9: function(arg0) {
358
+ __wbg_length_36bd29c6848c2144: function(arg0) {
303
359
  const ret = arg0.length;
304
360
  return ret;
305
361
  },
306
- __wbg_length_66f1a4b2e9026940: function(arg0) {
362
+ __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
307
363
  const ret = arg0.length;
308
364
  return ret;
309
365
  },
310
- __wbg_new_578aeef4b6b94378: function(arg0) {
366
+ __wbg_new_116be93542d39019: function() {
367
+ const ret = new Array();
368
+ return ret;
369
+ },
370
+ __wbg_new_77cc4f4f472aeb81: function(arg0) {
311
371
  const ret = new Uint8Array(arg0);
312
372
  return ret;
313
373
  },
314
- __wbg_new_622fc80556be2e26: function() {
374
+ __wbg_new_cdf041679ded4c5f: function() {
315
375
  const ret = new Map();
316
376
  return ret;
317
377
  },
318
- __wbg_new_ce1ab61c1c2b300d: function() {
378
+ __wbg_new_ebe3e0f6837f0879: function() {
319
379
  const ret = new Object();
320
380
  return ret;
321
381
  },
322
- __wbg_new_d90091b82fdf5b91: function() {
323
- const ret = new Array();
382
+ __wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
383
+ const ret = arg0.next();
324
384
  return ret;
325
- },
326
- __wbg_next_9e03acdf51c4960d: function(arg0) {
385
+ }, arguments); },
386
+ __wbg_next_8f26b64fa5e9f64b: function(arg0) {
327
387
  const ret = arg0.next;
328
388
  return ret;
329
389
  },
330
- __wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
331
- const ret = arg0.next();
332
- return ret;
333
- }, arguments); },
334
- __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
390
+ __wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
335
391
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
336
392
  },
337
- __wbg_set_52b1e1eb5bed906a: function(arg0, arg1, arg2) {
393
+ __wbg_set_014226dfeca53178: function(arg0, arg1, arg2) {
338
394
  const ret = arg0.set(arg1, arg2);
339
395
  return ret;
340
396
  },
341
397
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
342
398
  arg0[arg1] = arg2;
343
399
  },
344
- __wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
400
+ __wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
345
401
  arg0[arg1 >>> 0] = arg2;
346
402
  },
347
- __wbg_value_f3625092ee4b37f4: function(arg0) {
403
+ __wbg_value_1e2369fab29b420e: function(arg0) {
348
404
  const ret = arg0.value;
349
405
  return ret;
350
406
  },
@@ -593,11 +649,15 @@ function __wbg_finalize_init(instance, module) {
593
649
 
594
650
  async function __wbg_load(module, imports) {
595
651
  if (typeof Response === 'function' && module instanceof Response) {
652
+ if (!module.ok) {
653
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
654
+ }
655
+
596
656
  if (typeof WebAssembly.instantiateStreaming === 'function') {
597
657
  try {
598
658
  return await WebAssembly.instantiateStreaming(module, imports);
599
659
  } catch (e) {
600
- const validResponse = module.ok && expectedResponseType(module.type);
660
+ const validResponse = expectedResponseType(module.type);
601
661
 
602
662
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
603
663
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
Binary file