From c7bb651f79bf638379a88e483858193a6cc7abbb Mon Sep 17 00:00:00 2001 From: vitogit Date: Sun, 11 Apr 2021 11:50:25 -0300 Subject: [PATCH] Update readme and fix download_tournaments.py file name --- README.md | 58 ++++++++++++++----- ...ad_tourments.py => download_tournaments.py | 0 main.py | 4 +- 3 files changed, 44 insertions(+), 18 deletions(-) rename download_tourments.py => download_tournaments.py (100%) diff --git a/README.md b/README.md index eba8fae..acd5d44 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## 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. +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](https://github.com/clarkerubber/Python-Puzzle-Creator) by @clarkerubber @@ -11,7 +11,7 @@ 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 a param to change the depth if you want more precision. +- 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. @@ -19,7 +19,6 @@ 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* @@ -34,37 +33,64 @@ Is recommended that you use Python 3 and pip3. But it could work with Python 2.7 MacOS / Linux : `sh build-stockfish.sh` to obtain the current lichess Stockfish instance. ## Launching Application -First you can download your games from lichess with +### Downloading games for a specific user +You can download games from a specific user using this command: `python3 download_games.py ` -This will download the last 60 games from blitz,rapid and classical. You can add some params like max number of games and the lichess api token that make the download faster. https://lichess.org/api#operation/apiGamesUser + +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 --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` -Then execute the generator (it will look for a file called games.pgn) -`python3 main.py --quiet` -You can also use parameters +**Arguments** -- --quiet to reduce the screen output. -- --depth=8 param to 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 . False to generate more tactics but a little more ambiguous. Default is `True` -- Threads and Hash defaults to 4 and 2048 +- `--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` Example: -`python3 main.py --quiet --depth=18 --games=ruy_lopez.pgn --strict=True <#Threads = 4> ` +`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 it's 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. +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 - If you have problems building stockfish try downloading stockfish directly https://stockfishchess.org/download/ -## Want to see all my chess related projects? +## Want to see all my chess related projects? Check [My projects](http://vitomd.com/blog/projects/) for a full detailed list. diff --git a/download_tourments.py b/download_tournaments.py similarity index 100% rename from download_tourments.py rename to download_tournaments.py diff --git a/main.py b/main.py index 4a89ba4..f509ba8 100755 --- a/main.py +++ b/main.py @@ -17,9 +17,9 @@ parser = argparse.ArgumentParser(description=__doc__) -parser.add_argument("threads", metavar="THREADS", nargs="?", type=int, default=4, +parser.add_argument("--threads", metavar="THREADS", nargs="?", type=int, default=4, help="number of engine threads") -parser.add_argument("memory", metavar="MEMORY", nargs="?", type=int, default=2048, +parser.add_argument("--memory", metavar="MEMORY", nargs="?", type=int, default=2048, help="memory in MB to use for engine hashtables") parser.add_argument("--depth", metavar="DEPTH", nargs="?", type=int, default=8, help="depth for stockfish analysis")