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

File metadata

File hashes

Hashes for chesslib-1.0.340183814-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 81dd62006f804d4673915c16c7d447b91efcdd7df14fd5b96e61e9311db6521e
MD5 22b787075b69537c4584631ee3c5663b
BLAKE2b-256 ff2c383f29d3d3cefaa23becafecdea301454e3b136b991848d1154bf16a3cca

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c82da4e50b05119075d0b9ae49a5d95f283e7b61555ab0908c3b7634fc539191
MD5 f62c366c328c9c4fbc15d87f0a2104e8
BLAKE2b-256 65a245d5f83cf762da62f6bb11ec29236338615d4ced0c1573c2efd2ceca7d53

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 17ab0f7514b4fe0e382455a49b267ed364e9ea3baf32bfdfd8e46444fef0d0c6
MD5 c6c84e62d366a5692da29acbe7908a0d
BLAKE2b-256 2605cd83b47c6e87e4defa05c5da0bebdb190a9f42ed6c6aeed7cd9b9797a921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340183814-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a8635d66e37e367d157fcde3f6142fe10f2b18deff14e9f234f7b178742ecbff
MD5 210850c6ef787d838c4e27f93d8cd3be
BLAKE2b-256 c377910176396c02a6c3e44c3df444c0766efe370224a9eb8cb1a83e47a7eb94

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3b6e38f624bdf49077ce5475364586468341fc5a5efaed0dac5a16e9d992069
MD5 978c5847482ddb099d534450800881e9
BLAKE2b-256 6d006c5e13d6a92848046f7287990c95c4d7af67d61ee926bbe61014a330ce05

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ff4e1157ce77a6e11784a3362a0c0376293f6b559d4f0832a84b358b55574db5
MD5 b8fddb7bae763f51add1af89e2a0a6ca
BLAKE2b-256 3fdbf3102d6dc8481c9de2c045aba75eea2d2b949bdb40638dc6ed386144ad1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340183814-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c78ff1f706f34fa10f7ad5ab411006f12619b7a70f78bc18926348cd35390539
MD5 8779d71cea1f984175a6f6632a1b9b56
BLAKE2b-256 66ff763c7ff2f5079c51d7488cb75cbf6b7815e1d6cebb0c0400b339c50aea99

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c188901f7e517d98c7fcdc0a57f75c8d5b9e111b6a1e76dd696ac75b35f0951
MD5 7e01a5e24b3295f3843cfbb201a9d0d3
BLAKE2b-256 7e14be1f32a9605442e1a061f35e88ebf51a50649a6dd494dff92e16d8bcd7cf

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 048743629747291f082671790212aed25af95bfb3138b4365ffa127cde1938ec
MD5 3a0e40773b6fcdb350e2c37b4ce9b5a0
BLAKE2b-256 60a0082edd7db60430832653b3275eb271de233ad6724d0c3231f093c18dc07e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.340183814-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1ba3a48f8261192d3ee1336eb98003985055bf14d8c8ac5e19db1bf6b0ebbf17
MD5 4865adffd5793d45434c631c1b01cbcc
BLAKE2b-256 3b1e632f75ac70e4a05727911fdf62d479d8c0b39b5358db88563c205decb22f

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76174eb075030458b9ba6b6754fe0b9015175d40bc1a82946c87216d5d74a537
MD5 79b7c93ac566be4b723a45dd66e15393
BLAKE2b-256 d9606f6981c46505056c03bb6f651ce5a67499c31c6c335c3dc3ef943dc5ecd7

See more details on using hashes here.

File details

Details for the file chesslib-1.0.340183814-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.340183814-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b0a9522c9a5893663526a976001411c3d94c859e9a9e5e279825585cca11ae1e
MD5 6cbcee25610a55e30bf98834fbaf6f7f
BLAKE2b-256 aadc1d4d1c91d834c60e24719fa08ae3cd8c98c0c1fa9cd1eecbac5bdea039d4

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