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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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