Skip to main content

Python3 library for efficient chess draw-gen functions

Project description

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).

How to Build / Test

The commands for building the Python3 extension module and testing it properly are wrapped as a Docker image. Therefore just build the Dockerfile and use the image as base for your Python3 application importing the module.

Alternatively you could run the commands from the Dockerfile onto an Ubuntu-like machine and build the binaries on your own. I'm using the default distutils tools, so making your own builds should not be too hard to achieve.

# install docker (e.g. Ubuntu 18.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
git clone https://github.com/Bonifatius94/ChessLib.Py
cd ChessLib.Py

# build the chesslib Python3 module using the commands from the Dockerfile
# this also includes running the unit tests (Docker build fails if tests don't pass)
docker build . -t "chesslib-python3:1.0"

# run a test command using the chesslib
docker run "chesslib-python3:1.0" python3 test.py

Usage

Install the official Python package using pip:

pip install chesslib

The following sample outlines the usage of the ChessLib:

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 ChessLib/test.py file for more examples

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
  • think of performence testing / performance improvements (especially draw-gen)

Following optional / fancy improvements are to be considered:

  • add fancy travis build labels, 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.329487606-cp37-cp37m-manylinux1_x86_64.whl (61.8 kB view details)

Uploaded CPython 3.7m

chesslib-1.0.329487606-cp36-cp36m-manylinux1_x86_64.whl (60.8 kB view details)

Uploaded CPython 3.6m

chesslib-1.0.329487606-cp35-cp35m-manylinux1_x86_64.whl (60.6 kB view details)

Uploaded CPython 3.5m

File details

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

File metadata

  • Download URL: chesslib-1.0.329487606-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.2 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.329487606-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 826afa222eb6613b4c05f927720f04dbc6e88fb68848c965334f3d2217080660
MD5 90419d33c3eb3052585b182e19426c7b
BLAKE2b-256 f259dbcf6abfe6b81616a31e01e0d39de3fb917ce0d076bf6db94ad72143e0e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329487606-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82dac1a7a6ad584fc31bc4819d88d97a99ef369dbe390f657a43a734253abe8a
MD5 6fe4e314dee20e88533a2d8192aea787
BLAKE2b-256 870974451d0b2571d1223fefc39cc703e34337ab286a4226b00bd6c14a7d6179

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329487606-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 61.0 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.329487606-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1573d1823697bac67bc7b3c3155a6fe5bb1127e0e0f257cbbd4bde209dc9025e
MD5 4db6e6059d8cc262d0c03a7cc493c80a
BLAKE2b-256 fcecb90e59ea88454d71acaffe187c6e5e80bdbe0348e1358b7c424bd54260f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329487606-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5e32b1931280bbd2c87149614551acb1b5313297f01e78f06b64588e87567d3
MD5 3c36722ba580ec1694205e1628579d19
BLAKE2b-256 6fd1731d7c2fc3497be51586630649e45260779112fa77cd19f9ddcc15ca77a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329487606-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 61.8 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.329487606-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7838045f999d692ba7ab595c1b1dcb001a873fda6c417c99439800a164354b44
MD5 ef42d47184cadbe6e621e567b085b6b4
BLAKE2b-256 9dd6bbbf3cc7e22453be221c97eea41cacda3ee72336bb3aca1b85a5c7f2628e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329487606-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6071e3d6fead32f97776b44c7bf4d400f15cd93fb0c98dab1e0abe7c57107986
MD5 e32a87da76ae59ca1d71b04a85ce4458
BLAKE2b-256 fee64d7523cefb234ec0cf8cf14d73ea1f84e2d4bfa564d370a144325a5703f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329487606-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.8 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.329487606-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 74410513cd3d1d3ba7a08e1da7a9355f81a11d2b6da788db6678170bca6f5a57
MD5 a997c46e4bda9affc7a0e95d80fee734
BLAKE2b-256 b91629b9e323bc92cdfd62e4a0fc5b16a271956ba7aea7f4f639077ba8c75cf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329487606-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46b84b7d6e61ca8b2b09f4efdd5a6baf3a96c1a64ba42e3eeb1ebb21450c8caa
MD5 15a0b75b0942df22ae3f4b48846c2c91
BLAKE2b-256 fc4b495043c71699dfce0927390201c0c997a7485bbd1cb82f0bdff0fdc64d4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329487606-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.6 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.329487606-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3bf04df98b80ccb5a477c7720af3bb92e98e590c3b2181cd08d881eb385c9a6b
MD5 6408ecffca9277b8d1c74f5f1e527e94
BLAKE2b-256 98d2423988b786e186e572bb7a5370d47a93dcf5c93b0994760e89b24b963fda

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