caissify-pairings 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.
- caissify_pairings-0.1.0/.gitignore +32 -0
- caissify_pairings-0.1.0/CHANGELOG.md +39 -0
- caissify_pairings-0.1.0/LICENSE +21 -0
- caissify_pairings-0.1.0/PKG-INFO +241 -0
- caissify_pairings-0.1.0/README.md +212 -0
- caissify_pairings-0.1.0/doc/DIVERGENCE_TESTING.md +414 -0
- caissify_pairings-0.1.0/doc/ENGINE_STATUS.md +182 -0
- caissify_pairings-0.1.0/doc/FIDE_ENDORSEMENT_REQUIREMENTS.md +229 -0
- caissify_pairings-0.1.0/doc/ROADMAP.md +375 -0
- caissify_pairings-0.1.0/pyproject.toml +80 -0
- caissify_pairings-0.1.0/src/caissify_pairings/__init__.py +52 -0
- caissify_pairings-0.1.0/src/caissify_pairings/__main__.py +73 -0
- caissify_pairings-0.1.0/src/caissify_pairings/base.py +57 -0
- caissify_pairings-0.1.0/src/caissify_pairings/engines/__init__.py +43 -0
- caissify_pairings-0.1.0/src/caissify_pairings/engines/dutch.py +3334 -0
- caissify_pairings-0.1.0/src/caissify_pairings/fpc.py +499 -0
- caissify_pairings-0.1.0/src/caissify_pairings/rtg.py +393 -0
- caissify_pairings-0.1.0/src/caissify_pairings/trf.py +458 -0
- caissify_pairings-0.1.0/tests/__init__.py +0 -0
- caissify_pairings-0.1.0/tests/fixtures/big_30p11r_even.trf +43 -0
- caissify_pairings-0.1.0/tests/fixtures/big_30p11r_varied.trf +42 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_10p5r_s42.trf +13 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_10p5r_s43.trf +13 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_10p5r_s44.trf +13 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_11p5r_s42.trf +14 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_11p5r_s43.trf +14 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_20p7r_s42.trf +23 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_20p7r_s43.trf +23 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_40p9r_s42.trf +43 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_dutch_C5.trf +8 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_dutch_C9.trf +7 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_issue15_180p11r.trf +182 -0
- caissify_pairings-0.1.0/tests/fixtures/fide_official/bbp_issue7_60p14r.trf +62 -0
- caissify_pairings-0.1.0/tests/fixtures/large_15p9r_byes.trf +28 -0
- caissify_pairings-0.1.0/tests/fixtures/large_15p9r_mixed.trf +28 -0
- caissify_pairings-0.1.0/tests/fixtures/large_15p9r_spread.trf +28 -0
- caissify_pairings-0.1.0/tests/fixtures/medium_9p7r_clean.trf +21 -0
- caissify_pairings-0.1.0/tests/fixtures/medium_9p7r_forfeits.trf +21 -0
- caissify_pairings-0.1.0/tests/fixtures/misc_edge_case_1.trf +92 -0
- caissify_pairings-0.1.0/tests/fixtures/misc_edge_case_2.trf +92 -0
- caissify_pairings-0.1.0/tests/fixtures/misc_edge_case_3.trf +92 -0
- caissify_pairings-0.1.0/tests/fixtures/small_7p5r_byes.trf +20 -0
- caissify_pairings-0.1.0/tests/fixtures/small_7p5r_clean.trf +20 -0
- caissify_pairings-0.1.0/tests/fixtures/small_7p5r_varied.trf +20 -0
- caissify_pairings-0.1.0/tests/fixtures/stress_50p15r.trf +63 -0
- caissify_pairings-0.1.0/tests/fixtures/stress_50p31r_manybyes.trf +63 -0
- caissify_pairings-0.1.0/tests/test_cross_validation.py +291 -0
- caissify_pairings-0.1.0/tests/test_dutch_engine.py +435 -0
- caissify_pairings-0.1.0/tests/test_dutch_fide_official.py +125 -0
- caissify_pairings-0.1.0/tests/test_dutch_fpc.py +291 -0
- caissify_pairings-0.1.0/tests/test_dutch_integration.py +424 -0
- caissify_pairings-0.1.0/tests/test_dutch_javafo.py +640 -0
- caissify_pairings-0.1.0/tests/test_dutch_trf_fixtures.py +799 -0
- caissify_pairings-0.1.0/tests/test_rtg.py +197 -0
- caissify_pairings-0.1.0/tests/test_rtg_fpc_validation.py +139 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.whl
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
|
|
16
|
+
# IDE
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
*.swp
|
|
20
|
+
*.swo
|
|
21
|
+
|
|
22
|
+
# OS
|
|
23
|
+
.DS_Store
|
|
24
|
+
Thumbs.db
|
|
25
|
+
|
|
26
|
+
# Testing
|
|
27
|
+
.pytest_cache/
|
|
28
|
+
.coverage
|
|
29
|
+
htmlcov/
|
|
30
|
+
|
|
31
|
+
# Vendor (compiled reference engines)
|
|
32
|
+
vendor/
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
Breaking changes may occur between `0.x` releases; the API will be frozen
|
|
8
|
+
at `1.0.0`.
|
|
9
|
+
|
|
10
|
+
## [Unreleased]
|
|
11
|
+
|
|
12
|
+
## [0.1.0] — 2026-04-20
|
|
13
|
+
|
|
14
|
+
First public release.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- **FIDE Dutch System (C.04.3, Feb 2026)** pairing engine with full
|
|
18
|
+
A.7 conformance against `bbpPairings`:
|
|
19
|
+
- 5000 × 20p/9r benchmark: **0 discrepancies / 45,000 rounds**.
|
|
20
|
+
- 5000 × 10p/5r benchmark: **0 discrepancies / 25,000 rounds**.
|
|
21
|
+
- TRF16 parser and writer (`caissify_pairings.trf`).
|
|
22
|
+
- Free Pairings Checker (`caissify_pairings.fpc`) — validate a TRF file
|
|
23
|
+
against the engine.
|
|
24
|
+
- Random Tournament Generator (`caissify_pairings.rtg`).
|
|
25
|
+
- Top-level `generate_pairings(system=..., ...)` API and
|
|
26
|
+
`caissify_pairings.engines` registry.
|
|
27
|
+
- CLI entry points: `caissify-pairings` (JSON stdin/stdout),
|
|
28
|
+
`caissify-pairings-check`, `caissify-pairings-rtg`.
|
|
29
|
+
|
|
30
|
+
### Known limitations
|
|
31
|
+
- Only the Dutch system is implemented (no Accelerated Dutch, Burstein,
|
|
32
|
+
Monrad, or round-robin yet).
|
|
33
|
+
- Exact-pair match rate against pre-recorded `bbpPairings` fixtures drops
|
|
34
|
+
at 40+ players; the A.7 conformance benchmark tops out at 20p/9r where
|
|
35
|
+
the engine is at 0 discrepancies.
|
|
36
|
+
- Not FIDE-endorsed (endorsement is a separate administrative process).
|
|
37
|
+
|
|
38
|
+
[Unreleased]: https://github.com/lexisvar/caissify_pairings/compare/v0.1.0...HEAD
|
|
39
|
+
[0.1.0]: https://github.com/lexisvar/caissify_pairings/releases/tag/v0.1.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lexisvar
|
|
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.
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: caissify-pairings
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Chess tournament pairing engines — FIDE Dutch System (C.04.3), matched against bbpPairings to A.7 conformance.
|
|
5
|
+
Project-URL: Homepage, https://github.com/lexisvar/caissify_pairings
|
|
6
|
+
Project-URL: Repository, https://github.com/lexisvar/caissify_pairings
|
|
7
|
+
Project-URL: Issues, https://github.com/lexisvar/caissify_pairings/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/lexisvar/caissify_pairings/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: lexisvar <lexisvar@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: arbiter,chess,dutch,fide,pairing,pairings,swiss,tournament
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Other Audience
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Games/Entertainment :: Board Games
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: networkx>=3.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# caissify-pairings
|
|
31
|
+
|
|
32
|
+
Chess tournament pairing engines for Python. Currently implements the
|
|
33
|
+
**FIDE Dutch System (C.04.3)**, cross-validated against the FIDE-endorsed
|
|
34
|
+
reference `bbpPairings` to full **A.7 conformance**.
|
|
35
|
+
|
|
36
|
+
## What you get
|
|
37
|
+
|
|
38
|
+
- A programmable pairing engine — use it as a library, call it from a web
|
|
39
|
+
service, or wrap it in a tournament-director UI.
|
|
40
|
+
- TRF16 parser and writer.
|
|
41
|
+
- A Free Pairings Checker (FPC) — validate a TRF file against the engine.
|
|
42
|
+
- A Random Tournament Generator (RTG) — generate simulated tournaments for
|
|
43
|
+
testing.
|
|
44
|
+
- A simple JSON-over-stdin CLI.
|
|
45
|
+
|
|
46
|
+
## FIDE A.7 conformance
|
|
47
|
+
|
|
48
|
+
The FIDE *Swiss Pairings Programs Commission* evaluates endorsed pairing
|
|
49
|
+
software using the **A.7 test**: a program is expected to produce pairings
|
|
50
|
+
that match an already-endorsed program on at least **4990 of 5000** random
|
|
51
|
+
tournaments (≤ 10 discrepancies).
|
|
52
|
+
|
|
53
|
+
Measured against [`bbpPairings`](https://github.com/BieremaBoyzvoortMediaFoundation/bbpPairings)
|
|
54
|
+
(FIDE-endorsed, C++) using our Random Tournament Generator + Free Pairings
|
|
55
|
+
Checker pipeline:
|
|
56
|
+
|
|
57
|
+
| Benchmark | Rounds checked | Discrepancies | FIDE target | Result |
|
|
58
|
+
|-----------|----------------|---------------|-------------|--------|
|
|
59
|
+
| 5000 × 20-player / 9-round | 45,000 | **0** | ≤ 10 | ✅ PASS |
|
|
60
|
+
| 5000 × 10-player / 5-round | 25,000 | **0** | ≤ 10 | ✅ PASS |
|
|
61
|
+
|
|
62
|
+
See [`doc/ENGINE_STATUS.md`](doc/ENGINE_STATUS.md) for the full story
|
|
63
|
+
and [`doc/DIVERGENCE_TESTING.md`](doc/DIVERGENCE_TESTING.md) for the
|
|
64
|
+
methodology.
|
|
65
|
+
|
|
66
|
+
> **Note.** A.7 conformance is a technical criterion. `caissify-pairings`
|
|
67
|
+
> is **not yet FIDE-endorsed** — endorsement is a separate administrative
|
|
68
|
+
> process with the FIDE SPP Commission.
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install caissify-pairings
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Requires Python 3.10+. The only runtime dependency is [`networkx`](https://networkx.org/)
|
|
77
|
+
(for maximum-weight matching).
|
|
78
|
+
|
|
79
|
+
## Quick start — library
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from caissify_pairings import generate_pairings
|
|
83
|
+
|
|
84
|
+
players = [
|
|
85
|
+
{"id": 1, "name": "Carlsen", "score": 2.0, "rating": 2830,
|
|
86
|
+
"starting_number": 1, "color_hist": ["white", "black"],
|
|
87
|
+
"float_history": [], "bye_count": 0},
|
|
88
|
+
{"id": 2, "name": "Firouzja", "score": 2.0, "rating": 2785,
|
|
89
|
+
"starting_number": 2, "color_hist": ["black", "white"],
|
|
90
|
+
"float_history": [], "bye_count": 0},
|
|
91
|
+
{"id": 3, "name": "Ding", "score": 1.5, "rating": 2780,
|
|
92
|
+
"starting_number": 3, "color_hist": ["white", "black"],
|
|
93
|
+
"float_history": [], "bye_count": 0},
|
|
94
|
+
{"id": 4, "name": "Nepo", "score": 1.5, "rating": 2775,
|
|
95
|
+
"starting_number": 4, "color_hist": ["black", "white"],
|
|
96
|
+
"float_history": [], "bye_count": 0},
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
pairings = generate_pairings(
|
|
100
|
+
system="dutch",
|
|
101
|
+
players=players,
|
|
102
|
+
previous_pairings={(1, 3), (2, 4)},
|
|
103
|
+
round_number=3,
|
|
104
|
+
total_rounds=9,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
for p in pairings:
|
|
108
|
+
print(f"Table {p['table']}: {p['white_id']} vs {p['black_id']}")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Command-line usage
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Pair a round from a JSON state on stdin, write pairings to stdout
|
|
115
|
+
caissify-pairings < tournament_state.json
|
|
116
|
+
|
|
117
|
+
# Validate a FIDE TRF file against the Dutch engine
|
|
118
|
+
caissify-pairings-check tournament.trf
|
|
119
|
+
|
|
120
|
+
# Generate random tournaments for testing
|
|
121
|
+
caissify-pairings-rtg --players 20 --rounds 9 -n 100 -o ./output/
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Input JSON schema
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"system": "dutch",
|
|
129
|
+
"players": [
|
|
130
|
+
{
|
|
131
|
+
"id": 1,
|
|
132
|
+
"name": "Player Name",
|
|
133
|
+
"score": 0.0,
|
|
134
|
+
"rating": 2400,
|
|
135
|
+
"starting_number": 1,
|
|
136
|
+
"color_hist": [],
|
|
137
|
+
"float_history": [],
|
|
138
|
+
"bye_count": 0
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"previous_pairings": [[1, 3], [2, 4]],
|
|
142
|
+
"round_number": 1,
|
|
143
|
+
"total_rounds": 9,
|
|
144
|
+
"bye_value": 1.0,
|
|
145
|
+
"max_byes_per_player": 1
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Output JSON schema
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
[
|
|
153
|
+
{"white_id": 1, "black_id": 4, "table": 1},
|
|
154
|
+
{"white_id": 3, "black_id": 2, "table": 2}
|
|
155
|
+
]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## What works today
|
|
159
|
+
|
|
160
|
+
- **FIDE Dutch System (C.04.3, Feb 2026 spec)** — full A.7 conformance
|
|
161
|
+
against `bbpPairings` on 20p/9r and 10p/5r benchmarks (see above).
|
|
162
|
+
- Full TRF16 round-trip parsing/writing.
|
|
163
|
+
- Free Pairings Checker (FPC) for validating existing TRF files.
|
|
164
|
+
- Random Tournament Generator (RTG) for test corpora.
|
|
165
|
+
- Pure-Python, single runtime dependency (`networkx`).
|
|
166
|
+
|
|
167
|
+
## What does not work yet
|
|
168
|
+
|
|
169
|
+
Being honest up front — these are known limitations you will hit if your
|
|
170
|
+
use-case is beyond them:
|
|
171
|
+
|
|
172
|
+
- **Only the Dutch system is implemented.** No Accelerated Dutch, Burstein,
|
|
173
|
+
Monrad, or round-robin generators yet.
|
|
174
|
+
- **Large-tournament fixture match rates are lower** against pre-recorded
|
|
175
|
+
`bbpPairings` outputs for 40+ players (e.g. 40p/9r reports ~11% exact
|
|
176
|
+
pair agreement on a handful of fixtures). The 5000-tournament A.7
|
|
177
|
+
conformance benchmark tops out at 20p/9r, where the engine is at 0
|
|
178
|
+
discrepancies; at larger scales tie-breaking divergences are expected.
|
|
179
|
+
- **No tournament-director UI.** This is an engine / library, not a
|
|
180
|
+
standalone product.
|
|
181
|
+
- **No FIDE endorsement.** A.7 conformance is met technically; endorsement
|
|
182
|
+
is a separate process that has not been pursued.
|
|
183
|
+
- **API is not stabilised.** Version `0.x` may introduce breaking changes.
|
|
184
|
+
API will be frozen at `1.0.0`.
|
|
185
|
+
|
|
186
|
+
If any of these block you, please open an issue — priorities are driven by
|
|
187
|
+
real user needs.
|
|
188
|
+
|
|
189
|
+
## Using an engine directly
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from caissify_pairings.engines.dutch import dutch_pairings
|
|
193
|
+
|
|
194
|
+
pairings = dutch_pairings(
|
|
195
|
+
players=players,
|
|
196
|
+
previous_pairings=set(),
|
|
197
|
+
round_number=1,
|
|
198
|
+
total_rounds=9,
|
|
199
|
+
)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Extending
|
|
203
|
+
|
|
204
|
+
New pairing systems plug in via a small registry.
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from caissify_pairings.base import BasePairingEngine
|
|
208
|
+
|
|
209
|
+
class MyEngine(BasePairingEngine):
|
|
210
|
+
name = "my_system"
|
|
211
|
+
|
|
212
|
+
def generate_pairings(self) -> list[dict]:
|
|
213
|
+
...
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Register it in `caissify_pairings/engines/__init__.py` to expose it through
|
|
217
|
+
the top-level `generate_pairings(system="my_system", ...)` call.
|
|
218
|
+
|
|
219
|
+
## Testing
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Fast suite (skip @slow 5000-tournament benchmarks)
|
|
223
|
+
pytest -m "not slow"
|
|
224
|
+
|
|
225
|
+
# Full suite including FIDE A.7 benchmarks (takes ~25 min)
|
|
226
|
+
pytest
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Acknowledgements
|
|
230
|
+
|
|
231
|
+
Cross-validated against the FIDE-endorsed reference implementations:
|
|
232
|
+
|
|
233
|
+
- **[bbpPairings](https://github.com/BieremaBoyzvoortMediaFoundation/bbpPairings)**
|
|
234
|
+
by Bierema Boyzvoort Media Foundation — Apache-2.0.
|
|
235
|
+
- **[JaVaFo](https://javafo.sourceforge.net/)** by Roberto Ricca.
|
|
236
|
+
|
|
237
|
+
Thanks to their authors for making these tools freely available.
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT — see [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# caissify-pairings
|
|
2
|
+
|
|
3
|
+
Chess tournament pairing engines for Python. Currently implements the
|
|
4
|
+
**FIDE Dutch System (C.04.3)**, cross-validated against the FIDE-endorsed
|
|
5
|
+
reference `bbpPairings` to full **A.7 conformance**.
|
|
6
|
+
|
|
7
|
+
## What you get
|
|
8
|
+
|
|
9
|
+
- A programmable pairing engine — use it as a library, call it from a web
|
|
10
|
+
service, or wrap it in a tournament-director UI.
|
|
11
|
+
- TRF16 parser and writer.
|
|
12
|
+
- A Free Pairings Checker (FPC) — validate a TRF file against the engine.
|
|
13
|
+
- A Random Tournament Generator (RTG) — generate simulated tournaments for
|
|
14
|
+
testing.
|
|
15
|
+
- A simple JSON-over-stdin CLI.
|
|
16
|
+
|
|
17
|
+
## FIDE A.7 conformance
|
|
18
|
+
|
|
19
|
+
The FIDE *Swiss Pairings Programs Commission* evaluates endorsed pairing
|
|
20
|
+
software using the **A.7 test**: a program is expected to produce pairings
|
|
21
|
+
that match an already-endorsed program on at least **4990 of 5000** random
|
|
22
|
+
tournaments (≤ 10 discrepancies).
|
|
23
|
+
|
|
24
|
+
Measured against [`bbpPairings`](https://github.com/BieremaBoyzvoortMediaFoundation/bbpPairings)
|
|
25
|
+
(FIDE-endorsed, C++) using our Random Tournament Generator + Free Pairings
|
|
26
|
+
Checker pipeline:
|
|
27
|
+
|
|
28
|
+
| Benchmark | Rounds checked | Discrepancies | FIDE target | Result |
|
|
29
|
+
|-----------|----------------|---------------|-------------|--------|
|
|
30
|
+
| 5000 × 20-player / 9-round | 45,000 | **0** | ≤ 10 | ✅ PASS |
|
|
31
|
+
| 5000 × 10-player / 5-round | 25,000 | **0** | ≤ 10 | ✅ PASS |
|
|
32
|
+
|
|
33
|
+
See [`doc/ENGINE_STATUS.md`](doc/ENGINE_STATUS.md) for the full story
|
|
34
|
+
and [`doc/DIVERGENCE_TESTING.md`](doc/DIVERGENCE_TESTING.md) for the
|
|
35
|
+
methodology.
|
|
36
|
+
|
|
37
|
+
> **Note.** A.7 conformance is a technical criterion. `caissify-pairings`
|
|
38
|
+
> is **not yet FIDE-endorsed** — endorsement is a separate administrative
|
|
39
|
+
> process with the FIDE SPP Commission.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install caissify-pairings
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Requires Python 3.10+. The only runtime dependency is [`networkx`](https://networkx.org/)
|
|
48
|
+
(for maximum-weight matching).
|
|
49
|
+
|
|
50
|
+
## Quick start — library
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from caissify_pairings import generate_pairings
|
|
54
|
+
|
|
55
|
+
players = [
|
|
56
|
+
{"id": 1, "name": "Carlsen", "score": 2.0, "rating": 2830,
|
|
57
|
+
"starting_number": 1, "color_hist": ["white", "black"],
|
|
58
|
+
"float_history": [], "bye_count": 0},
|
|
59
|
+
{"id": 2, "name": "Firouzja", "score": 2.0, "rating": 2785,
|
|
60
|
+
"starting_number": 2, "color_hist": ["black", "white"],
|
|
61
|
+
"float_history": [], "bye_count": 0},
|
|
62
|
+
{"id": 3, "name": "Ding", "score": 1.5, "rating": 2780,
|
|
63
|
+
"starting_number": 3, "color_hist": ["white", "black"],
|
|
64
|
+
"float_history": [], "bye_count": 0},
|
|
65
|
+
{"id": 4, "name": "Nepo", "score": 1.5, "rating": 2775,
|
|
66
|
+
"starting_number": 4, "color_hist": ["black", "white"],
|
|
67
|
+
"float_history": [], "bye_count": 0},
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
pairings = generate_pairings(
|
|
71
|
+
system="dutch",
|
|
72
|
+
players=players,
|
|
73
|
+
previous_pairings={(1, 3), (2, 4)},
|
|
74
|
+
round_number=3,
|
|
75
|
+
total_rounds=9,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
for p in pairings:
|
|
79
|
+
print(f"Table {p['table']}: {p['white_id']} vs {p['black_id']}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Command-line usage
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Pair a round from a JSON state on stdin, write pairings to stdout
|
|
86
|
+
caissify-pairings < tournament_state.json
|
|
87
|
+
|
|
88
|
+
# Validate a FIDE TRF file against the Dutch engine
|
|
89
|
+
caissify-pairings-check tournament.trf
|
|
90
|
+
|
|
91
|
+
# Generate random tournaments for testing
|
|
92
|
+
caissify-pairings-rtg --players 20 --rounds 9 -n 100 -o ./output/
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Input JSON schema
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"system": "dutch",
|
|
100
|
+
"players": [
|
|
101
|
+
{
|
|
102
|
+
"id": 1,
|
|
103
|
+
"name": "Player Name",
|
|
104
|
+
"score": 0.0,
|
|
105
|
+
"rating": 2400,
|
|
106
|
+
"starting_number": 1,
|
|
107
|
+
"color_hist": [],
|
|
108
|
+
"float_history": [],
|
|
109
|
+
"bye_count": 0
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"previous_pairings": [[1, 3], [2, 4]],
|
|
113
|
+
"round_number": 1,
|
|
114
|
+
"total_rounds": 9,
|
|
115
|
+
"bye_value": 1.0,
|
|
116
|
+
"max_byes_per_player": 1
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Output JSON schema
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
[
|
|
124
|
+
{"white_id": 1, "black_id": 4, "table": 1},
|
|
125
|
+
{"white_id": 3, "black_id": 2, "table": 2}
|
|
126
|
+
]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## What works today
|
|
130
|
+
|
|
131
|
+
- **FIDE Dutch System (C.04.3, Feb 2026 spec)** — full A.7 conformance
|
|
132
|
+
against `bbpPairings` on 20p/9r and 10p/5r benchmarks (see above).
|
|
133
|
+
- Full TRF16 round-trip parsing/writing.
|
|
134
|
+
- Free Pairings Checker (FPC) for validating existing TRF files.
|
|
135
|
+
- Random Tournament Generator (RTG) for test corpora.
|
|
136
|
+
- Pure-Python, single runtime dependency (`networkx`).
|
|
137
|
+
|
|
138
|
+
## What does not work yet
|
|
139
|
+
|
|
140
|
+
Being honest up front — these are known limitations you will hit if your
|
|
141
|
+
use-case is beyond them:
|
|
142
|
+
|
|
143
|
+
- **Only the Dutch system is implemented.** No Accelerated Dutch, Burstein,
|
|
144
|
+
Monrad, or round-robin generators yet.
|
|
145
|
+
- **Large-tournament fixture match rates are lower** against pre-recorded
|
|
146
|
+
`bbpPairings` outputs for 40+ players (e.g. 40p/9r reports ~11% exact
|
|
147
|
+
pair agreement on a handful of fixtures). The 5000-tournament A.7
|
|
148
|
+
conformance benchmark tops out at 20p/9r, where the engine is at 0
|
|
149
|
+
discrepancies; at larger scales tie-breaking divergences are expected.
|
|
150
|
+
- **No tournament-director UI.** This is an engine / library, not a
|
|
151
|
+
standalone product.
|
|
152
|
+
- **No FIDE endorsement.** A.7 conformance is met technically; endorsement
|
|
153
|
+
is a separate process that has not been pursued.
|
|
154
|
+
- **API is not stabilised.** Version `0.x` may introduce breaking changes.
|
|
155
|
+
API will be frozen at `1.0.0`.
|
|
156
|
+
|
|
157
|
+
If any of these block you, please open an issue — priorities are driven by
|
|
158
|
+
real user needs.
|
|
159
|
+
|
|
160
|
+
## Using an engine directly
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from caissify_pairings.engines.dutch import dutch_pairings
|
|
164
|
+
|
|
165
|
+
pairings = dutch_pairings(
|
|
166
|
+
players=players,
|
|
167
|
+
previous_pairings=set(),
|
|
168
|
+
round_number=1,
|
|
169
|
+
total_rounds=9,
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Extending
|
|
174
|
+
|
|
175
|
+
New pairing systems plug in via a small registry.
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from caissify_pairings.base import BasePairingEngine
|
|
179
|
+
|
|
180
|
+
class MyEngine(BasePairingEngine):
|
|
181
|
+
name = "my_system"
|
|
182
|
+
|
|
183
|
+
def generate_pairings(self) -> list[dict]:
|
|
184
|
+
...
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Register it in `caissify_pairings/engines/__init__.py` to expose it through
|
|
188
|
+
the top-level `generate_pairings(system="my_system", ...)` call.
|
|
189
|
+
|
|
190
|
+
## Testing
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Fast suite (skip @slow 5000-tournament benchmarks)
|
|
194
|
+
pytest -m "not slow"
|
|
195
|
+
|
|
196
|
+
# Full suite including FIDE A.7 benchmarks (takes ~25 min)
|
|
197
|
+
pytest
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Acknowledgements
|
|
201
|
+
|
|
202
|
+
Cross-validated against the FIDE-endorsed reference implementations:
|
|
203
|
+
|
|
204
|
+
- **[bbpPairings](https://github.com/BieremaBoyzvoortMediaFoundation/bbpPairings)**
|
|
205
|
+
by Bierema Boyzvoort Media Foundation — Apache-2.0.
|
|
206
|
+
- **[JaVaFo](https://javafo.sourceforge.net/)** by Roberto Ricca.
|
|
207
|
+
|
|
208
|
+
Thanks to their authors for making these tools freely available.
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT — see [`LICENSE`](LICENSE).
|