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

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

chesslib-1.0.329512032-cp38-cp38-manylinux2010_x86_64.whl (60.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

chesslib-1.0.329512032-cp37-cp37m-manylinux2010_x86_64.whl (61.5 kB view details)

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

chesslib-1.0.329512032-cp37-cp37m-manylinux1_x86_64.whl (50.2 kB view details)

Uploaded CPython 3.7m

chesslib-1.0.329512032-cp36-cp36m-manylinux2010_x86_64.whl (60.5 kB view details)

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

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

Uploaded CPython 3.6m

chesslib-1.0.329512032-cp35-cp35m-manylinux2010_x86_64.whl (60.3 kB view details)

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

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

Uploaded CPython 3.5m

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329512032-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88c046339b94d9cfa0bae15ac72ff560fc11c155f2a8ac2fe294513d31c5d018
MD5 b540bc0ee2b1ee363a047706898432b7
BLAKE2b-256 b4dc36e38dc59d46a2c5bdedb20386811fe276f33d0d8fafb17fc23ea82102f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 60.4 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.329512032-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 de34a864f306e38f485d933247f205499513839952c7de2643cb1247cdd6d233
MD5 0c9faab604644476df8996ad5b032d40
BLAKE2b-256 9acac62749d0defdc456770901b8e1743baa214c1165fd780e668f5d4ae106bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-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.329512032-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 693036cc9f5bfc675522826f8e5621bcd76219bb3b6a3ce7784737cbbeeda295
MD5 d43a42347e3e1731ce55b2b306bd06c2
BLAKE2b-256 af55ddef4a83bdc9ddb6b90aa39a81fcfa635f3af3eec044d67f3830cc87fe7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329512032-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c202941fce74df8f2ce43557b76361597cea073a2c7cdd782057644b004d00ad
MD5 40afbf87b5e3a6b89d306098a7f1e23b
BLAKE2b-256 03c25c7d6de957078a34aa97b1b782226a739de20e23c1806ca7af4f41f6aa30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 60.7 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.329512032-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 eed4fab22514fcf668daca66f34fb61cb95b469004dd48fd1ac504a1e53f6ea4
MD5 8d30415383ad2c6dd34752582e482d9c
BLAKE2b-256 f4c06ee395ed71eaa27c47d5c4a8d9bcfc4faabd49cfb68e50b2b933486277c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-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.329512032-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 90930ef8c738a7fe297b1e3e78b082d92534bf5a321e8f19a4c5f24631b1dd37
MD5 6955a7c34222c5491d9da5ed787a8cfe
BLAKE2b-256 0108952dcbe0f10c15b8d93e724619d54220c8b905f600c5739d2791a7f07892

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329512032-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62ea5e12126fc58d2501174caae2835919eb2d8380dcaee505ae61097427e9cf
MD5 a93d227125b134e36b93c237d8e17ff4
BLAKE2b-256 5cbab9aab0bb36986477a4532e725b62a5c4be0a34b39dfccd3a5e8f3f9e0d76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 61.5 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.329512032-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ea98e862c3da7f04812c301ee65e91274abc399ca5611011d7eaf79b9bb9861b
MD5 c655226b1ca10ea35f88336701d28129
BLAKE2b-256 8e442985a0bc87f64134abdd00a58109f468016a9538cb43a2e28b4e30f60211

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-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.329512032-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e4f0b65c8e5dcef7a9d1b4271f8debbb1e6628c03bec01f0ecd00503bd2a0274
MD5 7937d22fec0820a0d4951cd40a1e0a19
BLAKE2b-256 57dbb3a57af9722a185b2f16150bd042d9b2c7329e08b434be4e873fd649277a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329512032-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bb45cf3135c1467b138828571497d34afc7143c636b6ba08a89355c45e1ef80
MD5 6f1b7736f99890e6f720de7c6b9b1783
BLAKE2b-256 d03874b99db12fd6beefe6f1ac12a7f3a7cf64c77dd337329218b552d6e6d264

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 60.5 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.329512032-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d6e5601fdb043ea91067edea139c0cb2d31d5c11b9f7351990c6003ed41220df
MD5 ecfc87d46334c1e16f63d7e6825ec56b
BLAKE2b-256 ace214917eb495bbec05dffafbf4cdd50e277173b919a43e9f7f837eeb979de5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-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.329512032-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ad0e848d331a296f385d53779067231d99b4fbd6911b9b11ee11c969aaf52b2e
MD5 1d7e32477724bc44ce2f9fb42260f390
BLAKE2b-256 e84985168d34dcc6e20ca8679bd19c192601d4b9572cef2158c01fdb09c32c3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chesslib-1.0.329512032-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2fea6e7d7a2d259bd730b910e3bb3e463ec351737e1eea594c910114214700b
MD5 52ea6e876844fa1bbf69fa597113f718
BLAKE2b-256 e64067c3a2c40abeea38f7c84a3756eecd35143e126346f2a15e780c2b82ed72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 60.3 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.329512032-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8d9c1edfd9d05eaf4721552bd34c5ee0296cd89ccc4ba51998868db17b066f7a
MD5 3f94b676993b9c200275e87daad10166
BLAKE2b-256 7502316d6b5e96920566306f92deddc583bb26710ed747ec94a4d8108f5e0901

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chesslib-1.0.329512032-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.329512032-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a18161260416e033b175b2437ad0fed5f40865612b181f3aa271808afa39ec61
MD5 ef9ad6dfd3a41eed306948d6593995ec
BLAKE2b-256 c919989f3ca1be6702932c640b537f830e13e0a2742e573572584de49660eb87

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