banqi 0.0.0 → 0.0.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/README.md CHANGED
@@ -23,9 +23,9 @@ banqi-minimax = { git = "https://github.com/jacoblincool/banqi-minimax" }
23
23
  ### Basic Example
24
24
 
25
25
  ```rust
26
- use banqi_minimax::game::logic::make_test_state;
27
- use banqi_minimax::game::variant::VariantSpec;
28
- use banqi_minimax::minimax::{minimax_scores_one, EvalMode};
26
+ use banqi::game::logic::make_test_state;
27
+ use banqi::game::variant::VariantSpec;
28
+ use banqi::minimax::{minimax_scores_one, EvalMode};
29
29
 
30
30
  let spec = VariantSpec::standard();
31
31
  let state = make_test_state(42, 16, &spec); // seed=42, 16 pieces revealed
@@ -53,7 +53,7 @@ maturin develop --features python
53
53
  Example:
54
54
 
55
55
  ```python
56
- from banqi_minimax import BanqiGame, VariantSpec
56
+ from banqi import BanqiGame, VariantSpec
57
57
 
58
58
  variant = VariantSpec.standard()
59
59
  game = BanqiGame.make_test(seed=42, reveal_count=8, variant=variant)
@@ -81,7 +81,7 @@ The Vite scripts call `wasm-pack` and generate `examples/wasm-web/pkg/`.
81
81
  Build Node package and run smoke test:
82
82
 
83
83
  ```bash
84
- wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi_minimax . --features wasm
84
+ wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi . --features wasm
85
85
  node examples/wasm-web/smoke-node.mjs
86
86
  ```
87
87
 
package/node/README.md CHANGED
@@ -23,9 +23,9 @@ banqi-minimax = { git = "https://github.com/jacoblincool/banqi-minimax" }
23
23
  ### Basic Example
24
24
 
25
25
  ```rust
26
- use banqi_minimax::game::logic::make_test_state;
27
- use banqi_minimax::game::variant::VariantSpec;
28
- use banqi_minimax::minimax::{minimax_scores_one, EvalMode};
26
+ use banqi::game::logic::make_test_state;
27
+ use banqi::game::variant::VariantSpec;
28
+ use banqi::minimax::{minimax_scores_one, EvalMode};
29
29
 
30
30
  let spec = VariantSpec::standard();
31
31
  let state = make_test_state(42, 16, &spec); // seed=42, 16 pieces revealed
@@ -53,7 +53,7 @@ maturin develop --features python
53
53
  Example:
54
54
 
55
55
  ```python
56
- from banqi_minimax import BanqiGame, VariantSpec
56
+ from banqi import BanqiGame, VariantSpec
57
57
 
58
58
  variant = VariantSpec.standard()
59
59
  game = BanqiGame.make_test(seed=42, reveal_count=8, variant=variant)
@@ -81,7 +81,7 @@ The Vite scripts call `wasm-pack` and generate `examples/wasm-web/pkg/`.
81
81
  Build Node package and run smoke test:
82
82
 
83
83
  ```bash
84
- wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi_minimax . --features wasm
84
+ wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi . --features wasm
85
85
  node examples/wasm-web/smoke-node.mjs
86
86
  ```
87
87
 
@@ -0,0 +1,74 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class BanqiGameWasm {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ applyStep(action: number, seed: bigint): StepResultWasm;
9
+ static fromState(state: Int16Array): BanqiGameWasm;
10
+ static fromStateWithVariant(state: Int16Array, variant: VariantSpecWasm): BanqiGameWasm;
11
+ legalActions(): Int32Array;
12
+ static makeTest(seed: bigint, reveal_count: number): BanqiGameWasm;
13
+ static makeTestWithVariant(seed: bigint, reveal_count: number, variant: VariantSpecWasm): BanqiGameWasm;
14
+ minimaxScores(depth: number, eval_mode: string, time_limit_ms?: bigint | null, action_mask?: Uint32Array | null): Float32Array;
15
+ static softmaxPolicy(scores: Float32Array, temperature: number): Float32Array;
16
+ state(): Int16Array;
17
+ variant(): VariantSpecWasm;
18
+ }
19
+
20
+ export class CollectLeavesResultWasm {
21
+ private constructor();
22
+ free(): void;
23
+ [Symbol.dispose](): void;
24
+ readonly leafIds: Int32Array;
25
+ readonly states: Int16Array;
26
+ }
27
+
28
+ export class MctsResultWasm {
29
+ private constructor();
30
+ free(): void;
31
+ [Symbol.dispose](): void;
32
+ readonly action: number;
33
+ readonly policy: Float32Array;
34
+ }
35
+
36
+ export class MctsSessionWasm {
37
+ free(): void;
38
+ [Symbol.dispose](): void;
39
+ applyEvals(leaf_ids: Int32Array, priors_flat: Float32Array, prior_cols: number, values: Float32Array): void;
40
+ close(): void;
41
+ collectLeaves(max_leaves: number): CollectLeavesResultWasm;
42
+ isDone(): boolean;
43
+ constructor(root_state: Int16Array, variant: VariantSpecWasm, simulations: number, seed: bigint, c_puct: number, dirichlet_alpha: number, dirichlet_epsilon: number, root_chance_enumeration: boolean, time_limit_ms?: bigint | null, action_mask?: Uint32Array | null);
44
+ result(move_index: number, root_temperature_moves: number): MctsResultWasm;
45
+ readonly actionSize: number;
46
+ readonly closed: boolean;
47
+ }
48
+
49
+ export class StepResultWasm {
50
+ private constructor();
51
+ free(): void;
52
+ [Symbol.dispose](): void;
53
+ readonly done: boolean;
54
+ readonly draw: boolean;
55
+ readonly reward: number;
56
+ readonly state: Int16Array;
57
+ readonly winner: number;
58
+ }
59
+
60
+ export class VariantSpecWasm {
61
+ private constructor();
62
+ free(): void;
63
+ [Symbol.dispose](): void;
64
+ static create(variant_name: string, board_height: number, board_width: number, piece_counts_per_color: Int16Array, no_capture_draw_plies: number, max_episode_steps: number): VariantSpecWasm;
65
+ static standard(): VariantSpecWasm;
66
+ readonly actionSize: number;
67
+ readonly boardHeight: number;
68
+ readonly boardSize: number;
69
+ readonly boardWidth: number;
70
+ readonly maxEpisodeSteps: number;
71
+ readonly noCaptureDrawPlies: number;
72
+ readonly pieceCountsPerColor: Int16Array;
73
+ readonly variantName: string;
74
+ }
@@ -1,4 +1,4 @@
1
- /* @ts-self-types="./banqi_minimax.d.ts" */
1
+ /* @ts-self-types="./banqi.d.ts" */
2
2
 
3
3
  class BanqiGameWasm {
4
4
  static __wrap(ptr) {
@@ -556,7 +556,7 @@ function __wbg_get_imports() {
556
556
  };
557
557
  return {
558
558
  __proto__: null,
559
- "./banqi_minimax_bg.js": import0,
559
+ "./banqi_bg.js": import0,
560
560
  };
561
561
  }
562
562
 
@@ -735,7 +735,7 @@ if (!('encodeInto' in cachedTextEncoder)) {
735
735
 
736
736
  let WASM_VECTOR_LEN = 0;
737
737
 
738
- const wasmPath = `${__dirname}/banqi_minimax_bg.wasm`;
738
+ const wasmPath = `${__dirname}/banqi_bg.wasm`;
739
739
  const wasmBytes = require('fs').readFileSync(wasmPath);
740
740
  const wasmModule = new WebAssembly.Module(wasmBytes);
741
741
  const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
Binary file
@@ -0,0 +1,54 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_banqigamewasm_free: (a: number, b: number) => void;
5
+ export const __wbg_collectleavesresultwasm_free: (a: number, b: number) => void;
6
+ export const __wbg_mctsresultwasm_free: (a: number, b: number) => void;
7
+ export const __wbg_mctssessionwasm_free: (a: number, b: number) => void;
8
+ export const __wbg_stepresultwasm_free: (a: number, b: number) => void;
9
+ export const __wbg_variantspecwasm_free: (a: number, b: number) => void;
10
+ export const banqigamewasm_applyStep: (a: number, b: number, c: bigint) => number;
11
+ export const banqigamewasm_fromState: (a: any) => [number, number, number];
12
+ export const banqigamewasm_fromStateWithVariant: (a: any, b: number) => [number, number, number];
13
+ export const banqigamewasm_legalActions: (a: number) => any;
14
+ export const banqigamewasm_makeTest: (a: bigint, b: number) => number;
15
+ export const banqigamewasm_makeTestWithVariant: (a: bigint, b: number, c: number) => number;
16
+ export const banqigamewasm_minimaxScores: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number) => [number, number, number];
17
+ export const banqigamewasm_softmaxPolicy: (a: any, b: number) => any;
18
+ export const banqigamewasm_state: (a: number) => any;
19
+ export const banqigamewasm_variant: (a: number) => number;
20
+ export const collectleavesresultwasm_leafIds: (a: number) => any;
21
+ export const collectleavesresultwasm_states: (a: number) => any;
22
+ export const mctsresultwasm_action: (a: number) => number;
23
+ export const mctsresultwasm_policy: (a: number) => any;
24
+ export const mctssessionwasm_actionSize: (a: number) => number;
25
+ export const mctssessionwasm_applyEvals: (a: number, b: any, c: any, d: number, e: any) => [number, number];
26
+ export const mctssessionwasm_close: (a: number) => void;
27
+ export const mctssessionwasm_closed: (a: number) => number;
28
+ export const mctssessionwasm_collectLeaves: (a: number, b: number) => [number, number, number];
29
+ export const mctssessionwasm_isDone: (a: number) => [number, number, number];
30
+ export const mctssessionwasm_new: (a: any, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number, i: number, j: bigint, k: number, l: number) => [number, number, number];
31
+ export const mctssessionwasm_result: (a: number, b: number, c: number) => [number, number, number];
32
+ export const stepresultwasm_done: (a: number) => number;
33
+ export const stepresultwasm_draw: (a: number) => number;
34
+ export const stepresultwasm_reward: (a: number) => number;
35
+ export const stepresultwasm_state: (a: number) => any;
36
+ export const stepresultwasm_winner: (a: number) => number;
37
+ export const variantspecwasm_actionSize: (a: number) => number;
38
+ export const variantspecwasm_boardSize: (a: number) => number;
39
+ export const variantspecwasm_boardWidth: (a: number) => number;
40
+ export const variantspecwasm_create: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number];
41
+ export const variantspecwasm_maxEpisodeSteps: (a: number) => number;
42
+ export const variantspecwasm_noCaptureDrawPlies: (a: number) => number;
43
+ export const variantspecwasm_pieceCountsPerColor: (a: number) => any;
44
+ export const variantspecwasm_standard: () => number;
45
+ export const variantspecwasm_variantName: (a: number) => [number, number];
46
+ export const variantspecwasm_boardHeight: (a: number) => number;
47
+ export const __wbindgen_exn_store: (a: number) => void;
48
+ export const __externref_table_alloc: () => number;
49
+ export const __wbindgen_externrefs: WebAssembly.Table;
50
+ export const __externref_table_dealloc: (a: number) => void;
51
+ export const __wbindgen_malloc: (a: number, b: number) => number;
52
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
53
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
54
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "banqi",
3
+ "collaborators": [
4
+ "JacobLinCool <jacoblincool@gmail.com>"
5
+ ],
6
+ "description": "",
7
+ "version": "0.1.0",
8
+ "license": "MIT",
9
+ "files": [
10
+ "banqi_bg.wasm",
11
+ "banqi.js",
12
+ "banqi.d.ts"
13
+ ],
14
+ "main": "banqi.js",
15
+ "types": "banqi.d.ts"
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "banqi",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Banqi engine for Node and Web (WASM)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -9,10 +9,16 @@
9
9
  "README.md",
10
10
  "LICENSE"
11
11
  ],
12
- "main": "./node/banqi_minimax.js",
13
- "types": "./node/banqi_minimax.d.ts",
12
+ "main": "./node/banqi.js",
13
+ "types": "./node/banqi.d.ts",
14
14
  "exports": {
15
- ".": "./node/banqi_minimax.js",
16
- "./web": "./web/banqi_minimax.js"
15
+ ".": {
16
+ "types": "./node/banqi.d.ts",
17
+ "default": "./node/banqi.js"
18
+ },
19
+ "./web": {
20
+ "types": "./web/banqi.d.ts",
21
+ "default": "./web/banqi.js"
22
+ }
17
23
  }
18
24
  }
package/web/README.md CHANGED
@@ -23,9 +23,9 @@ banqi-minimax = { git = "https://github.com/jacoblincool/banqi-minimax" }
23
23
  ### Basic Example
24
24
 
25
25
  ```rust
26
- use banqi_minimax::game::logic::make_test_state;
27
- use banqi_minimax::game::variant::VariantSpec;
28
- use banqi_minimax::minimax::{minimax_scores_one, EvalMode};
26
+ use banqi::game::logic::make_test_state;
27
+ use banqi::game::variant::VariantSpec;
28
+ use banqi::minimax::{minimax_scores_one, EvalMode};
29
29
 
30
30
  let spec = VariantSpec::standard();
31
31
  let state = make_test_state(42, 16, &spec); // seed=42, 16 pieces revealed
@@ -53,7 +53,7 @@ maturin develop --features python
53
53
  Example:
54
54
 
55
55
  ```python
56
- from banqi_minimax import BanqiGame, VariantSpec
56
+ from banqi import BanqiGame, VariantSpec
57
57
 
58
58
  variant = VariantSpec.standard()
59
59
  game = BanqiGame.make_test(seed=42, reveal_count=8, variant=variant)
@@ -81,7 +81,7 @@ The Vite scripts call `wasm-pack` and generate `examples/wasm-web/pkg/`.
81
81
  Build Node package and run smoke test:
82
82
 
83
83
  ```bash
84
- wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi_minimax . --features wasm
84
+ wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi . --features wasm
85
85
  node examples/wasm-web/smoke-node.mjs
86
86
  ```
87
87
 
package/web/banqi.d.ts ADDED
@@ -0,0 +1,153 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class BanqiGameWasm {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ applyStep(action: number, seed: bigint): StepResultWasm;
9
+ static fromState(state: Int16Array): BanqiGameWasm;
10
+ static fromStateWithVariant(state: Int16Array, variant: VariantSpecWasm): BanqiGameWasm;
11
+ legalActions(): Int32Array;
12
+ static makeTest(seed: bigint, reveal_count: number): BanqiGameWasm;
13
+ static makeTestWithVariant(seed: bigint, reveal_count: number, variant: VariantSpecWasm): BanqiGameWasm;
14
+ minimaxScores(depth: number, eval_mode: string, time_limit_ms?: bigint | null, action_mask?: Uint32Array | null): Float32Array;
15
+ static softmaxPolicy(scores: Float32Array, temperature: number): Float32Array;
16
+ state(): Int16Array;
17
+ variant(): VariantSpecWasm;
18
+ }
19
+
20
+ export class CollectLeavesResultWasm {
21
+ private constructor();
22
+ free(): void;
23
+ [Symbol.dispose](): void;
24
+ readonly leafIds: Int32Array;
25
+ readonly states: Int16Array;
26
+ }
27
+
28
+ export class MctsResultWasm {
29
+ private constructor();
30
+ free(): void;
31
+ [Symbol.dispose](): void;
32
+ readonly action: number;
33
+ readonly policy: Float32Array;
34
+ }
35
+
36
+ export class MctsSessionWasm {
37
+ free(): void;
38
+ [Symbol.dispose](): void;
39
+ applyEvals(leaf_ids: Int32Array, priors_flat: Float32Array, prior_cols: number, values: Float32Array): void;
40
+ close(): void;
41
+ collectLeaves(max_leaves: number): CollectLeavesResultWasm;
42
+ isDone(): boolean;
43
+ constructor(root_state: Int16Array, variant: VariantSpecWasm, simulations: number, seed: bigint, c_puct: number, dirichlet_alpha: number, dirichlet_epsilon: number, root_chance_enumeration: boolean, time_limit_ms?: bigint | null, action_mask?: Uint32Array | null);
44
+ result(move_index: number, root_temperature_moves: number): MctsResultWasm;
45
+ readonly actionSize: number;
46
+ readonly closed: boolean;
47
+ }
48
+
49
+ export class StepResultWasm {
50
+ private constructor();
51
+ free(): void;
52
+ [Symbol.dispose](): void;
53
+ readonly done: boolean;
54
+ readonly draw: boolean;
55
+ readonly reward: number;
56
+ readonly state: Int16Array;
57
+ readonly winner: number;
58
+ }
59
+
60
+ export class VariantSpecWasm {
61
+ private constructor();
62
+ free(): void;
63
+ [Symbol.dispose](): void;
64
+ static create(variant_name: string, board_height: number, board_width: number, piece_counts_per_color: Int16Array, no_capture_draw_plies: number, max_episode_steps: number): VariantSpecWasm;
65
+ static standard(): VariantSpecWasm;
66
+ readonly actionSize: number;
67
+ readonly boardHeight: number;
68
+ readonly boardSize: number;
69
+ readonly boardWidth: number;
70
+ readonly maxEpisodeSteps: number;
71
+ readonly noCaptureDrawPlies: number;
72
+ readonly pieceCountsPerColor: Int16Array;
73
+ readonly variantName: string;
74
+ }
75
+
76
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
77
+
78
+ export interface InitOutput {
79
+ readonly memory: WebAssembly.Memory;
80
+ readonly __wbg_banqigamewasm_free: (a: number, b: number) => void;
81
+ readonly __wbg_collectleavesresultwasm_free: (a: number, b: number) => void;
82
+ readonly __wbg_mctsresultwasm_free: (a: number, b: number) => void;
83
+ readonly __wbg_mctssessionwasm_free: (a: number, b: number) => void;
84
+ readonly __wbg_stepresultwasm_free: (a: number, b: number) => void;
85
+ readonly __wbg_variantspecwasm_free: (a: number, b: number) => void;
86
+ readonly banqigamewasm_applyStep: (a: number, b: number, c: bigint) => number;
87
+ readonly banqigamewasm_fromState: (a: any) => [number, number, number];
88
+ readonly banqigamewasm_fromStateWithVariant: (a: any, b: number) => [number, number, number];
89
+ readonly banqigamewasm_legalActions: (a: number) => any;
90
+ readonly banqigamewasm_makeTest: (a: bigint, b: number) => number;
91
+ readonly banqigamewasm_makeTestWithVariant: (a: bigint, b: number, c: number) => number;
92
+ readonly banqigamewasm_minimaxScores: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number) => [number, number, number];
93
+ readonly banqigamewasm_softmaxPolicy: (a: any, b: number) => any;
94
+ readonly banqigamewasm_state: (a: number) => any;
95
+ readonly banqigamewasm_variant: (a: number) => number;
96
+ readonly collectleavesresultwasm_leafIds: (a: number) => any;
97
+ readonly collectleavesresultwasm_states: (a: number) => any;
98
+ readonly mctsresultwasm_action: (a: number) => number;
99
+ readonly mctsresultwasm_policy: (a: number) => any;
100
+ readonly mctssessionwasm_actionSize: (a: number) => number;
101
+ readonly mctssessionwasm_applyEvals: (a: number, b: any, c: any, d: number, e: any) => [number, number];
102
+ readonly mctssessionwasm_close: (a: number) => void;
103
+ readonly mctssessionwasm_closed: (a: number) => number;
104
+ readonly mctssessionwasm_collectLeaves: (a: number, b: number) => [number, number, number];
105
+ readonly mctssessionwasm_isDone: (a: number) => [number, number, number];
106
+ readonly mctssessionwasm_new: (a: any, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number, i: number, j: bigint, k: number, l: number) => [number, number, number];
107
+ readonly mctssessionwasm_result: (a: number, b: number, c: number) => [number, number, number];
108
+ readonly stepresultwasm_done: (a: number) => number;
109
+ readonly stepresultwasm_draw: (a: number) => number;
110
+ readonly stepresultwasm_reward: (a: number) => number;
111
+ readonly stepresultwasm_state: (a: number) => any;
112
+ readonly stepresultwasm_winner: (a: number) => number;
113
+ readonly variantspecwasm_actionSize: (a: number) => number;
114
+ readonly variantspecwasm_boardSize: (a: number) => number;
115
+ readonly variantspecwasm_boardWidth: (a: number) => number;
116
+ readonly variantspecwasm_create: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number];
117
+ readonly variantspecwasm_maxEpisodeSteps: (a: number) => number;
118
+ readonly variantspecwasm_noCaptureDrawPlies: (a: number) => number;
119
+ readonly variantspecwasm_pieceCountsPerColor: (a: number) => any;
120
+ readonly variantspecwasm_standard: () => number;
121
+ readonly variantspecwasm_variantName: (a: number) => [number, number];
122
+ readonly variantspecwasm_boardHeight: (a: number) => number;
123
+ readonly __wbindgen_exn_store: (a: number) => void;
124
+ readonly __externref_table_alloc: () => number;
125
+ readonly __wbindgen_externrefs: WebAssembly.Table;
126
+ readonly __externref_table_dealloc: (a: number) => void;
127
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
128
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
129
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
130
+ readonly __wbindgen_start: () => void;
131
+ }
132
+
133
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
134
+
135
+ /**
136
+ * Instantiates the given `module`, which can either be bytes or
137
+ * a precompiled `WebAssembly.Module`.
138
+ *
139
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
140
+ *
141
+ * @returns {InitOutput}
142
+ */
143
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
144
+
145
+ /**
146
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
147
+ * for everything else, calls `WebAssembly.instantiate` directly.
148
+ *
149
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
150
+ *
151
+ * @returns {Promise<InitOutput>}
152
+ */
153
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/web/banqi.js ADDED
@@ -0,0 +1,834 @@
1
+ /* @ts-self-types="./banqi.d.ts" */
2
+
3
+ export class BanqiGameWasm {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(BanqiGameWasm.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ BanqiGameWasmFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ BanqiGameWasmFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_banqigamewasm_free(ptr, 0);
20
+ }
21
+ /**
22
+ * @param {number} action
23
+ * @param {bigint} seed
24
+ * @returns {StepResultWasm}
25
+ */
26
+ applyStep(action, seed) {
27
+ const ret = wasm.banqigamewasm_applyStep(this.__wbg_ptr, action, seed);
28
+ return StepResultWasm.__wrap(ret);
29
+ }
30
+ /**
31
+ * @param {Int16Array} state
32
+ * @returns {BanqiGameWasm}
33
+ */
34
+ static fromState(state) {
35
+ const ret = wasm.banqigamewasm_fromState(state);
36
+ if (ret[2]) {
37
+ throw takeFromExternrefTable0(ret[1]);
38
+ }
39
+ return BanqiGameWasm.__wrap(ret[0]);
40
+ }
41
+ /**
42
+ * @param {Int16Array} state
43
+ * @param {VariantSpecWasm} variant
44
+ * @returns {BanqiGameWasm}
45
+ */
46
+ static fromStateWithVariant(state, variant) {
47
+ _assertClass(variant, VariantSpecWasm);
48
+ const ret = wasm.banqigamewasm_fromStateWithVariant(state, variant.__wbg_ptr);
49
+ if (ret[2]) {
50
+ throw takeFromExternrefTable0(ret[1]);
51
+ }
52
+ return BanqiGameWasm.__wrap(ret[0]);
53
+ }
54
+ /**
55
+ * @returns {Int32Array}
56
+ */
57
+ legalActions() {
58
+ const ret = wasm.banqigamewasm_legalActions(this.__wbg_ptr);
59
+ return ret;
60
+ }
61
+ /**
62
+ * @param {bigint} seed
63
+ * @param {number} reveal_count
64
+ * @returns {BanqiGameWasm}
65
+ */
66
+ static makeTest(seed, reveal_count) {
67
+ const ret = wasm.banqigamewasm_makeTest(seed, reveal_count);
68
+ return BanqiGameWasm.__wrap(ret);
69
+ }
70
+ /**
71
+ * @param {bigint} seed
72
+ * @param {number} reveal_count
73
+ * @param {VariantSpecWasm} variant
74
+ * @returns {BanqiGameWasm}
75
+ */
76
+ static makeTestWithVariant(seed, reveal_count, variant) {
77
+ _assertClass(variant, VariantSpecWasm);
78
+ const ret = wasm.banqigamewasm_makeTestWithVariant(seed, reveal_count, variant.__wbg_ptr);
79
+ return BanqiGameWasm.__wrap(ret);
80
+ }
81
+ /**
82
+ * @param {number} depth
83
+ * @param {string} eval_mode
84
+ * @param {bigint | null} [time_limit_ms]
85
+ * @param {Uint32Array | null} [action_mask]
86
+ * @returns {Float32Array}
87
+ */
88
+ minimaxScores(depth, eval_mode, time_limit_ms, action_mask) {
89
+ const ptr0 = passStringToWasm0(eval_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
90
+ const len0 = WASM_VECTOR_LEN;
91
+ var ptr1 = isLikeNone(action_mask) ? 0 : passArray32ToWasm0(action_mask, wasm.__wbindgen_malloc);
92
+ var len1 = WASM_VECTOR_LEN;
93
+ const ret = wasm.banqigamewasm_minimaxScores(this.__wbg_ptr, depth, ptr0, len0, !isLikeNone(time_limit_ms), isLikeNone(time_limit_ms) ? BigInt(0) : time_limit_ms, ptr1, len1);
94
+ if (ret[2]) {
95
+ throw takeFromExternrefTable0(ret[1]);
96
+ }
97
+ return takeFromExternrefTable0(ret[0]);
98
+ }
99
+ /**
100
+ * @param {Float32Array} scores
101
+ * @param {number} temperature
102
+ * @returns {Float32Array}
103
+ */
104
+ static softmaxPolicy(scores, temperature) {
105
+ const ret = wasm.banqigamewasm_softmaxPolicy(scores, temperature);
106
+ return ret;
107
+ }
108
+ /**
109
+ * @returns {Int16Array}
110
+ */
111
+ state() {
112
+ const ret = wasm.banqigamewasm_state(this.__wbg_ptr);
113
+ return ret;
114
+ }
115
+ /**
116
+ * @returns {VariantSpecWasm}
117
+ */
118
+ variant() {
119
+ const ret = wasm.banqigamewasm_variant(this.__wbg_ptr);
120
+ return VariantSpecWasm.__wrap(ret);
121
+ }
122
+ }
123
+ if (Symbol.dispose) BanqiGameWasm.prototype[Symbol.dispose] = BanqiGameWasm.prototype.free;
124
+
125
+ export class CollectLeavesResultWasm {
126
+ static __wrap(ptr) {
127
+ ptr = ptr >>> 0;
128
+ const obj = Object.create(CollectLeavesResultWasm.prototype);
129
+ obj.__wbg_ptr = ptr;
130
+ CollectLeavesResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
131
+ return obj;
132
+ }
133
+ __destroy_into_raw() {
134
+ const ptr = this.__wbg_ptr;
135
+ this.__wbg_ptr = 0;
136
+ CollectLeavesResultWasmFinalization.unregister(this);
137
+ return ptr;
138
+ }
139
+ free() {
140
+ const ptr = this.__destroy_into_raw();
141
+ wasm.__wbg_collectleavesresultwasm_free(ptr, 0);
142
+ }
143
+ /**
144
+ * @returns {Int32Array}
145
+ */
146
+ get leafIds() {
147
+ const ret = wasm.collectleavesresultwasm_leafIds(this.__wbg_ptr);
148
+ return ret;
149
+ }
150
+ /**
151
+ * @returns {Int16Array}
152
+ */
153
+ get states() {
154
+ const ret = wasm.collectleavesresultwasm_states(this.__wbg_ptr);
155
+ return ret;
156
+ }
157
+ }
158
+ if (Symbol.dispose) CollectLeavesResultWasm.prototype[Symbol.dispose] = CollectLeavesResultWasm.prototype.free;
159
+
160
+ export class MctsResultWasm {
161
+ static __wrap(ptr) {
162
+ ptr = ptr >>> 0;
163
+ const obj = Object.create(MctsResultWasm.prototype);
164
+ obj.__wbg_ptr = ptr;
165
+ MctsResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
166
+ return obj;
167
+ }
168
+ __destroy_into_raw() {
169
+ const ptr = this.__wbg_ptr;
170
+ this.__wbg_ptr = 0;
171
+ MctsResultWasmFinalization.unregister(this);
172
+ return ptr;
173
+ }
174
+ free() {
175
+ const ptr = this.__destroy_into_raw();
176
+ wasm.__wbg_mctsresultwasm_free(ptr, 0);
177
+ }
178
+ /**
179
+ * @returns {number}
180
+ */
181
+ get action() {
182
+ const ret = wasm.mctsresultwasm_action(this.__wbg_ptr);
183
+ return ret;
184
+ }
185
+ /**
186
+ * @returns {Float32Array}
187
+ */
188
+ get policy() {
189
+ const ret = wasm.mctsresultwasm_policy(this.__wbg_ptr);
190
+ return ret;
191
+ }
192
+ }
193
+ if (Symbol.dispose) MctsResultWasm.prototype[Symbol.dispose] = MctsResultWasm.prototype.free;
194
+
195
+ export class MctsSessionWasm {
196
+ __destroy_into_raw() {
197
+ const ptr = this.__wbg_ptr;
198
+ this.__wbg_ptr = 0;
199
+ MctsSessionWasmFinalization.unregister(this);
200
+ return ptr;
201
+ }
202
+ free() {
203
+ const ptr = this.__destroy_into_raw();
204
+ wasm.__wbg_mctssessionwasm_free(ptr, 0);
205
+ }
206
+ /**
207
+ * @returns {number}
208
+ */
209
+ get actionSize() {
210
+ const ret = wasm.mctssessionwasm_actionSize(this.__wbg_ptr);
211
+ return ret >>> 0;
212
+ }
213
+ /**
214
+ * @param {Int32Array} leaf_ids
215
+ * @param {Float32Array} priors_flat
216
+ * @param {number} prior_cols
217
+ * @param {Float32Array} values
218
+ */
219
+ applyEvals(leaf_ids, priors_flat, prior_cols, values) {
220
+ const ret = wasm.mctssessionwasm_applyEvals(this.__wbg_ptr, leaf_ids, priors_flat, prior_cols, values);
221
+ if (ret[1]) {
222
+ throw takeFromExternrefTable0(ret[0]);
223
+ }
224
+ }
225
+ close() {
226
+ wasm.mctssessionwasm_close(this.__wbg_ptr);
227
+ }
228
+ /**
229
+ * @returns {boolean}
230
+ */
231
+ get closed() {
232
+ const ret = wasm.mctssessionwasm_closed(this.__wbg_ptr);
233
+ return ret !== 0;
234
+ }
235
+ /**
236
+ * @param {number} max_leaves
237
+ * @returns {CollectLeavesResultWasm}
238
+ */
239
+ collectLeaves(max_leaves) {
240
+ const ret = wasm.mctssessionwasm_collectLeaves(this.__wbg_ptr, max_leaves);
241
+ if (ret[2]) {
242
+ throw takeFromExternrefTable0(ret[1]);
243
+ }
244
+ return CollectLeavesResultWasm.__wrap(ret[0]);
245
+ }
246
+ /**
247
+ * @returns {boolean}
248
+ */
249
+ isDone() {
250
+ const ret = wasm.mctssessionwasm_isDone(this.__wbg_ptr);
251
+ if (ret[2]) {
252
+ throw takeFromExternrefTable0(ret[1]);
253
+ }
254
+ return ret[0] !== 0;
255
+ }
256
+ /**
257
+ * @param {Int16Array} root_state
258
+ * @param {VariantSpecWasm} variant
259
+ * @param {number} simulations
260
+ * @param {bigint} seed
261
+ * @param {number} c_puct
262
+ * @param {number} dirichlet_alpha
263
+ * @param {number} dirichlet_epsilon
264
+ * @param {boolean} root_chance_enumeration
265
+ * @param {bigint | null} [time_limit_ms]
266
+ * @param {Uint32Array | null} [action_mask]
267
+ */
268
+ constructor(root_state, variant, simulations, seed, c_puct, dirichlet_alpha, dirichlet_epsilon, root_chance_enumeration, time_limit_ms, action_mask) {
269
+ _assertClass(variant, VariantSpecWasm);
270
+ var ptr0 = isLikeNone(action_mask) ? 0 : passArray32ToWasm0(action_mask, wasm.__wbindgen_malloc);
271
+ var len0 = WASM_VECTOR_LEN;
272
+ const ret = wasm.mctssessionwasm_new(root_state, variant.__wbg_ptr, simulations, seed, c_puct, dirichlet_alpha, dirichlet_epsilon, root_chance_enumeration, !isLikeNone(time_limit_ms), isLikeNone(time_limit_ms) ? BigInt(0) : time_limit_ms, ptr0, len0);
273
+ if (ret[2]) {
274
+ throw takeFromExternrefTable0(ret[1]);
275
+ }
276
+ this.__wbg_ptr = ret[0] >>> 0;
277
+ MctsSessionWasmFinalization.register(this, this.__wbg_ptr, this);
278
+ return this;
279
+ }
280
+ /**
281
+ * @param {number} move_index
282
+ * @param {number} root_temperature_moves
283
+ * @returns {MctsResultWasm}
284
+ */
285
+ result(move_index, root_temperature_moves) {
286
+ const ret = wasm.mctssessionwasm_result(this.__wbg_ptr, move_index, root_temperature_moves);
287
+ if (ret[2]) {
288
+ throw takeFromExternrefTable0(ret[1]);
289
+ }
290
+ return MctsResultWasm.__wrap(ret[0]);
291
+ }
292
+ }
293
+ if (Symbol.dispose) MctsSessionWasm.prototype[Symbol.dispose] = MctsSessionWasm.prototype.free;
294
+
295
+ export class StepResultWasm {
296
+ static __wrap(ptr) {
297
+ ptr = ptr >>> 0;
298
+ const obj = Object.create(StepResultWasm.prototype);
299
+ obj.__wbg_ptr = ptr;
300
+ StepResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
301
+ return obj;
302
+ }
303
+ __destroy_into_raw() {
304
+ const ptr = this.__wbg_ptr;
305
+ this.__wbg_ptr = 0;
306
+ StepResultWasmFinalization.unregister(this);
307
+ return ptr;
308
+ }
309
+ free() {
310
+ const ptr = this.__destroy_into_raw();
311
+ wasm.__wbg_stepresultwasm_free(ptr, 0);
312
+ }
313
+ /**
314
+ * @returns {boolean}
315
+ */
316
+ get done() {
317
+ const ret = wasm.stepresultwasm_done(this.__wbg_ptr);
318
+ return ret !== 0;
319
+ }
320
+ /**
321
+ * @returns {boolean}
322
+ */
323
+ get draw() {
324
+ const ret = wasm.stepresultwasm_draw(this.__wbg_ptr);
325
+ return ret !== 0;
326
+ }
327
+ /**
328
+ * @returns {number}
329
+ */
330
+ get reward() {
331
+ const ret = wasm.stepresultwasm_reward(this.__wbg_ptr);
332
+ return ret;
333
+ }
334
+ /**
335
+ * @returns {Int16Array}
336
+ */
337
+ get state() {
338
+ const ret = wasm.stepresultwasm_state(this.__wbg_ptr);
339
+ return ret;
340
+ }
341
+ /**
342
+ * @returns {number}
343
+ */
344
+ get winner() {
345
+ const ret = wasm.stepresultwasm_winner(this.__wbg_ptr);
346
+ return ret;
347
+ }
348
+ }
349
+ if (Symbol.dispose) StepResultWasm.prototype[Symbol.dispose] = StepResultWasm.prototype.free;
350
+
351
+ export class VariantSpecWasm {
352
+ static __wrap(ptr) {
353
+ ptr = ptr >>> 0;
354
+ const obj = Object.create(VariantSpecWasm.prototype);
355
+ obj.__wbg_ptr = ptr;
356
+ VariantSpecWasmFinalization.register(obj, obj.__wbg_ptr, obj);
357
+ return obj;
358
+ }
359
+ __destroy_into_raw() {
360
+ const ptr = this.__wbg_ptr;
361
+ this.__wbg_ptr = 0;
362
+ VariantSpecWasmFinalization.unregister(this);
363
+ return ptr;
364
+ }
365
+ free() {
366
+ const ptr = this.__destroy_into_raw();
367
+ wasm.__wbg_variantspecwasm_free(ptr, 0);
368
+ }
369
+ /**
370
+ * @returns {number}
371
+ */
372
+ get actionSize() {
373
+ const ret = wasm.variantspecwasm_actionSize(this.__wbg_ptr);
374
+ return ret >>> 0;
375
+ }
376
+ /**
377
+ * @returns {number}
378
+ */
379
+ get boardHeight() {
380
+ const ret = wasm.mctsresultwasm_action(this.__wbg_ptr);
381
+ return ret >>> 0;
382
+ }
383
+ /**
384
+ * @returns {number}
385
+ */
386
+ get boardSize() {
387
+ const ret = wasm.variantspecwasm_boardSize(this.__wbg_ptr);
388
+ return ret >>> 0;
389
+ }
390
+ /**
391
+ * @returns {number}
392
+ */
393
+ get boardWidth() {
394
+ const ret = wasm.variantspecwasm_boardWidth(this.__wbg_ptr);
395
+ return ret >>> 0;
396
+ }
397
+ /**
398
+ * @param {string} variant_name
399
+ * @param {number} board_height
400
+ * @param {number} board_width
401
+ * @param {Int16Array} piece_counts_per_color
402
+ * @param {number} no_capture_draw_plies
403
+ * @param {number} max_episode_steps
404
+ * @returns {VariantSpecWasm}
405
+ */
406
+ static create(variant_name, board_height, board_width, piece_counts_per_color, no_capture_draw_plies, max_episode_steps) {
407
+ const ptr0 = passStringToWasm0(variant_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
408
+ const len0 = WASM_VECTOR_LEN;
409
+ const ret = wasm.variantspecwasm_create(ptr0, len0, board_height, board_width, piece_counts_per_color, no_capture_draw_plies, max_episode_steps);
410
+ if (ret[2]) {
411
+ throw takeFromExternrefTable0(ret[1]);
412
+ }
413
+ return VariantSpecWasm.__wrap(ret[0]);
414
+ }
415
+ /**
416
+ * @returns {number}
417
+ */
418
+ get maxEpisodeSteps() {
419
+ const ret = wasm.variantspecwasm_maxEpisodeSteps(this.__wbg_ptr);
420
+ return ret >>> 0;
421
+ }
422
+ /**
423
+ * @returns {number}
424
+ */
425
+ get noCaptureDrawPlies() {
426
+ const ret = wasm.variantspecwasm_noCaptureDrawPlies(this.__wbg_ptr);
427
+ return ret;
428
+ }
429
+ /**
430
+ * @returns {Int16Array}
431
+ */
432
+ get pieceCountsPerColor() {
433
+ const ret = wasm.variantspecwasm_pieceCountsPerColor(this.__wbg_ptr);
434
+ return ret;
435
+ }
436
+ /**
437
+ * @returns {VariantSpecWasm}
438
+ */
439
+ static standard() {
440
+ const ret = wasm.variantspecwasm_standard();
441
+ return VariantSpecWasm.__wrap(ret);
442
+ }
443
+ /**
444
+ * @returns {string}
445
+ */
446
+ get variantName() {
447
+ let deferred1_0;
448
+ let deferred1_1;
449
+ try {
450
+ const ret = wasm.variantspecwasm_variantName(this.__wbg_ptr);
451
+ deferred1_0 = ret[0];
452
+ deferred1_1 = ret[1];
453
+ return getStringFromWasm0(ret[0], ret[1]);
454
+ } finally {
455
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
456
+ }
457
+ }
458
+ }
459
+ if (Symbol.dispose) VariantSpecWasm.prototype[Symbol.dispose] = VariantSpecWasm.prototype.free;
460
+
461
+ function __wbg_get_imports() {
462
+ const import0 = {
463
+ __proto__: null,
464
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
465
+ const ret = arg0 === undefined;
466
+ return ret;
467
+ },
468
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
469
+ throw new Error(getStringFromWasm0(arg0, arg1));
470
+ },
471
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
472
+ const ret = arg0.call(arg1);
473
+ return ret;
474
+ }, arguments); },
475
+ __wbg_length_500e25dbc316fd13: function(arg0) {
476
+ const ret = arg0.length;
477
+ return ret;
478
+ },
479
+ __wbg_length_9a7876c9728a0979: function(arg0) {
480
+ const ret = arg0.length;
481
+ return ret;
482
+ },
483
+ __wbg_length_b1593d937f31cef9: function(arg0) {
484
+ const ret = arg0.length;
485
+ return ret;
486
+ },
487
+ __wbg_new_from_slice_132ef6dc5072cf68: function(arg0, arg1) {
488
+ const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
489
+ return ret;
490
+ },
491
+ __wbg_new_from_slice_1c1c42c5954b2701: function(arg0, arg1) {
492
+ const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
493
+ return ret;
494
+ },
495
+ __wbg_new_from_slice_b5d5e7773e9f2033: function(arg0, arg1) {
496
+ const ret = new Int16Array(getArrayI16FromWasm0(arg0, arg1));
497
+ return ret;
498
+ },
499
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
500
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
501
+ return ret;
502
+ },
503
+ __wbg_now_2c95c9de01293173: function(arg0) {
504
+ const ret = arg0.now();
505
+ return ret;
506
+ },
507
+ __wbg_performance_7a3ffd0b17f663ad: function(arg0) {
508
+ const ret = arg0.performance;
509
+ return ret;
510
+ },
511
+ __wbg_prototypesetcall_55c7bc6bcd6a9457: function(arg0, arg1, arg2) {
512
+ Int16Array.prototype.set.call(getArrayI16FromWasm0(arg0, arg1), arg2);
513
+ },
514
+ __wbg_prototypesetcall_c7e6a26aeade796d: function(arg0, arg1, arg2) {
515
+ Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
516
+ },
517
+ __wbg_prototypesetcall_f8118a9f36fee41e: function(arg0, arg1, arg2) {
518
+ Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), arg2);
519
+ },
520
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
521
+ const ret = typeof global === 'undefined' ? null : global;
522
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
523
+ },
524
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
525
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
526
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
527
+ },
528
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
529
+ const ret = typeof self === 'undefined' ? null : self;
530
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
531
+ },
532
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
533
+ const ret = typeof window === 'undefined' ? null : window;
534
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
535
+ },
536
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
537
+ // Cast intrinsic for `Ref(String) -> Externref`.
538
+ const ret = getStringFromWasm0(arg0, arg1);
539
+ return ret;
540
+ },
541
+ __wbindgen_init_externref_table: function() {
542
+ const table = wasm.__wbindgen_externrefs;
543
+ const offset = table.grow(4);
544
+ table.set(0, undefined);
545
+ table.set(offset + 0, undefined);
546
+ table.set(offset + 1, null);
547
+ table.set(offset + 2, true);
548
+ table.set(offset + 3, false);
549
+ },
550
+ };
551
+ return {
552
+ __proto__: null,
553
+ "./banqi_bg.js": import0,
554
+ };
555
+ }
556
+
557
+ const BanqiGameWasmFinalization = (typeof FinalizationRegistry === 'undefined')
558
+ ? { register: () => {}, unregister: () => {} }
559
+ : new FinalizationRegistry(ptr => wasm.__wbg_banqigamewasm_free(ptr >>> 0, 1));
560
+ const CollectLeavesResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
561
+ ? { register: () => {}, unregister: () => {} }
562
+ : new FinalizationRegistry(ptr => wasm.__wbg_collectleavesresultwasm_free(ptr >>> 0, 1));
563
+ const MctsResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
564
+ ? { register: () => {}, unregister: () => {} }
565
+ : new FinalizationRegistry(ptr => wasm.__wbg_mctsresultwasm_free(ptr >>> 0, 1));
566
+ const MctsSessionWasmFinalization = (typeof FinalizationRegistry === 'undefined')
567
+ ? { register: () => {}, unregister: () => {} }
568
+ : new FinalizationRegistry(ptr => wasm.__wbg_mctssessionwasm_free(ptr >>> 0, 1));
569
+ const StepResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
570
+ ? { register: () => {}, unregister: () => {} }
571
+ : new FinalizationRegistry(ptr => wasm.__wbg_stepresultwasm_free(ptr >>> 0, 1));
572
+ const VariantSpecWasmFinalization = (typeof FinalizationRegistry === 'undefined')
573
+ ? { register: () => {}, unregister: () => {} }
574
+ : new FinalizationRegistry(ptr => wasm.__wbg_variantspecwasm_free(ptr >>> 0, 1));
575
+
576
+ function addToExternrefTable0(obj) {
577
+ const idx = wasm.__externref_table_alloc();
578
+ wasm.__wbindgen_externrefs.set(idx, obj);
579
+ return idx;
580
+ }
581
+
582
+ function _assertClass(instance, klass) {
583
+ if (!(instance instanceof klass)) {
584
+ throw new Error(`expected instance of ${klass.name}`);
585
+ }
586
+ }
587
+
588
+ function getArrayF32FromWasm0(ptr, len) {
589
+ ptr = ptr >>> 0;
590
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
591
+ }
592
+
593
+ function getArrayI16FromWasm0(ptr, len) {
594
+ ptr = ptr >>> 0;
595
+ return getInt16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
596
+ }
597
+
598
+ function getArrayI32FromWasm0(ptr, len) {
599
+ ptr = ptr >>> 0;
600
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
601
+ }
602
+
603
+ let cachedFloat32ArrayMemory0 = null;
604
+ function getFloat32ArrayMemory0() {
605
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
606
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
607
+ }
608
+ return cachedFloat32ArrayMemory0;
609
+ }
610
+
611
+ let cachedInt16ArrayMemory0 = null;
612
+ function getInt16ArrayMemory0() {
613
+ if (cachedInt16ArrayMemory0 === null || cachedInt16ArrayMemory0.byteLength === 0) {
614
+ cachedInt16ArrayMemory0 = new Int16Array(wasm.memory.buffer);
615
+ }
616
+ return cachedInt16ArrayMemory0;
617
+ }
618
+
619
+ let cachedInt32ArrayMemory0 = null;
620
+ function getInt32ArrayMemory0() {
621
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
622
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
623
+ }
624
+ return cachedInt32ArrayMemory0;
625
+ }
626
+
627
+ function getStringFromWasm0(ptr, len) {
628
+ ptr = ptr >>> 0;
629
+ return decodeText(ptr, len);
630
+ }
631
+
632
+ let cachedUint32ArrayMemory0 = null;
633
+ function getUint32ArrayMemory0() {
634
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
635
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
636
+ }
637
+ return cachedUint32ArrayMemory0;
638
+ }
639
+
640
+ let cachedUint8ArrayMemory0 = null;
641
+ function getUint8ArrayMemory0() {
642
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
643
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
644
+ }
645
+ return cachedUint8ArrayMemory0;
646
+ }
647
+
648
+ function handleError(f, args) {
649
+ try {
650
+ return f.apply(this, args);
651
+ } catch (e) {
652
+ const idx = addToExternrefTable0(e);
653
+ wasm.__wbindgen_exn_store(idx);
654
+ }
655
+ }
656
+
657
+ function isLikeNone(x) {
658
+ return x === undefined || x === null;
659
+ }
660
+
661
+ function passArray32ToWasm0(arg, malloc) {
662
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
663
+ getUint32ArrayMemory0().set(arg, ptr / 4);
664
+ WASM_VECTOR_LEN = arg.length;
665
+ return ptr;
666
+ }
667
+
668
+ function passStringToWasm0(arg, malloc, realloc) {
669
+ if (realloc === undefined) {
670
+ const buf = cachedTextEncoder.encode(arg);
671
+ const ptr = malloc(buf.length, 1) >>> 0;
672
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
673
+ WASM_VECTOR_LEN = buf.length;
674
+ return ptr;
675
+ }
676
+
677
+ let len = arg.length;
678
+ let ptr = malloc(len, 1) >>> 0;
679
+
680
+ const mem = getUint8ArrayMemory0();
681
+
682
+ let offset = 0;
683
+
684
+ for (; offset < len; offset++) {
685
+ const code = arg.charCodeAt(offset);
686
+ if (code > 0x7F) break;
687
+ mem[ptr + offset] = code;
688
+ }
689
+ if (offset !== len) {
690
+ if (offset !== 0) {
691
+ arg = arg.slice(offset);
692
+ }
693
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
694
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
695
+ const ret = cachedTextEncoder.encodeInto(arg, view);
696
+
697
+ offset += ret.written;
698
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
699
+ }
700
+
701
+ WASM_VECTOR_LEN = offset;
702
+ return ptr;
703
+ }
704
+
705
+ function takeFromExternrefTable0(idx) {
706
+ const value = wasm.__wbindgen_externrefs.get(idx);
707
+ wasm.__externref_table_dealloc(idx);
708
+ return value;
709
+ }
710
+
711
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
712
+ cachedTextDecoder.decode();
713
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
714
+ let numBytesDecoded = 0;
715
+ function decodeText(ptr, len) {
716
+ numBytesDecoded += len;
717
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
718
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
719
+ cachedTextDecoder.decode();
720
+ numBytesDecoded = len;
721
+ }
722
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
723
+ }
724
+
725
+ const cachedTextEncoder = new TextEncoder();
726
+
727
+ if (!('encodeInto' in cachedTextEncoder)) {
728
+ cachedTextEncoder.encodeInto = function (arg, view) {
729
+ const buf = cachedTextEncoder.encode(arg);
730
+ view.set(buf);
731
+ return {
732
+ read: arg.length,
733
+ written: buf.length
734
+ };
735
+ };
736
+ }
737
+
738
+ let WASM_VECTOR_LEN = 0;
739
+
740
+ let wasmModule, wasm;
741
+ function __wbg_finalize_init(instance, module) {
742
+ wasm = instance.exports;
743
+ wasmModule = module;
744
+ cachedFloat32ArrayMemory0 = null;
745
+ cachedInt16ArrayMemory0 = null;
746
+ cachedInt32ArrayMemory0 = null;
747
+ cachedUint32ArrayMemory0 = null;
748
+ cachedUint8ArrayMemory0 = null;
749
+ wasm.__wbindgen_start();
750
+ return wasm;
751
+ }
752
+
753
+ async function __wbg_load(module, imports) {
754
+ if (typeof Response === 'function' && module instanceof Response) {
755
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
756
+ try {
757
+ return await WebAssembly.instantiateStreaming(module, imports);
758
+ } catch (e) {
759
+ const validResponse = module.ok && expectedResponseType(module.type);
760
+
761
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
762
+ 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);
763
+
764
+ } else { throw e; }
765
+ }
766
+ }
767
+
768
+ const bytes = await module.arrayBuffer();
769
+ return await WebAssembly.instantiate(bytes, imports);
770
+ } else {
771
+ const instance = await WebAssembly.instantiate(module, imports);
772
+
773
+ if (instance instanceof WebAssembly.Instance) {
774
+ return { instance, module };
775
+ } else {
776
+ return instance;
777
+ }
778
+ }
779
+
780
+ function expectedResponseType(type) {
781
+ switch (type) {
782
+ case 'basic': case 'cors': case 'default': return true;
783
+ }
784
+ return false;
785
+ }
786
+ }
787
+
788
+ function initSync(module) {
789
+ if (wasm !== undefined) return wasm;
790
+
791
+
792
+ if (module !== undefined) {
793
+ if (Object.getPrototypeOf(module) === Object.prototype) {
794
+ ({module} = module)
795
+ } else {
796
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
797
+ }
798
+ }
799
+
800
+ const imports = __wbg_get_imports();
801
+ if (!(module instanceof WebAssembly.Module)) {
802
+ module = new WebAssembly.Module(module);
803
+ }
804
+ const instance = new WebAssembly.Instance(module, imports);
805
+ return __wbg_finalize_init(instance, module);
806
+ }
807
+
808
+ async function __wbg_init(module_or_path) {
809
+ if (wasm !== undefined) return wasm;
810
+
811
+
812
+ if (module_or_path !== undefined) {
813
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
814
+ ({module_or_path} = module_or_path)
815
+ } else {
816
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
817
+ }
818
+ }
819
+
820
+ if (module_or_path === undefined) {
821
+ module_or_path = new URL('banqi_bg.wasm', import.meta.url);
822
+ }
823
+ const imports = __wbg_get_imports();
824
+
825
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
826
+ module_or_path = fetch(module_or_path);
827
+ }
828
+
829
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
830
+
831
+ return __wbg_finalize_init(instance, module);
832
+ }
833
+
834
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,54 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_banqigamewasm_free: (a: number, b: number) => void;
5
+ export const __wbg_collectleavesresultwasm_free: (a: number, b: number) => void;
6
+ export const __wbg_mctsresultwasm_free: (a: number, b: number) => void;
7
+ export const __wbg_mctssessionwasm_free: (a: number, b: number) => void;
8
+ export const __wbg_stepresultwasm_free: (a: number, b: number) => void;
9
+ export const __wbg_variantspecwasm_free: (a: number, b: number) => void;
10
+ export const banqigamewasm_applyStep: (a: number, b: number, c: bigint) => number;
11
+ export const banqigamewasm_fromState: (a: any) => [number, number, number];
12
+ export const banqigamewasm_fromStateWithVariant: (a: any, b: number) => [number, number, number];
13
+ export const banqigamewasm_legalActions: (a: number) => any;
14
+ export const banqigamewasm_makeTest: (a: bigint, b: number) => number;
15
+ export const banqigamewasm_makeTestWithVariant: (a: bigint, b: number, c: number) => number;
16
+ export const banqigamewasm_minimaxScores: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number) => [number, number, number];
17
+ export const banqigamewasm_softmaxPolicy: (a: any, b: number) => any;
18
+ export const banqigamewasm_state: (a: number) => any;
19
+ export const banqigamewasm_variant: (a: number) => number;
20
+ export const collectleavesresultwasm_leafIds: (a: number) => any;
21
+ export const collectleavesresultwasm_states: (a: number) => any;
22
+ export const mctsresultwasm_action: (a: number) => number;
23
+ export const mctsresultwasm_policy: (a: number) => any;
24
+ export const mctssessionwasm_actionSize: (a: number) => number;
25
+ export const mctssessionwasm_applyEvals: (a: number, b: any, c: any, d: number, e: any) => [number, number];
26
+ export const mctssessionwasm_close: (a: number) => void;
27
+ export const mctssessionwasm_closed: (a: number) => number;
28
+ export const mctssessionwasm_collectLeaves: (a: number, b: number) => [number, number, number];
29
+ export const mctssessionwasm_isDone: (a: number) => [number, number, number];
30
+ export const mctssessionwasm_new: (a: any, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number, i: number, j: bigint, k: number, l: number) => [number, number, number];
31
+ export const mctssessionwasm_result: (a: number, b: number, c: number) => [number, number, number];
32
+ export const stepresultwasm_done: (a: number) => number;
33
+ export const stepresultwasm_draw: (a: number) => number;
34
+ export const stepresultwasm_reward: (a: number) => number;
35
+ export const stepresultwasm_state: (a: number) => any;
36
+ export const stepresultwasm_winner: (a: number) => number;
37
+ export const variantspecwasm_actionSize: (a: number) => number;
38
+ export const variantspecwasm_boardSize: (a: number) => number;
39
+ export const variantspecwasm_boardWidth: (a: number) => number;
40
+ export const variantspecwasm_create: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number];
41
+ export const variantspecwasm_maxEpisodeSteps: (a: number) => number;
42
+ export const variantspecwasm_noCaptureDrawPlies: (a: number) => number;
43
+ export const variantspecwasm_pieceCountsPerColor: (a: number) => any;
44
+ export const variantspecwasm_standard: () => number;
45
+ export const variantspecwasm_variantName: (a: number) => [number, number];
46
+ export const variantspecwasm_boardHeight: (a: number) => number;
47
+ export const __wbindgen_exn_store: (a: number) => void;
48
+ export const __externref_table_alloc: () => number;
49
+ export const __wbindgen_externrefs: WebAssembly.Table;
50
+ export const __externref_table_dealloc: (a: number) => void;
51
+ export const __wbindgen_malloc: (a: number, b: number) => number;
52
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
53
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
54
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "banqi",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "JacobLinCool <jacoblincool@gmail.com>"
6
+ ],
7
+ "description": "",
8
+ "version": "0.1.0",
9
+ "license": "MIT",
10
+ "files": [
11
+ "banqi_bg.wasm",
12
+ "banqi.js",
13
+ "banqi.d.ts"
14
+ ],
15
+ "main": "banqi.js",
16
+ "types": "banqi.d.ts",
17
+ "sideEffects": [
18
+ "./snippets/*"
19
+ ]
20
+ }