ankigammon 1.0.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.

Potentially problematic release.


This version of ankigammon might be problematic. Click here for more details.

Files changed (63) hide show
  1. ankigammon-1.0.0/LICENSE +21 -0
  2. ankigammon-1.0.0/PKG-INFO +370 -0
  3. ankigammon-1.0.0/README.md +334 -0
  4. ankigammon-1.0.0/ankigammon/__init__.py +7 -0
  5. ankigammon-1.0.0/ankigammon/__main__.py +6 -0
  6. ankigammon-1.0.0/ankigammon/analysis/__init__.py +13 -0
  7. ankigammon-1.0.0/ankigammon/analysis/score_matrix.py +373 -0
  8. ankigammon-1.0.0/ankigammon/anki/__init__.py +6 -0
  9. ankigammon-1.0.0/ankigammon/anki/ankiconnect.py +224 -0
  10. ankigammon-1.0.0/ankigammon/anki/apkg_exporter.py +123 -0
  11. ankigammon-1.0.0/ankigammon/anki/card_generator.py +1307 -0
  12. ankigammon-1.0.0/ankigammon/anki/card_styles.py +1034 -0
  13. ankigammon-1.0.0/ankigammon/gui/__init__.py +8 -0
  14. ankigammon-1.0.0/ankigammon/gui/app.py +209 -0
  15. ankigammon-1.0.0/ankigammon/gui/dialogs/__init__.py +10 -0
  16. ankigammon-1.0.0/ankigammon/gui/dialogs/export_dialog.py +597 -0
  17. ankigammon-1.0.0/ankigammon/gui/dialogs/import_options_dialog.py +163 -0
  18. ankigammon-1.0.0/ankigammon/gui/dialogs/input_dialog.py +776 -0
  19. ankigammon-1.0.0/ankigammon/gui/dialogs/note_dialog.py +93 -0
  20. ankigammon-1.0.0/ankigammon/gui/dialogs/settings_dialog.py +384 -0
  21. ankigammon-1.0.0/ankigammon/gui/format_detector.py +292 -0
  22. ankigammon-1.0.0/ankigammon/gui/main_window.py +1071 -0
  23. ankigammon-1.0.0/ankigammon/gui/resources/icon.icns +0 -0
  24. ankigammon-1.0.0/ankigammon/gui/resources/icon.ico +0 -0
  25. ankigammon-1.0.0/ankigammon/gui/resources/icon.png +0 -0
  26. ankigammon-1.0.0/ankigammon/gui/resources/style.qss +394 -0
  27. ankigammon-1.0.0/ankigammon/gui/resources.py +26 -0
  28. ankigammon-1.0.0/ankigammon/gui/widgets/__init__.py +8 -0
  29. ankigammon-1.0.0/ankigammon/gui/widgets/position_list.py +193 -0
  30. ankigammon-1.0.0/ankigammon/gui/widgets/smart_input.py +268 -0
  31. ankigammon-1.0.0/ankigammon/models.py +322 -0
  32. ankigammon-1.0.0/ankigammon/parsers/__init__.py +7 -0
  33. ankigammon-1.0.0/ankigammon/parsers/gnubg_parser.py +454 -0
  34. ankigammon-1.0.0/ankigammon/parsers/xg_binary_parser.py +870 -0
  35. ankigammon-1.0.0/ankigammon/parsers/xg_text_parser.py +729 -0
  36. ankigammon-1.0.0/ankigammon/renderer/__init__.py +5 -0
  37. ankigammon-1.0.0/ankigammon/renderer/animation_controller.py +406 -0
  38. ankigammon-1.0.0/ankigammon/renderer/animation_helper.py +221 -0
  39. ankigammon-1.0.0/ankigammon/renderer/color_schemes.py +145 -0
  40. ankigammon-1.0.0/ankigammon/renderer/svg_board_renderer.py +824 -0
  41. ankigammon-1.0.0/ankigammon/settings.py +239 -0
  42. ankigammon-1.0.0/ankigammon/thirdparty/__init__.py +7 -0
  43. ankigammon-1.0.0/ankigammon/thirdparty/xgdatatools/__init__.py +17 -0
  44. ankigammon-1.0.0/ankigammon/thirdparty/xgdatatools/xgimport.py +160 -0
  45. ankigammon-1.0.0/ankigammon/thirdparty/xgdatatools/xgstruct.py +1032 -0
  46. ankigammon-1.0.0/ankigammon/thirdparty/xgdatatools/xgutils.py +118 -0
  47. ankigammon-1.0.0/ankigammon/thirdparty/xgdatatools/xgzarc.py +260 -0
  48. ankigammon-1.0.0/ankigammon/utils/__init__.py +13 -0
  49. ankigammon-1.0.0/ankigammon/utils/gnubg_analyzer.py +431 -0
  50. ankigammon-1.0.0/ankigammon/utils/gnuid.py +622 -0
  51. ankigammon-1.0.0/ankigammon/utils/move_parser.py +239 -0
  52. ankigammon-1.0.0/ankigammon/utils/ogid.py +335 -0
  53. ankigammon-1.0.0/ankigammon/utils/xgid.py +419 -0
  54. ankigammon-1.0.0/ankigammon.egg-info/PKG-INFO +370 -0
  55. ankigammon-1.0.0/ankigammon.egg-info/SOURCES.txt +61 -0
  56. ankigammon-1.0.0/ankigammon.egg-info/dependency_links.txt +1 -0
  57. ankigammon-1.0.0/ankigammon.egg-info/entry_points.txt +2 -0
  58. ankigammon-1.0.0/ankigammon.egg-info/requires.txt +11 -0
  59. ankigammon-1.0.0/ankigammon.egg-info/top_level.txt +1 -0
  60. ankigammon-1.0.0/pyproject.toml +62 -0
  61. ankigammon-1.0.0/setup.cfg +4 -0
  62. ankigammon-1.0.0/tests/test_basic.py +818 -0
  63. ankigammon-1.0.0/tests/test_settings.py +83 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AnkiGammon
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,370 @@
1
+ Metadata-Version: 2.4
2
+ Name: ankigammon
3
+ Version: 1.0.0
4
+ Summary: Convert eXtreme Gammon backgammon analysis into Anki flashcards
5
+ Author-email: AnkiGammon Contributors <admin@ankigammon.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Deinonychus999/AnkiGammon
8
+ Project-URL: Repository, https://github.com/Deinonychus999/AnkiGammon
9
+ Project-URL: Documentation, https://github.com/Deinonychus999/AnkiGammon#readme
10
+ Project-URL: Issues, https://github.com/Deinonychus999/AnkiGammon/issues
11
+ Keywords: anki,flashcards,backgammon,extreme-gammon,xg,learning,spaced-repetition
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Topic :: Games/Entertainment :: Board Games
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: beautifulsoup4>=4.12.0
26
+ Requires-Dist: lxml>=4.9.0
27
+ Requires-Dist: genanki>=0.13.0
28
+ Requires-Dist: requests>=2.31.0
29
+ Requires-Dist: PySide6>=6.6.0
30
+ Requires-Dist: PySide6-Addons>=6.6.0
31
+ Requires-Dist: qtawesome>=1.3.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: pyinstaller>=6.0.0; extra == "dev"
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # AnkiGammon
38
+
39
+ A graphical application for converting backgammon positions into Anki flashcards. Analyze positions from eXtreme Gammon, OpenGammon, or GNU Backgammon and create smart study cards.
40
+
41
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/X8X31NIT0H)
42
+
43
+ ## Features
44
+
45
+ - **Modern GUI interface** - Easy-to-use graphical application, no command-line needed
46
+ - **Multiple position format support** - XGID (eXtreme Gammon), OGID (OpenGammon), and GNUID (GNU Backgammon)
47
+ - **Direct XG export support** - Copy/paste positions from eXtreme Gammon
48
+ - **Smart rendering** - Automatic board image generation from position IDs
49
+ - **Automatic format detection** - Paste any supported format, the app detects it automatically
50
+ - **Two export methods**:
51
+ - AnkiConnect: Push directly to Anki (recommended)
52
+ - APKG: Self-contained package for manual import
53
+ - **Customizable appearance** - 6 color schemes and board orientation options
54
+ - **Complete analysis** - Top 5 moves with equities and error calculations
55
+
56
+ ## Installation
57
+
58
+ ### Standalone Executable (Recommended)
59
+
60
+ **Windows:**
61
+ 1. Run `build_executable.bat` to create `ankigammon.exe`
62
+ 2. Double-click to run - no Python installation needed!
63
+
64
+ **macOS/Linux:**
65
+ 1. Run `./build_executable.sh` to create `ankigammon`
66
+ 2. Run from terminal: `./dist/ankigammon` - no Python installation needed!
67
+ 3. macOS first run: Right-click → Open (or allow in System Settings → Privacy & Security)
68
+
69
+ ### Development Install
70
+
71
+ For developers who want to run from source:
72
+
73
+ ```bash
74
+ git clone https://github.com/Deinonychus999/AnkiGammon.git
75
+ cd AnkiGammon
76
+ pip install -e . # Install in editable mode
77
+ python -m ankigammon # Launches the GUI
78
+ ```
79
+
80
+ ## Usage
81
+
82
+ 1. **Launch the application** - Double-click `ankigammon.exe` (Windows) or run `./ankigammon` (macOS/Linux)
83
+ 2. **Paste positions** - Copy analysis from eXtreme Gammon (Ctrl+C) and paste into the application
84
+ 3. **Configure settings** - Choose color scheme, board orientation, and export method in Settings
85
+ 4. **Generate cards** - Click "Generate Cards" to create Anki flashcards
86
+
87
+ ### Getting Positions from eXtreme Gammon
88
+
89
+ 1. In eXtreme Gammon, analyze a position
90
+ 2. Press Ctrl+C to copy the full analysis
91
+ 3. Paste into AnkiGammon's input area
92
+ 4. Click "Generate Cards"
93
+
94
+ **Example XG export format:**
95
+ ```
96
+ XGID=---BBBBAAA---Ac-bbccbAA-A-:1:1:-1:63:4:3:0:5:8
97
+
98
+ X:Player 2 O:Player 1
99
+ Score is X:3 O:4 5 pt.(s) match.
100
+ +13-14-15-16-17-18------19-20-21-22-23-24-+
101
+ | O O O | | O O O O |
102
+ ...
103
+
104
+ 1. XG Roller+ 11/8 11/5 eq:+0.589
105
+ Player: 79.46% (G:17.05% B:0.67%)
106
+ Opponent: 20.54% (G:2.22% B:0.06%)
107
+ ```
108
+
109
+ ## Supported Position Formats
110
+
111
+ AnkiGammon supports three backgammon position ID formats, with automatic detection:
112
+
113
+ ### XGID (eXtreme Gammon ID) - Primary Format
114
+ **Format:** `XGID=PPPPPPPPPPPPPPPPPPPPPPPPPP:CV:CP:T:D:S1:S2:CJ:ML:MC`
115
+
116
+ The standard XG format with 9 colon-separated fields including position, cube state, dice, and match info.
117
+
118
+ **Example:**
119
+ ```
120
+ XGID=---BBBBAAA---Ac-bbccbAA-A-:1:1:-1:63:4:3:0:5:8
121
+ ```
122
+
123
+ ### OGID (OpenGammon Position ID) - Alternative Format
124
+ **Format:** `P1:P2:CUBE[:DICE[:TURN[:STATE[:S1[:S2[:ML[:MID[:NCHECKERS]]]]]]]]`
125
+
126
+ Human-readable base-26 encoding with optional metadata fields. More verbose but easier to understand.
127
+
128
+ **Example:**
129
+ ```
130
+ cccccggggg:ddddiiiiii:N0N:63:W:IW:4:3:7:1:15
131
+ ```
132
+
133
+ ### GNUID (GNU Backgammon ID) - GnuBG Format
134
+ **Format:** `PositionID:MatchID` (Base64 encoded)
135
+
136
+ Compact format used by GNU Backgammon. 14-character Position ID + 12-character Match ID.
137
+
138
+ **Example:**
139
+ ```
140
+ 4HPwATDgc/ABMA:8IhuACAACAAE
141
+ ```
142
+
143
+ GNUID fully supports position encoding and decoding, including all checker positions, bars, cube state, and match metadata.
144
+
145
+ ### Format Detection
146
+
147
+ The application **automatically detects** which format you're using. Just paste your position and AnkiGammon will handle it:
148
+ - XGID: Detected by `XGID=` prefix
149
+ - OGID: Detected by base-26 pattern with colons
150
+ - GNUID: Detected by base64 pattern
151
+
152
+ You can mix formats in the same input - each position can use a different format!
153
+
154
+ ## Export Methods
155
+
156
+ ### AnkiConnect (Recommended)
157
+
158
+ Push cards directly to running Anki through the GUI:
159
+ - Install [AnkiConnect addon](https://ankiweb.net/shared/info/2055492159)
160
+ - Keep Anki running while generating cards
161
+ - Cards appear instantly in your deck
162
+
163
+ ### APKG
164
+
165
+ Generate a package file for manual import:
166
+ - Select "APKG" in Settings
167
+ - Import into Anki: File → Import → Select the .apkg file
168
+ - Useful for offline card generation
169
+
170
+ ## Card Format
171
+
172
+ Each position becomes one Anki card:
173
+
174
+ **Front:**
175
+ - Board image showing the position
176
+ - Metadata: player on roll, dice, score, cube, match length
177
+ - Multiple choice: 5 candidate moves (labeled A-E, shuffled)
178
+ - Optional text move descriptions
179
+
180
+ **Back:**
181
+ - Position image and metadata
182
+ - Ranked table of top 5 moves with equity and error
183
+ - Correct answer highlighted
184
+ - Source position ID for reference
185
+
186
+ ## Customization Options
187
+
188
+ The GUI Settings dialog provides:
189
+ - **Color Schemes**: Choose from 6 built-in themes (Classic, Forest, Ocean, Desert, Sunset, Midnight)
190
+ - **Board Orientation**: Counter-clockwise or Clockwise orientation
191
+ - **Deck Name**: Customize your Anki deck name
192
+ - **Show Move Options**: Toggle text move descriptions on card front
193
+ - **Interactive Moves**: Enable/disable move visualization
194
+ - **Export Method**: Choose between AnkiConnect or APKG output
195
+
196
+ ## Troubleshooting
197
+
198
+ **"Cannot connect to Anki-Connect"**
199
+ - Install AnkiConnect addon: https://ankiweb.net/shared/info/2055492159
200
+ - Make sure Anki is running
201
+ - Check firewall isn't blocking localhost:8765
202
+
203
+ **"No decisions found in input"**
204
+ - Ensure input includes position ID lines (XGID, OGID, or GNUID format)
205
+ - Make sure move analysis includes equity values (eq:)
206
+ - Copy the full position from XG (press Ctrl+C)
207
+ - For GNUID format: Consider using XGID or OGID instead due to known limitations
208
+
209
+ **Application won't start**
210
+ - Windows: Check Windows Defender isn't blocking the executable
211
+ - macOS: Right-click → Open, or remove quarantine with `xattr -cr ankigammon`
212
+ - Linux: Ensure execute permissions with `chmod +x ankigammon`
213
+
214
+ ## For Developers
215
+
216
+ ### Building the Executable
217
+
218
+ **Quick Build:**
219
+
220
+ Windows:
221
+ ```bash
222
+ build_executable.bat
223
+ ```
224
+
225
+ macOS/Linux:
226
+ ```bash
227
+ chmod +x build_executable.sh
228
+ ./build_executable.sh
229
+ ```
230
+
231
+ The executable will be in the `dist/` folder.
232
+
233
+ **Manual Build (if script doesn't work):**
234
+
235
+ Windows:
236
+ ```bash
237
+ # Install PyInstaller
238
+ pip install pyinstaller
239
+
240
+ # Clean previous builds
241
+ rmdir /s /q build dist
242
+
243
+ # Build
244
+ pyinstaller ankigammon.spec
245
+ ```
246
+
247
+ macOS/Linux:
248
+ ```bash
249
+ # Install PyInstaller
250
+ pip3 install pyinstaller
251
+
252
+ # Clean previous builds
253
+ rm -rf build dist
254
+
255
+ # Build
256
+ pyinstaller ankigammon.spec
257
+
258
+ # Remove quarantine attribute (macOS only)
259
+ xattr -cr dist/ankigammon
260
+ ```
261
+
262
+ ### Testing the Build
263
+
264
+ Windows:
265
+ ```bash
266
+ # Test the GUI launches
267
+ cd dist
268
+ ankigammon.exe
269
+ ```
270
+
271
+ macOS/Linux:
272
+ ```bash
273
+ # Test the GUI launches
274
+ cd dist
275
+ ./ankigammon
276
+ ```
277
+
278
+ ### Project Structure
279
+
280
+ - `ankigammon/` - Main package code
281
+ - `parsers/` - XG text format parsers
282
+ - `renderer/` - Board image generation (SVG-based)
283
+ - `anki/` - Anki card generation and export
284
+ - `utils/` - Position format encoding/decoding (XGID, OGID, GNUID)
285
+ - `gui/` - GUI components and format detection
286
+ - `tests/` - Unit tests (includes tests for all three formats)
287
+ - `ankigammon.spec` - PyInstaller configuration for GUI build
288
+ - `build_executable.bat/.sh` - Build scripts
289
+
290
+ ### Settings Storage
291
+
292
+ User preferences (color scheme, deck name, board orientation, etc.) are automatically saved to:
293
+ - Windows: `C:\Users\YourName\.ankigammon\config.json`
294
+ - macOS: `~/.ankigammon/config.json`
295
+ - Linux: `~/.ankigammon/config.json`
296
+
297
+ Settings persist across application restarts, even when using the standalone executable.
298
+
299
+ ### Troubleshooting Build Issues
300
+
301
+ **ImportError during build:**
302
+ - Add missing module to `hiddenimports` in `ankigammon.spec`
303
+
304
+ **"Module not found" when running executable:**
305
+ - Check the module is in `hiddenimports`
306
+ - Try: `pyinstaller --collect-all ankigammon ankigammon.spec`
307
+
308
+ **Executable too large:**
309
+ - Remove unused dependencies from requirements.txt
310
+ - Add more items to `excludes` in ankigammon.spec
311
+
312
+ **Executable won't run:**
313
+ - Test on clean machine without Python installed
314
+ - Check Windows Defender / antivirus isn't blocking it
315
+ - Look at build warnings: `pyinstaller ankigammon.spec > build.log 2>&1`
316
+
317
+ **Platform-Specific Issues:**
318
+
319
+ Windows:
320
+ - Some antivirus software may flag PyInstaller executables as suspicious (false positive)
321
+ - Users may need to add an exception in their antivirus
322
+ - To reduce false positives: Sign executable with code signing certificate
323
+
324
+ macOS:
325
+ - First run may show "cannot be opened because it is from an unidentified developer"
326
+ - Solution 1: Right-click executable → Open → Open anyway
327
+ - Solution 2: System Settings → Privacy & Security → Allow anyway
328
+ - Solution 3: Remove quarantine: `xattr -cr dist/ankigammon`
329
+ - For distribution: Sign with Apple Developer certificate and notarize
330
+
331
+ Linux:
332
+ - Ensure executable has execute permissions: `chmod +x ankigammon`
333
+ - May need to install dependencies on minimal systems: `sudo apt install libxcb1`
334
+
335
+ ## Requirements
336
+
337
+ - Python 3.8+ (for development install only)
338
+ - Dependencies automatically installed via `pip install .`: genanki, requests, beautifulsoup4, lxml, PySide6, qtawesome
339
+ - For standalone executable: No requirements - Python and all dependencies are bundled
340
+
341
+ ## Legal
342
+
343
+ ### Third-Party Software
344
+
345
+ This application uses several LGPL-licensed components:
346
+ - **PySide6** (LGPL-3.0) - Qt framework Python bindings for the GUI
347
+ - **xgdatatools** (LGPL-2.1) - Modules for parsing eXtreme Gammon binary file formats
348
+
349
+ See [THIRD-PARTY-LICENSES.md](THIRD-PARTY-LICENSES.md) for complete license information and attributions for all dependencies.
350
+
351
+ ### Trademarks
352
+
353
+ - "eXtreme Gammon" and "XG" are registered trademarks of GameSite 2000 Ltd.
354
+ - "Anki" is a trademark of Ankitects Pty Ltd
355
+ - "Qt" is a trademark of The Qt Company Ltd.
356
+ - GNU Backgammon is part of the GNU Project
357
+
358
+ **This project is not affiliated with or endorsed by the creators of eXtreme Gammon, Anki, Qt, GNU Backgammon, or any other mentioned software.**
359
+
360
+ ### Position Format Specifications
361
+
362
+ - **XGID format** specification is publicly documented by eXtreme Gammon (GameSite 2000 Ltd.) with explicit permission for redistribution: "This information can freely redistributed"
363
+ - **XG binary format** parsing is implemented using xgdatatools (LGPL-2.1) by Michael Petch, based on Delphi data structures provided by Xavier Dufaure de Citres
364
+ - **GNUID format** is documented in the GNU Backgammon manual (GPL-3.0 project); our implementation is original code that reads/writes this format without incorporating GPL code
365
+
366
+ All position encoding/decoding implementations in this project are original code, except for the xgdatatools modules used for XG binary file parsing.
367
+
368
+ ## License
369
+
370
+ AnkiGammon is licensed under the MIT License. See [LICENSE](LICENSE) for details.