@renju-note/quintet 0.10.4 → 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 WebAssembly
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.4",
8
+ "version": "0.11.0",
8
9
  "license": "MIT",
9
10
  "repository": {
10
11
  "type": "git",
@@ -16,10 +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
22
  "sideEffects": [
22
23
  "./quintet.js",
23
24
  "./snippets/*"
24
25
  ]
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,4 +1,9 @@
1
+ /* @ts-self-types="./quintet.d.ts" */
1
2
  import * as wasm from "./quintet_bg.wasm";
2
3
  import { __wbg_set_wasm } from "./quintet_bg.js";
4
+
3
5
  __wbg_set_wasm(wasm);
4
- export * from "./quintet_bg.js";
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,179 +1,149 @@
1
- let wasm;
2
- export function __wbg_set_wasm(val) {
3
- wasm = val;
4
- }
5
-
6
-
7
- let cachedUint8Memory0 = null;
8
-
9
- function getUint8Memory0() {
10
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
11
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
12
- }
13
- return cachedUint8Memory0;
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;
14
8
  }
15
9
 
16
- let WASM_VECTOR_LEN = 0;
17
-
18
- function passArray8ToWasm0(arg, malloc) {
19
- const ptr = malloc(arg.length * 1, 1) >>> 0;
20
- getUint8Memory0().set(arg, ptr / 1);
21
- WASM_VECTOR_LEN = arg.length;
22
- 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;
23
17
  }
24
18
 
25
- let cachedInt32Memory0 = null;
26
-
27
- function getInt32Memory0() {
28
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
29
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
30
- }
31
- return cachedInt32Memory0;
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;
32
27
  }
33
28
 
34
- function getArrayU8FromWasm0(ptr, len) {
35
- ptr = ptr >>> 0;
36
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
37
- }
38
29
  /**
39
- * @param {number} mode
40
- * @param {number} limit
41
- * @param {Uint8Array} blacks
42
- * @param {Uint8Array} whites
43
- * @param {boolean} black
44
- * @param {number} threat_limit
45
- * @returns {Uint8Array | undefined}
46
- */
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
+ */
47
38
  export function solve(mode, limit, blacks, whites, black, threat_limit) {
48
- try {
49
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
50
- const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
51
- const len0 = WASM_VECTOR_LEN;
52
- const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
53
- const len1 = WASM_VECTOR_LEN;
54
- wasm.solve(retptr, mode, limit, ptr0, len0, ptr1, len1, black, threat_limit);
55
- var r0 = getInt32Memory0()[retptr / 4 + 0];
56
- var r1 = getInt32Memory0()[retptr / 4 + 1];
57
- let v3;
58
- if (r0 !== 0) {
59
- v3 = getArrayU8FromWasm0(r0, r1).slice();
60
- wasm.__wbindgen_free(r0, r1 * 1, 1);
61
- }
62
- return v3;
63
- } finally {
64
- 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);
65
48
  }
49
+ return v3;
66
50
  }
67
51
 
68
52
  /**
69
- * @param {Uint8Array} blacks
70
- * @param {Uint8Array} whites
71
- * @param {boolean} black
72
- * @param {number} limit
73
- * @returns {Uint8Array | undefined}
74
- */
53
+ * @param {Uint8Array} blacks
54
+ * @param {Uint8Array} whites
55
+ * @param {boolean} black
56
+ * @param {number} limit
57
+ * @returns {Uint8Array | undefined}
58
+ */
75
59
  export function solve_vcf(blacks, whites, black, limit) {
76
- try {
77
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
78
- const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
79
- const len0 = WASM_VECTOR_LEN;
80
- const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
81
- const len1 = WASM_VECTOR_LEN;
82
- wasm.solve_vcf(retptr, ptr0, len0, ptr1, len1, black, limit);
83
- var r0 = getInt32Memory0()[retptr / 4 + 0];
84
- var r1 = getInt32Memory0()[retptr / 4 + 1];
85
- let v3;
86
- if (r0 !== 0) {
87
- v3 = getArrayU8FromWasm0(r0, r1).slice();
88
- wasm.__wbindgen_free(r0, r1 * 1, 1);
89
- }
90
- return v3;
91
- } finally {
92
- 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);
93
69
  }
70
+ return v3;
94
71
  }
95
72
 
96
73
  /**
97
- * @param {Uint8Array} blacks
98
- * @param {Uint8Array} whites
99
- * @param {boolean} black
100
- * @param {number} limit
101
- * @returns {Uint8Array | undefined}
102
- */
74
+ * @param {Uint8Array} blacks
75
+ * @param {Uint8Array} whites
76
+ * @param {boolean} black
77
+ * @param {number} limit
78
+ * @returns {Uint8Array | undefined}
79
+ */
103
80
  export function solve_vct(blacks, whites, black, limit) {
104
- try {
105
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
106
- const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
107
- const len0 = WASM_VECTOR_LEN;
108
- const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
109
- const len1 = WASM_VECTOR_LEN;
110
- wasm.solve_vct(retptr, ptr0, len0, ptr1, len1, black, limit);
111
- var r0 = getInt32Memory0()[retptr / 4 + 0];
112
- var r1 = getInt32Memory0()[retptr / 4 + 1];
113
- let v3;
114
- if (r0 !== 0) {
115
- v3 = getArrayU8FromWasm0(r0, r1).slice();
116
- wasm.__wbindgen_free(r0, r1 * 1, 1);
117
- }
118
- return v3;
119
- } finally {
120
- 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);
121
90
  }
91
+ return v3;
122
92
  }
123
93
 
124
94
  /**
125
- * @param {Uint8Array} blacks
126
- * @param {Uint8Array} whites
127
- * @param {boolean} black
128
- * @param {number} limit
129
- * @returns {Uint8Array | undefined}
130
- */
95
+ * @param {Uint8Array} blacks
96
+ * @param {Uint8Array} whites
97
+ * @param {boolean} black
98
+ * @param {number} limit
99
+ * @returns {Uint8Array | undefined}
100
+ */
131
101
  export function solve_vct_dfpn(blacks, whites, black, limit) {
132
- try {
133
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
134
- const ptr0 = passArray8ToWasm0(blacks, wasm.__wbindgen_malloc);
135
- const len0 = WASM_VECTOR_LEN;
136
- const ptr1 = passArray8ToWasm0(whites, wasm.__wbindgen_malloc);
137
- const len1 = WASM_VECTOR_LEN;
138
- wasm.solve_vct_dfpn(retptr, ptr0, len0, ptr1, len1, black, limit);
139
- var r0 = getInt32Memory0()[retptr / 4 + 0];
140
- var r1 = getInt32Memory0()[retptr / 4 + 1];
141
- let v3;
142
- if (r0 !== 0) {
143
- v3 = getArrayU8FromWasm0(r0, r1).slice();
144
- wasm.__wbindgen_free(r0, r1 * 1, 1);
145
- }
146
- return v3;
147
- } finally {
148
- 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);
149
111
  }
112
+ return v3;
150
113
  }
151
-
152
- /**
153
- * @param {number} x
154
- * @param {number} y
155
- * @returns {number}
156
- */
157
- export function encode_xy(x, y) {
158
- const ret = wasm.encode_xy(x, y);
159
- 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);
160
126
  }
161
127
 
162
- /**
163
- * @param {number} code
164
- * @returns {number}
165
- */
166
- export function decode_x(code) {
167
- const ret = wasm.decode_x(code);
168
- 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;
169
134
  }
170
135
 
171
- /**
172
- * @param {number} code
173
- * @returns {number}
174
- */
175
- export function decode_y(code) {
176
- const ret = wasm.decode_y(code);
177
- 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;
178
141
  }
179
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