shakmaty-python-binding 0.1.5__tar.gz → 0.1.6__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.
- shakmaty_python_binding-0.1.6/.github/workflows/ci.yml +61 -0
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/Cargo.lock +37 -103
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/Cargo.toml +4 -3
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/PKG-INFO +2 -2
- shakmaty_python_binding-0.1.6/dist/shakmaty_python_binding-0.1.6-cp314-cp314-manylinux_2_34_x86_64.whl +0 -0
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/pyproject.toml +2 -1
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/src/lib.rs +1 -2
- shakmaty_python_binding-0.1.6/tests/test_python314.py +57 -0
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/.gitignore +0 -0
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/README.md +0 -0
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/main.py +0 -0
- {shakmaty_python_binding-0.1.5 → shakmaty_python_binding-0.1.6}/shakmaty_python_binding.pyi +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
tags: ["v*"]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-24.04
|
|
16
|
+
timeout-minutes: 20
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.14"
|
|
22
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
23
|
+
- name: Verify release tag matches the package
|
|
24
|
+
run: |
|
|
25
|
+
python - <<'PY'
|
|
26
|
+
import os
|
|
27
|
+
import tomllib
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
version = tomllib.loads(Path("Cargo.toml").read_text())["package"]["version"]
|
|
30
|
+
ref = os.environ["GITHUB_REF"]
|
|
31
|
+
if ref.startswith("refs/tags/"):
|
|
32
|
+
assert ref == f"refs/tags/v{version}", (ref, version)
|
|
33
|
+
PY
|
|
34
|
+
- name: Build native wheel and source distribution
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install maturin==1.15.0 chess==1.11.2 twine==7.0.0
|
|
37
|
+
maturin build --release --locked --out dist
|
|
38
|
+
maturin sdist --out dist
|
|
39
|
+
python -m twine check --strict dist/*
|
|
40
|
+
- name: Exercise installed native binding
|
|
41
|
+
run: |
|
|
42
|
+
python -m pip install --no-deps dist/*.whl
|
|
43
|
+
python -m unittest discover -s tests -v
|
|
44
|
+
- uses: actions/upload-artifact@v4
|
|
45
|
+
with:
|
|
46
|
+
name: distributions
|
|
47
|
+
path: dist/
|
|
48
|
+
|
|
49
|
+
publish:
|
|
50
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
51
|
+
needs: test
|
|
52
|
+
runs-on: ubuntu-24.04
|
|
53
|
+
environment: pypi
|
|
54
|
+
permissions:
|
|
55
|
+
id-token: write
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/download-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
name: distributions
|
|
60
|
+
path: dist/
|
|
61
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This file is automatically @generated by Cargo.
|
|
2
2
|
# It is not intended for manual editing.
|
|
3
|
-
version =
|
|
3
|
+
version = 4
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
6
6
|
name = "android-tzdata"
|
|
@@ -186,6 +186,12 @@ version = "0.15.2"
|
|
|
186
186
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
187
187
|
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
|
188
188
|
|
|
189
|
+
[[package]]
|
|
190
|
+
name = "heck"
|
|
191
|
+
version = "0.5.0"
|
|
192
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
193
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
194
|
+
|
|
189
195
|
[[package]]
|
|
190
196
|
name = "hex"
|
|
191
197
|
version = "0.4.3"
|
|
@@ -251,12 +257,6 @@ dependencies = [
|
|
|
251
257
|
"serde",
|
|
252
258
|
]
|
|
253
259
|
|
|
254
|
-
[[package]]
|
|
255
|
-
name = "indoc"
|
|
256
|
-
version = "1.0.9"
|
|
257
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
258
|
-
checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"
|
|
259
|
-
|
|
260
260
|
[[package]]
|
|
261
261
|
name = "itoa"
|
|
262
262
|
version = "1.0.14"
|
|
@@ -279,16 +279,6 @@ version = "0.2.168"
|
|
|
279
279
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
280
280
|
checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d"
|
|
281
281
|
|
|
282
|
-
[[package]]
|
|
283
|
-
name = "lock_api"
|
|
284
|
-
version = "0.4.12"
|
|
285
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
286
|
-
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
|
287
|
-
dependencies = [
|
|
288
|
-
"autocfg",
|
|
289
|
-
"scopeguard",
|
|
290
|
-
]
|
|
291
|
-
|
|
292
282
|
[[package]]
|
|
293
283
|
name = "log"
|
|
294
284
|
version = "0.4.22"
|
|
@@ -301,15 +291,6 @@ version = "2.7.4"
|
|
|
301
291
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
302
292
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|
303
293
|
|
|
304
|
-
[[package]]
|
|
305
|
-
name = "memoffset"
|
|
306
|
-
version = "0.9.1"
|
|
307
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
308
|
-
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
309
|
-
dependencies = [
|
|
310
|
-
"autocfg",
|
|
311
|
-
]
|
|
312
|
-
|
|
313
294
|
[[package]]
|
|
314
295
|
name = "nohash-hasher"
|
|
315
296
|
version = "0.2.0"
|
|
@@ -333,32 +314,9 @@ dependencies = [
|
|
|
333
314
|
|
|
334
315
|
[[package]]
|
|
335
316
|
name = "once_cell"
|
|
336
|
-
version = "1.
|
|
317
|
+
version = "1.21.4"
|
|
337
318
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
338
|
-
checksum = "
|
|
339
|
-
|
|
340
|
-
[[package]]
|
|
341
|
-
name = "parking_lot"
|
|
342
|
-
version = "0.12.3"
|
|
343
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
344
|
-
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
|
345
|
-
dependencies = [
|
|
346
|
-
"lock_api",
|
|
347
|
-
"parking_lot_core",
|
|
348
|
-
]
|
|
349
|
-
|
|
350
|
-
[[package]]
|
|
351
|
-
name = "parking_lot_core"
|
|
352
|
-
version = "0.9.10"
|
|
353
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
354
|
-
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
|
|
355
|
-
dependencies = [
|
|
356
|
-
"cfg-if",
|
|
357
|
-
"libc",
|
|
358
|
-
"redox_syscall",
|
|
359
|
-
"smallvec",
|
|
360
|
-
"windows-targets",
|
|
361
|
-
]
|
|
319
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
362
320
|
|
|
363
321
|
[[package]]
|
|
364
322
|
name = "pin-project-lite"
|
|
@@ -366,6 +324,12 @@ version = "0.2.15"
|
|
|
366
324
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
367
325
|
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
|
|
368
326
|
|
|
327
|
+
[[package]]
|
|
328
|
+
name = "portable-atomic"
|
|
329
|
+
version = "1.15.0"
|
|
330
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
331
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
332
|
+
|
|
369
333
|
[[package]]
|
|
370
334
|
name = "powerfmt"
|
|
371
335
|
version = "0.2.0"
|
|
@@ -383,36 +347,32 @@ dependencies = [
|
|
|
383
347
|
|
|
384
348
|
[[package]]
|
|
385
349
|
name = "pyo3"
|
|
386
|
-
version = "0.
|
|
350
|
+
version = "0.30.1"
|
|
387
351
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
388
|
-
checksum = "
|
|
352
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
389
353
|
dependencies = [
|
|
390
|
-
"cfg-if",
|
|
391
|
-
"indoc",
|
|
392
354
|
"libc",
|
|
393
|
-
"
|
|
394
|
-
"
|
|
355
|
+
"once_cell",
|
|
356
|
+
"portable-atomic",
|
|
395
357
|
"pyo3-build-config",
|
|
396
358
|
"pyo3-ffi",
|
|
397
359
|
"pyo3-macros",
|
|
398
|
-
"unindent",
|
|
399
360
|
]
|
|
400
361
|
|
|
401
362
|
[[package]]
|
|
402
363
|
name = "pyo3-build-config"
|
|
403
|
-
version = "0.
|
|
364
|
+
version = "0.30.1"
|
|
404
365
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
405
|
-
checksum = "
|
|
366
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
406
367
|
dependencies = [
|
|
407
|
-
"once_cell",
|
|
408
368
|
"target-lexicon",
|
|
409
369
|
]
|
|
410
370
|
|
|
411
371
|
[[package]]
|
|
412
372
|
name = "pyo3-ffi"
|
|
413
|
-
version = "0.
|
|
373
|
+
version = "0.30.1"
|
|
414
374
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
415
|
-
checksum = "
|
|
375
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
416
376
|
dependencies = [
|
|
417
377
|
"libc",
|
|
418
378
|
"pyo3-build-config",
|
|
@@ -420,25 +380,26 @@ dependencies = [
|
|
|
420
380
|
|
|
421
381
|
[[package]]
|
|
422
382
|
name = "pyo3-macros"
|
|
423
|
-
version = "0.
|
|
383
|
+
version = "0.30.1"
|
|
424
384
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
425
|
-
checksum = "
|
|
385
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
426
386
|
dependencies = [
|
|
427
387
|
"proc-macro2",
|
|
428
388
|
"pyo3-macros-backend",
|
|
429
389
|
"quote",
|
|
430
|
-
"syn
|
|
390
|
+
"syn 3.0.9",
|
|
431
391
|
]
|
|
432
392
|
|
|
433
393
|
[[package]]
|
|
434
394
|
name = "pyo3-macros-backend"
|
|
435
|
-
version = "0.
|
|
395
|
+
version = "0.30.1"
|
|
436
396
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
437
|
-
checksum = "
|
|
397
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
438
398
|
dependencies = [
|
|
399
|
+
"heck",
|
|
439
400
|
"proc-macro2",
|
|
440
401
|
"quote",
|
|
441
|
-
"syn
|
|
402
|
+
"syn 3.0.9",
|
|
442
403
|
]
|
|
443
404
|
|
|
444
405
|
[[package]]
|
|
@@ -450,15 +411,6 @@ dependencies = [
|
|
|
450
411
|
"proc-macro2",
|
|
451
412
|
]
|
|
452
413
|
|
|
453
|
-
[[package]]
|
|
454
|
-
name = "redox_syscall"
|
|
455
|
-
version = "0.5.8"
|
|
456
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
457
|
-
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
|
|
458
|
-
dependencies = [
|
|
459
|
-
"bitflags",
|
|
460
|
-
]
|
|
461
|
-
|
|
462
414
|
[[package]]
|
|
463
415
|
name = "rustc-hash"
|
|
464
416
|
version = "1.1.0"
|
|
@@ -471,12 +423,6 @@ version = "1.0.18"
|
|
|
471
423
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
472
424
|
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
|
473
425
|
|
|
474
|
-
[[package]]
|
|
475
|
-
name = "scopeguard"
|
|
476
|
-
version = "1.2.0"
|
|
477
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
478
|
-
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
479
|
-
|
|
480
426
|
[[package]]
|
|
481
427
|
name = "serde"
|
|
482
428
|
version = "1.0.216"
|
|
@@ -569,7 +515,7 @@ dependencies = [
|
|
|
569
515
|
|
|
570
516
|
[[package]]
|
|
571
517
|
name = "shakmaty_python_binding"
|
|
572
|
-
version = "0.1.
|
|
518
|
+
version = "0.1.6"
|
|
573
519
|
dependencies = [
|
|
574
520
|
"arrayvec",
|
|
575
521
|
"bitflags",
|
|
@@ -590,12 +536,6 @@ version = "1.3.0"
|
|
|
590
536
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
591
537
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
592
538
|
|
|
593
|
-
[[package]]
|
|
594
|
-
name = "smallvec"
|
|
595
|
-
version = "1.13.2"
|
|
596
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
597
|
-
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
|
598
|
-
|
|
599
539
|
[[package]]
|
|
600
540
|
name = "strsim"
|
|
601
541
|
version = "0.11.1"
|
|
@@ -604,9 +544,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|
|
604
544
|
|
|
605
545
|
[[package]]
|
|
606
546
|
name = "syn"
|
|
607
|
-
version = "
|
|
547
|
+
version = "2.0.90"
|
|
608
548
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
609
|
-
checksum = "
|
|
549
|
+
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
|
610
550
|
dependencies = [
|
|
611
551
|
"proc-macro2",
|
|
612
552
|
"quote",
|
|
@@ -615,9 +555,9 @@ dependencies = [
|
|
|
615
555
|
|
|
616
556
|
[[package]]
|
|
617
557
|
name = "syn"
|
|
618
|
-
version = "
|
|
558
|
+
version = "3.0.9"
|
|
619
559
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
620
|
-
checksum = "
|
|
560
|
+
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
|
621
561
|
dependencies = [
|
|
622
562
|
"proc-macro2",
|
|
623
563
|
"quote",
|
|
@@ -626,9 +566,9 @@ dependencies = [
|
|
|
626
566
|
|
|
627
567
|
[[package]]
|
|
628
568
|
name = "target-lexicon"
|
|
629
|
-
version = "0.
|
|
569
|
+
version = "0.13.5"
|
|
630
570
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
631
|
-
checksum = "
|
|
571
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
632
572
|
|
|
633
573
|
[[package]]
|
|
634
574
|
name = "time"
|
|
@@ -698,12 +638,6 @@ version = "1.0.14"
|
|
|
698
638
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
699
639
|
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
|
700
640
|
|
|
701
|
-
[[package]]
|
|
702
|
-
name = "unindent"
|
|
703
|
-
version = "0.1.11"
|
|
704
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
705
|
-
checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c"
|
|
706
|
-
|
|
707
641
|
[[package]]
|
|
708
642
|
name = "wasm-bindgen"
|
|
709
643
|
version = "0.2.99"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "shakmaty_python_binding"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.6"
|
|
4
4
|
edition = "2021"
|
|
5
|
-
rust-version = "1.
|
|
5
|
+
rust-version = "1.85"
|
|
6
|
+
readme = "README.md"
|
|
6
7
|
|
|
7
8
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
8
9
|
[lib]
|
|
@@ -11,7 +12,7 @@ crate-type = ["cdylib"]
|
|
|
11
12
|
bench = false
|
|
12
13
|
|
|
13
14
|
[dependencies]
|
|
14
|
-
pyo3 = "0.
|
|
15
|
+
pyo3 = "0.30.1"
|
|
15
16
|
bitflags = "2.0.0"
|
|
16
17
|
btoi = "0.4"
|
|
17
18
|
arrayvec = { version = "0.7", default-features = false }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: shakmaty_python_binding
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
Binary file
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
[build-system]
|
|
3
|
-
requires = ["maturin>=1.
|
|
3
|
+
requires = ["maturin>=1.15.0,<2.0"]
|
|
4
4
|
build-backend = "maturin"
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "shakmaty_python_binding"
|
|
8
|
+
readme = "README.md"
|
|
8
9
|
requires-python = ">=3.11"
|
|
9
10
|
classifiers = [
|
|
10
11
|
"Programming Language :: Rust",
|
|
@@ -2,7 +2,6 @@ use std::collections::HashMap;
|
|
|
2
2
|
use std::collections::HashSet;
|
|
3
3
|
use std::vec::Vec;
|
|
4
4
|
|
|
5
|
-
use pyo3::ffi::newfunc;
|
|
6
5
|
//use pyo3::{pymodule,pymethods,pyclass, PyResult,Python};
|
|
7
6
|
//use pyo3::types::PyModule;
|
|
8
7
|
use pyo3::prelude::*;
|
|
@@ -612,7 +611,7 @@ impl MyChess {
|
|
|
612
611
|
}
|
|
613
612
|
|
|
614
613
|
#[pymodule]
|
|
615
|
-
fn shakmaty_python_binding(
|
|
614
|
+
fn shakmaty_python_binding(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
616
615
|
add_classes!(m, MyMove);
|
|
617
616
|
add_classes!(m, MyChess);
|
|
618
617
|
add_classes!(m, MyTableBase);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Exercise the native move constructor and compare real play with python-chess."""
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
import unittest
|
|
5
|
+
|
|
6
|
+
import chess
|
|
7
|
+
import shakmaty_python_binding as native
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class NativeChessTests(unittest.TestCase):
|
|
11
|
+
"""Keep native argument extraction and chess behavior independently checked."""
|
|
12
|
+
|
|
13
|
+
def assert_position_equal(self, expected, actual):
|
|
14
|
+
self.assertEqual(actual.fen(), expected.fen())
|
|
15
|
+
self.assertEqual(
|
|
16
|
+
sorted(move.uci() for move in actual.legal_moves()),
|
|
17
|
+
sorted(move.uci() for move in expected.legal_moves),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def test_special_move_construction(self):
|
|
21
|
+
cases = [
|
|
22
|
+
(chess.STARTING_FEN, "e2e4"),
|
|
23
|
+
("r3k2r/8/8/8/8/8/8/R3K2R w KQkq - 0 1", "e1g1"),
|
|
24
|
+
("r3k2r/8/8/8/8/8/8/R3K2R w KQkq - 0 1", "e1c1"),
|
|
25
|
+
("4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 1", "e5d6"),
|
|
26
|
+
] + [("4k3/P7/8/8/8/8/8/4K3 w - - 0 1", f"a7a8{piece}")
|
|
27
|
+
for piece in "qrbn"]
|
|
28
|
+
for fen, uci in cases:
|
|
29
|
+
with self.subTest(fen=fen, uci=uci):
|
|
30
|
+
expected = chess.Board(fen)
|
|
31
|
+
actual = native.MyChess(fen)
|
|
32
|
+
move = native.MyMove(uci, actual)
|
|
33
|
+
self.assertEqual(move.uci(), uci)
|
|
34
|
+
expected.push_uci(uci)
|
|
35
|
+
actual.play(move)
|
|
36
|
+
self.assert_position_equal(expected, actual)
|
|
37
|
+
self.assert_position_equal(expected, actual.copy())
|
|
38
|
+
|
|
39
|
+
def test_500_seeded_plies(self):
|
|
40
|
+
rng = random.Random(314)
|
|
41
|
+
expected = chess.Board()
|
|
42
|
+
actual = native.MyChess(expected.fen())
|
|
43
|
+
for index in range(500):
|
|
44
|
+
if expected.is_game_over():
|
|
45
|
+
expected = chess.Board()
|
|
46
|
+
actual = native.MyChess(expected.fen())
|
|
47
|
+
self.assert_position_equal(expected, actual)
|
|
48
|
+
uci = rng.choice(sorted(move.uci() for move in expected.legal_moves))
|
|
49
|
+
move = native.MyMove(uci, actual)
|
|
50
|
+
expected.push_uci(uci)
|
|
51
|
+
actual.play(move)
|
|
52
|
+
with self.subTest(ply=index):
|
|
53
|
+
self.assert_position_equal(expected, actual)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|