Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
//! A check of the `prep` crate on a real database, printed as text: the candidates
|
|
|
|
|
|
//! for a name, the repertoire tree of each colour, the opening table, where the games
|
|
|
|
|
|
//! left the book (the database itself, or another one), and, with an engine, the
|
|
|
|
|
|
//! opening errors by opening and the repeated ones.
|
|
|
|
|
|
//!
|
|
|
|
|
|
//! ```text
|
|
|
|
|
|
//! cargo run --release -p prep --example prep_report -- <database> "<player>" \
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
//! [--engine <path>] [--book <path>] [--plies 20] [--processes N] \
|
|
|
|
|
|
//! [--min-games 3] [--no-cache]
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
//! ```
|
|
|
|
|
|
//!
|
|
|
|
|
|
//! The report and the evaluations are cached under `~/.cache/chesspenguin/prep/`
|
|
|
|
|
|
//! like the application would (`--no-cache` ignores and does not write it).
|
|
|
|
|
|
|
|
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
|
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
|
|
|
|
|
use std::time::Instant;
|
|
|
|
|
|
|
2026-10-28 20:37:06 +03:00
|
|
|
|
use prep::{BookOptions, ColorReport, Options, Player, PositionCache, PrepReport, Side, Tree};
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
|
|
|
|
|
|
struct Args {
|
|
|
|
|
|
db: PathBuf,
|
|
|
|
|
|
player: String,
|
|
|
|
|
|
engine: Option<PathBuf>,
|
|
|
|
|
|
book: Option<PathBuf>,
|
|
|
|
|
|
plies: usize,
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
processes: usize,
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
min_games: u32,
|
|
|
|
|
|
cache: bool,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn args() -> Args {
|
|
|
|
|
|
let mut it = std::env::args().skip(1);
|
|
|
|
|
|
let mut a = Args {
|
|
|
|
|
|
db: PathBuf::new(),
|
|
|
|
|
|
player: String::new(),
|
|
|
|
|
|
engine: None,
|
|
|
|
|
|
book: None,
|
|
|
|
|
|
plies: prep::DEFAULT_PLIES,
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
processes: game_review::processes(game_review::MAX_PROCESSES),
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
min_games: 3,
|
|
|
|
|
|
cache: true,
|
|
|
|
|
|
};
|
|
|
|
|
|
let mut positional = Vec::new();
|
|
|
|
|
|
while let Some(arg) = it.next() {
|
|
|
|
|
|
match arg.as_str() {
|
|
|
|
|
|
"--engine" => a.engine = it.next().map(PathBuf::from),
|
|
|
|
|
|
"--book" => a.book = it.next().map(PathBuf::from),
|
|
|
|
|
|
"--plies" => a.plies = it.next().and_then(|v| v.parse().ok()).unwrap_or(a.plies),
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
"--processes" => {
|
2026-10-28 20:37:06 +03:00
|
|
|
|
a.processes = it
|
|
|
|
|
|
.next()
|
|
|
|
|
|
.and_then(|v| v.parse().ok())
|
|
|
|
|
|
.unwrap_or(a.processes)
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
}
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
"--min-games" => {
|
2026-10-28 20:37:06 +03:00
|
|
|
|
a.min_games = it
|
|
|
|
|
|
.next()
|
|
|
|
|
|
.and_then(|v| v.parse().ok())
|
|
|
|
|
|
.unwrap_or(a.min_games)
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
"--no-cache" => a.cache = false,
|
|
|
|
|
|
_ => positional.push(arg),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if positional.len() < 2 {
|
|
|
|
|
|
eprintln!("usage: prep_report <database> <player> [--engine path] [--book path] …");
|
|
|
|
|
|
std::process::exit(2);
|
|
|
|
|
|
}
|
|
|
|
|
|
a.db = PathBuf::from(&positional[0]);
|
|
|
|
|
|
a.player = positional[1].clone();
|
|
|
|
|
|
a
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn open(path: &Path) -> chess_import::Database {
|
|
|
|
|
|
let t = Instant::now();
|
2026-10-28 20:37:06 +03:00
|
|
|
|
let opened =
|
|
|
|
|
|
chess_import::open(path, &mut |_| {}, &AtomicBool::new(false)).unwrap_or_else(|e| {
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
eprintln!("cannot open {}: {e}", path.display());
|
|
|
|
|
|
std::process::exit(1);
|
|
|
|
|
|
});
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"[open] {} ({}): {} games, {:.2} s",
|
|
|
|
|
|
path.display(),
|
|
|
|
|
|
opened.format.label(),
|
|
|
|
|
|
opened.db.games(),
|
|
|
|
|
|
t.elapsed().as_secs_f64()
|
|
|
|
|
|
);
|
|
|
|
|
|
opened.db
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn tally(t: &prep::Tally) -> String {
|
|
|
|
|
|
format!("{} (+{} ={} -{})", t.games, t.wins, t.draws, t.losses)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn print_tree(tree: &Tree, node: usize, depth: usize, min_games: u32, report: &PrepReport) {
|
|
|
|
|
|
for &c in &tree.nodes[node].children {
|
|
|
|
|
|
let n = &tree.nodes[c as usize];
|
|
|
|
|
|
if n.tally.games < min_games {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
let name = match (n.named, n.opening) {
|
|
|
|
|
|
(true, Some(o)) => format!(" — {}", report.openings[o].name),
|
|
|
|
|
|
_ => String::new(),
|
|
|
|
|
|
};
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"{:indent$}{} {} {}{}{}{}",
|
|
|
|
|
|
"",
|
|
|
|
|
|
prep::move_label(usize::from(n.ply) - 1, &n.san),
|
|
|
|
|
|
tally(&n.tally),
|
|
|
|
|
|
n.last_date,
|
2026-10-28 20:37:06 +03:00
|
|
|
|
n.average_elo()
|
|
|
|
|
|
.map_or(String::new(), |e| format!(" Elo {e}")),
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
if n.transposition { " ↔" } else { "" },
|
|
|
|
|
|
name,
|
|
|
|
|
|
indent = depth * 2
|
|
|
|
|
|
);
|
|
|
|
|
|
if depth < 8 {
|
|
|
|
|
|
print_tree(tree, c as usize, depth + 1, min_games, report);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn print_color(report: &PrepReport, cr: &ColorReport, min_games: u32) {
|
|
|
|
|
|
let colour = if cr.white { "White" } else { "Black" };
|
2026-10-28 20:37:06 +03:00
|
|
|
|
println!(
|
|
|
|
|
|
"\n==== {colour}: {} games, {} tree nodes ====",
|
|
|
|
|
|
cr.games.len(),
|
|
|
|
|
|
cr.tree.nodes.len()
|
|
|
|
|
|
);
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
println!("-- repertoire (nodes with at least {min_games} games; ↔ = transposition)");
|
|
|
|
|
|
print_tree(&cr.tree, 0, 0, min_games, report);
|
|
|
|
|
|
println!("-- openings");
|
|
|
|
|
|
for f in &cr.families {
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"{} {}{}",
|
|
|
|
|
|
tally(&f.tally),
|
2026-10-28 20:37:06 +03:00
|
|
|
|
if f.name.is_empty() {
|
|
|
|
|
|
"(unnamed)"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
&f.name
|
|
|
|
|
|
},
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
errors_text(&f.errors)
|
|
|
|
|
|
);
|
|
|
|
|
|
for v in &f.variations {
|
|
|
|
|
|
let (name, line, eco) = match v.opening {
|
|
|
|
|
|
Some(o) => {
|
|
|
|
|
|
let o = &report.openings[o];
|
|
|
|
|
|
(o.name.as_str(), o.line.as_str(), o.eco.as_str())
|
|
|
|
|
|
}
|
|
|
|
|
|
None => ("(unnamed)", "", ""),
|
|
|
|
|
|
};
|
|
|
|
|
|
let games: Vec<String> = v
|
|
|
|
|
|
.games
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|&g| format!("#{}", report.games[g as usize].index + 1))
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
println!(
|
|
|
|
|
|
" {} {eco} {name} [{line}]{} — {}",
|
|
|
|
|
|
tally(&v.tally),
|
|
|
|
|
|
errors_text(&v.errors),
|
|
|
|
|
|
games.join(" ")
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if report.book.is_some() {
|
|
|
|
|
|
let (own, other) = cr.book_exits(&report.games);
|
|
|
|
|
|
let total = cr.games.len() as u32;
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"-- book: left by his own move in {own} games, by the opponent's in {other}, \
|
|
|
|
|
|
within the book for the whole line in {}",
|
|
|
|
|
|
total - own - other
|
|
|
|
|
|
);
|
|
|
|
|
|
let mut by_ply: Vec<(u32, bool, u32)> = cr
|
|
|
|
|
|
.games
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.filter_map(|&g| report.games[g as usize].book)
|
|
|
|
|
|
.map(|b| (b.ply, b.by_player, 1))
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
by_ply.sort_unstable();
|
|
|
|
|
|
by_ply.dedup_by(|a, b| {
|
|
|
|
|
|
if a.0 == b.0 && a.1 == b.1 {
|
|
|
|
|
|
b.2 += a.2;
|
|
|
|
|
|
true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
false
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
let text: Vec<String> = by_ply
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|(ply, own, n)| format!("ply {ply}{}: {n}", if *own { " (his)" } else { "" }))
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
println!(" {}", text.join(", "));
|
|
|
|
|
|
}
|
|
|
|
|
|
if !cr.errors.is_empty() || report.engine.is_some() {
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"-- errors: {} inaccuracies, {} mistakes, {} blunders in the player's moves",
|
|
|
|
|
|
cr.counts.inaccuracies, cr.counts.mistakes, cr.counts.blunders
|
|
|
|
|
|
);
|
|
|
|
|
|
for e in &cr.errors {
|
|
|
|
|
|
let g = &report.games[e.game as usize];
|
|
|
|
|
|
println!(
|
|
|
|
|
|
" #{} {} {:?}: {} (best {}) {} → {} [{}]",
|
|
|
|
|
|
g.index + 1,
|
|
|
|
|
|
g.move_label(e.ply as usize),
|
|
|
|
|
|
e.judgement,
|
|
|
|
|
|
e.san,
|
|
|
|
|
|
e.best_san,
|
|
|
|
|
|
e.before.format(),
|
|
|
|
|
|
e.after.format(),
|
|
|
|
|
|
e.opening.map_or("", |o| report.openings[o].name.as_str())
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
println!("-- repeated errors (same position, same move, two or more games)");
|
|
|
|
|
|
for r in &cr.repeated {
|
|
|
|
|
|
let games: Vec<String> = r
|
|
|
|
|
|
.games
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|&g| format!("#{}", report.games[g as usize].index + 1))
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
println!(
|
|
|
|
|
|
" {}× {} {:?} (best {}) {} — {} [{}]",
|
|
|
|
|
|
r.times(),
|
|
|
|
|
|
prep::move_label(r.ply as usize, &r.san),
|
|
|
|
|
|
r.judgement,
|
|
|
|
|
|
r.best_san,
|
|
|
|
|
|
tally(&r.tally),
|
|
|
|
|
|
games.join(" "),
|
|
|
|
|
|
r.opening.map_or("", |o| report.openings[o].name.as_str())
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn errors_text(e: &prep::ErrorCounts) -> String {
|
|
|
|
|
|
if e.total() == 0 {
|
|
|
|
|
|
String::new()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
format!(" ?!{} ?{} ??{}", e.inaccuracies, e.mistakes, e.blunders)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
let a = args();
|
|
|
|
|
|
let db = open(&a.db);
|
|
|
|
|
|
let never = AtomicBool::new(false);
|
|
|
|
|
|
let cache_dir = a.cache.then(|| {
|
|
|
|
|
|
std::env::home_dir()
|
|
|
|
|
|
.unwrap_or_else(|| PathBuf::from("."))
|
|
|
|
|
|
.join(".cache/chesspenguin/prep")
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let t = Instant::now();
|
|
|
|
|
|
let (list, total) = prep::candidates(&db, &a.player, 10);
|
2026-10-28 20:37:06 +03:00
|
|
|
|
println!(
|
|
|
|
|
|
"[candidates] {total} for «{}», {:.1} ms:",
|
|
|
|
|
|
a.player,
|
|
|
|
|
|
t.elapsed().as_secs_f64() * 1000.0
|
|
|
|
|
|
);
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
for c in &list {
|
|
|
|
|
|
println!(" {} · {} games (id {})", c.name, c.games, c.id);
|
|
|
|
|
|
}
|
|
|
|
|
|
let Some(chosen) = list
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.find(|c| c.name.to_lowercase() == a.player.to_lowercase())
|
|
|
|
|
|
.or(list.first())
|
|
|
|
|
|
else {
|
|
|
|
|
|
eprintln!("no such player");
|
|
|
|
|
|
std::process::exit(1);
|
|
|
|
|
|
};
|
|
|
|
|
|
let player = Player::new([chosen.id]);
|
|
|
|
|
|
println!("[player] {} ({} games)", chosen.name, chosen.games);
|
|
|
|
|
|
|
|
|
|
|
|
let options = Options {
|
|
|
|
|
|
plies: a.plies,
|
|
|
|
|
|
side: Side::Any,
|
2026-10-31 18:11:58 +03:00
|
|
|
|
period: prep::Period::All,
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
};
|
|
|
|
|
|
let t = Instant::now();
|
|
|
|
|
|
let cached = cache_dir
|
|
|
|
|
|
.as_deref()
|
|
|
|
|
|
.and_then(|d| PrepReport::load(d, &db, &player, &options));
|
|
|
|
|
|
let mut report = match cached {
|
|
|
|
|
|
Some(r) => {
|
2026-10-28 20:37:06 +03:00
|
|
|
|
println!(
|
|
|
|
|
|
"[report] from the cache, {:.1} ms",
|
|
|
|
|
|
t.elapsed().as_secs_f64() * 1000.0
|
|
|
|
|
|
);
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
r
|
|
|
|
|
|
}
|
|
|
|
|
|
None => {
|
|
|
|
|
|
let progress = AtomicUsize::new(0);
|
|
|
|
|
|
let r = prep::build(&db, &player, &options, &progress, &never).expect("not cancelled");
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"[report] built: {} games ({} skipped), {} plies, {} openings named, {:.1} ms",
|
|
|
|
|
|
r.games.len(),
|
|
|
|
|
|
r.skipped,
|
|
|
|
|
|
r.plies,
|
|
|
|
|
|
r.openings.len(),
|
|
|
|
|
|
t.elapsed().as_secs_f64() * 1000.0
|
|
|
|
|
|
);
|
|
|
|
|
|
r
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// The book: another database, or this one without the player's own games.
|
|
|
|
|
|
let t = Instant::now();
|
|
|
|
|
|
let book_options = BookOptions {
|
|
|
|
|
|
threshold: prep::DEFAULT_BOOK_THRESHOLD,
|
|
|
|
|
|
same_database: a.book.is_none(),
|
|
|
|
|
|
};
|
|
|
|
|
|
let book = a.book.as_deref().map(open);
|
|
|
|
|
|
let book_db = book.as_ref().unwrap_or(&db);
|
2026-10-28 20:37:06 +03:00
|
|
|
|
if report
|
|
|
|
|
|
.book
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
.is_some_and(|b| b.fingerprint == prep::fingerprint(book_db))
|
|
|
|
|
|
{
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
println!("[book] from the cached report");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let progress = AtomicUsize::new(0);
|
|
|
|
|
|
match report.find_book_exits(book_db, &book_options, &progress, &never) {
|
|
|
|
|
|
Some(()) => println!(
|
|
|
|
|
|
"[book] threshold {}: {} of {} games left the book, {:.2} s",
|
|
|
|
|
|
book_options.threshold,
|
|
|
|
|
|
report.book.as_ref().map_or(0, |b| b.left),
|
|
|
|
|
|
report.games.len(),
|
|
|
|
|
|
t.elapsed().as_secs_f64()
|
|
|
|
|
|
),
|
|
|
|
|
|
None => println!("[book] not searchable (no memory for the position table?)"),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for cr in [&report.white, &report.black] {
|
|
|
|
|
|
print_color(&report, cr, a.min_games);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(engine) = &a.engine {
|
|
|
|
|
|
let mut cache = cache_dir
|
|
|
|
|
|
.as_deref()
|
|
|
|
|
|
.map(PositionCache::load)
|
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"\n[engine] {} positions, {} distinct; {} cached evaluations on disk",
|
|
|
|
|
|
report.games.iter().map(|g| g.keys.len()).sum::<usize>(),
|
|
|
|
|
|
report.distinct_positions(),
|
|
|
|
|
|
cache.len()
|
|
|
|
|
|
);
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
let settings = game_review::JobSettings::new(a.processes, None);
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
let t = Instant::now();
|
|
|
|
|
|
let mut last_shown = Instant::now();
|
|
|
|
|
|
let mut first = true;
|
|
|
|
|
|
let result = prep::analyse(
|
|
|
|
|
|
&mut report,
|
|
|
|
|
|
&mut cache,
|
|
|
|
|
|
cache_dir.as_deref(),
|
|
|
|
|
|
uci::EngineConfig::new(engine.clone()),
|
|
|
|
|
|
&settings,
|
|
|
|
|
|
&never,
|
|
|
|
|
|
&mut |p| {
|
|
|
|
|
|
if first {
|
Review: one fixed engine search everywhere, in parallel engine processes
Every position of a game analysis (and of the opening errors) is searched by
ChessPenguin's Stockfish 19 to 1M nodes with one thread, a 32 MB hash and
ucinewgame before each search, so the evaluations depend on the position
alone: the same marks on every computer and phone, whatever the number of
engine processes (one per CPU, at most 8 on a computer and 4 on a phone, and
what the free memory holds) or the order of the positions.
- ReviewMeta.search: analyses of another search are stale; shown, but
Update makes them all again. The prep caches drop such evaluations.
- Desktop: no launch dialog (engine, quality, threads, memory are gone);
Analyse starts at once, its tooltip gives the time; the prep dialog keeps
the colour. Without the own Stockfish the download is offered.
- settings.review and prep.quality removed; old settings files still read.
- fake_uci --hash-memory; tests of determinism on processes and order.
- chesscom_check in the fixed search (CP_REVIEW_NODES for experiments);
review_bench example for times and determinism on a real engine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:19:44 +03:00
|
|
|
|
println!(
|
|
|
|
|
|
"[engine] {} positions to evaluate, {} engine processes",
|
|
|
|
|
|
p.total, a.processes
|
|
|
|
|
|
);
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
first = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if last_shown.elapsed().as_secs_f64() >= 5.0 {
|
2026-10-28 20:37:06 +03:00
|
|
|
|
println!(
|
|
|
|
|
|
" {} / {} ({:.0} s, nps {})",
|
|
|
|
|
|
p.done,
|
|
|
|
|
|
p.total,
|
|
|
|
|
|
t.elapsed().as_secs_f64(),
|
|
|
|
|
|
p.nps
|
|
|
|
|
|
);
|
Opponent prep: the `prep` crate (openings only)
A new crate shared by the apps, no UI: what a player of a database plays
in the opening and where in the opening he goes wrong.
- Player: candidates from the database's names (initials with a full
stop work), one or several ids, White, Black or both.
- Lines: the first N plies (default 20) of the main lines, position keys,
UCI/SAN, result from the player's side, full date, opponent's Elo;
games from a set-up position are skipped.
- Repertoire tree per colour by move order with position keys:
games (+/=/-), last date, average opponent Elo, game list,
transpositions marked.
- Opening names from lichess-org/chess-openings (CC0; revision and
SHA-256 pinned, files in crates/prep/data, THIRD_PARTY_NOTICES): the
deepest named position of a line, families and variations with their
first moves, grouped by name.
- Book: a second database (or the same one without the player's games)
says where each game left it (first position with fewer than T games,
T = 5) and whose move it was.
- Engine: every distinct position of the lines once through
game_review::run, judged with the game analysis rules for the player's
moves only; errors by opening and the repeated ones (same position,
same move in two or more games); evaluations cached per position across
reports, the report cached by database, player and plies.
- examples/prep_report.rs prints it all for a database and a player.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-28 12:32:39 +03:00
|
|
|
|
last_shown = Instant::now();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
match result {
|
|
|
|
|
|
Ok(()) => println!(
|
|
|
|
|
|
"[engine] done in {:.1} s; {} evaluations in the cache; engine {}",
|
|
|
|
|
|
t.elapsed().as_secs_f64(),
|
|
|
|
|
|
cache.len(),
|
|
|
|
|
|
report.engine.as_ref().map_or("?", |e| e.name.as_str())
|
|
|
|
|
|
),
|
|
|
|
|
|
Err(e) => println!("[engine] failed: {e:?}"),
|
|
|
|
|
|
}
|
|
|
|
|
|
for cr in [&report.white, &report.black] {
|
|
|
|
|
|
print_color(&report, cr, u32::MAX);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(dir) = &cache_dir {
|
|
|
|
|
|
match report.save(dir) {
|
|
|
|
|
|
Ok(()) => println!("[cache] report saved in {}", dir.display()),
|
|
|
|
|
|
Err(e) => println!("[cache] not saved: {e}"),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|