Skip to main content

Python CLI to explore chessboard positions.

Project description

Chessboard

Python CLI to explore chessboard positions.

Stable release: Last release Requirements freshness Software license Popularity

Development: Unit-tests status Coverage Status Code Quality

Motivation

This project is a playground to test some optimization strategies in Python, but is essentially an exemple of a real-life Python package, and serve me as a boilerplate project for future CLI.

Development philosophy

  1. First create something that work (to provide business value).

  2. Then something that’s beautiful (to lower maintenance costs).

  3. Finally works on performance (to avoid wasting time on premature optimizations).

Install

This package is available on PyPi, so you can install the latest stable release and its dependencies with a simple pip call:

$ pip install chessboard

Usage

$ chessboard --help
Usage: chessboard [OPTIONS]

  Python CLI to explore chessboard positions.

Options:
  --version             Show the version and exit.
  -l, --length INTEGER  Length of the board.  [required]
  -h, --height INTEGER  Height of the board.  [required]
  -s, --silent          Do not display result board, only final count.
  -v, --verbose         Print much more debug statements.
  --rook INTEGER        Number of rooks to add to the board.
  --king INTEGER        Number of kings to add to the board.
  --queen INTEGER       Number of queens to add to the board.
  --bishop INTEGER      Number of bishops to add to the board.
  --knight INTEGER      Number of knights to add to the board.
  --help                Show this message and exit.

Exemples

$ chessboard --length=3 --height=3 --king=2 --rook=1
Building up a chessboard...
Solving the chessboard...
┌───┬───┬───┐
        
├───┼───┼───┤
        
├───┼───┼───┤
        
└───┴───┴───┘
┌───┬───┬───┐
        
├───┼───┼───┤
        
├───┼───┼───┤
        
└───┴───┴───┘
┌───┬───┬───┐
       
├───┼───┼───┤
         
├───┼───┼───┤
        
└───┴───┴───┘
┌───┬───┬───┐
        
├───┼───┼───┤
         
├───┼───┼───┤
       
└───┴───┴───┘
4 results found in 0.03 seconds.

Development

Check out latest development branch:

$ git clone git@github.com:kdeldycke/chessboard.git
$ cd ./chessboard
$ python ./setup.py develop

Run unit-tests:

$ python ./setup.py nosetests

Stability policy

Here is a bunch of rules we’re trying to follow regarding stability:

  • Patch releases (0.x.n0.x.(n+1) upgrades) are bug-fix only. These releases must not break anything and keeps backward-compatibility with 0.x.* and 0.(x-1).* series.

  • Minor releases (0.n.*0.(n+1).0 upgrades) includes any non-bugfix changes. These releases must be backward-compatible with any 0.n.* version but are allowed to drop compatibility with the 0.(n-1).* series and below.

  • Major releases (n.*.*(n+1).0.0 upgrades) are not planned yet: we’re still in beta and the final feature set of the 1.0.0 release is not decided yet.

Release process

Start from the develop branch:

$ git clone git@github.com:kdeldycke/chessboard.git
$ git checkout develop

Update revision to its release number and update change log:

$ vi ./chessboard/__init__.py
$ vi ./CHANGES.rst

Create a release commit, tag it and merge it back to master branch:

$ git add ./chessboard/__init__.py ./CHANGES.rst
$ git commit -m "Release vX.Y.Z"
$ git tag "vX.Y.Z"
$ git push
$ git push --tags
$ git checkout master
$ git pull
$ git merge "vX.Y.Z"
$ git push

Push packaging to the test cheeseshop:

$ python setup.py register -r testpypi
$ pip install wheel
$ rm -rf ./build ./dist
$ python setup.py sdist bdist_egg bdist_wheel upload -r testpypi

Publish packaging to PyPi:

$ python setup.py register -r pypi
$ rm -rf ./build ./dist
$ python setup.py sdist bdist_egg bdist_wheel upload -r pypi

Bump revision back to its development state:

$ git checkout develop
$ vi ./chessboard/__init__.py
$ vi ./CHANGES.rst
$ git add ./chessboard/__init__.py ./CHANGES.rst
$ git commit -m "Post release version bump."

Third-party

This project package’s boilerplate is sourced from the code I wrote for Scaleway’s postal-address module, which is published under a GPLv2+ License.

The CLI code is based on the one I wrote for the kdenlive-tools module, published under a BSD license.

License

This software is licensed under the GNU General Public License v2 or later (GPLv2+).

ChangeLog

0.9.1 (2015-08-25)

  • Fix rendering of unicode string in terminal.

  • Document stability policy and release process.

  • Add PyPi-based badges.

0.9.0 (2015-08-25)

  • Validate CLI user inputs and provides hints.

  • Abandon branches of the search space as soon as possible. Closes #3.

  • Add --silent option to skip displaying of all board results in ASCII art.

0.8.0 (2015-08-15)

  • Refactor solver to deduplicate positions by kind (combination) before iterating the search space by brute force (cartesian product).

0.7.0 (2015-08-14)

  • Display results in unicode-art.

0.6.0 (2015-08-14)

  • Add Knight model.

0.5.0 (2015-08-13)

  • Add Rook and Bishop models.

  • Allow overlapping but non-threatening territory of pieces to co-exists.

0.4.0 (2015-08-13)

  • Add project status badges.

  • Enable continuous integration metrics: build status, coverage and code quality.

  • Fix index to position computation in non-square boards.

  • Remove restriction on board dimensions.

  • Unit-tests result sets produced by the solver.

0.3.0 (2015-08-12)

  • Add Queen piece.

  • Fix displaying of piece representation.

  • Fix persistence of square occupancy between each piece addition.

0.2.1 (2015-08-11)

  • Fix King displacement map.

0.2.0 (2015-08-11)

  • Allow initialization of board pieces.

  • Implement brute-force solver.

0.1.1 (2015-08-08)

  • Package re-release to fix bad version number.

0.1.0 (2015-08-08)

  • First public release.

  • Implements a CLI to inititalize the chessboard.

0.0.0 (2015-08-08)

  • First commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chessboard-0.9.1.tar.gz (25.4 kB view details)

Uploaded Source

Built Distributions

chessboard-0.9.1-py2.7.egg (20.2 kB view details)

Uploaded Source

chessboard-0.9.1-py2-none-any.whl (24.5 kB view details)

Uploaded Python 2

File details

Details for the file chessboard-0.9.1.tar.gz.

File metadata

  • Download URL: chessboard-0.9.1.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for chessboard-0.9.1.tar.gz
Algorithm Hash digest
SHA256 5dea7e7a2dc16b92c5cef33bfa24fd773c6f5fdf09faff46f81f11e34d1afc4e
MD5 a3738a162f0a182afc3557594a7db055
BLAKE2b-256 171d33a225ca1de868b11141e38a4580a00dbda7ff4d93d3387c59debce311dc

See more details on using hashes here.

File details

Details for the file chessboard-0.9.1-py2.7.egg.

File metadata

File hashes

Hashes for chessboard-0.9.1-py2.7.egg
Algorithm Hash digest
SHA256 df4460a3cf93fb23c0835969255b7fe915347bb69fb569a2b9da15a3461e4c03
MD5 a6c8c11b73b6e40455d100e56db0e940
BLAKE2b-256 6c6bf58244f6d4bc7648b77b158b9b068ce66f84db818a0d7a9bd5198de3e0aa

See more details on using hashes here.

File details

Details for the file chessboard-0.9.1-py2-none-any.whl.

File metadata

File hashes

Hashes for chessboard-0.9.1-py2-none-any.whl
Algorithm Hash digest
SHA256 442e7f5bbd871291cb39ec3e6836f46b0fd1a4756c8cd5a684f21849d6f5e788
MD5 598d9ee796cd5cff16c9a0ede2f9d59d
BLAKE2b-256 e68961d0a5a72350535df221f90c71f283cde380ed87b194d7f963d09fabf328

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