Skip to main content

EN ZH

KataGoAnal

Inject KataGo analysis — winrate, score lead, uncertainty — into SGF game records as standard C[...] comments. The output is readable by any SGF viewer (Sabaki, LGS, OGS, etc.), not just Sabaki. Designed exclusively for KataGo and cross-platform (Linux / macOS / Windows).

Project Structure

KataGoAnal/
├── pyproject.toml              # pip packaging metadata (name, version, dependencies, entry point)
├── README.md                   # This document
│
├── KataGoAnal/                 # Python package (the body of pip install)
│   ├── __init__.py             # Package declaration
│   ├── cli.py                  # Command dispatch + argparse (-h/-c/-m/-v/-o/--visits)
│   ├── configure.py            # katagoanal configure / init interactive setup
│   ├── sgf_io.py               # SGF read/write (sgfmill wrapper)
│   ├── katago_driver.py        # KataGo analysis subprocess driver
│   ├── inject.py               # Inject analysis as C[...] comments into game records
│   ├── paths.py                # User config directory + paths.json I/O + cfg read/write
│   └── configs/
│       └── config.cfg          # Bundled KataGo engine parameter template (shipped with package)
│
└── tests/                      # Test suite (pytest tests/)
    ├── fixtures.py             # Synthetic SGF test data
    ├── test_cli.py             # CLI tests
    ├── test_configure.py       # Configuration flow tests
    ├── test_sgf_io.py          # SGF logic tests
    ├── test_katago_driver.py   # Driver logic tests
    ├── test_inject.py          # Injection logic tests
    └── test_paths.py           # Paths I/O tests

Configuration Files

File Purpose Consumer
pyproject.toml pip packaging metadata: name, version, dependencies, entry point, package scope pip install
KataGoAnal/configs/config.cfg Bundled KataGo engine parameter template: reportAnalysisWinratesAs=BLACK, maxVisits, numAnalysisThreads, etc. Copied by configure on first run
~/.config/katagoanal/paths.json Three user-configured paths: binary, model, config katagoanal at runtime
~/.config/katagoanal/config.cfg User copy (configure copies from bundled template and rewrites threads/visits) katago analysis subprocess

Installation

pip install katagoanal          # Regular install

The console command katagoanal is available after installation. Manual configuration is required before first use.

Configuration

katagoanal configure

Interactive flow (brackets show the saved path; empty on a fresh install):

KataGo engine path []: /home/user/katago/katago
Model file (.bin) []: /home/user/katago/model.bin
Config file (.cfg) [/home/user/.config/katagoanal/config.cfg]:
Threads [8]:
Visits [800]:
  • Fresh install: brackets are empty — you must enter the paths.
  • Reconfigure: brackets show previously saved paths — press Enter to keep.
  • Non-existent paths are rejected with an error and you are prompted again.

Commands

katagoanal -h, --help           # Help
katagoanal -v, --version        # Version number
katagoanal -c, --config         # Current configuration (3 paths + visits/threads)
katagoanal -m, --model          # Model weight path + engine version
katagoanal configure | init     # Interactive setup
katagoanal <file.sgf>           # Inject analysis (winrate, score lead, uncertainty)
katagoanal <file.sgf> --visits 500 -o <dir>   # Custom visits and output directory
katagoanal <file.sgf> -l zh                    # Chinese comment labels
katagoanal <file.sgf> --clear-comments         # Overwrite existing comments

Usage

# Basic usage
katagoanal game.sgf

# Specify visits and output directory
katagoanal game.sgf --visits 500 -o output/

# Batch processing
katagoanal record/*.sgf --visits 800 -o injected/

# Chinese labels
katagoanal record/*.sgf --visits 800 -o injected/ -l zh

# Clear existing comments before writing
katagoanal record/*.sgf --visits 800 -o injected/ --clear-comments

# Directories expand to *.sgf automatically
katagoanal record/
  • -o/--output: Output directory (must already exist; default: current directory). Produces <stem>.injected.sgf.
  • -l/--language: Comment language — en (English) or zh (Chinese). Controls field labels and colon style. Numeric values are always in Arabic numerals. (default: en).
  • --clear-comments: Clear any existing C[...] comments on each node before writing new analysis data. By default, new content is prepended before existing comments, separated by a blank line.
  • --visits: KataGo search visits per move (default: maxVisits from config.cfg, falling back to 800).

Parameter Priority

  • Komi, rules (RU), board size, and handicap from the SGF are always sent with every query and take priority.
  • Rules are read from the SGF RU property; if absent, they are inferred from komi.
  • config.cfg holds only engine-level defaults (visits, threads, Black perspective) and never overrides game-specific parameters.
  • Analysis data is written into the standard C[...] comment property on each node, with perspective dynamically switching per move (Black's turn → Black perspective, White's turn → White perspective). The root node also gets a full metadata header including engine info, match rates, and key deviations.
  • Per-move comments include winrate/score lead with inline ± uncertainty (from KataGo's rawStWrError/rawStScoreError), deltas versus the previous position, komi, and an engine info suffix line.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

katagoanal-0.4.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

katagoanal-0.4.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file katagoanal-0.4.0.tar.gz.

File metadata

  • Download URL: katagoanal-0.4.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for katagoanal-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e43bade78c8f05605077c6bf10b9d8467124c6b8ec34ae7e36b3390367a4582b
MD5 a81afe5892f47d7e40d033e85a02229f
BLAKE2b-256 a5a85c61af251a3f0b3831036340ca6888d86321f46fe2a0b1744d3c472dacf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for katagoanal-0.4.0.tar.gz:

Publisher: publish.yml on Hoigin/KataGoAnal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file katagoanal-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: katagoanal-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for katagoanal-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fdd667efde812c5ab6df1bcf68511241a894e75330855c7aa3ecff3deb80c2c
MD5 84584e1d663d31df82b8a1de96291f5d
BLAKE2b-256 cebab71ee56ba95600944352328f71cf2c77962c9238df0f964e43d7143b3de3

See more details on using hashes here.

Provenance

The following attestation bundles were made for katagoanal-0.4.0-py3-none-any.whl:

Publisher: publish.yml on Hoigin/KataGoAnal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page