sanqi-python 0.1.0__tar.gz
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.
- sanqi_python-0.1.0/Cargo.lock +163 -0
- sanqi_python-0.1.0/Cargo.toml +16 -0
- sanqi_python-0.1.0/PKG-INFO +76 -0
- sanqi_python-0.1.0/README.md +51 -0
- sanqi_python-0.1.0/crates/sanqi-core/Cargo.toml +19 -0
- sanqi_python-0.1.0/crates/sanqi-core/README.md +23 -0
- sanqi_python-0.1.0/crates/sanqi-core/src/lib.rs +950 -0
- sanqi_python-0.1.0/crates/sanqi-engine/Cargo.toml +22 -0
- sanqi_python-0.1.0/crates/sanqi-engine/README.md +23 -0
- sanqi_python-0.1.0/crates/sanqi-engine/src/lib.rs +1123 -0
- sanqi_python-0.1.0/crates/sanqi-python/Cargo.toml +25 -0
- sanqi_python-0.1.0/crates/sanqi-python/README.md +51 -0
- sanqi_python-0.1.0/crates/sanqi-python/src/lib.rs +240 -0
- sanqi_python-0.1.0/crates/sanqi-render/Cargo.toml +22 -0
- sanqi_python-0.1.0/crates/sanqi-render/README.md +22 -0
- sanqi_python-0.1.0/crates/sanqi-render/src/lib.rs +242 -0
- sanqi_python-0.1.0/pyproject.toml +35 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "heck"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "libc"
|
|
13
|
+
version = "0.2.184"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "once_cell"
|
|
19
|
+
version = "1.21.4"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "portable-atomic"
|
|
25
|
+
version = "1.13.1"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "proc-macro2"
|
|
31
|
+
version = "1.0.106"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"unicode-ident",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "pyo3"
|
|
40
|
+
version = "0.28.3"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"libc",
|
|
45
|
+
"once_cell",
|
|
46
|
+
"portable-atomic",
|
|
47
|
+
"pyo3-build-config",
|
|
48
|
+
"pyo3-ffi",
|
|
49
|
+
"pyo3-macros",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[package]]
|
|
53
|
+
name = "pyo3-build-config"
|
|
54
|
+
version = "0.28.3"
|
|
55
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
+
checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
|
|
57
|
+
dependencies = [
|
|
58
|
+
"target-lexicon",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[[package]]
|
|
62
|
+
name = "pyo3-ffi"
|
|
63
|
+
version = "0.28.3"
|
|
64
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
65
|
+
checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
|
|
66
|
+
dependencies = [
|
|
67
|
+
"libc",
|
|
68
|
+
"pyo3-build-config",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[[package]]
|
|
72
|
+
name = "pyo3-macros"
|
|
73
|
+
version = "0.28.3"
|
|
74
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
75
|
+
checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
|
|
76
|
+
dependencies = [
|
|
77
|
+
"proc-macro2",
|
|
78
|
+
"pyo3-macros-backend",
|
|
79
|
+
"quote",
|
|
80
|
+
"syn",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "pyo3-macros-backend"
|
|
85
|
+
version = "0.28.3"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
|
|
88
|
+
dependencies = [
|
|
89
|
+
"heck",
|
|
90
|
+
"proc-macro2",
|
|
91
|
+
"pyo3-build-config",
|
|
92
|
+
"quote",
|
|
93
|
+
"syn",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[[package]]
|
|
97
|
+
name = "quote"
|
|
98
|
+
version = "1.0.45"
|
|
99
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
100
|
+
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
|
101
|
+
dependencies = [
|
|
102
|
+
"proc-macro2",
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
[[package]]
|
|
106
|
+
name = "sanqi-cli"
|
|
107
|
+
version = "0.1.0"
|
|
108
|
+
dependencies = [
|
|
109
|
+
"sanqi-core",
|
|
110
|
+
"sanqi-engine",
|
|
111
|
+
"sanqi-render",
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
[[package]]
|
|
115
|
+
name = "sanqi-core"
|
|
116
|
+
version = "0.1.0"
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "sanqi-engine"
|
|
120
|
+
version = "0.1.0"
|
|
121
|
+
dependencies = [
|
|
122
|
+
"sanqi-core",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[[package]]
|
|
126
|
+
name = "sanqi-python"
|
|
127
|
+
version = "0.1.0"
|
|
128
|
+
dependencies = [
|
|
129
|
+
"pyo3",
|
|
130
|
+
"sanqi-core",
|
|
131
|
+
"sanqi-engine",
|
|
132
|
+
"sanqi-render",
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
[[package]]
|
|
136
|
+
name = "sanqi-render"
|
|
137
|
+
version = "0.1.0"
|
|
138
|
+
dependencies = [
|
|
139
|
+
"sanqi-core",
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
[[package]]
|
|
143
|
+
name = "syn"
|
|
144
|
+
version = "2.0.117"
|
|
145
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
+
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
|
147
|
+
dependencies = [
|
|
148
|
+
"proc-macro2",
|
|
149
|
+
"quote",
|
|
150
|
+
"unicode-ident",
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
[[package]]
|
|
154
|
+
name = "target-lexicon"
|
|
155
|
+
version = "0.13.5"
|
|
156
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
158
|
+
|
|
159
|
+
[[package]]
|
|
160
|
+
name = "unicode-ident"
|
|
161
|
+
version = "1.0.24"
|
|
162
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
163
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
members = ["crates/sanqi-core", "crates/sanqi-engine", "crates/sanqi-render", "crates/sanqi-python"]
|
|
3
|
+
resolver = "2"
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
edition = "2024"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
repository = "https://github.com/curoli/sanqi"
|
|
10
|
+
homepage = "https://github.com/curoli/sanqi"
|
|
11
|
+
rust-version = "1.85"
|
|
12
|
+
|
|
13
|
+
[workspace.lints.clippy]
|
|
14
|
+
dbg_macro = "deny"
|
|
15
|
+
todo = "deny"
|
|
16
|
+
unwrap_used = "deny"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sanqi-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Rust
|
|
14
|
+
Summary: Python bindings for the Sanqi Rust engine
|
|
15
|
+
Keywords: sanqi,board game,game engine,rust
|
|
16
|
+
Home-Page: https://github.com/curoli/sanqi
|
|
17
|
+
Author: Oliver Ruebenacker
|
|
18
|
+
License: MIT
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
21
|
+
Project-URL: Homepage, https://github.com/curoli/sanqi
|
|
22
|
+
Project-URL: Issues, https://github.com/curoli/sanqi/issues
|
|
23
|
+
Project-URL: Repository, https://github.com/curoli/sanqi
|
|
24
|
+
|
|
25
|
+
# sanqi-python
|
|
26
|
+
|
|
27
|
+
Python bindings for the Sanqi Rust engine.
|
|
28
|
+
|
|
29
|
+
## Build
|
|
30
|
+
|
|
31
|
+
From `crates/sanqi-python`:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
maturin develop
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or build a wheel:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
maturin build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Example
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import sanqi_python as sanqi
|
|
47
|
+
|
|
48
|
+
position = sanqi.Position.initial()
|
|
49
|
+
print(position.legal_moves()[:5])
|
|
50
|
+
|
|
51
|
+
move = position.best_move(2)
|
|
52
|
+
if move is not None:
|
|
53
|
+
svg = position.svg_for_move(move)
|
|
54
|
+
position.apply_move(move)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Exposed API
|
|
58
|
+
|
|
59
|
+
- `Position.initial()`
|
|
60
|
+
- `Position.empty("white" | "black")`
|
|
61
|
+
- `Position.legal_moves()`
|
|
62
|
+
- `Position.is_legal_move(move)`
|
|
63
|
+
- `Position.apply_move(move)`
|
|
64
|
+
- `Position.piece_at(square)`
|
|
65
|
+
- `Position.set_piece(color, square)`
|
|
66
|
+
- `Position.clear_square(square)`
|
|
67
|
+
- `Position.piece_count(color)`
|
|
68
|
+
- `Position.ascii_board()`
|
|
69
|
+
- `Position.svg_board()`
|
|
70
|
+
- `Position.svg_for_move(move)`
|
|
71
|
+
- `Position.best_move(depth)`
|
|
72
|
+
- `Position.evaluate()`
|
|
73
|
+
- `Position.outcome()`
|
|
74
|
+
- `Position.supporting_pivots(move)`
|
|
75
|
+
|
|
76
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# sanqi-python
|
|
2
|
+
|
|
3
|
+
Python bindings for the Sanqi Rust engine.
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
From `crates/sanqi-python`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
maturin develop
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or build a wheel:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
maturin build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import sanqi_python as sanqi
|
|
23
|
+
|
|
24
|
+
position = sanqi.Position.initial()
|
|
25
|
+
print(position.legal_moves()[:5])
|
|
26
|
+
|
|
27
|
+
move = position.best_move(2)
|
|
28
|
+
if move is not None:
|
|
29
|
+
svg = position.svg_for_move(move)
|
|
30
|
+
position.apply_move(move)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Exposed API
|
|
34
|
+
|
|
35
|
+
- `Position.initial()`
|
|
36
|
+
- `Position.empty("white" | "black")`
|
|
37
|
+
- `Position.legal_moves()`
|
|
38
|
+
- `Position.is_legal_move(move)`
|
|
39
|
+
- `Position.apply_move(move)`
|
|
40
|
+
- `Position.piece_at(square)`
|
|
41
|
+
- `Position.set_piece(color, square)`
|
|
42
|
+
- `Position.clear_square(square)`
|
|
43
|
+
- `Position.piece_count(color)`
|
|
44
|
+
- `Position.ascii_board()`
|
|
45
|
+
- `Position.svg_board()`
|
|
46
|
+
- `Position.svg_for_move(move)`
|
|
47
|
+
- `Position.best_move(depth)`
|
|
48
|
+
- `Position.evaluate()`
|
|
49
|
+
- `Position.outcome()`
|
|
50
|
+
- `Position.supporting_pivots(move)`
|
|
51
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "sanqi-core"
|
|
3
|
+
version.workspace = true
|
|
4
|
+
edition.workspace = true
|
|
5
|
+
license.workspace = true
|
|
6
|
+
repository.workspace = true
|
|
7
|
+
homepage.workspace = true
|
|
8
|
+
rust-version.workspace = true
|
|
9
|
+
description = "Core rules and data structures for the Sanqi board game"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
keywords = ["board-game", "engine", "sanqi", "game"]
|
|
12
|
+
categories = ["game-engines"]
|
|
13
|
+
|
|
14
|
+
[lib]
|
|
15
|
+
name = "sanqi_core"
|
|
16
|
+
path = "src/lib.rs"
|
|
17
|
+
|
|
18
|
+
[lints]
|
|
19
|
+
workspace = true
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# sanqi-core
|
|
2
|
+
|
|
3
|
+
Core rules and data structures for the Sanqi board game.
|
|
4
|
+
|
|
5
|
+
This crate provides:
|
|
6
|
+
|
|
7
|
+
- `Position` for board state
|
|
8
|
+
- `Move` in `from-to` notation such as `a1-b3`
|
|
9
|
+
- `Game` for complete move histories
|
|
10
|
+
- legal move generation and move validation
|
|
11
|
+
- PGN-like movetext import/export such as `1. h1-d3 h8-d6 2. a1-d4`
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
|
|
15
|
+
```rust
|
|
16
|
+
use sanqi_core::Position;
|
|
17
|
+
|
|
18
|
+
let position = Position::initial();
|
|
19
|
+
let moves = position.legal_moves();
|
|
20
|
+
assert!(!moves.is_empty());
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Repository: <https://github.com/curoli/sanqi>
|