Python3 library for efficient chess draw-gen functions
Project description
ChessLib Python Extension
About
This project provides an efficient chess draw generation extension for Python3. The main purpose of this project is enabling further TensorFlow AI projects and learning how to write an efficient Python3 extension (using good old C).
Usage
Install the official Python package using pip:
pip install chesslib
Use the chesslib package like in the following example:
import chesslib
import numpy as np
import random
def test():
# create a new chess board in start formation
board = chesslib.ChessBoard_StartFormation()
# generate all possible draws
draws = chesslib.GenerateDraws(board, chesslib.ChessColor_White, chesslib.ChessDraw_Null, True)
# apply one of the possible draws
draw_to_apply = draws[random.randint(0, len(draws) - 1)]
new_board = chesslib.ApplyDraw(board, draw_to_apply)
# write the draw's name
print(chesslib.VisualizeDraw(draw_to_apply))
# visualize the board before / after applying the draw
print(chesslib.VisualizeBoard(board))
print(chesslib.VisualizeBoard(new_board))
# revert the draw (just call ApplyDraw again with the new board)
rev_board = chesslib.ApplyDraw(new_board, draw_to_apply)
# get the board's 40-byte-hash and create a new board instance from the hash
board_hash = chesslib.Board_ToHash(board)
board_reloaded = chesslib.Board_FromHash(board_hash)
# see tests/ folder for more examples
How to Develop
The commands for dev-testing the chesslib are wrapped within a Docker environment. Therefore build the 'Dockerfile-dev' file which takes your source code and performs all required CI steps (build + install + unit tests). Afterwards you may attach to the Docker image with the bash console interactively and run commands, etc.
# make a dev build using the 'Dockerfile-dev' build environment
# this runs all CI steps (build + install + unit tests)
docker build . --file Dockerfile-dev -t "chesslib-dev"
# attach to the build environment's interactive bash console (leave the session with 'exit')
docker run "chesslib-dev" -it bash
# mount a Python test script into the build environment and run it
docker run -v $PWD:/scripts "chesslib-dev" python3 /scripts/test.py
Advantages of this approach are that it simplifies the dev machine setup a lot as you only need Docker, git and a good text editor on your local machine. Moreover you don't mess up your dev machine when trying to build and install the chesslib package for debugging again and again. And most importantly you keep your local copy of the git repo clean as all temporary files are created within the Docker container, so you basically don't need to worry about accidentially including build files into git commits, etc.
For a quickstart, set up your dev machine as a VM (e.g. Ubuntu 20.04 hosted by VirtualBox). After successfully creating the VM, use following commands to install all essential dev tools (git, docker, good text editor).
# install docker (e.g. Ubuntu 20.04)
sudo apt-get update && sudo apt-get install -y git docker.io
sudo usermod -aG docker $USER && reboot
# download the project's source code (if you haven't done before)
git clone https://github.com/Bonifatius94/ChessLib.Py
cd ChessLib.Py
# install the 'Visual Studio Code' text editor (optional)
sudo snap install code --classic
Copyright
You may use this project under the MIT licence's conditions.
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 Distributions
Built Distributions
File details
Details for the file chesslib-1.0.333230494-cp39-cp39-manylinux2014_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp39-cp39-manylinux2014_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c114327950423f4d06993df045825ef61a428e06db0fced911721c88ef2812d5 |
|
MD5 | 3c5759c6b0d3685796ab95326ae64e0e |
|
BLAKE2b-256 | 66b3bda613dd869170777d46d85e6b36b17ca6769f19913fe533ef776e989665 |
File details
Details for the file chesslib-1.0.333230494-cp39-cp39-manylinux2010_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp39-cp39-manylinux2010_x86_64.whl
- Upload date:
- Size: 61.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 063f9c801a57cd1de4c23fb218a57104398d6b96657406c3211f7c7838d2c440 |
|
MD5 | 7f5ed8c8aa31c15fafc39564b58b9770 |
|
BLAKE2b-256 | 72c7e85f720365c1629d3745214b9948c2bd05fbe46ad2ff1d8655481f5279ad |
File details
Details for the file chesslib-1.0.333230494-cp39-cp39-manylinux1_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp39-cp39-manylinux1_x86_64.whl
- Upload date:
- Size: 50.9 kB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6c6b54f3dc31fa9f16a32430e911febaf25501bd60e4168e1c856a7c69cb662 |
|
MD5 | 3f8f076058d257b91bf8370f6961db4b |
|
BLAKE2b-256 | 20540525b58fa676eef772f15eac08eafef85f72f7c064a4863cff642aa3f9de |
File details
Details for the file chesslib-1.0.333230494-cp38-cp38-manylinux2014_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 61.8 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20eebcc4322561f229b010eb99f843513b719adfd83a4bd36f7d7335297058c5 |
|
MD5 | 74feec4d5a391eaf197a24d59111f6d7 |
|
BLAKE2b-256 | 36bede9f611d8e0dd3d5eadb34117a0746cd7199dfbb503df8e46ccfed68e296 |
File details
Details for the file chesslib-1.0.333230494-cp38-cp38-manylinux2010_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp38-cp38-manylinux2010_x86_64.whl
- Upload date:
- Size: 61.6 kB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c9070d8204d2b3ae461e525621c995aca9dbe5c442007c8dbfca0b7988dc4be |
|
MD5 | 573fd5c7dd466e3dbf678e1265be5cf5 |
|
BLAKE2b-256 | 3829d19db8d67dd52ae559d018f46c986b12cf926d419ba03a9b84514b20ab63 |
File details
Details for the file chesslib-1.0.333230494-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 51.3 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0406a3255d72323397666de2817f1859bf582e6fb87c7a62a4ecdee41aae92e |
|
MD5 | 588d0dd61656c2cfa60d47573d05f917 |
|
BLAKE2b-256 | d1b4423ff64174cb411cd045191c4650dc2ffd2132384ff8477c4867bebf4987 |
File details
Details for the file chesslib-1.0.333230494-cp37-cp37m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp37-cp37m-manylinux2014_x86_64.whl
- Upload date:
- Size: 62.6 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dabaaf0fee6e5970f3dd86580151c5b29aa2226ad3281839ea6346239f91286e |
|
MD5 | 5d901690412d69d77463efb364919a8c |
|
BLAKE2b-256 | c1bcf108a66da5bd616ab7a4c3c2980fc07ed91a17ffb3bd04389759df29fc00 |
File details
Details for the file chesslib-1.0.333230494-cp37-cp37m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp37-cp37m-manylinux2010_x86_64.whl
- Upload date:
- Size: 62.4 kB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8771e5829314cdaca3d6493ee9b50427d81af92be93981a5d5abb4f4bc30571 |
|
MD5 | b586c68d0063e17283c8adbcc01fa691 |
|
BLAKE2b-256 | fb6065e823355d51e01f9b8cfd5bd2fda9c477c40a91e0cf813243d425084c52 |
File details
Details for the file chesslib-1.0.333230494-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 50.9 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89468913929442dfa5135f71457a1eff851f72fe25065693f04cfab935c124bf |
|
MD5 | def1cf6a7b71180a5992b95214781ec3 |
|
BLAKE2b-256 | a133bf51885c5d3e37a7a28693b6e42451eb1c9bd6c0b168326041b0705533a9 |
File details
Details for the file chesslib-1.0.333230494-cp36-cp36m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp36-cp36m-manylinux2014_x86_64.whl
- Upload date:
- Size: 61.6 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 560a7067eb312c63cf38fbb40e3d291f4385e75687e5ee07466e69306c01b915 |
|
MD5 | 8e0f9754af264fa38b72de4e2340d48f |
|
BLAKE2b-256 | 39ff89f7421fe0a40fbdb9f5cb0b0cc44758c1926d20d22e8f484d9750f15102 |
File details
Details for the file chesslib-1.0.333230494-cp36-cp36m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp36-cp36m-manylinux2010_x86_64.whl
- Upload date:
- Size: 61.4 kB
- Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd2977a054f3b38359bdc5d19bbc0c4b7ae039e362d342fdde4489ac3d9a4e91 |
|
MD5 | f7889c91173577fa2ad92863f3ccca4f |
|
BLAKE2b-256 | c17a37b868473679c9cf46d00001a9be111cfeb0035e353529b7badaeb0a66b6 |
File details
Details for the file chesslib-1.0.333230494-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 50.9 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 442bd13a1ca78dea27e7411c0fef95b20c38244c3f1cce5e7667905f7e2a1627 |
|
MD5 | 13027aec595b25c84a8294a094e6e084 |
|
BLAKE2b-256 | fd7fda32c4d7b7eb990decd3762ef396bd0e81cbc9ef47db0d0992c75d30d831 |
File details
Details for the file chesslib-1.0.333230494-cp35-cp35m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp35-cp35m-manylinux2014_x86_64.whl
- Upload date:
- Size: 61.3 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a2a48c7dac0e1afa1035462aaf0540210c3b75f3a4cb4b09f61c0b11591c9a3 |
|
MD5 | 505cb97a72192163438730309d16ae6b |
|
BLAKE2b-256 | ffd482a2bda564abc27dd9a871d8108632a7b226d58f910c3a149045dc44341c |
File details
Details for the file chesslib-1.0.333230494-cp35-cp35m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp35-cp35m-manylinux2010_x86_64.whl
- Upload date:
- Size: 61.1 kB
- Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6be3783a3231e9af204151f389acce7b7bd6d42ec45e1f4d6d7fbe7452ad04b |
|
MD5 | d70b1ef86a904783aa076d3b7ab5733d |
|
BLAKE2b-256 | 47ea1692b843f0fdc9240d6e38326e0c1023e51f781dbf1a1092d6793dd266a0 |
File details
Details for the file chesslib-1.0.333230494-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: chesslib-1.0.333230494-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 50.9 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7f63691d64df17b42b62b9fc19c085d2a9217ed1a76694dbc6ebb89c56b2df |
|
MD5 | f9fde8ccdff2affa1c012b42a5e734c2 |
|
BLAKE2b-256 | 5e66ef1c584eb3d83fb56c2e32d9d92367c0e4e8226090050b1281839854f0cb |