trainer: the opening trainer as a crate shared by the desktop and Android
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

apps/desktop/src/train.rs moves to crates/trainer; the rule of a move (right,
the last one, wrong) becomes Training::judge, the desktop uses it; the app
names the stats file (set_file). The line's last move comes in plain SAN; the
desktop shows it its own way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-26 01:00:11 +03:00
parent 45a37fc65b
commit bb2ef38ef6
7 changed files with 166 additions and 33 deletions

View file

@ -28,7 +28,6 @@ mod san;
mod settings;
mod settings_ui;
mod sound;
mod train;
mod translate;
mod translate_ui;
mod update;
@ -36,6 +35,9 @@ mod update_ui;
mod viewed;
mod widgets;
/// Learning an opening: shared with the Android app.
use trainer as train;
fn main() -> eframe::Result {
// `chesspenguin --bench <database> [report.txt]`: timings instead of the window
// (`docs/dev/import.md`, "Замер на другой машине").
@ -58,6 +60,16 @@ fn main() -> eframe::Result {
return Ok(());
}
crate::i18n::set_lang(settings::Settings::load().language);
// The runs of the opening trainer (`CP_TRAINING_FILE` elsewhere: development).
if let Some(file) = std::env::var_os("CP_TRAINING_FILE")
.map(std::path::PathBuf::from)
.or_else(|| {
directories::ProjectDirs::from("io.github", "vrubelroman", "ChessPenguin")
.map(|d| d.data_local_dir().join("training.json"))
})
{
train::set_file(file);
}
graphics::install_panic_hook();
graphics::init_library_log();
let mode = graphics::choose();