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


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

Roadmap

Following features are planned for the near future:

  • change Board_ToHash() / Board_FromHash() exchange format to Python type 'bytes' or 'bytearray' for better compatibility
  • improve code coverage of unit tests
  • implement CI/CD GitHub pipelines for DockerHub and PyPi releases
  • fix all memory leaks of the lib (if there even are leaks)
  • think of performence testing / performance improvements (especially draw-gen)

Following optional / fancy improvements are to be considered:

  • add fancy status badges, beautify README
  • add API documentation compatible with common Python linters

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

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

chesslib-1.0.329518997-cp38-cp38-manylinux2010_x86_64.whl (61.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

chesslib-1.0.329518997-cp37-cp37m-manylinux2010_x86_64.whl (62.0 kB view details)

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

chesslib-1.0.329518997-cp37-cp37m-manylinux1_x86_64.whl (50.7 kB view details)

Uploaded CPython 3.7m

chesslib-1.0.329518997-cp36-cp36m-manylinux2010_x86_64.whl (61.0 kB view details)

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

chesslib-1.0.329518997-cp36-cp36m-manylinux1_x86_64.whl (50.7 kB view details)

Uploaded CPython 3.6m

chesslib-1.0.329518997-cp35-cp35m-manylinux2010_x86_64.whl (60.8 kB view details)

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

chesslib-1.0.329518997-cp35-cp35m-manylinux1_x86_64.whl (50.7 kB view details)

Uploaded CPython 3.5m

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329518997-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7e518e8ea774c55a612b99180e5d85be822b62d5927aa1fc9ceb2f20bbb1a08d
MD5 4bcb06ec860f80ed7be57af584cb2530
BLAKE2b-256 3b8dac0cc29a6255d52063ac59cf2c588e9b0b38c6f946880e3d362c090d5079

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 60.8 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3dcf352f34dea618bdad278fb45e8bb3a865ac46627103bc98518e4c26b49c11
MD5 270ebd556b4c69d29fa92f2cdb4beff6
BLAKE2b-256 762b09b97e6aa03cb5f0fcec4621006aa463096b43a6715a726100a321099f9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f10df4ee7c210fb0778dd71f2d107e59d5bf043387b83a4a7933b35c7995cd21
MD5 743209ec080e3398976bdb1481229556
BLAKE2b-256 5177c9932881e8c77472e10864075dd54a453fc6bb9da7a35ec29bd1bc28abd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329518997-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b116b6c6896696d4ddd770faabdb5085e39e8de4fd4a505b7fc8982377b5e002
MD5 9afa9fd69cf89426decdc368248e2e3b
BLAKE2b-256 0086482dabd5e4d07419e1163705ed4b4eb1a517c1b62dabd92f8afae3e048a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 61.2 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b92ad48fe744daf672ffb60c9d81f7b1c08478cf538fec9c447beece85fd13db
MD5 9c5b254a44ba9487cb40d9a3e6f59406
BLAKE2b-256 84c2a09c7a1631bfad919aad26da697dab583c40b3e68a034faa17ea68436580

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 67ec86c82e3c419744ae50ebc57fe02c30b3adf2c5f2a4d3202bbc14991354e5
MD5 e0113670157bc39ba360b31af2ead953
BLAKE2b-256 49d335bd6d275dbf8194a06b592399ec2c149d5a539dbf6c24610d0551f39f8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329518997-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 802fa82a25180e2e259524bbb48123e68398a90c761fd583d532145d6e3a337c
MD5 b2b7fa41cd32f80397c96b04eca56149
BLAKE2b-256 40c654f9f311a836489838fe1a0a511470903fc8dfdf665cbbac02c8ef240242

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 62.0 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7fac5784ad0d6ba9f322658833ba6fec925e201929af42fa7153e99afd98dae3
MD5 2864c964e125039d4bc35a80233ece09
BLAKE2b-256 a11955dfbcb31afef7f4c7f19f5143cc58f91eb9be0acc56f9a02984937f30b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d2c31f7c1fca2bb62872281cc26bc9c2cc7eabfc4e23ad310a5395fd2d1705dc
MD5 b44a61f2c7a19c65fee700a9865d4157
BLAKE2b-256 24192846944cdaf3329fea73de26d202e178aeff0fdcd8bf044487c10e15c85e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329518997-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0fab6f5306829f9ca6925b52ba1310c00e2e027b343839b5ee5acaa684153cc
MD5 66c1ddd5b872d73a54b42e3ddc4250cd
BLAKE2b-256 232c1075c5bfd334ef12ce3e24e48c87f432f679ac6fcf47ca093d1ec024edd9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 61.0 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0a6f629d5de6a4383c0925d25783f4dd22f9024f5374887e4e1ea0fd147cf814
MD5 e2c6c5aa5fa1b91dd7adba63e97ffcbc
BLAKE2b-256 4c2ada85ac3aa99ed8086db85566e5f185b867ebed411f98a9c5555bdb44bc2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329518997-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fb0dab7b7fcbefdb28c770842d1a360553738f7cac5dec32d6e861a2a1723407
MD5 aed1c9a29ef2572d8a199624fdc86c07
BLAKE2b-256 e89ee2be1b01f3f7de30826cc5a2fb8cfaac86ad1ef325ed1823dbe498533e5e

See more details on using hashes here.

File details

Details for the file chesslib-1.0.329518997-cp35-cp35m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chesslib-1.0.329518997-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d1eb482679712dd54b9c619064417ea753cdc29af7ceddc0a0ec9a391f06383
MD5 923f13599b834f421cc3b1603481d51d
BLAKE2b-256 22b56b0c7a1af4df62fd0aa70a0af73c37cb78c284c3255b1a941af4f895f02f

See more details on using hashes here.

File details

Details for the file chesslib-1.0.329518997-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.329518997-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 60.8 kB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 251f3851c914e2f21e802460745fbacc0430b70727278447c7f5051f128798ca
MD5 4eff9267d4c5dfc1e857f2d785042371
BLAKE2b-256 c8e59e529b1d23910508cf416a8f5d442146f0b6878480b0450f682ba3709f7c

See more details on using hashes here.

File details

Details for the file chesslib-1.0.329518997-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: chesslib-1.0.329518997-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for chesslib-1.0.329518997-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2cd666a49ee0a2dc65f419fafe2b85fa869bace689f75d7b8919a9e9f6e0658e
MD5 4df4c86cc8d80fe812912f6a5fd557b4
BLAKE2b-256 03cbccfe68196cf7047fa34bd193f9f6250713c98895ab295d9f5a3e984b458b

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