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.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (56.2 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (65.9 kB view details)

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

chesslib-1.0.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (65.4 kB view details)

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

chesslib-1.0.340181575-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (56.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

chesslib-1.0.340181575-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (66.3 kB view details)

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

chesslib-1.0.340181575-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (65.8 kB view details)

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

chesslib-1.0.340181575-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (56.2 kB view details)

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

chesslib-1.0.340181575-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (67.1 kB view details)

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

chesslib-1.0.340181575-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (66.6 kB view details)

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

chesslib-1.0.340181575-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (56.2 kB view details)

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

chesslib-1.0.340181575-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (66.2 kB view details)

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

chesslib-1.0.340181575-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (65.7 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.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 38c0fec8a8ff9371bfc54f40769e26c4bc352c96b09b079207417c612c183fbd
MD5 1a5f9eca8d51c6552d03985c6d19e21d
BLAKE2b-256 1feb1903a8ed0c55bc73a794ac38304b196023f63f18c1c451d846a9fd39d3a3

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bfb0a9add5b1703bb78ab5d9ebe6371cd5b108d80ef4a48a82b38ed8d99bf2bd
MD5 5e21145131d9fa86cf984e2ecb35e7db
BLAKE2b-256 57ac3cf5fb4f87b71e836e865d8594b04ff51b30a4f17bf0e3a954471f6d911f

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c1de6ac7a2b67ffddd1413137dbe84c541d5603571f2d4bfc04e2be3a4fe9088
MD5 5c2dcc0e8869bb25ad6fab905d6fd985
BLAKE2b-256 99654465c095b850f62ef58165c1cb444983182cd394d6ae36d98a3c05299775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340181575-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1a67a65052352552b31af81f77f1c71bbb3ce2aee8eac24c78fa64d9bee53481
MD5 c0206e20627128f5b919271f6e183895
BLAKE2b-256 a8794f0d7ab26061ab28a130059deb4704aefef829fab803b6aa3a5e29b91460

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67751b5d2a99cc6be5023f6a28cc4376732886a094dd09330afd6caef158c4db
MD5 2e2d2f27937de253660558290097c1b2
BLAKE2b-256 87b3fd3f37be6d56057ebfbdbbaef1a806de10ea8905df7623d7b46ed16b2550

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0844fb961b84439ca8d9c6db7daa07ec8278426ce6e756de37ac9836d340d352
MD5 b9b9635c34cc6161120b63571fd46866
BLAKE2b-256 3dcdddeb77712265a6f45ac8da73c0d90c29c610dd9c4f49a4a122c58a32db83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340181575-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 51555c5f3b4083cf3951a3fcf06f9eb780c3a331205de1d6d8a0ee5e03c55732
MD5 c69429b219e8ba35a50e368a112ede32
BLAKE2b-256 2a4391936709d761b690bd6c298de48014bcd2d8e899feb15e823ec177b57730

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 edd3882146ab08d6a829c6cb93a06e4c8175e5f0fbcfe4dfe1e3127b5892a020
MD5 dd4e50acedc436a34cc9340031081c2e
BLAKE2b-256 f3ece27b98038a233b72de93cdb9b99178d21e42c6189d82084e2d46219d8a7e

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0f53019510ba6d5f6d57cb4f08c5e24bf1876e400cba4bc08c322e80161b4f1e
MD5 5507514cf3c9351696ab93fb075e197b
BLAKE2b-256 aee6bea646a06698d6cc3ccc50f0f25ab9302d1a8cf141e27ffabd36c8b960f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340181575-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 36ebc29d5d5622f3a94378948ef8f9e00bcc1b72423ac7c4940adb85adebd2ee
MD5 764fe35196f7465985d1e55d53fd78d5
BLAKE2b-256 68a863b257635f2f29f83f49ea51e1f0281536ff38563bfa9d7949a302b4a198

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8247ae314088090fdd17d5812af6492c2c438cf29b1548fdfa9d730115e59d4
MD5 ba70d71fd800810625bb7fe96574ecb4
BLAKE2b-256 310716f75a3114331fd7d66709a8245d4e724be05b0a5bf12094e0bc9a31db92

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340181575-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.340181575-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 950a567dc9d7711e09f39fd12c87af8e509295c28940549b2d55f87ae05414cd
MD5 3a647e6e63e6da9c97ca623fb2b5e1d0
BLAKE2b-256 5fa229830c41e33c6d46e211f4bc0aa65dadda0edbec039fc714372e113efde6

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