Skip to main content

Python3 library for efficient chess draw-gen functions

Project description

PyPi Release Docker CI

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

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

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 -it "chesslib-dev" bash

# mount a Python test script into the build environment and run it
docker run -v $PWD:/scripts "chesslib-dev" python3 /scripts/test.py

# debug the GitHub release pipeline
docker run -v $PWD/dist:/output -v $PWD:/build -it "chesslib-dev" bash

Copyright

This software is available under the MIT licence's terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (53.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (63.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (63.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (63.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (63.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (53.8 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (64.6 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (64.2 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (53.8 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (63.7 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (63.3 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

File details

Details for the file chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2dd00ff9fb5c6f69bf5c384b242ee9e72f8fac0ca2fbabc15af9851fa4e6f00d
MD5 fbe8fc9f817da7cec13fc3961377364a
BLAKE2b-256 039b1db64a736a8de950499a010b1e55c74bdf4264538d2b5b65c68b4089b502

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d37d177e97f274f22e5e7c8d9d91defe5247cbef371d78110f684896c22b957
MD5 fd9a89e8c9d0c4467c6057735491defb
BLAKE2b-256 5fff248c6937993f430976ba6b3ebba1edad007639c437b62783953443173403

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d63b2e52cfba6b53dad7c097f9f642720e193b013dc8d225b7208380498d1e54
MD5 0df7fda1bb09a1c77025ba8d8d23a123
BLAKE2b-256 6e5d92f8350a54627336265d3ef3de6ae8c0e6754dc1b167477c4065419f9e81

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f2c04da44d5219e6a95f253c19ce689092493de281101b68161e5d72fadcd06c
MD5 15c53985fb2e81eccc92a26d8fd63033
BLAKE2b-256 73ac86f73c8105cb19d4f6f447b0fef2965098569f455a4a332f92f685b7b379

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 144648a69240683aec5bcce9f7f47e30ce95d520be5fc1c0a622eae75bd449d3
MD5 e8402ef8185a72eeab0a2f6683efefd9
BLAKE2b-256 f5ec8d12df136a20bd363cd1ed2d868315f4c2646a25d0dc637b7c25c70773d3

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 405f8315eb259c5650d43399a991335fd5486772ed44ea3a951e790dfe88dfcf
MD5 c97013879f0e7b80e03f6d9485b29773
BLAKE2b-256 b641d3394edd8eb116e2e4699f0f6fad8b1cd448d4a5b3ca885bd76666d3fe78

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 edc3d6799e039f5e2e185f2b6456e9642f0f4ba1d4d9acd9e2c7dd59b5949592
MD5 d84b5880f34e2ca0eae896cb98eaded1
BLAKE2b-256 876dfeee03d093bef38e22bb0047d0e66e3e4c9df3bdf1d29faaa9e6d2e5b995

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 417a9ad9ba0108e87a8802eb371da37f5c58ecb48b26225a5c37c66d94e69c13
MD5 0f967237b2229c5e53a0df9f9d303916
BLAKE2b-256 af367dc4264f5fce2f4b78b983dc7d4773cb89bfc62df659ae655536950cce27

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 326886a04fc41a3e5a9362d204544e808a24210e2e1327937ed8714cb818986a
MD5 8dd6b181402c39ed45a8e88f69e6c829
BLAKE2b-256 8ffbca067e8c0f0225d17628700fb51607528dadb30adc9bbec4624096eed6e4

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c3ff30ee1edfeebe3a408a900c62459d98c04e7529a76278d5d2a42ff587b0bf
MD5 f2658914352934b4c6eda7ccdabf041c
BLAKE2b-256 421dfa4a654c74421d92f772a465efbd2ad13a64dd8d6c5686b931ac0dd83533

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9232c9fe2655e6c5487f1653b76b903d61293deb9bcf7ed0e6df72fb72d40abe
MD5 cd808c6935f023ede4983155a9c8a68e
BLAKE2b-256 daca88e1bbb81dc705f54078919ee1d49e5725bfa94c93c617af65a6074e000c

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340011501-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5c719c66ac649fe1213f44856a90e63ec709ee31e91ddd9c25a3becab1e9cb02
MD5 4299ad0239f145b79227435e3b3ac7a2
BLAKE2b-256 4e16b061d46cbbc6d3e0ca679c4502c1dafbf5c66255bac75c5e98973ce9e7a5

See more details on using hashes here.

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