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.329485867-cp37-cp37m-manylinux1_x86_64.whl (50.2 kB view details)

Uploaded CPython 3.7m

chesslib-1.0.329485867-cp36-cp36m-manylinux1_x86_64.whl (50.2 kB view details)

Uploaded CPython 3.6m

chesslib-1.0.329485867-cp35-cp35m-manylinux1_x86_64.whl (50.2 kB view details)

Uploaded CPython 3.5m

File details

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

File metadata

  • Download URL: chesslib-1.0.329485867-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.329485867-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 27676396f79f7d4461e89375a0c2a72f98fe007f4ec3d347aa5b52b34df9ba3a
MD5 2a6aacab1ca304a6aef19402e76aca16
BLAKE2b-256 910e16f38b11bcc51c836514aabd6b464efa0b574c6d2ec77cc00f078b7b6338

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329485867-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.6 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.329485867-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8b9ed4518aee2fdffa1b7230249e31e0752f4f2cfbdf2f39af7864ceeb23ccc6
MD5 cdce17a4676acb3435e876be6f5776e8
BLAKE2b-256 af9583c6db9903dc9d2cda7ba245ec0c65a2af70423a34134d164e3cdefa2964

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329485867-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.2 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.329485867-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4dbe7444af0d99346ffc8881f9492c40f0214b25d8cc8f9146261234278a4a18
MD5 25a50f584e61f5c5acb00e1185eb87f6
BLAKE2b-256 5e485273bdcdae0895a53102f9d981e7f4c6b3832797a60cea55c30fd978c185

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329485867-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.2 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.329485867-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e49db485dce8319606643cc14e9717d7e5a3a9e8a347ae7d7ed48a44885a3e86
MD5 e7d34648bc71e96e2e4a41d9a840d19c
BLAKE2b-256 7fbf9f55667a7fa79d665c58df8affc33d440121e57a50f0de90d5e2bfcda2da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329485867-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 50.2 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.329485867-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5571aa3d908284e02e990912dee819d743c41eaabf7df6c8f45a3b5f8fe1e190
MD5 6be6dd2ad58528af64fe68d216c40d2b
BLAKE2b-256 c1e6552be0c98a639b59fcbf16046121e8f31ebc75572d041892421df82b839c

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