Skip to main content

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

Project description

pydraughts

PyPI version Tests Build CodeQL codecov

pydraughts is a draughts library for Python with move generation, PDN reading and writing, engine communication and balloted openings. 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 pydraughts
from draughts import Game, Move, WHITE, BLACK
  • Create a game
game = Game(variant="standard", fen="startpos")
  • Make a move
game.push([34, 30])

# Multi-capture
game2 = Game(fen="W:WK40:B19,29")
game2.push([[40, 23], [23, 14]])
  • Get legal moves
moves, captures = game.legal_moves()
  • Detect wins and draws
has_white_won = game.has_player_won(WHITE)
is_draw = game.is_draw()
winnner = game.get_winner()
is_game_over = game.game_over()
  • 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)
  • Get a ballot
from draughts.ballots import Ballots
ballots = Ballots('english')
ballot1 = ballots.get_ballot()
ballot2 = ballots.get_ballot()

Acknowledgements

Thanks to fishnet 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 MIT License. Check out LICENSE for the full text. The licenses of the other projects that pydraughts uses are in the other_licenses folder.

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.5.6.tar.gz (170.5 kB view details)

Uploaded Source

Built Distribution

pydraughts-0.5.6-py3-none-any.whl (182.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydraughts-0.5.6.tar.gz
  • Upload date:
  • Size: 170.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for pydraughts-0.5.6.tar.gz
Algorithm Hash digest
SHA256 22f668a6c97daeb10172cf6c968477d0a0ca0d40aa13da0e679fa8e744de6110
MD5 ce5dcda3d23d0aaffab19d543cf89285
BLAKE2b-256 822f7a51184c8351abc4436f8aa286e31571fd553691cca6071439d9b185b696

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydraughts-0.5.6-py3-none-any.whl
  • Upload date:
  • Size: 182.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for pydraughts-0.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 859e393acbd217588a8c2ad6a30e1b3a1a2402b292966fa25ec5ddea501d6f42
MD5 36a7f6d177c9d21b6ce1b9a35aa5ba6d
BLAKE2b-256 6546a90c5ef757aca779bcd50db0e2ddcfe91de7b90191cf9da16f9031f846b5

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