用于解决组合棋谜的cli。
chessboard的Python项目详细描述
用于解决组合棋谜的cli。
动机
这个项目的开始是一个编码挑战,我被要求在 2015年软件工程职位面试 Uber。
面试结束后,我一直把代码当游乐场玩。 在python中测试一些优化策略。现在是一个样板 我过去:
- 基于引导cli的项目,使用Click,
- 跟上Python packaging,
- 简化数据堆栈的集成(Numpy, Pandas, Seaborn和 Conda),
- 自动化testing and quality checks(单元测试, 覆盖范围、编码风格和包装),
- 提供auto-generated documentation。
示例
简单的3x3板,有两个国王和一个车:
$ chessboard solve --length=3 --height=3 --king=2 --rook=1<SolverContext: length=3, height=3, pieces={'rook': 1, 'king': 2, 'queen': 0, 'bishop': 0, 'knight': 0}> Searching positions... ┌───┬───┬───┐ │ ♚ │ │ │ ├───┼───┼───┤ │ │ │ ♜ │ ├───┼───┼───┤ │ ♚ │ │ │ └───┴───┴───┘ ┌───┬───┬───┐ │ │ │ ♚ │ ├───┼───┼───┤ │ ♜ │ │ │ ├───┼───┼───┤ │ │ │ ♚ │ └───┴───┴───┘ ┌───┬───┬───┐ │ ♚ │ │ ♚ │ ├───┼───┼───┤ │ │ │ │ ├───┼───┼───┤ │ │ ♜ │ │ └───┴───┴───┘ ┌───┬───┬───┐ │ │ ♜ │ │ ├───┼───┼───┤ │ │ │ │ ├───┼───┼───┤ │ ♚ │ │ ♚ │ └───┴───┴───┘ 4 results found in 0.03 seconds.
著名的八皇后拼图,无需打印解决方案即可加快速度:
$ chessboard solve --length=8 --height=8 --queen=8 --silent <SolverContext: length=8, height=8, pieces={'rook': 0, 'king': 0, 'queen': 8, 'bishop': 0, 'knight': 0}> Searching positions... 92 results found in 119.87 seconds.
巨大的组合问题可能需要一些时间来解决:
$ chessboard solve --length=7 --height=7 --king=2 --queen=2 --bishop=2 --knight=1 --silent <SolverContext: length=7, height=7, pieces={'rook': 0, 'king': 2, 'queen': 2, 'bishop': 2, 'knight': 1}> Searching positions... 3063828 results found in 9328.33 seconds.
cli允许生成分析图,以识别代码热点和 瓶颈:。
$ chessboard solve --length=6 --height=6 --king=2 --queen=2 --bishop=2 --knight=1 --silent --profile <SolverContext: length=6, height=6, pieces={'rook': 0, 'king': 2, 'queen': 2, 'bishop': 2, 'knight': 1}> Searching positions... 23752 results found in 207.25 seconds. Execution profile saved at /home/kevin/chessboard/solver-profile.png
第三方
这个项目包的样板来自 Scaleway的postal-address module,在 GPLv2+ License。
cli代码基于我为kdenlive-tools module编写的代码,在BSD license下发布。
其他资源
Changes for v1.5.4 (2017-08-11)
- 在调试模式下显示选定的日志级别。
- 在Mac OS X 10.9上放弃支持和单元测试。
- 为Travis CI版本添加新的MacOS 10.12目标。
- 将要求提升到readme_renderer >= 16.0。
- 将安装说明移到文档中。
- 将性能页移到文档。
- 将cli用法移到docs中的own部分。
- 在Python3.6中激活unittests。
- 在travis作业中显示环境变量以进行调试。
- 检查travis作业中没有冲突的依赖项。
- 在文档中显示包依赖关系图。
- 修复了macOS+python 3.3 travis作业中setuptools的升级。