Python package to generate and tag puzzles from chess games.
From pypi:
pip install chess-puzzler`From source:
pip install git+https://github.com/cakiki/chess-puzzler.git`Finding puzzles and some tagging functions require a UCI-compliant chess engine like Stockfish.
You can use chess-puzzler as a CLI tool or as a python library:
puzzler find game.pgn --all --tagimport chess.pgn
from chess_puzzler import Generator, open_engine
from chess_puzzler.tagger import cook
engine = open_engine("stockfish")
game = chess.pgn.read_game(open("game.pgn"))
puzzles = Generator(engine).analyze_game(game, all_puzzles=True)
for puzzle in puzzles:
puzzle.tags = cook(puzzle, engine=engine)
print(puzzle.to_dict())
engine.close()Important
Stockfish is non-deterministic when running multi-threaded. For reproducible results across different runs, make sure to run with threads=1.
TODO
This is a refactor of ornicar/lichess-puzzler, also inspired by kraktus/lichess-puzzler and fitztrev/puzzler. The goal was to make the lichess-puzzler more pythonic and pip installable.
chess-puzzler is licensed under the GNU Affero General Public License 3 or any later version of your choice.