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

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


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.333892741-cp39-cp39-manylinux2010_x86_64.whl (63.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

chesslib-1.0.333892741-cp38-cp38-manylinux2010_x86_64.whl (63.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

chesslib-1.0.333892741-cp37-cp37m-manylinux2010_x86_64.whl (64.7 kB view details)

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

chesslib-1.0.333892741-cp37-cp37m-manylinux1_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.7m

chesslib-1.0.333892741-cp36-cp36m-manylinux2010_x86_64.whl (63.7 kB view details)

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

chesslib-1.0.333892741-cp36-cp36m-manylinux1_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.6m

File details

Details for the file chesslib-1.0.333892741-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.333892741-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01e7c9c1227cb90bc252919e09980fb5f2fbd1c7bfcb9b3e416431eda5b54d14
MD5 cf4ac9baa950b634767e4e9c23d1e64d
BLAKE2b-256 2ad4eea98d72482e02411cce1d8ab7035a8b30d246d17f3e8c16b341f38e86cc

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 63.5 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2f41d43306bf4826eed1f6ac22ff2056c970d2914e73276404480e3e016f2c55
MD5 f25a081709e39767a941155113904fc2
BLAKE2b-256 d7f24c3583fff5b75c35e13dc989d2a7d809991f5f53758ba1e92e6329259d21

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 54.2 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 37213d224f04c4de4b9bfddae862ec8e8dd5728c3f474a3722abb9d435548324
MD5 de234df8c1f5e425748bc2392a04e5e3
BLAKE2b-256 67500f03c422c0b919f86e99ee26eaa44f889d86de18cf9cde00938ce5e349b3

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.333892741-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c706d27d185894fb74261cae0a31c700dcadfeaf375e81bb409b1438efd10a0
MD5 aa65940a7741c9b55210d6269563833c
BLAKE2b-256 6fd562ace8832484119e9ca0f6d7e6192d030303ac00d9e795908bb4056a5f06

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 63.9 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8f694a314650ddbb8f4c949c2a12c1018f9341c74ecc65a68151eba8cb0655a0
MD5 9df03745f7dff5aeb45e1643db010e3e
BLAKE2b-256 6ea8b610dd1f1977c4c73bbca992d7aaba6ef21b0cdfb87de6d0e559ac95ca91

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 54.7 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 be19fbd7c08493ecac7469ead771e8f62a8cba22f5612e6d989cdc474a6d5cfb
MD5 f02803e1713c233f9b0f66f5d095ca58
BLAKE2b-256 3f316aa0110cc6808e5f6bafde9f32b3a821a5b3c3539efd2aff2c7c37dd85eb

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.333892741-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0449c8e485e081a8ba9ec317ba56fe16d3cd6f5e2659691e772cf14a44b071e6
MD5 009ffba6bcbc253c774ef933b5173d33
BLAKE2b-256 d187c29d653520838fe0ad7cd123de22c87c92dc8cc003c7d103fe89cede3da5

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 64.7 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cd07b2de0ede6398891cefc032461cf6481f0ec0d7220b929108c46fe015223c
MD5 e1b109ec94c83b01fee80872fac9b0d0
BLAKE2b-256 27af4997844c7e08aca8e7e565da2166c1d48a5b7a713624ae02dbaac794f082

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 54.3 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3b7b9b1f7c1a547640db96bf5d6b01876b5f7a6cf60cafe6d8ca410ebbe67cf8
MD5 74439340a5e2de7462e9b9acbec0a0c1
BLAKE2b-256 139378f92c1ebf788ab1e254e3be803814a9d0681974f40b28e203de5269201f

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.333892741-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1795deb2dd04b7d711c53c484559ea69b9dbf1a5d7b69e1b52119e813beffff
MD5 36c16be9eee3283d0d808d2a738b5cb2
BLAKE2b-256 6749645f936cca10a7b8e52f26790a4bfae533b457339d2504beae9de0705c12

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 63.7 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 6188b81cfa5e3ae0b25d66d483ab7d7386927eaff975caea8a506be4b7712c1b
MD5 c33822fb52dbfd9b2fae0b7264bcf322
BLAKE2b-256 d51ab3344f0a4816d97364ab81e70997a5574b59a8fee43bd3a64685d9018fcb

See more details on using hashes here.

File details

Details for the file chesslib-1.0.333892741-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.333892741-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 54.3 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.58.0 CPython/3.8.7

File hashes

Hashes for chesslib-1.0.333892741-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4f28b5418979496587302c2a19fd0b284862bc8b2e70ccc50aa5f32a8da7d8ed
MD5 0880e0138148d81678be999e994d47ff
BLAKE2b-256 d5c4eb6d3b636b8273747a4330a7093cb268747033700774c21f143b9271f812

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