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§
- Analysis
Progress - An in-progress analysis operation for a single position.
- Analysis
Request - A game record to be analyzed, along with analysis settings.
- Analysis
Result - 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-configcommand line argument, and theoverrideSettingsproperty of analysis requests. - Coord
- A board location in (x, y) format, where (0, 0) is the top-left corner of the board.
- Game
Analysis Progress - A collection of in-progress analysis operations for multiple positions in a single game.
- Ignore
Warnings - Warnings will be dropped.
- Matrix
- A 2D matrix representing the game board.
- Maybe
Warnings - A result that may contain warnings.
- Model
- Information about a neural network model.
- Move
Info - The result of analyzing a candidate move.
- Restricted
Moves - A list of moves that are either forbidden with
AnalysisRequest::avoid_movesor allowed withAnalysisRequest::allow_moves. - Return
Warnings - Warnings will be returned in a
MaybeWarnings. - Root
Info - The result of analyzing the root position.
- Version
Info - KataGo’s version information.
- Warning
- A warning returned by the analysis engine.
- Warnings
AsErrors - 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§
- Warning
Handling - Specifies how warnings from the analysis engine should be handled.
Type Aliases§
- Result
- The type of results returned by methods in this library.
- Warning
Result - The type of results which may contain warnings returned by the analysis engine.