From 21d6f22cf2dad1007c8a69e8c127d861c16bcd77 Mon Sep 17 00:00:00 2001 From: Sander Land Date: Sun, 10 May 2020 12:12:20 +0200 Subject: [PATCH] formatting --- README.md | 28 +++++++++++++++------------- core/engine.py | 6 +++--- gui/popups.py | 2 +- spec/KaTrain.spec | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index bf08978..8deb8e5 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ but has since grown to include a wide range of features, including: ## Screenshots - | Analyze games | Play against an AI Teacher | | ------------- | ------------- | | ![screenshot](img/screenshot_analyze.png) | ![screenshot](img/screenshot_play.png) | @@ -29,7 +28,7 @@ but has since grown to include a wide range of features, including: ### Quick Installation for Windows users - * See the [releases tab](https://github.com/sanderland/katrain/releases) for pre-built installers. +See the [releases tab](https://github.com/sanderland/katrain/releases) for pre-built installers. ### Installation from source for Windows users @@ -37,7 +36,7 @@ but has since grown to include a wide range of features, including: * Make sure you have a python installation, I will assume Anaconda (Python 3.7), available [here](https://www.anaconda.com/distribution/#download-section). * Open 'Anaconda prompt' from the start menu and navigate to where you extracted the zip file using the `cd ` command. * Execute the command `pip install kivy_deps.glew kivy_deps.sdl2 kivy_deps.gstreamer kivy` -* Start the app by running `python katrain.py` in the directory where you downloaded the scripts. Note that the program can be slow to initialize the first time, due to kata's gpu tuning. +* Start the app by running `python katrain.py` in the directory where you downloaded the scripts. Note that the program can be slow to initialize the first time, due to KataGo's gpu tuning. ### Installation for Linux users @@ -51,7 +50,7 @@ but has since grown to include a wide range of features, including: * Git clone or download the repository. * Run the command `pip install kivy` in the terminal. -* Follow instructions [here](https://github.com/lightvector/KataGo) to compile KataGo yourself -- note that the version required is currently too new for the 'brew' method. +* Follow instructions [here](https://github.com/lightvector/KataGo) to compile KataGo yourself -- note that the version required may be currently too new for the 'brew' method. * Start the app by running `python katrain.py`, change the path of the 'katago' setting to the path where you compiled it, and click 'Apply and Save'. ## Manual @@ -59,6 +58,7 @@ but has since grown to include a wide range of features, including: ### Play Under the 'play' tab you can select who is playing black and white. + * Human is simple play with potential feedback, but without auto-undo. * Teach will give you instant feedback, and auto-undo bad moves to give you a second chance. * Settings for this mode can be found under 'Configure Teacher' @@ -84,7 +84,7 @@ while stronger players can pay more attention to smaller mistakes. Available AIs, with strength indicating an estimate for the default settings, are: * **[9p+]** **Default** is full KataGo, above professional level. -* **[~1d?]** **ScoreLoss** is KataGo making moves with probability `~ e^(-strength * points lost)`. +* **[~1k?]** **ScoreLoss** is KataGo making moves with probability `~ e^(-strength * points lost)`, playing a varied style with small mistakes. * **Balance** is KataGo occasionally making weaker moves, attempting to win by ~2 points. * **Jigo** is KataGo aggressively making weaker moves, attempting to win by 0.5 points. * **[~4d]** **Policy** uses the top move from the policy network (it's 'shape sense' without reading), should be around high dan level depending on the model used. There is a setting to increase variety in the opening, but otherwise it plays deterministically. @@ -144,14 +144,16 @@ If you ever need to reset to the original settings, simply re-download the `conf ### Settings Panel * engine settings - * max_visits: The number of visits used in analyses and AI moves, higher is more accurate but slower. - * max_time: Maximal time in seconds for analyses, even when the target number of visits has not been reached. - * fast_visits: The number of visits used for certain operations with fewer visits. - * wide_root_noise: Consider a wider variety of moves, using KataGo's `analysisWideRootNoise` option. Will affect both analysis and AIs such as ScoreLoss. (KataGo 1.4+ only, keep at 0.0 otherwise) - * katago: Path to your KataGo executable. - * model: Path to your KataGo model file. Note that the default model file included is an older 15 block one. Replace it with a new model from [here](https://github.com/lightvector/KataGo/releases) for maximal strength. - * config: Path to your KataGo config file. - * threads: Number of threads to use in the KataGo analysis engine. + * These settings can be updated anytime: + * max_visits: The number of visits used in analyses and AI moves, higher is more accurate but slower. + * max_time: Maximal time in seconds for analyses, even when the target number of visits has not been reached. + * fast_visits: The number of visits used for certain operations with fewer visits. + * wide_root_noise: Consider a wider variety of moves, using KataGo's `analysisWideRootNoise` option. Will affect both analysis and AIs such as ScoreLoss. (KataGo 1.4+ only, keep at 0.0 otherwise) + * These settings cause the engine to be restarted: + * katago: Path to your KataGo executable. + * model: Path to your KataGo model file. Note that the default model file included is an older 15 block one for high speed and low memory requirements. Replace it with a new model from [here](https://github.com/lightvector/KataGo/releases) for maximal strength. + * config: Path to your KataGo config file. + * threads: Number of threads to use in the KataGo analysis engine. * game settings * init_size: the initial size of the board, on start-up. * init_komi: likewise, for komi. diff --git a/core/engine.py b/core/engine.py index 83a3d54..bda2fa5 100644 --- a/core/engine.py +++ b/core/engine.py @@ -35,7 +35,7 @@ class KataGoEngine: self.query_counter = 0 self.katago_process = None self.base_priority = 0 - self.override_settings = {} # mainly for bot scripts to hook into + self.override_settings = {} # mainly for bot scripts to hook into self._lock = threading.Lock() self.start() self.analysis_thread = threading.Thread(target=self._analysis_read_thread, daemon=True).start() @@ -155,7 +155,7 @@ class KataGoEngine: settings = self.override_settings if time_limit: settings["maxTime"] = self.config["max_time"] - if self.config.get("wide_root_noise",0.0) > 0.0: # don't send if 0.0, so older versions don't error + if self.config.get("wide_root_noise", 0.0) > 0.0: # don't send if 0.0, so older versions don't error settings["wideRootNoise"] = self.config["wide_root_noise"] query = { @@ -169,6 +169,6 @@ class KataGoEngine: "includeOwnership": ownership, "includePolicy": not next_move, "moves": [[m.player, m.gtp()] for m in moves], - "overrideSettings": settings + "overrideSettings": settings, } self.send_query(query, callback, error_callback, next_move) diff --git a/gui/popups.py b/gui/popups.py index 1bbc56a..bb21833 100644 --- a/gui/popups.py +++ b/gui/popups.py @@ -163,7 +163,7 @@ class ConfigPopup(QuickConfigGui): engine_updates = updated_cat["engine"] if "visits" in engine_updates: self.katrain.engine.visits = engine_updates["visits"] - if {key for key in engine_updates if key not in {"max_visits", "max_time", "enable_ownership","wide_root_noise"}}: + if {key for key in engine_updates if key not in {"max_visits", "max_time", "enable_ownership", "wide_root_noise"}}: self.katrain.log(f"Restarting Engine after {engine_updates} settings change") self.info_label.text = "Restarting engine\nplease wait." self.katrain.controls.set_status(f"Restarted Engine after {engine_updates} settings change.") diff --git a/spec/KaTrain.spec b/spec/KaTrain.spec index 77aa90e..0732aaa 100644 --- a/spec/KaTrain.spec +++ b/spec/KaTrain.spec @@ -34,7 +34,7 @@ exe = EXE(pyz, upx=True, console=True) # , icon='..\\icon.png' -EXCLUDE_SUFFIX = ['katago','b10-1.3.txt.gz','screenshot_analyze.png','screenshot_play.png'] +EXCLUDE_SUFFIX = ['b10-1.3.txt.gz','screenshot_analyze.png','screenshot_play.png'] EXCLUDE = ['KataGoData'] a.datas = [(ff,ft,tp) for ff,ft,tp in a.datas if not any(ff.endswith(suffix) for suffix in EXCLUDE_SUFFIX) and not any(kw in ff for kw in EXCLUDE)] coll = COLLECT(exe,