All Projects → vitogit → pgn-tactics-generator

vitogit / pgn-tactics-generator

Licence: MIT license
Generate chess puzzles / tactics from a pgn file

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to pgn-tactics-generator

stockfish.js
The strong open source chess engine Stockfish compiled to JavaScript and WebAssembly using Emscripten
Stars: ✭ 140 (+68.67%)
Mutual labels:  chess, lichess, stockfish
chess-puzzle-maker
Creates chess puzzles from chess games and positions
Stars: ✭ 34 (-59.04%)
Mutual labels:  chess, chess-puzzle, stockfish
chess
An R package to read, write, create and explore chess games
Stars: ✭ 60 (-27.71%)
Mutual labels:  chess, stockfish
chessops
Chess and chess variant rules and operations in TypeScript
Stars: ✭ 66 (-20.48%)
Mutual labels:  chess, lichess
blitz-tactics
Fast-paced chess tactics trainer
Stars: ✭ 137 (+65.06%)
Mutual labels:  chess, chess-puzzle
python-chess-annotator
Reads chess games in PGN format and adds annotations using an engine
Stars: ✭ 48 (-42.17%)
Mutual labels:  chess, python-chess
lila-tablebase
Tablebase server
Stars: ✭ 51 (-38.55%)
Mutual labels:  chess, lichess
lila-gif
Webservice to render Gifs of chess positions and games, and stream them frame by frame
Stars: ✭ 63 (-24.1%)
Mutual labels:  chess, lichess
should-i-play-f6
Chess project to analyze the statistical effect of playing f3 (as white) or f6 (as black) on the outcome of the game.
Stars: ✭ 15 (-81.93%)
Mutual labels:  chess, lichess
liground
A free, open-source and modern Chess Variant Analysis GUI for the 21st century
Stars: ✭ 41 (-50.6%)
Mutual labels:  chess, lichess
liPGN
This program uses the lichess REST API to retrieve all the games of a user and transform them into a big PGN file that you can then import into your favourite game analysis tool (ie. scid)
Stars: ✭ 14 (-83.13%)
Mutual labels:  chess, lichess
chess-openings
An aggregated data set of chess opening names
Stars: ✭ 223 (+168.67%)
Mutual labels:  chess, lichess
lila-openingexplorer
Opening explorer for lichess.org that can handle all the variants and billions of unique positions
Stars: ✭ 89 (+7.23%)
Mutual labels:  chess, lichess
bot-o-tron
Try out lichess' bot interface
Stars: ✭ 36 (-56.63%)
Mutual labels:  chess, lichess
stockfish-chess-web-gui
Responsive chess web GUI to play against the Stockfish 10 chess engine. Multiple web GUI implementations have also been included.
Stars: ✭ 21 (-74.7%)
Mutual labels:  chess, stockfish
chessground
Chessground React Wrapper
Stars: ✭ 15 (-81.93%)
Mutual labels:  chess, lichess
Lila
♞ lichess.org: the forever free, adless and open source chess server ♞
Stars: ✭ 10,315 (+12327.71%)
Mutual labels:  chess, lichess
Openingtree
Consolidated view of all your chess games from chess.com, lichess, grandmaster games or custom pgn.
Stars: ✭ 143 (+72.29%)
Mutual labels:  chess
chess-api
Chess API: REST API for playing chess and storing highscores
Stars: ✭ 39 (-53.01%)
Mutual labels:  chess
Raspberryturk
The Raspberry Turk is a robot that can play chess—it's entirely open source, based on Raspberry Pi, and inspired by the 18th century chess playing machine, the Mechanical Turk.
Stars: ✭ 140 (+68.67%)
Mutual labels:  chess

pgn-tactics-generator

About

This is a python application dedicated to creating chess puzzles/tactics from a pgn file. Also it can download your games from lichess.org and use that file.

It's based on the great https://github.com/clarkerubber/Python-Puzzle-Creator by @clarkerubber

Things that I changed:

  • Use a local pgn file with games as a source.
  • Write results to a file called tactics.pgn
  • Default engine depth to 8, so it's faster. Before it was nodes=3500000 this is a depth around 20. So it took several minutes to analyze a game. With depth 8 it takes seconds.
  • You can use the depth argument to change the depth if you want more precision.
  • chess.pop_count to chess.popcount, because it was failing

This is too complex, give something easy.

There is another option if you don't want to install and manage python scripts I created a more user friendly tactics generator and it's online http://chesstacticsgenerator.vitomd.com It uses a different approach to create tactics, so probably it will generate a different set of tactics.

Installation

This script requires the Requests and Python-Chess libraries to run, as well as a copy of Stockfish Is recommended that you use Python 3 and pip3. But it could work with Python 2.7 and pip (probably you will need to install futures pip install futures )

Please, take a look at development doc for details.

Install requirements

pip3 install -r requirements.txt --user

Setup

MacOS / Linux : sh build-stockfish.sh to obtain the current lichess Stockfish instance.

Launching Application

Downloading games for a specific user

You can download games from a specific user using this command: python3 download_games.py <lichess username>

By default, it will download the last 60 games from blitz, rapid and classical.

Arguments

You can use the max argument to get more games and use the lichess api token with the token argument to make the download faster. https://lichess.org/api#operation/apiGamesUser

It will save the games in the games.pgn file

Example to get 100 games using the token

python3 download_games.py <lichess username> --max 100 --token 123456789

Downloading games from tournaments

You can download games from multiple tournaments using this command:

python3 download_tournaments.py E14kHVwX tdntXNhy

The arguments are the tournaments ids separate by a space

It will save the games in the games.pgn file

Generate tactics

To execute the generator execute this command. By default it will look for the games.pgn file:

python3 main.py

Arguments

  • --quiet to reduce the screen output.
  • --depth=8 select the Stockfish depth analysis. Default is 8 and will take some seconds to analyze a game, with --depth=18 will take around 6 minutes.
  • --games=ruy_lopez.pgn to select a specific pgn file. Default is games.pgn
  • --strict=False Use False to generate more tactics but a little more ambiguous. Default is True
  • --threads=4 Stockfish argument, number of engine threads, default 4
  • --memory=2048 Stockfish argument, memory in MB to use for engine hashtables, default 2048
  • --includeBlunder=False If False then generated puzzles won't include initial blunder move, default is True
  • --stockfish=./stockfish-x86_64-bmi2 Path to Stockfish binary. Optional. If omitted, the program will try to locate Stockfish in current directory or download it from the net

Example: python3 main.py --quiet --depth=12 --games=ruy_lopez.pgn --strict=True --threads=2 --memory=1024

Tactics output

The resulting file will be a pgn file called tactics.pgn. Each tactic contains the headers from the source game. The result header is the tactic result and not the game result. It can be loaded to a Lichess study or to an app like iChess to practice tactics.

Problems?

Stockfish errors

Want to see all my chess related projects?

Check My projects for a full detailed list.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].