pydraughts


Namepydraughts JSON
Version 0.6.5 PyPI version JSON
download
home_pagehttps://github.com/AttackingOrDefending/pydraughts
SummaryA draughts library for Python with move generation, PDN reading and writing, engine communication and balloted openings
upload_time2024-02-15 17:33:05
maintainer
docs_urlNone
authorIoannis Pantidis
requires_python>=3.8
license
keywords checkers draughts game fen pdn
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # pydraughts
[![PyPI version](https://badge.fury.io/py/pydraughts.svg)](https://badge.fury.io/py/pydraughts) [![Tests](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/tests.yml/badge.svg)](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/tests.yml) [![Build](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/build.yml/badge.svg)](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/build.yml) [![CodeQL](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/codeql-analysis.yml) [![codecov](https://codecov.io/gh/AttackingOrDefending/pydraughts/branch/main/graph/badge.svg?token=ZSPXIVSAWN)](https://codecov.io/gh/AttackingOrDefending/pydraughts)

pydraughts is a draughts (checkers) library for Python with move generation, PDN reading and writing, engine communication and balloted openings. It is based on [ImparaAI/checkers](https://github.com/ImparaAI/checkers).

Installing
----------

Download and install the latest release:

    pip install pydraughts

## Features

**Variants:**
* Standard (International)
* Frisian
* frysk!
* Antidraughts
* Breakthrough
* Russian
* Brazilian
* English/American
* Italian
* Turkish

**Engine protocols:**
* Hub
* DXP
* CheckerBoard

**PDN Reading and Writing**
<br/></br>
* Import pydraughts
```python
from draughts import Board, Move, WHITE, BLACK
```
* Create a game
```python
board = Board(variant="standard", fen="startpos")
```
* Make a move
```python
move = Move(board, steps_move=[34, 30])
board.push(move)

# Multi-capture
board2 = Board(fen="W:WK40:B19,29")
board2.push(Move(board2, pdn_move='40x14'))
```
* Get a visual representation of the board
```python
print(board)

"""
   | b |   | b |   | b |   | b |   | b 
---------------------------------------
 b |   | b |   | b |   | b |   | b |   
---------------------------------------
   | b |   | b |   | b |   | b |   | b 
---------------------------------------
 b |   | b |   | b |   | b |   | b |   
---------------------------------------
   |   |   |   |   |   |   |   |   |   
---------------------------------------
   |   |   |   |   |   |   |   | w |   
---------------------------------------
   | w |   | w |   | w |   |   |   | w 
---------------------------------------
 w |   | w |   | w |   | w |   | w |   
---------------------------------------
   | w |   | w |   | w |   | w |   | w 
---------------------------------------
 w |   | w |   | w |   | w |   | w |   
"""
```
* Get legal moves
```python
moves = board.legal_moves()
```
* Detect wins and draws
```python
has_white_won = board.winner() == WHITE
is_draw = board.winner() == 0
winnner = board.winner()
is_game_over = board.is_over()
```
* Convert move to other types
```python
move = Move(board, board_move=moves[0].board_move).pdn_move
```
* Get fen
```python
fen = game.fen
```
* Communicate with engines
```python
from draughts.engine import HubEngine, Limit
engine = HubEngine(["scan.exe", "hub"])
engine.init()
limit = Limit(time=10)
engine_move = engine.play(board, limit, ponder=False)
```
* Read PDN games
```python
from draughts.PDN import PDNReader
games = PDNReader(filename=filepath)
game = games.games[0]
moves = game.moves
```
* Write PDN games
```python
from draughts.PDN import PDNWriter
games = PDNWriter(filename=filepath, board=board)
```
* Get a ballot
```python
from draughts.ballots import Ballots
ballots = Ballots('english')
ballot1 = ballots.get_ballot()
ballot2 = ballots.get_ballot()
```
* Run tournaments
```python
from draughts.tournament import RoundRobin
player1 = (["scan.exe", "hub"], "hub", {}, None)
player2 = ("kr_hub.exe", "hub", {}, None)
players = [player1, player2]
tournament = RoundRobin("tournament.pdn", players, start_time=20, increment=0.2, games_per_pair=4)
scores = tournament.play()
print(scores)
tournament.print_standings()
```

## Acknowledgements
Thanks to [fishnet](https://github.com/lichess-org/fishnet/tree/ebd2a5e16d37135509cbfbff9998e0b798866ef5) which was modified to add support for Hub engines. Thanks to [akalverboer](https://github.com/akalverboer) for their [DXC100_draughts_client](https://github.com/akalverboer/DXC100_draughts_client) which was modified to add support for DXP engines.

## License
pydraughts is licensed under The MIT License. Check out `LICENSE` for the full text.
The licenses of the other projects that pydraughts uses are in the `other_licenses` folder.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AttackingOrDefending/pydraughts",
    "name": "pydraughts",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "checkers,draughts,game,fen,pdn",
    "author": "Ioannis Pantidis",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f6/2f/8fa04a514c74e786d2ff15615280865b7a931dbf3658184a12d819762157/pydraughts-0.6.5.tar.gz",
    "platform": null,
    "description": "# pydraughts\r\n[![PyPI version](https://badge.fury.io/py/pydraughts.svg)](https://badge.fury.io/py/pydraughts) [![Tests](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/tests.yml/badge.svg)](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/tests.yml) [![Build](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/build.yml/badge.svg)](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/build.yml) [![CodeQL](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AttackingOrDefending/pydraughts/actions/workflows/codeql-analysis.yml) [![codecov](https://codecov.io/gh/AttackingOrDefending/pydraughts/branch/main/graph/badge.svg?token=ZSPXIVSAWN)](https://codecov.io/gh/AttackingOrDefending/pydraughts)\r\n\r\npydraughts is a draughts (checkers) library for Python with move generation, PDN reading and writing, engine communication and balloted openings. It is based on [ImparaAI/checkers](https://github.com/ImparaAI/checkers).\r\n\r\nInstalling\r\n----------\r\n\r\nDownload and install the latest release:\r\n\r\n    pip install pydraughts\r\n\r\n## Features\r\n\r\n**Variants:**\r\n* Standard (International)\r\n* Frisian\r\n* frysk!\r\n* Antidraughts\r\n* Breakthrough\r\n* Russian\r\n* Brazilian\r\n* English/American\r\n* Italian\r\n* Turkish\r\n\r\n**Engine protocols:**\r\n* Hub\r\n* DXP\r\n* CheckerBoard\r\n\r\n**PDN Reading and Writing**\r\n<br/></br>\r\n* Import pydraughts\r\n```python\r\nfrom draughts import Board, Move, WHITE, BLACK\r\n```\r\n* Create a game\r\n```python\r\nboard = Board(variant=\"standard\", fen=\"startpos\")\r\n```\r\n* Make a move\r\n```python\r\nmove = Move(board, steps_move=[34, 30])\r\nboard.push(move)\r\n\r\n# Multi-capture\r\nboard2 = Board(fen=\"W:WK40:B19,29\")\r\nboard2.push(Move(board2, pdn_move='40x14'))\r\n```\r\n* Get a visual representation of the board\r\n```python\r\nprint(board)\r\n\r\n\"\"\"\r\n   | b |   | b |   | b |   | b |   | b \r\n---------------------------------------\r\n b |   | b |   | b |   | b |   | b |   \r\n---------------------------------------\r\n   | b |   | b |   | b |   | b |   | b \r\n---------------------------------------\r\n b |   | b |   | b |   | b |   | b |   \r\n---------------------------------------\r\n   |   |   |   |   |   |   |   |   |   \r\n---------------------------------------\r\n   |   |   |   |   |   |   |   | w |   \r\n---------------------------------------\r\n   | w |   | w |   | w |   |   |   | w \r\n---------------------------------------\r\n w |   | w |   | w |   | w |   | w |   \r\n---------------------------------------\r\n   | w |   | w |   | w |   | w |   | w \r\n---------------------------------------\r\n w |   | w |   | w |   | w |   | w |   \r\n\"\"\"\r\n```\r\n* Get legal moves\r\n```python\r\nmoves = board.legal_moves()\r\n```\r\n* Detect wins and draws\r\n```python\r\nhas_white_won = board.winner() == WHITE\r\nis_draw = board.winner() == 0\r\nwinnner = board.winner()\r\nis_game_over = board.is_over()\r\n```\r\n* Convert move to other types\r\n```python\r\nmove = Move(board, board_move=moves[0].board_move).pdn_move\r\n```\r\n* Get fen\r\n```python\r\nfen = game.fen\r\n```\r\n* Communicate with engines\r\n```python\r\nfrom draughts.engine import HubEngine, Limit\r\nengine = HubEngine([\"scan.exe\", \"hub\"])\r\nengine.init()\r\nlimit = Limit(time=10)\r\nengine_move = engine.play(board, limit, ponder=False)\r\n```\r\n* Read PDN games\r\n```python\r\nfrom draughts.PDN import PDNReader\r\ngames = PDNReader(filename=filepath)\r\ngame = games.games[0]\r\nmoves = game.moves\r\n```\r\n* Write PDN games\r\n```python\r\nfrom draughts.PDN import PDNWriter\r\ngames = PDNWriter(filename=filepath, board=board)\r\n```\r\n* Get a ballot\r\n```python\r\nfrom draughts.ballots import Ballots\r\nballots = Ballots('english')\r\nballot1 = ballots.get_ballot()\r\nballot2 = ballots.get_ballot()\r\n```\r\n* Run tournaments\r\n```python\r\nfrom draughts.tournament import RoundRobin\r\nplayer1 = ([\"scan.exe\", \"hub\"], \"hub\", {}, None)\r\nplayer2 = (\"kr_hub.exe\", \"hub\", {}, None)\r\nplayers = [player1, player2]\r\ntournament = RoundRobin(\"tournament.pdn\", players, start_time=20, increment=0.2, games_per_pair=4)\r\nscores = tournament.play()\r\nprint(scores)\r\ntournament.print_standings()\r\n```\r\n\r\n## Acknowledgements\r\nThanks to [fishnet](https://github.com/lichess-org/fishnet/tree/ebd2a5e16d37135509cbfbff9998e0b798866ef5) which was modified to add support for Hub engines. Thanks to [akalverboer](https://github.com/akalverboer) for their [DXC100_draughts_client](https://github.com/akalverboer/DXC100_draughts_client) which was modified to add support for DXP engines.\r\n\r\n## License\r\npydraughts is licensed under The MIT License. Check out `LICENSE` for the full text.\r\nThe licenses of the other projects that pydraughts uses are in the `other_licenses` folder.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A draughts library for Python with move generation, PDN reading and writing, engine communication and balloted openings",
    "version": "0.6.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/AttackingOrDefending/pydraughts/issues",
        "Homepage": "https://github.com/AttackingOrDefending/pydraughts"
    },
    "split_keywords": [
        "checkers",
        "draughts",
        "game",
        "fen",
        "pdn"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "783a2da82cb7bcb93d36dd6512bfdd5059d5c7df053f0d5341e28e2a8d79cd35",
                "md5": "a608b409690ec6424e4b3b39b84ca0e1",
                "sha256": "1cb71c9e315a4dafdb8d7c636565549012de854541edc6712331afa05745f3d7"
            },
            "downloads": -1,
            "filename": "pydraughts-0.6.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a608b409690ec6424e4b3b39b84ca0e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 193089,
            "upload_time": "2024-02-15T17:32:55",
            "upload_time_iso_8601": "2024-02-15T17:32:55.542215Z",
            "url": "https://files.pythonhosted.org/packages/78/3a/2da82cb7bcb93d36dd6512bfdd5059d5c7df053f0d5341e28e2a8d79cd35/pydraughts-0.6.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f62f8fa04a514c74e786d2ff15615280865b7a931dbf3658184a12d819762157",
                "md5": "6db7c720e53ccfd3f40e9472652dc89f",
                "sha256": "5366edc17e68291a3f74090aaac93c69866fb0dd7d1efcef907706eb40e6d63e"
            },
            "downloads": -1,
            "filename": "pydraughts-0.6.5.tar.gz",
            "has_sig": false,
            "md5_digest": "6db7c720e53ccfd3f40e9472652dc89f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 179518,
            "upload_time": "2024-02-15T17:33:05",
            "upload_time_iso_8601": "2024-02-15T17:33:05.743048Z",
            "url": "https://files.pythonhosted.org/packages/f6/2f/8fa04a514c74e786d2ff15615280865b7a931dbf3658184a12d819762157/pydraughts-0.6.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-15 17:33:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AttackingOrDefending",
    "github_project": "pydraughts",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pydraughts"
}
        
Elapsed time: 0.20096s