{"id":24573875,"url":"https://github.com/miskibin/py-draughts","last_synced_at":"2026-04-26T09:05:44.914Z","repository":{"id":176534580,"uuid":"658863535","full_name":"miskibin/py-draughts","owner":"miskibin","description":"A checkers library with modern web GUI,  Supprots multiple variants of game.","archived":false,"fork":false,"pushed_at":"2026-04-24T09:00:25.000Z","size":44057,"stargazers_count":14,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-04-24T10:40:11.036Z","etag":null,"topics":["ai","alpha-beta-pruning","checkers","contributions-welcome","draughts","fastapi","mini-max-algorithm","open-to-collaborate","reinforcement-learning"],"latest_commit_sha":null,"homepage":"https://miskibin.github.io/py-draughts/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miskibin.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-26T16:37:44.000Z","updated_at":"2026-04-04T21:23:48.000Z","dependencies_parsed_at":"2023-11-28T21:57:49.874Z","dependency_job_id":"1c73b9c8-5fe6-4cf5-b256-bac0634ca257","html_url":"https://github.com/miskibin/py-draughts","commit_stats":null,"previous_names":["michalskibinski109/checkers","miskibin/py-draughts","michalskibinski109/py-draughts"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/miskibin/py-draughts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskibin%2Fpy-draughts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskibin%2Fpy-draughts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskibin%2Fpy-draughts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskibin%2Fpy-draughts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miskibin","download_url":"https://codeload.github.com/miskibin/py-draughts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miskibin%2Fpy-draughts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32291347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T08:29:33.829Z","status":"ssl_error","status_checked_at":"2026-04-26T08:29:18.366Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","alpha-beta-pruning","checkers","contributions-welcome","draughts","fastapi","mini-max-algorithm","open-to-collaborate","reinforcement-learning"],"created_at":"2025-01-23T20:22:38.076Z","updated_at":"2026-04-26T09:05:44.909Z","avatar_url":"https://github.com/miskibin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# py-draughts\n\n[![GitHub Actions](https://github.com/michalskibinski109/checkers/actions/workflows/python-app.yml/badge.svg)](https://github.com/michalskibinski109/checkers/actions/workflows/python-app.yml)\n[![PyPI version](https://badge.fury.io/py/py-draughts.svg)](https://badge.fury.io/py/py-draughts)\n[![Downloads](https://static.pepy.tech/badge/py-draughts)](https://pepy.tech/project/py-draughts)\n[![Docs](https://img.shields.io/badge/docs-online-blue)](https://miskibin.github.io/py-draughts/)\n\nFast, modern draughts library with move generation, validation, PDN support, and AI engines. HUB protocol for external engines communication\n\n\u003e [!IMPORTANT]  \n\u003e Best optimized draughts library utilizing bitboards for ~200x faster move generation than alternatives.\n\n**Features:** multiple variants • Built-in AI engine • (HUB protocol) External engine support ([Scan](https://hjetten.home.xs4all.nl/scan/scan.html), [Kingsrow](http://www.edgilbert.org/Checkers/KingsRow.htm)) • RL/ML ready • Web UI\n\n## [Installation](https://miskibin.github.io/py-draughts/)\n\n```bash\npip install py-draughts\n```\n\n## [Core](https://miskibin.github.io/py-draughts/core.html)\n\n```python\n\u003e\u003e\u003e import draughts\n\u003e\u003e\u003e board = draughts.Board()\n\n\u003e\u003e\u003e board.legal_moves\n[Move: 31-\u003e27, Move: 31-\u003e26, Move: 32-\u003e28, ...]\n\n\u003e\u003e\u003e board.push_uci(\"31-27\")\n\u003e\u003e\u003e board.push_uci(\"18-22\")\n\u003e\u003e\u003e board.push_uci(\"27x18\")\n\u003e\u003e\u003e board.push_uci(\"12x23\")\n\n\u003e\u003e\u003e board\n . b . b . b . b . b\n b . b . b . b . b .\n . b . b . . . b . b\n . . . . b . b . b .\n . . . b . . . . . .\n . . . . . . . . . .\n . w . w . w . w . w\n w . w . w . w . w .\n . w . w . w . w . w\n w . w . w . w . w .\n\n\u003e\u003e\u003e board.pop()  # Unmake the last move\nMove: 12-\u003e23\n\n\u003e\u003e\u003e board.turn\nColor.WHITE\n```\n\n### Make and unmake moves\n\n```python\n\u003e\u003e\u003e board.push_uci(\"32-28\")  # Make a move\n\u003e\u003e\u003e board.pop()              # Unmake the last move\nMove: 32-\u003e28\n```\n\n### Show ASCII board\n\n```python\n\u003e\u003e\u003e board = draughts.Board()\n\u003e\u003e\u003e print(board)\n . b . b . b . b . b     .  1 .  2 .  3 .  4 .  5\n b . b . b . b . b .      6 .  7 .  8 .  9 . 10 .\n . b . b . b . b . b     . 11 . 12 . 13 . 14 . 15\n b . b . b . b . b .     16 . 17 . 18 . 19 . 20 .\n . . . . . . . . . .     . 21 . 22 . 23 . 24 . 25\n . . . . . . . . . .     26 . 27 . 28 . 29 . 30 .\n . w . w . w . w . w     . 31 . 32 . 33 . 34 . 35\n w . w . w . w . w .     36 . 37 . 38 . 39 . 40 .\n . w . w . w . w . w     . 41 . 42 . 43 . 44 . 45\n w . w . w . w . w .     46 . 47 . 48 . 49 . 50 .\n```\n\n### Detects draws and game end\n\n```python\n\u003e\u003e\u003e board.is_draw\nFalse\n\u003e\u003e\u003e board.is_threefold_repetition\nFalse\n\u003e\u003e\u003e board.game_over\nFalse\n\u003e\u003e\u003e board.result\n'-'\n```\n\n### [FEN](https://miskibin.github.io/py-draughts/core.html#notation) parsing and writing\n\n```python\n\u003e\u003e\u003e board.fen\n'[FEN \"W:W:W31,32,33,...:B1,2,3,...\"]'\n\n\u003e\u003e\u003e board = draughts.Board.from_fen(\"W:WK10,K20:BK35,K45\")\n\u003e\u003e\u003e board\n . . . . . . . B . .\n . . . . . . . . . .\n . . . . . . . . . .\n . . . . . . . . . .\n . . . . . . . . . .\n . . . . . . . . . .\n . . . . W . . . . .\n . . . . . . . . . .\n . . . . W . . . . .\n B . . . . . . . . .\n```\n\n### [PDN](https://miskibin.github.io/py-draughts/core.html#notation) parsing and writing\n\n```python\n\u003e\u003e\u003e board = draughts.Board()\n\u003e\u003e\u003e board.push_uci(\"32-28\")\n\u003e\u003e\u003e board.push_uci(\"18-23\")\n\u003e\u003e\u003e board.pdn\n'[GameType \"20\"]\n[Variant \"Standard (international) checkers\"]\n[Result \"-\"]\n1. 32-28 18-23'\n\n\u003e\u003e\u003e board = draughts.Board.from_pdn('[GameType \"20\"]\\n1. 32-28 19-23 2. 28x19 14x23')\n```\n\n## [Variants](https://miskibin.github.io/py-draughts/core.html#boards)\n\n| Variant | Class | Board | Flying Kings | Max Capture |\n|---------|-------|-------|--------------|-------------|\n| Standard | `StandardBoard` | 10×10 | Yes | Required |\n| American | `AmericanBoard` | 8×8 | No | Not required |\n| Frisian | `FrisianBoard` | 10×10 | Yes | Required |\n| Russian | `RussianBoard` | 8×8 | Yes | Not required |\n\n```python\n\u003e\u003e\u003e from draughts import StandardBoard, AmericanBoard, FrisianBoard, RussianBoard\n\n\u003e\u003e\u003e board = AmericanBoard()\n\u003e\u003e\u003e board\n . b . b . b . b\n b . b . b . b .\n . b . b . b . b\n . . . . . . . .\n . . . . . . . .\n w . w . w . w .\n . w . w . w . w\n w . w . w . w .\n```\n\n## [SVG Rendering](https://miskibin.github.io/py-draughts/svg.html)\n\n```python\n\u003e\u003e\u003e import draughts\n\u003e\u003e\u003e board = draughts.Board()\n\u003e\u003e\u003e draughts.svg.board(board, size=400)  # Returns SVG string\n```\n\n\u003cimg src=\"docs/source/_static/board_standard.svg\" alt=\"Standard draughts board\" width=\"400\"\u003e\n\n```python\n\u003e\u003e\u003e board = draughts.Board.from_fen(\"W:WK10,K20:BK35,K45\")\n\u003e\u003e\u003e draughts.svg.board(board, size=400)\n```\n\n\u003cimg src=\"docs/source/_static/board_kings.svg\" alt=\"Board with kings\" width=\"400\"\u003e\n\n## [Engine](https://miskibin.github.io/py-draughts/engine.html)\n\nBuilt-in alpha-beta engine with transposition tables and iterative deepening:\n\n```python\n\u003e\u003e\u003e from draughts import Board, AlphaBetaEngine\n\n\u003e\u003e\u003e board = Board()\n\u003e\u003e\u003e engine = AlphaBetaEngine(depth_limit=5)\n\n\u003e\u003e\u003e move = engine.get_best_move(board)\n\u003e\u003e\u003e move\nMove: 32-\u003e28\n\n\u003e\u003e\u003e move, score = engine.get_best_move(board, with_evaluation=True)\n\u003e\u003e\u003e score\n0.15\n```\n\n### External Engines (Hub Protocol)\n\nUse external engines like [Scan](https://hjetten.home.xs4all.nl/scan/scan.html) via the Hub protocol:\n\n```python\n\u003e\u003e\u003e from draughts import Board, HubEngine\n\n\u003e\u003e\u003e with HubEngine(\"path/to/scan.exe\", time_limit=1.0) as engine:\n...     board = Board()\n...     move, score = engine.get_best_move(board, with_evaluation=True)\n...     print(f\"Best: {move}, Score: {score}\")\nBest: 32-28, Score: 0.15\n```\n\nCompatible engines:\n- **[Scan](https://hjetten.home.xs4all.nl/scan/scan.html)** - World champion level, supports 10x10\n- **[Kingsrow](http://www.edgilbert.org/Checkers/KingsRow.htm)** - Multiple variants, endgame databases\n- Any engine implementing the Hub protocol\n\n## [Engine Benchmarking](https://miskibin.github.io/py-draughts/engine.html#benchmarking)\n\nCompare engines against each other with comprehensive statistics:\n\n```python\n\u003e\u003e\u003e from draughts import Benchmark, AlphaBetaEngine\n\n\u003e\u003e\u003e stats = Benchmark(\n...     AlphaBetaEngine(depth_limit=4),\n...     AlphaBetaEngine(depth_limit=6),\n...     games=20\n... ).run()\n\n\u003e\u003e\u003e print(stats)\n============================================================\n  BENCHMARK: AlphaBetaEngine (d=4) vs AlphaBetaEngine (d=6)\n============================================================\n  RESULTS: 2-12-6 (W-L-D)\n  AlphaBetaEngine (d=4) win rate: 25.0%\n  Elo difference: -191\n  ...\n```\n\n## [Writing Your Own AI](https://miskibin.github.io/py-draughts/ai.html)\n\nBuild custom agents with neural networks, MCTS, or any algorithm:\n\n```python\n\u003e\u003e\u003e from draughts import Board, BaseAgent, AgentEngine, Benchmark\n\n\u003e\u003e\u003e class GreedyAgent(BaseAgent):\n...     def select_move(self, board):\n...         return max(board.legal_moves, key=lambda m: len(m.captured_list))\n\n\u003e\u003e\u003e board = Board()\n\u003e\u003e\u003e agent = GreedyAgent()\n\u003e\u003e\u003e move = agent.select_move(board)\n\n# Use with Benchmark\n\u003e\u003e\u003e stats = Benchmark(agent.as_engine(), AlphaBetaEngine(depth_limit=4), games=10).run()\n```\n\n**ML-ready features:**\n\n```python\n\u003e\u003e\u003e board.to_tensor()        # (4, 50) tensor for neural networks\n\u003e\u003e\u003e board.legal_moves_mask() # Boolean mask for policy outputs\n\u003e\u003e\u003e board.features()         # Material, mobility, game phase\n\u003e\u003e\u003e clone = board.copy()     # Fast cloning for tree search\n```\n\n## [Server](https://miskibin.github.io/py-draughts/server.html)\n\nInteractive web interface for playing and engine testing:\n\n```python\nfrom draughts import Board, Server, AlphaBetaEngine, HubEngine\n\nserver = Server(\n    board=Board(),\n    white_engine=AlphaBetaEngine(depth_limit=6),\n    black_engine=HubEngine(\"path/to/scan.exe\", time_limit=1.0)\n)\nserver.run() # Open http://localhost:8000\n```\n\n\u003cimg width=\"1914\" height=\"1022\" alt=\"image\" src=\"https://github.com/user-attachments/assets/20fefe48-c0d8-470d-b7d8-b9fd4e9d72e0\" /\u003e\n\n\n## [Performance](https://miskibin.github.io/py-draughts/benchmarking.html)\n\nLegal moves generation in **~10-30 microseconds**:\n\n| Operation | py-draughts | pydraughts | Speedup |\n|-----------|-------------|------------|---------|\n| Board init | 2.30 µs | 547.10 µs | **238x faster** |\n| FEN parse | 21.00 µs | 358.90 µs | **17x faster** |\n| Legal moves | 17.40 µs | 3.61 ms | **207x faster** |\n| Make move | 0.90 µs | 507.75 µs | **564x faster** |\n\n\u003cimg src=\"docs/source/_static/speed_comparison.png\" alt=\"Speed Comparison Chart\" width=\"700\"\u003e\n\nEngine search at various depths:\n\n| Depth | Time | Nodes |\n|-------|------|-------|\n| 5 | 130 ms | 3,525 |\n| 6 | 350 ms | 9,537 |\n| 7 | 933 ms | 25,202 |\n| 8 | 4.9 s | 122,168 |\n\n\u003cimg src=\"docs/source/_static/engine_benchmark.png\" alt=\"Engine Benchmark\" width=\"600\"\u003e\n\n## Testing\n\nComprehensive test suite with 260+ tests covering all variants and edge cases:\n\n```bash\npytest test/ -v\n```\n\nTests include:\n- **Move generation** - Push/pop roundtrips, legal move validation\n- **Real game replays** - PDN games from Lidraughts for all variants\n- **Edge cases** - Complex king captures, promotion mid-capture, draw rules\n- **Engine correctness** - Hash stability, transposition tables, board immutability\n- **All 4 variants** - Standard, American, Frisian, Russian\n\n## Contributing\n\nContributions welcome! Please open an issue or submit a pull request.\n\n## License\n\npy-draughts is licensed under the GPL 3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiskibin%2Fpy-draughts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiskibin%2Fpy-draughts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiskibin%2Fpy-draughts/lists"}