Skip to main content

A draughts library for Python with move generation, PDN reading and writing and engine communication

Project description

pydraughts

PyPI version Tests Build CodeQL

pydraughts is a draughts library for Python with move generation, PDN reading and writing and engine communication. It is based on ImparaAI/checkers.

Installing

Download and install the latest release:

pip install pydraughts

Features

Note: White always starts. Black always has the squares starting from 1 (e.g. 1-20 in international draughts).

Variants:

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

Engine protocols:

  • Hub
  • DXP
  • CheckerBoard

PDN Reading and Writing

  • Import library
from draughts import Game, Move
  • Create a game
game = Game(variant="standard", fen="startpos")
  • Make a move
game.move([34, 30])
  • Get legal moves
moves, captures = game.legal_moves()
  • Convert move to other types
move = Move(game, board_move=moves[0]).pdn_move
  • Get fen
fen = game.get_li_fen()
  • Communicate with engines
from draughts.engine import HubEngine, Limit
engine = HubEngine("scan.exe hub")
engine.init()
limit = Limit(time=10)
engine_move = engine.play(game, limit, ponder=False)
  • Read PDN games
from draughts.PDN import PDNReader
games = PDNReader(filename=filepath)
game = games.games[0]
moves = game.moves
  • Write PDN games
from draughts.PDN import PDNWriter
games = PDNWriter(filename=filepath, board=game)

Acknowledgements

Thanks to RoepStoep for his draughtsnet which was modified to add support for Hub engines. Thanks to akalverboer for their DXC100_draughts_client which was modified to add support for DXP engines.

License

pydraughts is licensed under the GPL 3 (or any later version at your option). Check out LICENSE.txt for the full text. The license of ImparaAI/checkers is also present here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydraughts-0.3.4.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

pydraughts-0.3.4-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

Details for the file pydraughts-0.3.4.tar.gz.

File metadata

  • Download URL: pydraughts-0.3.4.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.6.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.2

File hashes

Hashes for pydraughts-0.3.4.tar.gz
Algorithm Hash digest
SHA256 e03c01f0305f2a22e6f5398cce339aa9f8003d5f8c0f2d8bbd8514043e587c51
MD5 cdc94bb8843233fd246f529e180a7f03
BLAKE2b-256 c9a9bc9239c252d6a873c3ab6bef925813f19a6ec15db7643844e3fee2c78924

See more details on using hashes here.

File details

Details for the file pydraughts-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: pydraughts-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.6.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.2

File hashes

Hashes for pydraughts-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0bff6b81394f4ae42ac137bef2a7603906f58be24c9b46ec9f204ca08b5a67e8
MD5 e74ffa3c480c716416da137529b6cea9
BLAKE2b-256 e374fc2b1e04b7f535ff7ca16c1517d8eee05540ca3b6768732108422bc2d47c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page