Python CLI to explore chessboard positions.
Project description
Chessboard
Python CLI to explore chessboard positions.
Motivation
This project is a playground to test some optimization strategies in Python.
The current implementation work but is quite slow. The pending work is available in the form of issues.
Development philosophy
First create something that work (to provide business value).
Then something that’s beautiful (to lower maintenance costs).
Finally works on performance (to avoid wasting time on premature optimizations).
Install
$ git clone git@github.com:kdeldycke/chessboard.git
$ cd ./chessboard
$ python ./setup.py develop
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.
Unit-tests
$ python ./setup.py nosetests
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.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.