Go/Baduk/Weiqi playing and teaching app with a variety of AIs
Project description
KaTrain v1.0.6
KaTrain is a tool for analyzing and playing go with AI feedback from KataGo.
The original idea was to give immediate feedback on the many large mistakes we make in terms of inefficient moves, but has since grown to include a wide range of features, including:
- Review your games to find the moves that were most costly in terms of points lost.
- Play against AI and get immediate feedback on mistakes with option to retry.
- Play against a wide range of weakened versions of AI with various styles.
- Play against a stronger player and use the retry option instead of handicap stones.
- Automatically generate focused SGF reviews which show your biggest mistakes.
Animated Screenshots
Analyze games | Play against an AI Teacher |
---|---|
Quickstart
- You can right-click most button or checkbox labels to get a tooltip with help.
- To analyze a game, load it using the button in the bottom right, or press
ctrl-L
- To play against AI, pick an AI from the dropdown and either 'human' or 'teach' for yourself and start playing.
- For different board sizes, use the button with the little goban in the bottom right for a new game.
Installation
- See the releases tab for pre-built installers for windows.
- Alternatively use
pip3 install -U katrain
to install the latest version from PyPI on any OS.- Note that on MacOS you will need to set up KataGo using brew, as described here.
- See here for detailed instructions for running from source files on Window, Linux and MacOS, as well as setting up KataGo to use multiple GPUs.
Manual
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'
- AI will activate the AI in the dropdown menu next to the buttons.
- Settings for all AIs can be found under 'Configure AIs'
If you do not want to see 'Points lost' or other feedback for your moves, set 'show last n dots' to 0 under 'Configure Teacher', and click on the words 'Points lost' to hide its value.
What are all these coloured dots?
The dots indicate how many points were lost by that move.
- The colour indicates the size of the mistake according to KataGo
- The size indicates if the mistake was actually punished. Going from fully punished at maximal size, to no actual effect on the score at minimal size.
In short, if you are a weaker player you should mostly on large dots that are red or purple, while stronger players can pay more attention to smaller mistakes. If you want to hide some colours, you can do so under 'Configure Teacher'.
AIs
Available AIs, with strength indicating an estimate for the default settings based on their current OGS rankings, are:
- [9p+] Default is full KataGo, above professional level.
- (RECOMMENDED) [~5k] 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.
- (RECOMMENDED) [~3k]: P:Weighted picks a random move weighted by the policy, as long as it's above
lower_bound
.weaken_fac
usespolicy^(1/weaken_fac)
, increasing the chance for weaker moves. - [~7k]: P:Pick picks
pick_n + pick_frac * <number of legal moves>
moves at random, and play the best move among them. The settingpick_override
determines the minimum value at which this process is bypassed to play the best move instead, preventing obvious blunders. This, along with 'Weighted' are probably the best choice for kyu players who want a chance of winning without playing the sillier bots below. Variants of this strategy include:- [~3k]: P:Local will pick such moves biased towards the last move with probability related to
local_stddev
. - [~5k]: P:Tenuki is biased in the opposite way as P:Local, using the same setting. After about half the board is filled, it stops and plays like P:Pick.
- [~6k]: P:Influence is biased towards 4th+ line moves, with every line below that dividing both the chance of considering the move and the policy value by
influence_weight
. Consider settingpick_frac=1.0
to only affect the policy weight. - [~8k]: P:Territory is biased in the opposite way, towards 1-3rd line moves, using the same setting. Both of these also stop the strategy in endgame and revert to P:Pick.
- [~3k]: P:Local will pick such moves biased towards the last move with probability related to
The Engine based AIs (Default, ScoreLoss, Balance, Jigo) are affected by both the model and choice of max_visits/max_time, while the Policy net based AIs (Policy, P:...) are affected by the choice of model file, but work identically with 'max_visits' set to 1.
Analysis
Keyboard shortcuts are shown with [key].
-
The checkboxes configure:
- [q]: Child moves are shown. On by default, can turn it off to avoid obscuring other information or when wanting to guess the next move.
- [w]: All dots: Show all evaluation dots instead of the last few.
- You can configure how many are shown with this setting off, and whether they are shown for AIs under 'Play/Configure Teacher'.
- [e]: Top moves: Show the next moves KataGo considered, colored by their expected point loss. Small dots indicate high uncertainty. Hover over any of them to see the principal variation.
- [r]: Show owner: Show expected ownership of each intersection.
- [t]: NN Policy: Show KataGo's policy network evaluation, i.e. where it thinks the best next move is purely from the position, and in the absence of any 'reading'.
-
The analysis buttons are used for:
- [a]: Extra: Re-evaluate the position using more visits, usually resulting in a more accurate evaluation.
- [s]: Equalize: Re-evaluate all currently shown next moves with the same visits as the current top move. Useful to increase confidence in the suggestions with high uncertainty.
- [d]: Sweep: Evaluate all possible next moves. This can take a bit of time even though 'fast_visits' is used, but the result is nothing if not colourful.
Keyboard and mouse shortcuts
In addition to shortcuts mentioned above, there are:
- [Tab]: to switch between analysis and play modes. (NB. keyboard shortcuts function regardless)
- [~] or [`] or [m]: Hide side panel UI and only show the board.
- [enter]: AI Move
- [p]: Pass
- [spacebar]: Pause/Resume timer
- [arrow up] or [z]: Undo move. Hold shift for 10 moves at a time, or ctrl to skip to the start.
- [arrow down] or [x]: Redo move. Hold shift for 10 moves at a time, or ctrl to skip to the start.
- [scroll up]: Undo move. Only works when hovering the cursor over the board.
- [scroll down]: Redo move. Only works when hovering the cursor over the board.
- [click on a move]: See detailed statistics for a previous move, along with expected variation that was best instead of this move.
- [double-click on a move]: Navigate directly to that point in the game.
- [Ctrl-v]: Load SGF from clipboard and do a 'fast' analysis of the game (with a high priority normal analysis for the last move).
- [Ctrl-c]: Save SGF to clipboard.
- [Ctrl-l]: Load SGF from file and do a normal analysis.
- [Ctrl-s]: Save SGF with automated review to file.
- [Ctrl-n]: Load SGF from clipboard
Configuration
Configuration is stored in config.json
. Most settings are now available to edit in the program, but some advanced options are not.
You can use python katrain.py your_config_file.json
to use another config file instead.
If you ever need to reset to the original settings, simply re-download the config.json
file in this repository.
Settings Panel
- engine settings
- 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. If blank, as is the default, uses the included binaries on windows/linux, or 'katago' on MacOS (which assumes you have installed KataGo yourself).
- 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 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:
- game settings
- init_size: the initial size of the board, on start-up.
- init_komi: likewise, for komi.
- sgf settings
- sgf_load: default path where the load SGF dialog opens.
- sgf_save: path where SGF files are saved.
- board_ui settings
- anim_pv_time: time in seconds between each stone when animating variations.
- eval_dot_max_size: size of coloured dots when point size is maximal, relative to stone size.
- eval_dot_min_size: size of coloured dots when point size is minimal
- ... various other minor cosmetic options.
- debug settings
- level: determines the level of output in the console, where 0 shows no debug output, 1 shows some and 2 shows a lot. This is mainly used for reporting bugs.
FAQ
- The program is running too slowly. How can I speed it up?
- Adjust the number of visits or maximum time allowed in the settings.
- KataGo crashes with out of memory errors, how can I prevent this?
- Try using a lower number for
nnMaxBatchSize
inKataGo/analysis_config.cfg
, and avoid using versions compiled with large board sizes.
- Try using a lower number for
- How can I play on larger boards?
- For windows, change the
katago
setting tokatrain\KataGo\katago-bs52.exe
. For other operating systems, you need to compile your own KataGo version with higher limits.
- For windows, change the
Contributing
- Feedback and pull requests are both very welcome. I would also be happy to host translations of this manual into languages where English fluency is typically lower.
- For suggestions and planned improvements, see the 'issues' tab on github.
- You can also contact me on discord (Sander#3278), KakaoTalk or Reddit to give feedback, or simply show your appreciation.
- Some people have also asked me how to donate. Something go-related such as a book or teaching time is highly appreciated.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file KaTrain-1.0.6.tar.gz
.
File metadata
- Download URL: KaTrain-1.0.6.tar.gz
- Upload date:
- Size: 43.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5daa8212bda093e6c0ffe0112365bc571cb92e1d306266b6aabd8a4b4391653 |
|
MD5 | cb83c70764d0d7cb630456915bc2b8be |
|
BLAKE2b-256 | d532c7cbe9dff573a94d455b6f64ad03bdf0baf9947d1485f4afe1c580a35d48 |
File details
Details for the file KaTrain-1.0.6-py3-none-any.whl
.
File metadata
- Download URL: KaTrain-1.0.6-py3-none-any.whl
- Upload date:
- Size: 43.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ea03b39e09571810b74633e2fccef42675fc61475749a4a90ad2efa69bae7aa |
|
MD5 | 034ecac368b11ece3913bf304d531f23 |
|
BLAKE2b-256 | 97e7162db287e5243fd2360c7657c5d078bf00e757cb1cd31b61278ddff682f6 |