A checkers library for Python, with move generation and validation, PDN parsing and writing. Supprots multiple variants of game.
Project description
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
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for py_draughts-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d61de824553c80e749b2f23b41ac724c2ebd56f881ea9fe17c9b99e87eb91ba2 |
|
MD5 | 62a058b50f4d9e83a1855ad8dba6c2ee |
|
BLAKE2b-256 | 404c339fab80bcac87fa3a6fde1ebdf59dbc511d2b86bb38652a250e60faa5e1 |