Skip to main content

Crate katago_analysis

Crate katago_analysis 

Source
Expand description

A wrapper around KataGo’s analysis protocol.

See KataGo Parallel Analysis Engine for official documentation of the analysis engine.

Note: The asynchronous methods in this library must be called from within a Tokio runtime.

§Examples

After launching an Engine, the primary entry point for using this library is Analyzer.

use katago_analysis::{
    AnalysisRequest, Analyzer, Coord, Move, Player, Result, Rules,
    engine::{Engine, LaunchOptions},
};

async fn example(
    katago_path: String,
    analysis_config_path: String,
    model_path: String,
) -> Result<()> {
    let options = LaunchOptions::new(katago_path, analysis_config_path, model_path);
    let mut analyzer: Analyzer = Engine::launch(&options)?.into();

    let request = AnalysisRequest::new(
        Rules::chinese(),
        19,
        19,
        vec![
            (Player::Black, Move::Move(Coord(15, 3))),
            (Player::White, Move::Move(Coord(3, 15))),
        ],
    );

    let results = analyzer.analyze_game(request).await?;
    for i in 0..results.len() {
        println!(
            "Move {i}: {:.1}%",
            results.get(&i).unwrap().root_info.winrate * 100.0
        );
    }
    Ok(())
}

Modules§

engine
KataGo’s analysis protocol, implemented as a low-level stream of unsynchronized messages.

Structs§

AnalysisProgress
An in-progress analysis operation for a single position.
AnalysisRequest
A game record to be analyzed, along with analysis settings.
AnalysisResult
The result of analyzing a position.
Analyzer
An instance of the KataGo analysis engine, launched as a child process.
Config
KataGo configuration as used in .cfg files, the -override-config command line argument, and the overrideSettings property of analysis requests.
Coord
A board location in (x, y) format, where (0, 0) is the top-left corner of the board.
GameAnalysisProgress
A collection of in-progress analysis operations for multiple positions in a single game.
IgnoreWarnings
Warnings will be dropped.
Matrix
A 2D matrix representing the game board.
MaybeWarnings
A result that may contain warnings.
Model
Information about a neural network model.
MoveInfo
The result of analyzing a candidate move.
RestrictedMoves
A list of moves that are either forbidden with AnalysisRequest::avoid_moves or allowed with AnalysisRequest::allow_moves.
ReturnWarnings
Warnings will be returned in a MaybeWarnings.
RootInfo
The result of analyzing the root position.
VersionInfo
KataGo’s version information.
Warning
A warning returned by the analysis engine.
WarningsAsErrors
Warnings will return Error::UnhandledWarnings.

Enums§

Bonus
Bonus points white receives in handicap games.
Enabled
The enabled state of a feature.
Error
Errors that can occur while interacting with the analysis engine.
Ko
Ko rules.
Move
A move in a game.
Player
Player colours.
Rules
Rules settings for KataGo.
Scoring
Scoring methods.
Side
A side which values can be calculated relative to.
Tax
Group tax rules.

Traits§

WarningHandling
Specifies how warnings from the analysis engine should be handled.

Type Aliases§

Result
The type of results returned by methods in this library.
WarningResult
The type of results which may contain warnings returned by the analysis engine.