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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-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.340009677-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.340009677-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4955482f057a839459ee99719afcaab56dcb12053833478343a804b8ded776b0
MD5 42a40776fe469e861f078f05be67aa91
BLAKE2b-256 5108c9e30e8823cdcce8a05afc2c2acc750e17898337c413c32295fa96b67b09

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b39f477a3a16fbfed73310b688d597181cff8d9a9c19a8fe0bc6e916577afdd8
MD5 463ccf4c6a2c43efe2a0c9e89065ba43
BLAKE2b-256 39a5d6028d33d252daefd42825c9cd36b200ebfb083d90a2de31ef3bbd4c82f4

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 be5d28803cb697337d57b3caad1f9c8d4f262acdc1ae2925c0e432d964f5178f
MD5 c1f6335e09259b364c0f70999e8d36f7
BLAKE2b-256 23ca574d3c1bbcab1add1a1c0606dc929075fcbcaada250d4bf53b19581eabc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340009677-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bcd4aba56cfa991fa88a3fca6c577697b7b1b3c4ff07e24eeb8ceea62dbddc5e
MD5 d1d9e4762cdeea3c1f68c6cafdb7f81a
BLAKE2b-256 0f20b4e21c57d5f2e935387943b410e4901a46a968491637005829bb237f6e7a

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c4c48ff835de866826a9c87345d919642c520de25905ec56502499355b2635f
MD5 fcd1e63195e4cdbb8735581839f2226e
BLAKE2b-256 64e03dfbb69ae68f2a029e69aa7998c606bbd7114d0501cf2165d9783d6f8d4e

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5ce5809ea7bf94a9719b80f7676af0c727fa6a1d2027c9393518b8cc307c891d
MD5 08ceb5278d5dbf64433e09251f4c193a
BLAKE2b-256 e247db7be09cfd4f86779da1e682ca2d6aa7b721748053d1e82b9db82ee56e50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340009677-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e9371a62cee042192a285b1bc2b415058d77964f71f45223f50276c1d76e5347
MD5 bf5caf846cdd43770af98a270297fab5
BLAKE2b-256 b331daecc3869f3ffb17bd38cfc78d82260daa9f1054d25d6202f3a65d94ab1c

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26dc421ebab581fcde74ffaf2e311218561a38e185adc66130d60d8e850bac37
MD5 7f446c0e8e1aedc0484e02ee6f4b66b7
BLAKE2b-256 95d76321d0635b2b2ee3e60ad865dc02c29b0f14ae5f96cdb3b451a70768d536

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 90d26982c9058f214f1c176b5fe3747a2de64584ae2c06f032975fbddc8a2a15
MD5 035c7de4d615bf21f5b3c7bf5b2d21ab
BLAKE2b-256 c44ed5153386db0119e4564ec0e9dc88e473535fbc4d2678c4cfb1be9909292e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340009677-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 31260bd243471841e945372c82d003011eac9cfee1c244a0fde7273de6b00585
MD5 d26ccf05ddb54d49f8d3581fe604aa94
BLAKE2b-256 deb386cabad16d45382278b869743b0f10bb81c9f9a1098d65fc65f43861eab3

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e99a5fcbd9b00a0aa8b16d52ad3f47e9973669c366940380525a3c189d927618
MD5 d6d4b2e1549ee429f1de03933d618f72
BLAKE2b-256 efdec22f5b6869ec24a90310ecb096b01f82ff6c73704159c1d1358a77445c8e

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340009677-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.340009677-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 fc06cbe92c0d65864a47d722afe2759f26cc8e2b5c8afbf6068f6907cacaf929
MD5 0f72688bde960489dc65757ab4c67a67
BLAKE2b-256 8faf1345655e235495e1a7cac16514e2aba2add88f981574cf249138b2a4928f

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