banqi 0.0.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/LICENSE +21 -0
- package/README.md +160 -0
- package/node/LICENSE +21 -0
- package/node/README.md +160 -0
- package/node/banqi_minimax.js +742 -0
- package/package.json +18 -0
- package/web/LICENSE +21 -0
- package/web/README.md +160 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JacobLinCool
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# banqi-minimax
|
|
2
|
+
|
|
3
|
+
High-performance game engine for **Banqi** (暗棋, Chinese Dark Chess) with Minimax and MCTS search algorithms, written in Rust.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Minimax Search** with alpha-beta pruning and transposition table
|
|
8
|
+
- **Monte Carlo Tree Search (MCTS)** with Dirichlet noise and chance node enumeration
|
|
9
|
+
- **Depth-1 flip caching** for dramatically faster expectimax evaluation
|
|
10
|
+
- **Parallel root evaluation** via Rayon work-stealing
|
|
11
|
+
- **Customizable game variants** (board size, piece counts, draw rules)
|
|
12
|
+
- Two material evaluation modes: **Static** (simple counting) and **Dynamic** (scarcity-adjusted)
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Add to your `Cargo.toml`:
|
|
17
|
+
|
|
18
|
+
```toml
|
|
19
|
+
[dependencies]
|
|
20
|
+
banqi-minimax = { git = "https://github.com/jacoblincool/banqi-minimax" }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Basic Example
|
|
24
|
+
|
|
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};
|
|
29
|
+
|
|
30
|
+
let spec = VariantSpec::standard();
|
|
31
|
+
let state = make_test_state(42, 16, &spec); // seed=42, 16 pieces revealed
|
|
32
|
+
|
|
33
|
+
let scores = minimax_scores_one(state, 3, &spec, EvalMode::Dynamic);
|
|
34
|
+
// scores[action] = expected value for each legal action
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Arena (Self-Play)
|
|
38
|
+
|
|
39
|
+
Compare Static vs Dynamic evaluation:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cargo run --features cli --release --bin arena -- --games 10 --depth 3
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Python (PyO3 + Maturin)
|
|
46
|
+
|
|
47
|
+
Build and install the local extension module:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
maturin develop --features python
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from banqi_minimax import BanqiGame, VariantSpec
|
|
57
|
+
|
|
58
|
+
variant = VariantSpec.standard()
|
|
59
|
+
game = BanqiGame.make_test(seed=42, reveal_count=8, variant=variant)
|
|
60
|
+
scores = game.minimax_scores(depth=2, eval_mode="dynamic")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Smoke test:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pytest python/tests/test_bindings_smoke.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### WebAssembly (wasm-bindgen + wasm-pack + Vite)
|
|
70
|
+
|
|
71
|
+
Run the browser minimax playground with Vite:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd examples/wasm-web
|
|
75
|
+
pnpm install
|
|
76
|
+
pnpm dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The Vite scripts call `wasm-pack` and generate `examples/wasm-web/pkg/`.
|
|
80
|
+
|
|
81
|
+
Build Node package and run smoke test:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi_minimax . --features wasm
|
|
85
|
+
node examples/wasm-web/smoke-node.mjs
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Architecture
|
|
89
|
+
|
|
90
|
+
### State Representation
|
|
91
|
+
|
|
92
|
+
Game state is a fixed-size `[i16; 66]` array (132 bytes), passed by value (`Copy`):
|
|
93
|
+
|
|
94
|
+
| Index | Content |
|
|
95
|
+
| ----- | ------------------------------------------------ |
|
|
96
|
+
| 0-31 | Board cells (0=empty, 15=face-down, 1-14=pieces) |
|
|
97
|
+
| 32 | Side to move |
|
|
98
|
+
| 33 | No-capture ply counter |
|
|
99
|
+
| 34 | Ply count |
|
|
100
|
+
| 35 | Board size |
|
|
101
|
+
| 36-49 | Unflipped piece pool (14 types) |
|
|
102
|
+
| 50-63 | Captured piece counts (14 types) |
|
|
103
|
+
| 64-65 | Player color assignments |
|
|
104
|
+
|
|
105
|
+
### Search
|
|
106
|
+
|
|
107
|
+
- **Depth <= 3**: Parallel root evaluation (Rayon) without transposition table
|
|
108
|
+
- **Depth > 3**: Sequential evaluation with 4-way set-associative transposition table (262K entries)
|
|
109
|
+
- **Move ordering**: Captures > Quiet moves > Flips (O(n) partition)
|
|
110
|
+
- **Flip caching**: At depth 1, all flip actions share the same expected value since material evaluation is position-independent
|
|
111
|
+
|
|
112
|
+
### Modules
|
|
113
|
+
|
|
114
|
+
| Module | Description |
|
|
115
|
+
| --------------- | --------------------------------------------------- |
|
|
116
|
+
| `game::variant` | Game variant configuration (`VariantSpec`) |
|
|
117
|
+
| `game::logic` | Core game mechanics, legal actions, evaluation |
|
|
118
|
+
| `game::rng` | Deterministic RNG (SplitMix64) |
|
|
119
|
+
| `minimax` | Alpha-beta minimax with expectimax for chance nodes |
|
|
120
|
+
| `mcts` | Monte Carlo Tree Search with UCB exploration |
|
|
121
|
+
|
|
122
|
+
## Benchmarks
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cargo bench --bench minimax
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Typical results on Apple M1 Pro 2021 (depth 3, 16 revealed pieces):
|
|
129
|
+
|
|
130
|
+
| Metric | Value |
|
|
131
|
+
| ------- | ------- |
|
|
132
|
+
| Depth 2 | ~125 us |
|
|
133
|
+
| Depth 3 | ~6.5 ms |
|
|
134
|
+
| Depth 4 | ~6.3 s |
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Run tests
|
|
140
|
+
cargo test
|
|
141
|
+
|
|
142
|
+
# Check Python bindings compile
|
|
143
|
+
cargo check --features python
|
|
144
|
+
|
|
145
|
+
# Check wasm bindings compile
|
|
146
|
+
cargo check --target wasm32-unknown-unknown --features wasm
|
|
147
|
+
|
|
148
|
+
# Run snapshot tests
|
|
149
|
+
cargo test --test minimax_snapshot
|
|
150
|
+
|
|
151
|
+
# Update snapshots after intentional changes
|
|
152
|
+
cargo insta review
|
|
153
|
+
|
|
154
|
+
# Run benchmarks
|
|
155
|
+
cargo bench
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
package/node/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JacobLinCool
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/node/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# banqi-minimax
|
|
2
|
+
|
|
3
|
+
High-performance game engine for **Banqi** (暗棋, Chinese Dark Chess) with Minimax and MCTS search algorithms, written in Rust.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Minimax Search** with alpha-beta pruning and transposition table
|
|
8
|
+
- **Monte Carlo Tree Search (MCTS)** with Dirichlet noise and chance node enumeration
|
|
9
|
+
- **Depth-1 flip caching** for dramatically faster expectimax evaluation
|
|
10
|
+
- **Parallel root evaluation** via Rayon work-stealing
|
|
11
|
+
- **Customizable game variants** (board size, piece counts, draw rules)
|
|
12
|
+
- Two material evaluation modes: **Static** (simple counting) and **Dynamic** (scarcity-adjusted)
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Add to your `Cargo.toml`:
|
|
17
|
+
|
|
18
|
+
```toml
|
|
19
|
+
[dependencies]
|
|
20
|
+
banqi-minimax = { git = "https://github.com/jacoblincool/banqi-minimax" }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Basic Example
|
|
24
|
+
|
|
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};
|
|
29
|
+
|
|
30
|
+
let spec = VariantSpec::standard();
|
|
31
|
+
let state = make_test_state(42, 16, &spec); // seed=42, 16 pieces revealed
|
|
32
|
+
|
|
33
|
+
let scores = minimax_scores_one(state, 3, &spec, EvalMode::Dynamic);
|
|
34
|
+
// scores[action] = expected value for each legal action
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Arena (Self-Play)
|
|
38
|
+
|
|
39
|
+
Compare Static vs Dynamic evaluation:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cargo run --features cli --release --bin arena -- --games 10 --depth 3
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Python (PyO3 + Maturin)
|
|
46
|
+
|
|
47
|
+
Build and install the local extension module:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
maturin develop --features python
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from banqi_minimax import BanqiGame, VariantSpec
|
|
57
|
+
|
|
58
|
+
variant = VariantSpec.standard()
|
|
59
|
+
game = BanqiGame.make_test(seed=42, reveal_count=8, variant=variant)
|
|
60
|
+
scores = game.minimax_scores(depth=2, eval_mode="dynamic")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Smoke test:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pytest python/tests/test_bindings_smoke.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### WebAssembly (wasm-bindgen + wasm-pack + Vite)
|
|
70
|
+
|
|
71
|
+
Run the browser minimax playground with Vite:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd examples/wasm-web
|
|
75
|
+
pnpm install
|
|
76
|
+
pnpm dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The Vite scripts call `wasm-pack` and generate `examples/wasm-web/pkg/`.
|
|
80
|
+
|
|
81
|
+
Build Node package and run smoke test:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi_minimax . --features wasm
|
|
85
|
+
node examples/wasm-web/smoke-node.mjs
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Architecture
|
|
89
|
+
|
|
90
|
+
### State Representation
|
|
91
|
+
|
|
92
|
+
Game state is a fixed-size `[i16; 66]` array (132 bytes), passed by value (`Copy`):
|
|
93
|
+
|
|
94
|
+
| Index | Content |
|
|
95
|
+
| ----- | ------------------------------------------------ |
|
|
96
|
+
| 0-31 | Board cells (0=empty, 15=face-down, 1-14=pieces) |
|
|
97
|
+
| 32 | Side to move |
|
|
98
|
+
| 33 | No-capture ply counter |
|
|
99
|
+
| 34 | Ply count |
|
|
100
|
+
| 35 | Board size |
|
|
101
|
+
| 36-49 | Unflipped piece pool (14 types) |
|
|
102
|
+
| 50-63 | Captured piece counts (14 types) |
|
|
103
|
+
| 64-65 | Player color assignments |
|
|
104
|
+
|
|
105
|
+
### Search
|
|
106
|
+
|
|
107
|
+
- **Depth <= 3**: Parallel root evaluation (Rayon) without transposition table
|
|
108
|
+
- **Depth > 3**: Sequential evaluation with 4-way set-associative transposition table (262K entries)
|
|
109
|
+
- **Move ordering**: Captures > Quiet moves > Flips (O(n) partition)
|
|
110
|
+
- **Flip caching**: At depth 1, all flip actions share the same expected value since material evaluation is position-independent
|
|
111
|
+
|
|
112
|
+
### Modules
|
|
113
|
+
|
|
114
|
+
| Module | Description |
|
|
115
|
+
| --------------- | --------------------------------------------------- |
|
|
116
|
+
| `game::variant` | Game variant configuration (`VariantSpec`) |
|
|
117
|
+
| `game::logic` | Core game mechanics, legal actions, evaluation |
|
|
118
|
+
| `game::rng` | Deterministic RNG (SplitMix64) |
|
|
119
|
+
| `minimax` | Alpha-beta minimax with expectimax for chance nodes |
|
|
120
|
+
| `mcts` | Monte Carlo Tree Search with UCB exploration |
|
|
121
|
+
|
|
122
|
+
## Benchmarks
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cargo bench --bench minimax
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Typical results on Apple M1 Pro 2021 (depth 3, 16 revealed pieces):
|
|
129
|
+
|
|
130
|
+
| Metric | Value |
|
|
131
|
+
| ------- | ------- |
|
|
132
|
+
| Depth 2 | ~125 us |
|
|
133
|
+
| Depth 3 | ~6.5 ms |
|
|
134
|
+
| Depth 4 | ~6.3 s |
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Run tests
|
|
140
|
+
cargo test
|
|
141
|
+
|
|
142
|
+
# Check Python bindings compile
|
|
143
|
+
cargo check --features python
|
|
144
|
+
|
|
145
|
+
# Check wasm bindings compile
|
|
146
|
+
cargo check --target wasm32-unknown-unknown --features wasm
|
|
147
|
+
|
|
148
|
+
# Run snapshot tests
|
|
149
|
+
cargo test --test minimax_snapshot
|
|
150
|
+
|
|
151
|
+
# Update snapshots after intentional changes
|
|
152
|
+
cargo insta review
|
|
153
|
+
|
|
154
|
+
# Run benchmarks
|
|
155
|
+
cargo bench
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
/* @ts-self-types="./banqi_minimax.d.ts" */
|
|
2
|
+
|
|
3
|
+
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
|
+
exports.BanqiGameWasm = BanqiGameWasm;
|
|
125
|
+
|
|
126
|
+
class CollectLeavesResultWasm {
|
|
127
|
+
static __wrap(ptr) {
|
|
128
|
+
ptr = ptr >>> 0;
|
|
129
|
+
const obj = Object.create(CollectLeavesResultWasm.prototype);
|
|
130
|
+
obj.__wbg_ptr = ptr;
|
|
131
|
+
CollectLeavesResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
132
|
+
return obj;
|
|
133
|
+
}
|
|
134
|
+
__destroy_into_raw() {
|
|
135
|
+
const ptr = this.__wbg_ptr;
|
|
136
|
+
this.__wbg_ptr = 0;
|
|
137
|
+
CollectLeavesResultWasmFinalization.unregister(this);
|
|
138
|
+
return ptr;
|
|
139
|
+
}
|
|
140
|
+
free() {
|
|
141
|
+
const ptr = this.__destroy_into_raw();
|
|
142
|
+
wasm.__wbg_collectleavesresultwasm_free(ptr, 0);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @returns {Int32Array}
|
|
146
|
+
*/
|
|
147
|
+
get leafIds() {
|
|
148
|
+
const ret = wasm.collectleavesresultwasm_leafIds(this.__wbg_ptr);
|
|
149
|
+
return ret;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @returns {Int16Array}
|
|
153
|
+
*/
|
|
154
|
+
get states() {
|
|
155
|
+
const ret = wasm.collectleavesresultwasm_states(this.__wbg_ptr);
|
|
156
|
+
return ret;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (Symbol.dispose) CollectLeavesResultWasm.prototype[Symbol.dispose] = CollectLeavesResultWasm.prototype.free;
|
|
160
|
+
exports.CollectLeavesResultWasm = CollectLeavesResultWasm;
|
|
161
|
+
|
|
162
|
+
class MctsResultWasm {
|
|
163
|
+
static __wrap(ptr) {
|
|
164
|
+
ptr = ptr >>> 0;
|
|
165
|
+
const obj = Object.create(MctsResultWasm.prototype);
|
|
166
|
+
obj.__wbg_ptr = ptr;
|
|
167
|
+
MctsResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
168
|
+
return obj;
|
|
169
|
+
}
|
|
170
|
+
__destroy_into_raw() {
|
|
171
|
+
const ptr = this.__wbg_ptr;
|
|
172
|
+
this.__wbg_ptr = 0;
|
|
173
|
+
MctsResultWasmFinalization.unregister(this);
|
|
174
|
+
return ptr;
|
|
175
|
+
}
|
|
176
|
+
free() {
|
|
177
|
+
const ptr = this.__destroy_into_raw();
|
|
178
|
+
wasm.__wbg_mctsresultwasm_free(ptr, 0);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @returns {number}
|
|
182
|
+
*/
|
|
183
|
+
get action() {
|
|
184
|
+
const ret = wasm.mctsresultwasm_action(this.__wbg_ptr);
|
|
185
|
+
return ret;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @returns {Float32Array}
|
|
189
|
+
*/
|
|
190
|
+
get policy() {
|
|
191
|
+
const ret = wasm.mctsresultwasm_policy(this.__wbg_ptr);
|
|
192
|
+
return ret;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (Symbol.dispose) MctsResultWasm.prototype[Symbol.dispose] = MctsResultWasm.prototype.free;
|
|
196
|
+
exports.MctsResultWasm = MctsResultWasm;
|
|
197
|
+
|
|
198
|
+
class MctsSessionWasm {
|
|
199
|
+
__destroy_into_raw() {
|
|
200
|
+
const ptr = this.__wbg_ptr;
|
|
201
|
+
this.__wbg_ptr = 0;
|
|
202
|
+
MctsSessionWasmFinalization.unregister(this);
|
|
203
|
+
return ptr;
|
|
204
|
+
}
|
|
205
|
+
free() {
|
|
206
|
+
const ptr = this.__destroy_into_raw();
|
|
207
|
+
wasm.__wbg_mctssessionwasm_free(ptr, 0);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* @returns {number}
|
|
211
|
+
*/
|
|
212
|
+
get actionSize() {
|
|
213
|
+
const ret = wasm.mctssessionwasm_actionSize(this.__wbg_ptr);
|
|
214
|
+
return ret >>> 0;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* @param {Int32Array} leaf_ids
|
|
218
|
+
* @param {Float32Array} priors_flat
|
|
219
|
+
* @param {number} prior_cols
|
|
220
|
+
* @param {Float32Array} values
|
|
221
|
+
*/
|
|
222
|
+
applyEvals(leaf_ids, priors_flat, prior_cols, values) {
|
|
223
|
+
const ret = wasm.mctssessionwasm_applyEvals(this.__wbg_ptr, leaf_ids, priors_flat, prior_cols, values);
|
|
224
|
+
if (ret[1]) {
|
|
225
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
close() {
|
|
229
|
+
wasm.mctssessionwasm_close(this.__wbg_ptr);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @returns {boolean}
|
|
233
|
+
*/
|
|
234
|
+
get closed() {
|
|
235
|
+
const ret = wasm.mctssessionwasm_closed(this.__wbg_ptr);
|
|
236
|
+
return ret !== 0;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @param {number} max_leaves
|
|
240
|
+
* @returns {CollectLeavesResultWasm}
|
|
241
|
+
*/
|
|
242
|
+
collectLeaves(max_leaves) {
|
|
243
|
+
const ret = wasm.mctssessionwasm_collectLeaves(this.__wbg_ptr, max_leaves);
|
|
244
|
+
if (ret[2]) {
|
|
245
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
246
|
+
}
|
|
247
|
+
return CollectLeavesResultWasm.__wrap(ret[0]);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* @returns {boolean}
|
|
251
|
+
*/
|
|
252
|
+
isDone() {
|
|
253
|
+
const ret = wasm.mctssessionwasm_isDone(this.__wbg_ptr);
|
|
254
|
+
if (ret[2]) {
|
|
255
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
256
|
+
}
|
|
257
|
+
return ret[0] !== 0;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* @param {Int16Array} root_state
|
|
261
|
+
* @param {VariantSpecWasm} variant
|
|
262
|
+
* @param {number} simulations
|
|
263
|
+
* @param {bigint} seed
|
|
264
|
+
* @param {number} c_puct
|
|
265
|
+
* @param {number} dirichlet_alpha
|
|
266
|
+
* @param {number} dirichlet_epsilon
|
|
267
|
+
* @param {boolean} root_chance_enumeration
|
|
268
|
+
* @param {bigint | null} [time_limit_ms]
|
|
269
|
+
* @param {Uint32Array | null} [action_mask]
|
|
270
|
+
*/
|
|
271
|
+
constructor(root_state, variant, simulations, seed, c_puct, dirichlet_alpha, dirichlet_epsilon, root_chance_enumeration, time_limit_ms, action_mask) {
|
|
272
|
+
_assertClass(variant, VariantSpecWasm);
|
|
273
|
+
var ptr0 = isLikeNone(action_mask) ? 0 : passArray32ToWasm0(action_mask, wasm.__wbindgen_malloc);
|
|
274
|
+
var len0 = WASM_VECTOR_LEN;
|
|
275
|
+
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);
|
|
276
|
+
if (ret[2]) {
|
|
277
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
278
|
+
}
|
|
279
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
280
|
+
MctsSessionWasmFinalization.register(this, this.__wbg_ptr, this);
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* @param {number} move_index
|
|
285
|
+
* @param {number} root_temperature_moves
|
|
286
|
+
* @returns {MctsResultWasm}
|
|
287
|
+
*/
|
|
288
|
+
result(move_index, root_temperature_moves) {
|
|
289
|
+
const ret = wasm.mctssessionwasm_result(this.__wbg_ptr, move_index, root_temperature_moves);
|
|
290
|
+
if (ret[2]) {
|
|
291
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
292
|
+
}
|
|
293
|
+
return MctsResultWasm.__wrap(ret[0]);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (Symbol.dispose) MctsSessionWasm.prototype[Symbol.dispose] = MctsSessionWasm.prototype.free;
|
|
297
|
+
exports.MctsSessionWasm = MctsSessionWasm;
|
|
298
|
+
|
|
299
|
+
class StepResultWasm {
|
|
300
|
+
static __wrap(ptr) {
|
|
301
|
+
ptr = ptr >>> 0;
|
|
302
|
+
const obj = Object.create(StepResultWasm.prototype);
|
|
303
|
+
obj.__wbg_ptr = ptr;
|
|
304
|
+
StepResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
305
|
+
return obj;
|
|
306
|
+
}
|
|
307
|
+
__destroy_into_raw() {
|
|
308
|
+
const ptr = this.__wbg_ptr;
|
|
309
|
+
this.__wbg_ptr = 0;
|
|
310
|
+
StepResultWasmFinalization.unregister(this);
|
|
311
|
+
return ptr;
|
|
312
|
+
}
|
|
313
|
+
free() {
|
|
314
|
+
const ptr = this.__destroy_into_raw();
|
|
315
|
+
wasm.__wbg_stepresultwasm_free(ptr, 0);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @returns {boolean}
|
|
319
|
+
*/
|
|
320
|
+
get done() {
|
|
321
|
+
const ret = wasm.stepresultwasm_done(this.__wbg_ptr);
|
|
322
|
+
return ret !== 0;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @returns {boolean}
|
|
326
|
+
*/
|
|
327
|
+
get draw() {
|
|
328
|
+
const ret = wasm.stepresultwasm_draw(this.__wbg_ptr);
|
|
329
|
+
return ret !== 0;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @returns {number}
|
|
333
|
+
*/
|
|
334
|
+
get reward() {
|
|
335
|
+
const ret = wasm.stepresultwasm_reward(this.__wbg_ptr);
|
|
336
|
+
return ret;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* @returns {Int16Array}
|
|
340
|
+
*/
|
|
341
|
+
get state() {
|
|
342
|
+
const ret = wasm.stepresultwasm_state(this.__wbg_ptr);
|
|
343
|
+
return ret;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @returns {number}
|
|
347
|
+
*/
|
|
348
|
+
get winner() {
|
|
349
|
+
const ret = wasm.stepresultwasm_winner(this.__wbg_ptr);
|
|
350
|
+
return ret;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (Symbol.dispose) StepResultWasm.prototype[Symbol.dispose] = StepResultWasm.prototype.free;
|
|
354
|
+
exports.StepResultWasm = StepResultWasm;
|
|
355
|
+
|
|
356
|
+
class VariantSpecWasm {
|
|
357
|
+
static __wrap(ptr) {
|
|
358
|
+
ptr = ptr >>> 0;
|
|
359
|
+
const obj = Object.create(VariantSpecWasm.prototype);
|
|
360
|
+
obj.__wbg_ptr = ptr;
|
|
361
|
+
VariantSpecWasmFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
362
|
+
return obj;
|
|
363
|
+
}
|
|
364
|
+
__destroy_into_raw() {
|
|
365
|
+
const ptr = this.__wbg_ptr;
|
|
366
|
+
this.__wbg_ptr = 0;
|
|
367
|
+
VariantSpecWasmFinalization.unregister(this);
|
|
368
|
+
return ptr;
|
|
369
|
+
}
|
|
370
|
+
free() {
|
|
371
|
+
const ptr = this.__destroy_into_raw();
|
|
372
|
+
wasm.__wbg_variantspecwasm_free(ptr, 0);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* @returns {number}
|
|
376
|
+
*/
|
|
377
|
+
get actionSize() {
|
|
378
|
+
const ret = wasm.variantspecwasm_actionSize(this.__wbg_ptr);
|
|
379
|
+
return ret >>> 0;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* @returns {number}
|
|
383
|
+
*/
|
|
384
|
+
get boardHeight() {
|
|
385
|
+
const ret = wasm.mctsresultwasm_action(this.__wbg_ptr);
|
|
386
|
+
return ret >>> 0;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @returns {number}
|
|
390
|
+
*/
|
|
391
|
+
get boardSize() {
|
|
392
|
+
const ret = wasm.variantspecwasm_boardSize(this.__wbg_ptr);
|
|
393
|
+
return ret >>> 0;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* @returns {number}
|
|
397
|
+
*/
|
|
398
|
+
get boardWidth() {
|
|
399
|
+
const ret = wasm.variantspecwasm_boardWidth(this.__wbg_ptr);
|
|
400
|
+
return ret >>> 0;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @param {string} variant_name
|
|
404
|
+
* @param {number} board_height
|
|
405
|
+
* @param {number} board_width
|
|
406
|
+
* @param {Int16Array} piece_counts_per_color
|
|
407
|
+
* @param {number} no_capture_draw_plies
|
|
408
|
+
* @param {number} max_episode_steps
|
|
409
|
+
* @returns {VariantSpecWasm}
|
|
410
|
+
*/
|
|
411
|
+
static create(variant_name, board_height, board_width, piece_counts_per_color, no_capture_draw_plies, max_episode_steps) {
|
|
412
|
+
const ptr0 = passStringToWasm0(variant_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
413
|
+
const len0 = WASM_VECTOR_LEN;
|
|
414
|
+
const ret = wasm.variantspecwasm_create(ptr0, len0, board_height, board_width, piece_counts_per_color, no_capture_draw_plies, max_episode_steps);
|
|
415
|
+
if (ret[2]) {
|
|
416
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
417
|
+
}
|
|
418
|
+
return VariantSpecWasm.__wrap(ret[0]);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* @returns {number}
|
|
422
|
+
*/
|
|
423
|
+
get maxEpisodeSteps() {
|
|
424
|
+
const ret = wasm.variantspecwasm_maxEpisodeSteps(this.__wbg_ptr);
|
|
425
|
+
return ret >>> 0;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* @returns {number}
|
|
429
|
+
*/
|
|
430
|
+
get noCaptureDrawPlies() {
|
|
431
|
+
const ret = wasm.variantspecwasm_noCaptureDrawPlies(this.__wbg_ptr);
|
|
432
|
+
return ret;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @returns {Int16Array}
|
|
436
|
+
*/
|
|
437
|
+
get pieceCountsPerColor() {
|
|
438
|
+
const ret = wasm.variantspecwasm_pieceCountsPerColor(this.__wbg_ptr);
|
|
439
|
+
return ret;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* @returns {VariantSpecWasm}
|
|
443
|
+
*/
|
|
444
|
+
static standard() {
|
|
445
|
+
const ret = wasm.variantspecwasm_standard();
|
|
446
|
+
return VariantSpecWasm.__wrap(ret);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* @returns {string}
|
|
450
|
+
*/
|
|
451
|
+
get variantName() {
|
|
452
|
+
let deferred1_0;
|
|
453
|
+
let deferred1_1;
|
|
454
|
+
try {
|
|
455
|
+
const ret = wasm.variantspecwasm_variantName(this.__wbg_ptr);
|
|
456
|
+
deferred1_0 = ret[0];
|
|
457
|
+
deferred1_1 = ret[1];
|
|
458
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
459
|
+
} finally {
|
|
460
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (Symbol.dispose) VariantSpecWasm.prototype[Symbol.dispose] = VariantSpecWasm.prototype.free;
|
|
465
|
+
exports.VariantSpecWasm = VariantSpecWasm;
|
|
466
|
+
|
|
467
|
+
function __wbg_get_imports() {
|
|
468
|
+
const import0 = {
|
|
469
|
+
__proto__: null,
|
|
470
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
471
|
+
const ret = arg0 === undefined;
|
|
472
|
+
return ret;
|
|
473
|
+
},
|
|
474
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
475
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
476
|
+
},
|
|
477
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
478
|
+
const ret = arg0.call(arg1);
|
|
479
|
+
return ret;
|
|
480
|
+
}, arguments); },
|
|
481
|
+
__wbg_length_500e25dbc316fd13: function(arg0) {
|
|
482
|
+
const ret = arg0.length;
|
|
483
|
+
return ret;
|
|
484
|
+
},
|
|
485
|
+
__wbg_length_9a7876c9728a0979: function(arg0) {
|
|
486
|
+
const ret = arg0.length;
|
|
487
|
+
return ret;
|
|
488
|
+
},
|
|
489
|
+
__wbg_length_b1593d937f31cef9: function(arg0) {
|
|
490
|
+
const ret = arg0.length;
|
|
491
|
+
return ret;
|
|
492
|
+
},
|
|
493
|
+
__wbg_new_from_slice_132ef6dc5072cf68: function(arg0, arg1) {
|
|
494
|
+
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
495
|
+
return ret;
|
|
496
|
+
},
|
|
497
|
+
__wbg_new_from_slice_1c1c42c5954b2701: function(arg0, arg1) {
|
|
498
|
+
const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
|
|
499
|
+
return ret;
|
|
500
|
+
},
|
|
501
|
+
__wbg_new_from_slice_b5d5e7773e9f2033: function(arg0, arg1) {
|
|
502
|
+
const ret = new Int16Array(getArrayI16FromWasm0(arg0, arg1));
|
|
503
|
+
return ret;
|
|
504
|
+
},
|
|
505
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
506
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
507
|
+
return ret;
|
|
508
|
+
},
|
|
509
|
+
__wbg_now_2c95c9de01293173: function(arg0) {
|
|
510
|
+
const ret = arg0.now();
|
|
511
|
+
return ret;
|
|
512
|
+
},
|
|
513
|
+
__wbg_performance_7a3ffd0b17f663ad: function(arg0) {
|
|
514
|
+
const ret = arg0.performance;
|
|
515
|
+
return ret;
|
|
516
|
+
},
|
|
517
|
+
__wbg_prototypesetcall_55c7bc6bcd6a9457: function(arg0, arg1, arg2) {
|
|
518
|
+
Int16Array.prototype.set.call(getArrayI16FromWasm0(arg0, arg1), arg2);
|
|
519
|
+
},
|
|
520
|
+
__wbg_prototypesetcall_c7e6a26aeade796d: function(arg0, arg1, arg2) {
|
|
521
|
+
Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
|
|
522
|
+
},
|
|
523
|
+
__wbg_prototypesetcall_f8118a9f36fee41e: function(arg0, arg1, arg2) {
|
|
524
|
+
Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), arg2);
|
|
525
|
+
},
|
|
526
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
527
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
528
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
529
|
+
},
|
|
530
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
531
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
532
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
533
|
+
},
|
|
534
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
535
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
536
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
537
|
+
},
|
|
538
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
539
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
540
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
541
|
+
},
|
|
542
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
543
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
544
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
545
|
+
return ret;
|
|
546
|
+
},
|
|
547
|
+
__wbindgen_init_externref_table: function() {
|
|
548
|
+
const table = wasm.__wbindgen_externrefs;
|
|
549
|
+
const offset = table.grow(4);
|
|
550
|
+
table.set(0, undefined);
|
|
551
|
+
table.set(offset + 0, undefined);
|
|
552
|
+
table.set(offset + 1, null);
|
|
553
|
+
table.set(offset + 2, true);
|
|
554
|
+
table.set(offset + 3, false);
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
return {
|
|
558
|
+
__proto__: null,
|
|
559
|
+
"./banqi_minimax_bg.js": import0,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const BanqiGameWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
564
|
+
? { register: () => {}, unregister: () => {} }
|
|
565
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_banqigamewasm_free(ptr >>> 0, 1));
|
|
566
|
+
const CollectLeavesResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
567
|
+
? { register: () => {}, unregister: () => {} }
|
|
568
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_collectleavesresultwasm_free(ptr >>> 0, 1));
|
|
569
|
+
const MctsResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
570
|
+
? { register: () => {}, unregister: () => {} }
|
|
571
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mctsresultwasm_free(ptr >>> 0, 1));
|
|
572
|
+
const MctsSessionWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
573
|
+
? { register: () => {}, unregister: () => {} }
|
|
574
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mctssessionwasm_free(ptr >>> 0, 1));
|
|
575
|
+
const StepResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
576
|
+
? { register: () => {}, unregister: () => {} }
|
|
577
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_stepresultwasm_free(ptr >>> 0, 1));
|
|
578
|
+
const VariantSpecWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
579
|
+
? { register: () => {}, unregister: () => {} }
|
|
580
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_variantspecwasm_free(ptr >>> 0, 1));
|
|
581
|
+
|
|
582
|
+
function addToExternrefTable0(obj) {
|
|
583
|
+
const idx = wasm.__externref_table_alloc();
|
|
584
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
585
|
+
return idx;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function _assertClass(instance, klass) {
|
|
589
|
+
if (!(instance instanceof klass)) {
|
|
590
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
595
|
+
ptr = ptr >>> 0;
|
|
596
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function getArrayI16FromWasm0(ptr, len) {
|
|
600
|
+
ptr = ptr >>> 0;
|
|
601
|
+
return getInt16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
605
|
+
ptr = ptr >>> 0;
|
|
606
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
610
|
+
function getFloat32ArrayMemory0() {
|
|
611
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
612
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
613
|
+
}
|
|
614
|
+
return cachedFloat32ArrayMemory0;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
let cachedInt16ArrayMemory0 = null;
|
|
618
|
+
function getInt16ArrayMemory0() {
|
|
619
|
+
if (cachedInt16ArrayMemory0 === null || cachedInt16ArrayMemory0.byteLength === 0) {
|
|
620
|
+
cachedInt16ArrayMemory0 = new Int16Array(wasm.memory.buffer);
|
|
621
|
+
}
|
|
622
|
+
return cachedInt16ArrayMemory0;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
let cachedInt32ArrayMemory0 = null;
|
|
626
|
+
function getInt32ArrayMemory0() {
|
|
627
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
628
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
629
|
+
}
|
|
630
|
+
return cachedInt32ArrayMemory0;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function getStringFromWasm0(ptr, len) {
|
|
634
|
+
ptr = ptr >>> 0;
|
|
635
|
+
return decodeText(ptr, len);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
let cachedUint32ArrayMemory0 = null;
|
|
639
|
+
function getUint32ArrayMemory0() {
|
|
640
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
641
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
642
|
+
}
|
|
643
|
+
return cachedUint32ArrayMemory0;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
let cachedUint8ArrayMemory0 = null;
|
|
647
|
+
function getUint8ArrayMemory0() {
|
|
648
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
649
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
650
|
+
}
|
|
651
|
+
return cachedUint8ArrayMemory0;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function handleError(f, args) {
|
|
655
|
+
try {
|
|
656
|
+
return f.apply(this, args);
|
|
657
|
+
} catch (e) {
|
|
658
|
+
const idx = addToExternrefTable0(e);
|
|
659
|
+
wasm.__wbindgen_exn_store(idx);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function isLikeNone(x) {
|
|
664
|
+
return x === undefined || x === null;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
668
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
669
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
670
|
+
WASM_VECTOR_LEN = arg.length;
|
|
671
|
+
return ptr;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
675
|
+
if (realloc === undefined) {
|
|
676
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
677
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
678
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
679
|
+
WASM_VECTOR_LEN = buf.length;
|
|
680
|
+
return ptr;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
let len = arg.length;
|
|
684
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
685
|
+
|
|
686
|
+
const mem = getUint8ArrayMemory0();
|
|
687
|
+
|
|
688
|
+
let offset = 0;
|
|
689
|
+
|
|
690
|
+
for (; offset < len; offset++) {
|
|
691
|
+
const code = arg.charCodeAt(offset);
|
|
692
|
+
if (code > 0x7F) break;
|
|
693
|
+
mem[ptr + offset] = code;
|
|
694
|
+
}
|
|
695
|
+
if (offset !== len) {
|
|
696
|
+
if (offset !== 0) {
|
|
697
|
+
arg = arg.slice(offset);
|
|
698
|
+
}
|
|
699
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
700
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
701
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
702
|
+
|
|
703
|
+
offset += ret.written;
|
|
704
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
WASM_VECTOR_LEN = offset;
|
|
708
|
+
return ptr;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function takeFromExternrefTable0(idx) {
|
|
712
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
713
|
+
wasm.__externref_table_dealloc(idx);
|
|
714
|
+
return value;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
718
|
+
cachedTextDecoder.decode();
|
|
719
|
+
function decodeText(ptr, len) {
|
|
720
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const cachedTextEncoder = new TextEncoder();
|
|
724
|
+
|
|
725
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
726
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
727
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
728
|
+
view.set(buf);
|
|
729
|
+
return {
|
|
730
|
+
read: arg.length,
|
|
731
|
+
written: buf.length
|
|
732
|
+
};
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
let WASM_VECTOR_LEN = 0;
|
|
737
|
+
|
|
738
|
+
const wasmPath = `${__dirname}/banqi_minimax_bg.wasm`;
|
|
739
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
740
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
741
|
+
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
742
|
+
wasm.__wbindgen_start();
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "banqi",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Banqi engine for Node and Web (WASM)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"node",
|
|
8
|
+
"web",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"main": "./node/banqi_minimax.js",
|
|
13
|
+
"types": "./node/banqi_minimax.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./node/banqi_minimax.js",
|
|
16
|
+
"./web": "./web/banqi_minimax.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/web/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JacobLinCool
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/web/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# banqi-minimax
|
|
2
|
+
|
|
3
|
+
High-performance game engine for **Banqi** (暗棋, Chinese Dark Chess) with Minimax and MCTS search algorithms, written in Rust.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Minimax Search** with alpha-beta pruning and transposition table
|
|
8
|
+
- **Monte Carlo Tree Search (MCTS)** with Dirichlet noise and chance node enumeration
|
|
9
|
+
- **Depth-1 flip caching** for dramatically faster expectimax evaluation
|
|
10
|
+
- **Parallel root evaluation** via Rayon work-stealing
|
|
11
|
+
- **Customizable game variants** (board size, piece counts, draw rules)
|
|
12
|
+
- Two material evaluation modes: **Static** (simple counting) and **Dynamic** (scarcity-adjusted)
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Add to your `Cargo.toml`:
|
|
17
|
+
|
|
18
|
+
```toml
|
|
19
|
+
[dependencies]
|
|
20
|
+
banqi-minimax = { git = "https://github.com/jacoblincool/banqi-minimax" }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Basic Example
|
|
24
|
+
|
|
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};
|
|
29
|
+
|
|
30
|
+
let spec = VariantSpec::standard();
|
|
31
|
+
let state = make_test_state(42, 16, &spec); // seed=42, 16 pieces revealed
|
|
32
|
+
|
|
33
|
+
let scores = minimax_scores_one(state, 3, &spec, EvalMode::Dynamic);
|
|
34
|
+
// scores[action] = expected value for each legal action
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Arena (Self-Play)
|
|
38
|
+
|
|
39
|
+
Compare Static vs Dynamic evaluation:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cargo run --features cli --release --bin arena -- --games 10 --depth 3
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Python (PyO3 + Maturin)
|
|
46
|
+
|
|
47
|
+
Build and install the local extension module:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
maturin develop --features python
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from banqi_minimax import BanqiGame, VariantSpec
|
|
57
|
+
|
|
58
|
+
variant = VariantSpec.standard()
|
|
59
|
+
game = BanqiGame.make_test(seed=42, reveal_count=8, variant=variant)
|
|
60
|
+
scores = game.minimax_scores(depth=2, eval_mode="dynamic")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Smoke test:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pytest python/tests/test_bindings_smoke.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### WebAssembly (wasm-bindgen + wasm-pack + Vite)
|
|
70
|
+
|
|
71
|
+
Run the browser minimax playground with Vite:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd examples/wasm-web
|
|
75
|
+
pnpm install
|
|
76
|
+
pnpm dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The Vite scripts call `wasm-pack` and generate `examples/wasm-web/pkg/`.
|
|
80
|
+
|
|
81
|
+
Build Node package and run smoke test:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
wasm-pack build --target nodejs --out-dir pkg-node --out-name banqi_minimax . --features wasm
|
|
85
|
+
node examples/wasm-web/smoke-node.mjs
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Architecture
|
|
89
|
+
|
|
90
|
+
### State Representation
|
|
91
|
+
|
|
92
|
+
Game state is a fixed-size `[i16; 66]` array (132 bytes), passed by value (`Copy`):
|
|
93
|
+
|
|
94
|
+
| Index | Content |
|
|
95
|
+
| ----- | ------------------------------------------------ |
|
|
96
|
+
| 0-31 | Board cells (0=empty, 15=face-down, 1-14=pieces) |
|
|
97
|
+
| 32 | Side to move |
|
|
98
|
+
| 33 | No-capture ply counter |
|
|
99
|
+
| 34 | Ply count |
|
|
100
|
+
| 35 | Board size |
|
|
101
|
+
| 36-49 | Unflipped piece pool (14 types) |
|
|
102
|
+
| 50-63 | Captured piece counts (14 types) |
|
|
103
|
+
| 64-65 | Player color assignments |
|
|
104
|
+
|
|
105
|
+
### Search
|
|
106
|
+
|
|
107
|
+
- **Depth <= 3**: Parallel root evaluation (Rayon) without transposition table
|
|
108
|
+
- **Depth > 3**: Sequential evaluation with 4-way set-associative transposition table (262K entries)
|
|
109
|
+
- **Move ordering**: Captures > Quiet moves > Flips (O(n) partition)
|
|
110
|
+
- **Flip caching**: At depth 1, all flip actions share the same expected value since material evaluation is position-independent
|
|
111
|
+
|
|
112
|
+
### Modules
|
|
113
|
+
|
|
114
|
+
| Module | Description |
|
|
115
|
+
| --------------- | --------------------------------------------------- |
|
|
116
|
+
| `game::variant` | Game variant configuration (`VariantSpec`) |
|
|
117
|
+
| `game::logic` | Core game mechanics, legal actions, evaluation |
|
|
118
|
+
| `game::rng` | Deterministic RNG (SplitMix64) |
|
|
119
|
+
| `minimax` | Alpha-beta minimax with expectimax for chance nodes |
|
|
120
|
+
| `mcts` | Monte Carlo Tree Search with UCB exploration |
|
|
121
|
+
|
|
122
|
+
## Benchmarks
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cargo bench --bench minimax
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Typical results on Apple M1 Pro 2021 (depth 3, 16 revealed pieces):
|
|
129
|
+
|
|
130
|
+
| Metric | Value |
|
|
131
|
+
| ------- | ------- |
|
|
132
|
+
| Depth 2 | ~125 us |
|
|
133
|
+
| Depth 3 | ~6.5 ms |
|
|
134
|
+
| Depth 4 | ~6.3 s |
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Run tests
|
|
140
|
+
cargo test
|
|
141
|
+
|
|
142
|
+
# Check Python bindings compile
|
|
143
|
+
cargo check --features python
|
|
144
|
+
|
|
145
|
+
# Check wasm bindings compile
|
|
146
|
+
cargo check --target wasm32-unknown-unknown --features wasm
|
|
147
|
+
|
|
148
|
+
# Run snapshot tests
|
|
149
|
+
cargo test --test minimax_snapshot
|
|
150
|
+
|
|
151
|
+
# Update snapshots after intentional changes
|
|
152
|
+
cargo insta review
|
|
153
|
+
|
|
154
|
+
# Run benchmarks
|
|
155
|
+
cargo bench
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|