{"id":43564552,"url":"https://github.com/vitogit/pgn-tactics-generator","last_synced_at":"2026-02-03T21:17:13.404Z","repository":{"id":34035009,"uuid":"147864953","full_name":"vitogit/pgn-tactics-generator","owner":"vitogit","description":"Generate chess puzzles / tactics from a pgn file","archived":false,"fork":false,"pushed_at":"2023-06-14T13:58:33.000Z","size":1412,"stargazers_count":91,"open_issues_count":13,"forks_count":27,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-08-03T22:54:27.575Z","etag":null,"topics":["chess","chess-puzzle","creator","generator","lichess","puzzles","python-chess","stockfish","tactics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitogit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-07T19:15:18.000Z","updated_at":"2023-07-19T08:22:52.000Z","dependencies_parsed_at":"2022-08-08T14:30:20.545Z","dependency_job_id":null,"html_url":"https://github.com/vitogit/pgn-tactics-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/vitogit/pgn-tactics-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitogit%2Fpgn-tactics-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitogit%2Fpgn-tactics-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitogit%2Fpgn-tactics-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitogit%2Fpgn-tactics-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitogit","download_url":"https://codeload.github.com/vitogit/pgn-tactics-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitogit%2Fpgn-tactics-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29057381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T20:13:53.544Z","status":"ssl_error","status_checked_at":"2026-02-03T20:13:40.507Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","chess-puzzle","creator","generator","lichess","puzzles","python-chess","stockfish","tactics"],"created_at":"2026-02-03T21:17:12.389Z","updated_at":"2026-02-03T21:17:13.388Z","avatar_url":"https://github.com/vitogit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgn-tactics-generator\n\n## About\n\nThis is a python application dedicated to creating chess puzzles/tactics from a pgn file.\nAlso it can download your games from lichess.org and use that file.\n\nIt's based on the great  [https://github.com/clarkerubber/Python-Puzzle-Creator](https://github.com/clarkerubber/Python-Puzzle-Creator) by @clarkerubber\n\nThings that I changed:\n- Use a local pgn file with games as a source.\n- Write results to a file called tactics.pgn\n- 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.\n- You can use the `depth` argument to change the depth if you want more precision.\n- chess.pop_count to chess.popcount, because it was failing\n\n### This is too complex, give something easy.\nThere is another option if you don't want to install and manage python scripts\nI created a more user friendly tactics generator and it's online http://chesstacticsgenerator.vitomd.com\nIt uses a different approach to create tactics, so probably it will generate a different set of tactics.\n\n## Installation\n\nThis script requires the *Requests* and *Python-Chess* libraries to run, as well as a copy of *Stockfish*\nIs 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` )\n\nPlease, take a look at [development doc](DEVELOPMENT.md) for details.\n\n### Install requirements\n\n`pip3 install -r requirements.txt --user`\n\n### Setup\n\nMacOS / Linux : `sh build-stockfish.sh` to obtain the current lichess Stockfish instance.\n\n## Launching Application\n\n### Downloading games for a specific user\nYou can download games from a specific user using this command:\n`python3 download_games.py \u003clichess username\u003e`\n\n\nBy default, it will download the last 60 games from blitz, rapid and classical.\n\n**Arguments**\n\nYou 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\n\nIt will save the games in the `games.pgn` file\n\n\n**Example to get 100 games using the token**\n\n`python3 download_games.py \u003clichess username\u003e --max 100 --token 123456789`\n\n### Downloading games from tournaments\nYou can download games from multiple tournaments using this command:\n\n`python3 download_tournaments.py E14kHVwX tdntXNhy`\n\n**The arguments are the tournaments ids separate by a space**\n\nIt will save the games in the `games.pgn` file\n\n\n### Generate tactics\n\n\nTo execute the generator execute this command. By default it will look for the `games.pgn` file:\n\n`python3 main.py`\n\n\n**Arguments**\n\n- `--quiet` to reduce the screen output.\n- `--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.\n- `--games=ruy_lopez.pgn` to select a specific pgn file. Default is `games.pgn`\n- `--strict=False` Use `False` to generate more tactics but a little more ambiguous. Default is `True`\n- `--threads=4` Stockfish argument, number of engine threads, default `4`\n- `--memory=2048` Stockfish argument, memory in MB to use for engine hashtables, default `2048`\n- `--includeBlunder=False` If False then generated puzzles won't include initial blunder move, default is `True`\n- `--stockfish=./stockfish-x86_64-bmi2` Path to Stockfish binary. \n  Optional. If omitted, the program will try to locate Stockfish in current directory or download it from the net\n\nExample:\n`python3 main.py --quiet --depth=12 --games=ruy_lopez.pgn --strict=True --threads=2 --memory=1024`\n\n## Tactics output\n\nThe resulting file will be a pgn file called `tactics.pgn`. Each tactic contains the headers from the source game.\nThe `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.\n\n## Problems?\n\n#### Stockfish errors\n- If you have problems building Stockfish try downloading Stockfish directly https://stockfishchess.org/download/\n\n## Want to see all my chess related projects?\nCheck [My projects](http://vitomd.com/blog/projects/) for a full detailed list.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitogit%2Fpgn-tactics-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitogit%2Fpgn-tactics-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitogit%2Fpgn-tactics-generator/lists"}