@renju-note/quintet 0.10.3 → 0.11.0

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
@@ -1,54 +1,114 @@
1
1
  # quintet
2
2
 
3
- Renju mate solver compilable to WebAssemby
3
+ A [Renju](https://www.renju.net/rifrules/) mate solver written in Rust and
4
+ compiled to WebAssembly. Given a position and a side to move, it searches for
5
+ a forced win and returns the winning sequence.
4
6
 
5
- ## Run
7
+ quintet powers the analysis features of [renju-note](https://github.com/renju-note),
8
+ and is published to npm as
9
+ [`@renju-note/quintet`](https://www.npmjs.com/package/@renju-note/quintet).
6
10
 
7
- ### VCF
11
+ ## What it solves
8
12
 
13
+ | Mode | Meaning |
14
+ | --- | --- |
15
+ | **VCF** (Victory by Continuous Fours) | A forced win using only *fours*: every attacking move threatens to complete five, so every reply is forced. |
16
+ | **VCT** (Victory by Continuous Threats) | A forced win using *fours and threes*. The defender may answer a three in several ways, so this is a proper AND/OR tree search, solved with proof numbers. |
17
+
18
+ Renju rules are fully modelled: Black's forbidden moves (double-three,
19
+ double-four, overline) are detected — including the recursive "real vs. fake
20
+ three" rule — and can be both an obstacle for a Black attacker and a winning
21
+ resource for a White attacker. Opening restrictions and passing are not
22
+ modelled; the solver takes an arbitrary position.
23
+
24
+ ## Usage
25
+
26
+ ### From JavaScript
27
+
28
+ ```sh
29
+ npm install @renju-note/quintet
9
30
  ```
10
- % cargo run --release --example solve vcf 10 5 x \
11
- H8,H7,F6,G7,I7,G9,G6,H6,F8,E8,F9,F7,E7,D6,H4,G5,J6,I5,J4,K5,J5,J3,J8,J7,I4,K4,K6,L7,L6,M6,I2,N7,L5,K7,M7,G4,I8,G8,K8,L8,D5,E4,F4,F3,H3,G2,E2,I10,J11,F11,G11,D9,E10,E12,F13,C10,B11,C12,D12
12
- Finished release [optimized] target(s) in 0.00s
13
- Running `target/release/examples/solve vcf 10 x H8,H7,F6,G7,I7,G9,G6,H6,F8,E8,F9,F7,E7,D6,H4,G5,J6,I5,J4,K5,J5,J3,J8,J7,I4,K4,K6,L7,L6,M6,I2,N7,L5,K7,M7,G4,I8,G8,K8,L8,D5,E4,F4,F3,H3,G2,E2,I10,J11,F11,G11,D9,E10,E12,F13,C10,B11,C12,D12`
14
- Kind: VCF
15
- MaxDepth: 10
16
- Player: White
17
- Board:
18
- 15 . . . . . . . . . . . . . . .
19
- 14 . . . . . . . . . . . . . . .
20
- 13 . . . . . o . . . . . . . . .
21
- 12 . . x o x . . . . . . . . . .
22
- 11 . o . . . x o . . o . . . . .
23
- 10 . . x . o . . . x . . . . . .
24
- 9 . . . x . o x . . . . . . . .
25
- 8 . . . . x o x o o o o x . . .
26
- 7 . . . . o x x x o x x x o x .
27
- 6 . . . x . o o x . o o o x . .
28
- 5 . . . o . . x . x o x o . . .
29
- 4 . . . . x o x o o o x . . . .
30
- 3 . . . . . x . o . x . . . . .
31
- 2 . . . . o . x . o . . . . . .
32
- 1 . . . . . . . . . . . . . . .
33
- A B C D E F G H I J K L M N O
34
31
 
35
- Solving...
32
+ ```js
33
+ import init, { solve_vct_dfpn, encode_xy, decode_x, decode_y } from "@renju-note/quintet";
36
34
 
37
- Elapsed: 45.041µs
38
- Depth: 8
39
- Solution: G1,G3,E6,H9,H5,I6,F5,E5,C8,D7,C11,C9,C14,C13,D13
35
+ await init();
36
+
37
+ // Points are encoded as a single byte: x * 15 + y, with x, y in 0..15
38
+ // (x = column A..O, y = row 1..15).
39
+ const blacks = [encode_xy(7, 7), encode_xy(7, 6)]; // H8, H7
40
+ const whites = [encode_xy(6, 6)]; // G7
41
+
42
+ // solve_vct_dfpn(blacks, whites, blackToMove, limit) -> Uint8Array | undefined
43
+ const path = solve_vct_dfpn(blacks, whites, true, 10);
44
+ if (path) {
45
+ const moves = Array.from(path, (p) => [decode_x(p), decode_y(p)]);
46
+ // moves alternates attacker, defender, attacker, ...
47
+ }
40
48
  ```
41
49
 
42
- ### VCT
50
+ Exported functions (`src/wasm.rs`):
51
+
52
+ | Function | Description |
53
+ | --- | --- |
54
+ | `solve(mode, limit, blacks, whites, black, threat_limit)` | General entry point. `mode` is a numeric `SolveMode` code: `0` = VCF, `10` = VCT (DFS), `15` = VCT (PNS), `16` = VCT (df-pn). |
55
+ | `solve_vcf(blacks, whites, black, limit)` | Shorthand for `mode = 0`. |
56
+ | `solve_vct(blacks, whites, black, limit)` | Shorthand for `mode = 10`, `threat_limit = limit`. |
57
+ | `solve_vct_dfpn(blacks, whites, black, limit)` | Shorthand for `mode = 16`, `threat_limit = limit`. The recommended VCT solver. |
58
+ | `encode_xy(x, y)` / `decode_x(code)` / `decode_y(code)` | Point encoding helpers. |
59
+
60
+ All solvers return the winning path as encoded points, or nothing if no win
61
+ is found within the limits.
62
+
63
+ ### From Rust
64
+
65
+ ```toml
66
+ [dependencies]
67
+ quintet = { git = "https://github.com/renju-note/quintet" }
68
+ ```
69
+
70
+ ```rust
71
+ use quintet::board::*;
72
+ use quintet::mate::*;
73
+
74
+ let board: Board = "H8,H7,F6".parse()?; // moves alternating Black, White, ...
75
+ let mate = solve(SolveMode::VCTDFPNS, 10, &board, Player::Black, 3);
76
+ if let Some(m) = mate {
77
+ println!("{}", Points(m.path));
78
+ }
79
+ ```
80
+
81
+ ### Parameters
82
+
83
+ - **`limit`** — maximum number of *attacker* moves in the solution. Larger
84
+ values find longer wins but take longer.
85
+ - **`threat_limit`** — depth of the nested VCF search used to decide whether
86
+ a move is a threat (VCT only). `1` recognises only fours and threes as
87
+ threats; higher values also find "hidden" threats that prepare a
88
+ four-three.
89
+
90
+ ### Command line
91
+
92
+ `examples/solve.rs` wraps the solver for quick experiments:
93
+
94
+ ```sh
95
+ cargo run --release --example solve <mode> <limit> <threat_limit> <o|x> <position>
96
+ ```
97
+
98
+ - `mode`: `vcf`, `vct`, `vct_pns` or `vct_dfpns`
99
+ - `o|x`: the attacker (`o` = Black, `x` = White)
100
+ - `position`: a move list `H8,H7,F6,...` (alternating from Black), or a
101
+ stone list `H8,F6/H7` written as `blacks/whites`
102
+
103
+ Example — White has a 15-move VCT ending in a forbidden move for Black:
43
104
 
44
105
  ```
45
106
  % cargo run --release --example solve vct_dfpns 255 3 x \
46
107
  H8,I9,H7,J8,F8,H9,G9,H10,G11,F10,I10,G10,I8,J9,E10,K9,L9,G8,J10,K7,L6,K8,K6,L10,I7,J6,M9,I5,H4,F7,G6,E6,D5,F5,G4
47
- Finished release [optimized] target(s) in 0.03s
48
- Running `target/release/examples/solve vct_dfpn 255 x H8,I9,H7,J8,F8,H9,G9,H10,G11,F10,I10,G10,I8,J9,E10,K9,L9,G8,J10,K7,L6,K8,K6,L10,I7,J6,M9,I5,H4,F7,G6,E6,D5,F5,G4`
49
- Kind: VCTDFPN
50
- MaxDepth: 255
51
- Player: White
108
+ Mode: VCTDFPNS
109
+ Limit: 255
110
+ ThreatLimit: 3
111
+ Attacker: White
52
112
  Board:
53
113
  15 . . . . . . . . . . . . . . .
54
114
  14 . . . . . . . . . . . . . . .
@@ -69,21 +129,57 @@ Board:
69
129
 
70
130
  Solving...
71
131
 
72
- Elapsed: 2.370459s
73
- Depth: 17
74
- Solution: K11,K10,N12,M11,N8,H5,H6,L8,J5,J7,M5,L4,M6,K5,N7,N5,M4,M7,J4,I6,F3,M8,M10,I12,J11,K3,K4,J3,O8,L5,M2,M3,N1
132
+ Elapsed: 889.191875ms
133
+ End: Forbidden(L7)
134
+ Times (Length): 15 (29)
135
+ Moves: K11,K10,N12,M11,N8,H5,H6,L8,J5,J7,M5,L4,M6,K5,J4,K3,J3,J2,K4,L5,M4,L3,L2,F3,I6,E2,D1,M3,N5
75
136
  ```
76
137
 
77
- Original game: https://www.renju.net/media/games.php?gameid=92337
138
+ (Original game: <https://www.renju.net/media/games.php?gameid=92337>)
78
139
 
79
- ## Release
140
+ ## How it works
141
+
142
+ - `src/board/` — bit-packed board representation. Every rule concept (five,
143
+ four, three, forbidden move) is detected by sliding a 5-cell window over
144
+ bitmask lines.
145
+ - `src/mate/vcf/` — depth-first VCF search over four-making moves, with a
146
+ transposition memo.
147
+ - `src/mate/vct/` — VCT search as a proof-number AND/OR tree. The DFS, PNS
148
+ and df-pn variants share one solver and differ only in their threshold
149
+ policy. Threats are recognised by running a nested VCF search after a
150
+ hypothetical pass.
151
+ - `src/analysis/` — potential-field heuristics used for move ordering.
152
+ - `src/wasm.rs` — the `wasm-bindgen` surface.
153
+
154
+ The [`docs/`](docs/README.en.md) directory has detailed documentation in
155
+ English and Japanese: the Renju rules, how the board code implements them,
156
+ and how the solvers work.
80
157
 
158
+ ## Development
159
+
160
+ ```sh
161
+ cargo test --release # always test in release; the solvers are slow in debug
162
+ cargo test --release -- --ignored # also run the slow benchmark cases
163
+ cargo fmt --check
164
+ cargo clippy --all-targets -- -D warnings
165
+ cargo build --target wasm32-unknown-unknown
81
166
  ```
82
- # build
83
- $ wasm-pack build --scope renju-note
84
167
 
85
- # publish
86
- $ wasm-pack publish
168
+ Everything under `src/` must stay compilable for `wasm32-unknown-unknown`:
169
+ no threads, no filesystem, no `std::time` in library code.
170
+
171
+ ## Release
172
+
173
+ Publishing a GitHub release triggers
174
+ [`.github/workflows/wasm-pack-release.yml`](.github/workflows/wasm-pack-release.yml),
175
+ which sets the crate version from the tag (`vX.Y.Z`), runs
176
+ `wasm-pack build --scope renju-note` and publishes the package to npm with
177
+ trusted publishing. To build the package locally:
178
+
179
+ ```sh
180
+ wasm-pack build --scope renju-note
87
181
  ```
88
182
 
89
- See also: https://developer.mozilla.org/ja/docs/WebAssembly/Rust_to_wasm
183
+ ## License
184
+
185
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@renju-note/quintet",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "yubessy <yubessy0@gmail.com>"
5
6
  ],
6
7
  "description": "Renju mate solver compilable to WebAssemby",
7
- "version": "0.10.3",
8
+ "version": "0.11.0",
8
9
  "license": "MIT",
9
10
  "repository": {
10
11
  "type": "git",
@@ -16,7 +17,10 @@
16
17
  "quintet_bg.js",
17
18
  "quintet.d.ts"
18
19
  ],
19
- "module": "quintet.js",
20
+ "main": "quintet.js",
20
21
  "types": "quintet.d.ts",
21
- "sideEffects": false
22
- }
22
+ "sideEffects": [
23
+ "./quintet.js",
24
+ "./snippets/*"
25
+ ]
26
+ }
package/quintet.d.ts CHANGED
@@ -1,52 +1,16 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * @param {number} mode
5
- * @param {number} limit
6
- * @param {Uint8Array} blacks
7
- * @param {Uint8Array} whites
8
- * @param {boolean} black
9
- * @param {number} threat_limit
10
- * @returns {Uint8Array | undefined}
11
- */
3
+
4
+ export function decode_x(code: number): number;
5
+
6
+ export function decode_y(code: number): number;
7
+
8
+ export function encode_xy(x: number, y: number): number;
9
+
12
10
  export function solve(mode: number, limit: number, blacks: Uint8Array, whites: Uint8Array, black: boolean, threat_limit: number): Uint8Array | undefined;
13
- /**
14
- * @param {Uint8Array} blacks
15
- * @param {Uint8Array} whites
16
- * @param {boolean} black
17
- * @param {number} limit
18
- * @returns {Uint8Array | undefined}
19
- */
11
+
20
12
  export function solve_vcf(blacks: Uint8Array, whites: Uint8Array, black: boolean, limit: number): Uint8Array | undefined;
21
- /**
22
- * @param {Uint8Array} blacks
23
- * @param {Uint8Array} whites
24
- * @param {boolean} black
25
- * @param {number} limit
26
- * @returns {Uint8Array | undefined}
27
- */
13
+
28
14
  export function solve_vct(blacks: Uint8Array, whites: Uint8Array, black: boolean, limit: number): Uint8Array | undefined;
29
- /**
30
- * @param {Uint8Array} blacks
31
- * @param {Uint8Array} whites
32
- * @param {boolean} black
33
- * @param {number} limit
34
- * @returns {Uint8Array | undefined}
35
- */
15
+
36
16
  export function solve_vct_dfpn(blacks: Uint8Array, whites: Uint8Array, black: boolean, limit: number): Uint8Array | undefined;
37
- /**
38
- * @param {number} x
39
- * @param {number} y
40
- * @returns {number}
41
- */
42
- export function encode_xy(x: number, y: number): number;
43
- /**
44
- * @param {number} code
45
- * @returns {number}
46
- */
47
- export function decode_x(code: number): number;
48
- /**
49
- * @param {number} code
50
- * @returns {number}
51
- */
52
- export function decode_y(code: number): number;
package/quintet.js CHANGED
@@ -1,2 +1,9 @@
1
+ /* @ts-self-types="./quintet.d.ts" */
1
2
  import * as wasm from "./quintet_bg.wasm";
2
- export * from "./quintet_bg.js";
3
+ import { __wbg_set_wasm } from "./quintet_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ decode_x, decode_y, encode_xy, solve, solve_vcf, solve_vct, solve_vct_dfpn
9
+ } from "./quintet_bg.js";
package/quintet_bg.js CHANGED
@@ -1,172 +1,149 @@
1
- import * as wasm from './quintet_bg.wasm';
2
-
3
- let cachegetUint8Memory0 = null;
4
- function getUint8Memory0() {
5
- if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
6
- cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
7
- }
8
- return cachegetUint8Memory0;
1
+ /**
2
+ * @param {number} code
3
+ * @returns {number}
4
+ */
5
+ export function decode_x(code) {
6
+ const ret = wasm.decode_x(code);
7
+ return ret;
9
8
  }
10
9
 
11
- let WASM_VECTOR_LEN = 0;
12
-
13
- function passArray8ToWasm0(arg, malloc) {
14
- const ptr = malloc(arg.length * 1);
15
- getUint8Memory0().set(arg, ptr / 1);
16
- WASM_VECTOR_LEN = arg.length;
17
- return ptr;
10
+ /**
11
+ * @param {number} code
12
+ * @returns {number}
13
+ */
14
+ export function decode_y(code) {
15
+ const ret = wasm.decode_y(code);
16
+ return ret;
18
17
  }
19
18
 
20
- let cachegetInt32Memory0 = null;
21
- function getInt32Memory0() {
22
- if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
23
- cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
24
- }
25
- return cachegetInt32Memory0;
19
+ /**
20
+ * @param {number} x
21
+ * @param {number} y
22
+ * @returns {number}
23
+ */
24
+ export function encode_xy(x, y) {
25
+ const ret = wasm.encode_xy(x, y);
26
+ return ret;
26
27
  }
27
28
 
28
- function getArrayU8FromWasm0(ptr, len) {
29
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
30
- }
31
29
  /**
32
- * @param {number} mode
33
- * @param {number} limit
34
- * @param {Uint8Array} blacks
35
- * @param {Uint8Array} whites
36
- * @param {boolean} black
37
- * @param {number} threat_limit
38
- * @returns {Uint8Array | undefined}
39
- */
30
+ * @param {number} mode
31
+ * @param {number} limit
32
+ * @param {Uint8Array} blacks
33
+ * @param {Uint8Array} whites
34
+ * @param {boolean} black
35
+ * @param {number} threat_limit
36
+ * @returns {Uint8Array | undefined}
37
+ */
40
38
  export function solve(mode, limit, blacks, whites, black, threat_limit) {
41
- try {
42
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
43
- var ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
44
- var len0 = WASM_VECTOR_LEN;
45
- var ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
46
- var len1 = WASM_VECTOR_LEN;
47
- wasm.solve(retptr, mode, limit, ptr0, len0, ptr1, len1, black, threat_limit);
48
- var r0 = getInt32Memory0()[retptr / 4 + 0];
49
- var r1 = getInt32Memory0()[retptr / 4 + 1];
50
- let v2;
51
- if (r0 !== 0) {
52
- v2 = getArrayU8FromWasm0(r0, r1).slice();
53
- wasm.__wbindgen_free(r0, r1 * 1);
54
- }
55
- return v2;
56
- } finally {
57
- wasm.__wbindgen_add_to_stack_pointer(16);
39
+ const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
40
+ const len0 = WASM_VECTOR_LEN;
41
+ const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
42
+ const len1 = WASM_VECTOR_LEN;
43
+ const ret = wasm.solve(mode, limit, ptr0, len0, ptr1, len1, black, threat_limit);
44
+ let v3;
45
+ if (ret[0] !== 0) {
46
+ v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
47
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
58
48
  }
49
+ return v3;
59
50
  }
60
51
 
61
52
  /**
62
- * @param {Uint8Array} blacks
63
- * @param {Uint8Array} whites
64
- * @param {boolean} black
65
- * @param {number} limit
66
- * @returns {Uint8Array | undefined}
67
- */
53
+ * @param {Uint8Array} blacks
54
+ * @param {Uint8Array} whites
55
+ * @param {boolean} black
56
+ * @param {number} limit
57
+ * @returns {Uint8Array | undefined}
58
+ */
68
59
  export function solve_vcf(blacks, whites, black, limit) {
69
- try {
70
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
71
- var ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
72
- var len0 = WASM_VECTOR_LEN;
73
- var ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
74
- var len1 = WASM_VECTOR_LEN;
75
- wasm.solve_vcf(retptr, ptr0, len0, ptr1, len1, black, limit);
76
- var r0 = getInt32Memory0()[retptr / 4 + 0];
77
- var r1 = getInt32Memory0()[retptr / 4 + 1];
78
- let v2;
79
- if (r0 !== 0) {
80
- v2 = getArrayU8FromWasm0(r0, r1).slice();
81
- wasm.__wbindgen_free(r0, r1 * 1);
82
- }
83
- return v2;
84
- } finally {
85
- wasm.__wbindgen_add_to_stack_pointer(16);
60
+ const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
61
+ const len0 = WASM_VECTOR_LEN;
62
+ const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
63
+ const len1 = WASM_VECTOR_LEN;
64
+ const ret = wasm.solve_vcf(ptr0, len0, ptr1, len1, black, limit);
65
+ let v3;
66
+ if (ret[0] !== 0) {
67
+ v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
68
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
86
69
  }
70
+ return v3;
87
71
  }
88
72
 
89
73
  /**
90
- * @param {Uint8Array} blacks
91
- * @param {Uint8Array} whites
92
- * @param {boolean} black
93
- * @param {number} limit
94
- * @returns {Uint8Array | undefined}
95
- */
74
+ * @param {Uint8Array} blacks
75
+ * @param {Uint8Array} whites
76
+ * @param {boolean} black
77
+ * @param {number} limit
78
+ * @returns {Uint8Array | undefined}
79
+ */
96
80
  export function solve_vct(blacks, whites, black, limit) {
97
- try {
98
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
99
- var ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
100
- var len0 = WASM_VECTOR_LEN;
101
- var ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
102
- var len1 = WASM_VECTOR_LEN;
103
- wasm.solve_vct(retptr, ptr0, len0, ptr1, len1, black, limit);
104
- var r0 = getInt32Memory0()[retptr / 4 + 0];
105
- var r1 = getInt32Memory0()[retptr / 4 + 1];
106
- let v2;
107
- if (r0 !== 0) {
108
- v2 = getArrayU8FromWasm0(r0, r1).slice();
109
- wasm.__wbindgen_free(r0, r1 * 1);
110
- }
111
- return v2;
112
- } finally {
113
- wasm.__wbindgen_add_to_stack_pointer(16);
81
+ const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
82
+ const len0 = WASM_VECTOR_LEN;
83
+ const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
84
+ const len1 = WASM_VECTOR_LEN;
85
+ const ret = wasm.solve_vct(ptr0, len0, ptr1, len1, black, limit);
86
+ let v3;
87
+ if (ret[0] !== 0) {
88
+ v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
89
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
114
90
  }
91
+ return v3;
115
92
  }
116
93
 
117
94
  /**
118
- * @param {Uint8Array} blacks
119
- * @param {Uint8Array} whites
120
- * @param {boolean} black
121
- * @param {number} limit
122
- * @returns {Uint8Array | undefined}
123
- */
95
+ * @param {Uint8Array} blacks
96
+ * @param {Uint8Array} whites
97
+ * @param {boolean} black
98
+ * @param {number} limit
99
+ * @returns {Uint8Array | undefined}
100
+ */
124
101
  export function solve_vct_dfpn(blacks, whites, black, limit) {
125
- try {
126
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
127
- var ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
128
- var len0 = WASM_VECTOR_LEN;
129
- var ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
130
- var len1 = WASM_VECTOR_LEN;
131
- wasm.solve_vct_dfpn(retptr, ptr0, len0, ptr1, len1, black, limit);
132
- var r0 = getInt32Memory0()[retptr / 4 + 0];
133
- var r1 = getInt32Memory0()[retptr / 4 + 1];
134
- let v2;
135
- if (r0 !== 0) {
136
- v2 = getArrayU8FromWasm0(r0, r1).slice();
137
- wasm.__wbindgen_free(r0, r1 * 1);
138
- }
139
- return v2;
140
- } finally {
141
- wasm.__wbindgen_add_to_stack_pointer(16);
102
+ const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
105
+ const len1 = WASM_VECTOR_LEN;
106
+ const ret = wasm.solve_vct_dfpn(ptr0, len0, ptr1, len1, black, limit);
107
+ let v3;
108
+ if (ret[0] !== 0) {
109
+ v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
110
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
142
111
  }
112
+ return v3;
143
113
  }
144
-
145
- /**
146
- * @param {number} x
147
- * @param {number} y
148
- * @returns {number}
149
- */
150
- export function encode_xy(x, y) {
151
- var ret = wasm.encode_xy(x, y);
152
- return ret;
114
+ export function __wbindgen_init_externref_table() {
115
+ const table = wasm.__wbindgen_externrefs;
116
+ const offset = table.grow(4);
117
+ table.set(0, undefined);
118
+ table.set(offset + 0, undefined);
119
+ table.set(offset + 1, null);
120
+ table.set(offset + 2, true);
121
+ table.set(offset + 3, false);
122
+ }
123
+ function getArrayU8FromWasm0(ptr, len) {
124
+ ptr = ptr >>> 0;
125
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
153
126
  }
154
127
 
155
- /**
156
- * @param {number} code
157
- * @returns {number}
158
- */
159
- export function decode_x(code) {
160
- var ret = wasm.decode_x(code);
161
- return ret;
128
+ let cachedUint8ArrayMemory0 = null;
129
+ function getUint8ArrayMemory0() {
130
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
131
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
132
+ }
133
+ return cachedUint8ArrayMemory0;
162
134
  }
163
135
 
164
- /**
165
- * @param {number} code
166
- * @returns {number}
167
- */
168
- export function decode_y(code) {
169
- var ret = wasm.decode_y(code);
170
- return ret;
136
+ function passArray8ToWasm0(arg, malloc) {
137
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
138
+ getUint8ArrayMemory0().set(arg, ptr / 1);
139
+ WASM_VECTOR_LEN = arg.length;
140
+ return ptr;
171
141
  }
172
142
 
143
+ let WASM_VECTOR_LEN = 0;
144
+
145
+
146
+ let wasm;
147
+ export function __wbg_set_wasm(val) {
148
+ wasm = val;
149
+ }
package/quintet_bg.wasm CHANGED
Binary file