Skip to main content

A checkers library for Python, with move generation and validation, PDN parsing and writing. Supprots multiple variants of game.

Project description

https://github.com/michalskibinski109/checkers/actions/workflows/python-app.yml/badge.svg https://badge.fury.io/py/fast_checkers.svg

Draughts

Project still under active developement. Still lacking some important functionality.

Efficient Modern and flexible implementation of draughts game with beautiful web interface. Supports multiple variants of the game and allows to play against AI.

Documentation

Installation

python -m pip install py-draughts

Usage

simple

>>> import draughts.american as draughts

>>> board = draughts.Board()
---------------------------------
|   | x |   | x |   | x |   | x |
---------------------------------
| x |   | x |   | x |   | x |   |
---------------------------------
|   | x |   | x |   | x |   | x |
---------------------------------
|   |   |   |   |   |   |   |   |
---------------------------------
|   |   |   |   |   |   |   |   |
---------------------------------
| o |   | o |   | o |   | o |   |
---------------------------------
|   | o |   | o |   | o |   | o |
---------------------------------
| o |   | o |   | o |   | o |   |

Moving pieces

>>> board.push_from_str("24-19")
>>> board.push_from_str("12-16")
>>> board.push_from_str("23-18")
>>> board.push_from_str("16x23")
>>> board.push_from_str("26x19")
>>> board.pop()
>>> print(board)
---------------------------------
|   | x |   | x |   | x |   | x |
---------------------------------
| x |   | x |   | x |   | x |   |
---------------------------------
|   | x |   | x |   | x |   |   |
---------------------------------
|   |   |   |   |   |   |   |   |
---------------------------------
|   |   |   | o |   |   |   |   |
---------------------------------
| o |   | o |   | x |   |   |   |
---------------------------------
|   | o |   | o |   | o |   | o |
---------------------------------
| o |   | o |   | o |   | o |   |
>>> print(list(board.legal_moves))
[Move: 21->17, Move: 22->18, Move: 22->17, Move: 23->19, Move: 23->18, Move: 24->20, Move: 24->19]

Creating custom board

import draughts.base as draughts
import numpy as np
CUSTOM_POSITION = np.array([1] * 20 + [-1] * 12, dtype=np.int8)
board = draughts.BaseBoard(starting_position=CUSTOM_POSITION)
board.legal_moves = ... # create your own custom legal_moves method (property)

UI

from draughts.server import Server
Server().run()

It is as simple as that!

https://github.com/michalskibinski109/draughts/assets/77834536/4ec36e49-38cc-45e8-a500-d0d24b21fce7 https://github.com/michalskibinski109/draughts/assets/77834536/b7e0bf73-1bc5-4769-8f82-a22cde3b7e90

pseudo legal moves for selected square

https://github.com/michalskibinski109/draughts/assets/77834536/ef64179a-1e7d-46d4-991e-5a34fc803d7e

Contributing

Contributions to this project are welcome. If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the project repository.

Bibliography

  1. notation

  2. rules and variants

  3. list of pdns

  4. droughts online

  5. additional 1 (checkers online)

  6. additional 2 (chinook)

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

py-draughts-0.3.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

py_draughts-0.3.1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file py-draughts-0.3.1.tar.gz.

File metadata

  • Download URL: py-draughts-0.3.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for py-draughts-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bb43db070a36d0a14b0ef775f5fcfc72a09597d1a5c261024cab2e935b2d8027
MD5 8ea6a3be3e3c1532ffb809fef79db378
BLAKE2b-256 e81f94d9033707fa33ecfe9e8abf9118dd12168dcff8cfcebdf37abad5d52479

See more details on using hashes here.

File details

Details for the file py_draughts-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: py_draughts-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for py_draughts-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d61de824553c80e749b2f23b41ac724c2ebd56f881ea9fe17c9b99e87eb91ba2
MD5 62a058b50f4d9e83a1855ad8dba6c2ee
BLAKE2b-256 404c339fab80bcac87fa3a6fde1ebdf59dbc511d2b86bb38652a250e60faa5e1

See more details on using hashes here.

Supported by

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