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!
pseudo legal moves for selected square
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
Release files for py-draughts 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py-draughts-0.3.1.tar.gz | 30.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_draughts-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.6 kB
Release files / py-draughts-0.3.1.tar.gz
| Download URL | py-draughts-0.3.1.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb43db070a36d0a14b0ef775f5fcfc72a09597d1a5c261024cab2e935b2d8027
|
|
BLAKE2b-256 checksum How to use checksums |
e81f94d9033707fa33ecfe9e8abf9118dd12168dcff8cfcebdf37abad5d52479
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.1 CPython/3.11.4
|
Release files / py_draughts-0.3.1-py3-none-any.whl
| Download URL | py_draughts-0.3.1-py3-none-any.whl |
|---|---|
| Size | 31.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d61de824553c80e749b2f23b41ac724c2ebd56f881ea9fe17c9b99e87eb91ba2
|
|
BLAKE2b-256 checksum How to use checksums |
404c339fab80bcac87fa3a6fde1ebdf59dbc511d2b86bb38652a250e60faa5e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.1 CPython/3.11.4
|