Play: each engine on its own scale (Maia 600–2600, Rodent V 800–3000)
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

The owner's decision: no conversion by our measurements. Maia plays the rating
on the slider (temperature 1, the large model when it is there, else the small
one), Rodent V its UCI_Elo; under the slider: these are the engines' own
ratings, not a person's Elo. No automatic switch past Maia's top; changing the
engine brings the strength into its range. Styles without strength ranges.

The journal test waits out a lock held for a moment by another test's child
process (it gets the parent's files until it runs its program).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-26 15:48:59 +03:00
parent 300430f2a8
commit aa136fb85e
6 changed files with 116 additions and 332 deletions

View file

@ -12,10 +12,12 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https
players of one computer each get their own database (the ▾ list by the name). It can players of one computer each get their own database (the ▾ list by the name). It can
be turned off: Settings → Interface → Your databases. be turned off: Settings → Interface → Your databases.
- Play against Rodent V (desktop, Linux and Windows): a strong engine with a style — - Play against Rodent V (desktop, Linux and Windows): a strong engine with a style —
balanced, attacking, chaotic, restricting, classical, or Tal — at a strength measured balanced, attacking, chaotic, restricting, classical, or Tal. It is downloaded once on
on the Lichess blitz scale, 1900 to 3000. It is downloaded once on request (48 MB, the request (48 MB, the authors' release).
authors' release). One strength slider serves both opponents: past Maia's 2100 Rodent - The opponent's strength is on the engine's own scale, as its authors give it: Maia
takes over. 600–2600, Rodent V 800–3000 (its UCI_Elo). The dialog says that these are the engines'
ratings, not a person's Elo. (1.5's slider showed Maia's strength measured on the
Lichess blitz scale; a remembered strength keeps its number.)
- Offer Maia a draw (desktop and Android): she accepts when she is clearly worse, or - Offer Maia a draw (desktop and Android): she accepts when she is clearly worse, or
when the position is about level (at most +0.2 for her) and has kept its character for when the position is about level (at most +0.2 for her) and has kept its character for
her last three moves; after a refusal, again two of her moves later. She judges with her last three moves; after a refusal, again two of her moves later. She judges with

View file

@ -2216,15 +2216,9 @@ impl GameView {
clock: start.clock.map(Clock::new), clock: start.clock.map(Clock::new),
opponent: match engine { opponent: match engine {
crate::play::Engine::Maia(_) => Opponent::start(file, ctx), crate::play::Engine::Maia(_) => Opponent::start(file, ctx),
crate::play::Engine::Rodent => Opponent::start_rodent( crate::play::Engine::Rodent => {
file, Opponent::start_rodent(file, start.style.clone(), Some(start.strength), ctx)
start.style.clone(), }
Some(crate::play::rodent_elo(
crate::play::style(&start.style),
start.strength,
)),
ctx,
),
}, },
resign_asked: false, resign_asked: false,
judge: judge.map(|p| { judge: judge.map(|p| {

View file

@ -11752,6 +11752,28 @@ const ROWS: &[[&str; 9]] = &[
"Tugallanmagan o‘yin (dastur yopildi) «{db}» ga yozildi, № {n}", "Tugallanmagan o‘yin (dastur yopildi) «{db}» ga yozildi, № {n}",
"Аяқталмаған ойын (бағдарлама жабылды) «{db}» базасына жазылды, № {n}", "Аяқталмаған ойын (бағдарлама жабылды) «{db}» базасына жазылды, № {n}",
], ],
[
"Rodent V's own rating (UCI_Elo): it does not match a person's Elo.",
"Собственный рейтинг Rodent V (UCI_Elo): он не равен Эло человека.",
"Le classement propre de Rodent V (UCI_Elo) : il ne correspond pas à l’Elo d’une personne.",
"Die eigene Wertung von Rodent V (UCI_Elo): sie entspricht nicht der Elo eines Menschen.",
"El rating propio de Rodent V (UCI_Elo): no equivale al Elo de una persona.",
"Il rating proprio di Rodent V (UCI_Elo): non corrisponde all’Elo di una persona.",
"O rating próprio do Rodent V (UCI_Elo): não corresponde ao Elo de uma pessoa.",
"Rodent V ning o‘z reytingi (UCI_Elo): u odamning Elo reytingiga teng emas.",
"Rodent V-тің өз рейтингі (UCI_Elo): ол адамның Эло рейтингіне сәйкес келмейді.",
],
[
"Maia's own rating: it does not match a person's Elo.",
"Собственный рейтинг Maia: он не равен Эло человека.",
"Le classement propre de Maia : il ne correspond pas à l’Elo d’une personne.",
"Die eigene Wertung von Maia: sie entspricht nicht der Elo eines Menschen.",
"El rating propio de Maia: no equivale al Elo de una persona.",
"Il rating proprio di Maia: non corrisponde all’Elo di una persona.",
"O rating próprio da Maia: não corresponde ao Elo de uma pessoa.",
"Maia ning o‘z reytingi: u odamning Elo reytingiga teng emas.",
"Maia-ның өз рейтингі: ол адамның Эло рейтингіне сәйкес келмейді.",
],
[ [
"Maia resigned", "Maia resigned",
"Maia сдалась", "Maia сдалась",

View file

@ -134,8 +134,8 @@ pub struct PlayPrefs {
pub color: ColorChoice, pub color: ColorChoice,
/// `None`: no clock. /// `None`: no clock.
pub clock: Option<TimeControl>, pub clock: Option<TimeControl>,
/// Maia's strength: a rating on the Lichess blitz scale (`level`: before 1.5 the /// The opponent's strength on its own scale: Maia's rating, Rodent's UCI_Elo
/// field `strength` held her rating input, a different scale, and is dropped). /// (decisions «Сила соперника — по шкале самого движка»). Kept as `level`.
#[serde(rename = "level")] #[serde(rename = "level")]
pub strength: u32, pub strength: u32,
/// The opponent: Maia or Rodent, and Rodent's style (a personality file's name). /// The opponent: Maia or Rodent, and Rodent's style (a personality file's name).
@ -162,9 +162,6 @@ pub struct Style {
title: &'static str, title: &'static str,
pub about: &'static str, pub about: &'static str,
pub player: bool, pub player: bool,
/// Measured: how much weaker (Elo) the style plays than the balanced one at the same
/// UCI_Elo, at some UCI_Elo values (in proportion between them, the nearest beyond).
weaker: &'static [(u32, u32)],
} }
impl Style { impl Style {
@ -181,7 +178,6 @@ pub const STYLES: &[Style] = &[
title: "Balanced", title: "Balanced",
about: "Even, all-round play with no bias.", about: "Even, all-round play with no bias.",
player: false, player: false,
weaker: &[],
}, },
Style { Style {
id: "ampere", id: "ampere",
@ -189,7 +185,6 @@ pub const STYLES: &[Style] = &[
title: "Attacking", title: "Attacking",
about: "Active pieces and attack, sound pawn structure.", about: "Active pieces and attack, sound pawn structure.",
player: false, player: false,
weaker: &[(800, 288), (1600, 295), (2400, 308), (3000, 301)],
}, },
Style { Style {
id: "chaotic", id: "chaotic",
@ -197,7 +192,6 @@ pub const STYLES: &[Style] = &[
title: "Chaotic", title: "Chaotic",
about: "Aggressive, tricky openings, careless with pawns.", about: "Aggressive, tricky openings, careless with pawns.",
player: false, player: false,
weaker: &[(800, 338), (1600, 252), (2400, 363), (3000, 354)],
}, },
Style { Style {
id: "nimzoid", id: "nimzoid",
@ -205,7 +199,6 @@ pub const STYLES: &[Style] = &[
title: "Restricting", title: "Restricting",
about: "Closed positions, cramping the opponent, old openings.", about: "Closed positions, cramping the opponent, old openings.",
player: false, player: false,
weaker: &[(800, 173), (1600, 200), (2400, 147), (3000, 263)],
}, },
Style { Style {
id: "hector", id: "hector",
@ -213,7 +206,6 @@ pub const STYLES: &[Style] = &[
title: "Classical", title: "Classical",
about: "Hand-written evaluation, no neural network.", about: "Hand-written evaluation, no neural network.",
player: false, player: false,
weaker: &[(800, 392), (1600, 402), (2400, 512), (3000, 372)],
}, },
Style { Style {
id: "tal_hybrid", id: "tal_hybrid",
@ -221,7 +213,6 @@ pub const STYLES: &[Style] = &[
title: "Tal", title: "Tal",
about: "Attacking style tuned on Tal's games.", about: "Attacking style tuned on Tal's games.",
player: true, player: true,
weaker: &[(800, 463), (1600, 392), (2400, 676), (3000, 676)],
}, },
Style { Style {
id: "tal_nnue", id: "tal_nnue",
@ -229,7 +220,6 @@ pub const STYLES: &[Style] = &[
title: "Tal (network)", title: "Tal (network)",
about: "A neural network trained on Tal's games.", about: "A neural network trained on Tal's games.",
player: true, player: true,
weaker: &[(800, 78), (1600, 115), (2400, 131), (3000, 131)],
}, },
]; ];
@ -264,24 +254,37 @@ impl Default for PlayPrefs {
} }
} }
pub const STRENGTH_MIN: u32 = 1100; // ----- the opponent's strength ---------------------------------------------------------
pub const STRENGTH_MAX: u32 = 2100;
// ----- Maia's strength ---------------------------------------------------------------- // Each engine on its own scale, as its authors give it (the owner's decision, after the
// measurements of docs/research/maia-strength.md and rodent.md): these are not a
// person's Elo, and the dialog says so.
pub use maia::strength::{SMALL_MAX, rating_input, temperature}; /// Maia's ratings: what her network was trained on.
pub const MAIA_MIN: u32 = 600;
pub const MAIA_MAX: u32 = 2600;
/// Rodent's UCI_Elo.
pub const RODENT_MIN: u32 = 800;
pub const RODENT_MAX: u32 = 3000;
/// The model to play at `strength`, with its file: the large one when it is there, /// The strengths `rival` plays.
/// else the small one up to its ceiling. `Err`: the model to download. pub fn range(rival: Rival) -> (u32, u32) {
pub fn model_for(strength: u32) -> Result<(Model, std::path::PathBuf), Model> { match rival {
Rival::Maia => (MAIA_MIN, MAIA_MAX),
Rival::Rodent => (RODENT_MIN, RODENT_MAX),
}
}
/// The Maia that plays, with its file: the large one when it is there, else the small
/// one. `Err`: the model to download.
pub fn model_for() -> Result<(Model, std::path::PathBuf), Model> {
use crate::maia_download::installed; use crate::maia_download::installed;
if let Some(p) = installed(Model::Large) { if let Some(p) = installed(Model::Large) {
return Ok((Model::Large, p)); return Ok((Model::Large, p));
} }
match installed(Model::Small) { installed(Model::Small)
Some(p) if strength <= SMALL_MAX => Ok((Model::Small, p)), .map(|p| (Model::Small, p))
_ => Err(Model::Large), .ok_or(Model::Large)
}
} }
// ----- the clock ----------------------------------------------------------------------- // ----- the clock -----------------------------------------------------------------------
@ -628,59 +631,6 @@ impl Opponent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test]
fn rodent_strength_to_uci_elo() {
use super::{STYLES, rodent_elo, rodent_range, style};
let balanced = style("rodent");
assert_eq!(rodent_range(balanced), (2250, 3000));
assert_eq!(rodent_elo(balanced, 2254), 800);
assert_eq!(rodent_elo(balanced, 2715), 2000);
let mid = rodent_elo(balanced, 2778);
assert!((2090..=2110).contains(&mid), "{mid}");
for st in STYLES {
let (min, max) = rodent_range(st);
assert!(min < max, "{}", st.id);
// A stronger choice always means a higher setting, within his settings.
let mut last = 0;
for s in (min..=max).step_by(50) {
let e = rodent_elo(st, s);
assert!(e >= last && (800..=3000).contains(&e), "{} {s}", st.id);
last = e;
}
}
// A weaker style needs a higher setting for the same strength.
assert!(rodent_elo(style("tal_hybrid"), 2400) > rodent_elo(balanced, 2400));
}
#[test]
fn strength_to_rating_input() {
use maia::strength::Model;
// The measured points themselves, in proportion between them, the ends held.
assert_eq!(rating_input(Model::Large, 1605), 1500);
assert_eq!(rating_input(Model::Large, 2000), 2600);
// Above the top input: surer choices, down to the most likely move.
assert_eq!(temperature(Model::Large, 1900), 1.0);
assert!((temperature(Model::Large, 2053) - 0.5).abs() < 1e-6);
assert!(temperature(Model::Large, STRENGTH_MAX) < 0.5);
assert!(temperature(Model::Small, SMALL_MAX) < 1.0);
assert_eq!(rating_input(Model::Small, 1485), 1500);
assert_eq!(rating_input(Model::Small, SMALL_MAX), 2600);
let mid = rating_input(Model::Large, (1605 + 1794) / 2);
assert!((1690..=1710).contains(&mid), "{mid}");
// The bottom of the slider is within what both models measured.
assert!(rating_input(Model::Large, STRENGTH_MIN) > 600);
assert!(rating_input(Model::Small, STRENGTH_MIN) > 600);
// Stronger always means a higher input.
for model in [Model::Small, Model::Large] {
let mut last = 0;
for level in (STRENGTH_MIN..=STRENGTH_MAX).step_by(50) {
let v = rating_input(model, level);
assert!(v >= last, "{model:?} {level}");
last = v;
}
}
}
use super::*; use super::*;
use chess_core::shakmaty::uci::UciMove; use chess_core::shakmaty::uci::UciMove;
@ -886,11 +836,11 @@ pub enum Engine {
} }
impl Engine { impl Engine {
/// Maia's rating input and temperature for `strength` (Rodent takes its strength as /// Maia's rating and temperature for `strength`: the rating itself, her moves drawn
/// UCI_Elo when it starts: nothing per move). /// as she predicts them (Rodent takes its strength as UCI_Elo when it starts).
pub fn input(self, strength: u32) -> (u32, f32) { pub fn input(self, strength: u32) -> (u32, f32) {
match self { match self {
Engine::Maia(m) => (rating_input(m, strength), temperature(m, strength)), Engine::Maia(_) => (strength, 1.0),
Engine::Rodent => (0, 0.0), Engine::Rodent => (0, 0.0),
} }
} }
@ -900,90 +850,11 @@ impl Engine {
/// downloaded first (the dialog offers it). /// downloaded first (the dialog offers it).
pub fn engine_for(start: &Start) -> Option<(Engine, std::path::PathBuf)> { pub fn engine_for(start: &Start) -> Option<(Engine, std::path::PathBuf)> {
match start.rival { match start.rival {
Rival::Maia => model_for(start.strength) Rival::Maia => model_for().ok().map(|(m, p)| (Engine::Maia(m), p)),
.ok()
.map(|(m, p)| (Engine::Maia(m), p)),
Rival::Rodent => crate::rodent_download::installed().map(|p| (Engine::Rodent, p)), Rival::Rodent => crate::rodent_download::installed().map(|p| (Engine::Rodent, p)),
} }
} }
/// Measured (docs/research/rodent.md, «Замер»): Rodent's UCI_Elo → its strength on the
/// Lichess blitz scale (default personality, its book off; 3900 games with random
/// openings against Maia and the Maia-1 bots, and level against level).
const RODENT: &[(u32, u32)] = &[
(800, 2254),
(1000, 2344),
(1200, 2401),
(1400, 2458),
(1600, 2506),
(1800, 2606),
(2000, 2715),
(2200, 2842),
(2400, 2948),
(2600, 3079),
(2800, 3226),
(3000, 3338),
];
/// The strongest Rodent offered: a strong grandmaster's blitz; beyond, the scale is not
/// measured against people.
const RODENT_TOP: u32 = 3000;
/// In proportion between measured points `(x, y)` (sorted by x), the nearest beyond.
fn between(points: &[(u32, u32)], x: u32) -> f64 {
let Some(&(x0, y0)) = points.first() else {
return 0.0;
};
if x <= x0 {
return f64::from(y0);
}
for w in points.windows(2) {
let ((a, ya), (b, yb)) = (w[0], w[1]);
if x <= b {
let t = f64::from(x - a) / f64::from(b - a);
return f64::from(ya) + t * (f64::from(yb) - f64::from(ya));
}
}
f64::from(points[points.len() - 1].1)
}
/// The strength Rodent plays at with `style` at each measured UCI_Elo: (UCI_Elo, strength).
fn rodent_curve(style: &Style) -> Vec<(u32, f64)> {
RODENT
.iter()
.map(|&(elo, base)| (elo, f64::from(base) - between(style.weaker, elo)))
.collect()
}
/// The strengths Rodent plays with `style` (from his lowest setting up to `RODENT_TOP`, or
/// his top with the style), on the slider's steps of 50 (the nearest one at the bottom:
/// well within the measurement's error).
pub fn rodent_range(style: &Style) -> (u32, u32) {
let curve = rodent_curve(style);
let (low, high) = (curve[0].1, curve[curve.len() - 1].1);
let min = ((low / 50.0).round() * 50.0) as u32;
let max = (((high / 50.0).floor() * 50.0) as u32).min(RODENT_TOP);
(min, max)
}
/// The UCI_Elo for Rodent to play at `strength` with `style` (in proportion between the
/// measured points; his lowest or highest setting beyond them).
pub fn rodent_elo(style: &Style, strength: u32) -> u32 {
let curve = rodent_curve(style);
let s = f64::from(strength);
if s <= curve[0].1 {
return curve[0].0;
}
for w in curve.windows(2) {
let ((a, sa), (b, sb)) = (w[0], w[1]);
if s <= sb {
let t = (s - sa) / (sb - sa);
return (f64::from(a) + t * f64::from(b - a)).round() as u32;
}
}
curve[curve.len() - 1].0
}
/// Dev hook `CP_RIVAL=rodent[:style]`: the opponent of a game started by a hook. /// Dev hook `CP_RIVAL=rodent[:style]`: the opponent of a game started by a hook.
pub fn debug_rival() -> (Rival, String) { pub fn debug_rival() -> (Rival, String) {
match std::env::var("CP_RIVAL") match std::env::var("CP_RIVAL")
@ -1062,11 +933,6 @@ pub struct Dialog {
download: Option<crate::maia_download::Download>, download: Option<crate::maia_download::Download>,
/// Rodent's download (docs/design/rodent-opponent.md §6). /// Rodent's download (docs/design/rodent-opponent.md §6).
rodent_download: Option<crate::engine_download::Download>, rodent_download: Option<crate::engine_download::Download>,
/// What the dialog just did with the opponent or the strength, said under the slider
/// (§4): an automatic switch, a strength raised or lowered.
event: Option<String>,
/// Rodent was chosen by the slider going past Maia (not by the user's click).
auto_switched: bool,
/// «Download and play» was pressed: the game starts once Maia is there. /// «Download and play» was pressed: the game starts once Maia is there.
play_after: bool, play_after: bool,
/// The game goes on from a position of another game. /// The game goes on from a position of another game.
@ -1099,15 +965,8 @@ impl Dialog {
if prefs.rival == Rival::Rodent && !rodent_ok { if prefs.rival == Rival::Rodent && !rodent_ok {
prefs.rival = Rival::Maia; prefs.rival = Rival::Maia;
} }
let (rodent_min, rodent_max) = rodent_range(style(&prefs.style)); let (min, max) = range(prefs.rival);
match prefs.rival { prefs.strength = prefs.strength.clamp(min, max);
Rival::Maia if prefs.strength > STRENGTH_MAX && rodent_ok => {
prefs.rival = Rival::Rodent;
prefs.strength = prefs.strength.clamp(rodent_min, rodent_max);
}
Rival::Maia => prefs.strength = prefs.strength.clamp(STRENGTH_MIN, STRENGTH_MAX),
Rival::Rodent => prefs.strength = prefs.strength.clamp(rodent_min, rodent_max),
}
let custom = prefs.clock.is_some_and(|c| !PRESETS.contains(&c)); let custom = prefs.clock.is_some_and(|c| !PRESETS.contains(&c));
Dialog { Dialog {
name: settings.your_name.clone(), name: settings.your_name.clone(),
@ -1116,8 +975,6 @@ impl Dialog {
custom, custom,
download: None, download: None,
rodent_download: None, rodent_download: None,
event: None,
auto_switched: false,
play_after: false, play_after: false,
focus: true, focus: true,
from: None, from: None,
@ -1219,7 +1076,7 @@ impl Dialog {
use egui::RichText; use egui::RichText;
let mut out = None; let mut out = None;
let rival_before = self.prefs.rival; let rival_before = self.prefs.rival;
let model = model_for(self.prefs.strength); let model = model_for();
let body_h = (ctx.content_rect().height() - 140.0).max(160.0); let body_h = (ctx.content_rect().height() - 140.0).max(160.0);
egui::Modal::new(egui::Id::new("play_dialog")).show(ctx, |ui| { egui::Modal::new(egui::Id::new("play_dialog")).show(ctx, |ui| {
ui.set_width(460.0); ui.set_width(460.0);
@ -1401,15 +1258,7 @@ impl Dialog {
}; };
if tile(ui, !rodent, true, "Maia", tr("plays like a human")).clicked() && rodent { if tile(ui, !rodent, true, "Maia", tr("plays like a human")).clicked() && rodent {
self.prefs.rival = Rival::Maia; self.prefs.rival = Rival::Maia;
self.auto_switched = false; self.prefs.strength = self.prefs.strength.clamp(MAIA_MIN, MAIA_MAX);
self.event = None;
if self.prefs.strength > STRENGTH_MAX {
self.prefs.strength = STRENGTH_MAX;
self.event = Some(crate::i18n::trf(
"Maia plays up to {elo}: the strength is lowered to {elo}.",
&[("elo", &STRENGTH_MAX)],
));
}
} }
let about = if rodent_ok { let about = if rodent_ok {
tr("strong, with a style") tr("strong, with a style")
@ -1423,108 +1272,33 @@ impl Dialog {
) }); ) });
if r.clicked() && !rodent { if r.clicked() && !rodent {
self.prefs.rival = Rival::Rodent; self.prefs.rival = Rival::Rodent;
self.auto_switched = false; self.prefs.strength = self.prefs.strength.clamp(RODENT_MIN, RODENT_MAX);
self.event = None;
let (min, _) = rodent_range(style(&self.prefs.style));
if self.prefs.strength < min {
self.prefs.strength = min;
self.event = Some(crate::i18n::trf(
"Rodent V plays from {elo}: the strength is raised to {elo}.",
&[("elo", &min)],
));
}
} }
}); });
// One scale for both: a point of the slider is always the same strength, whatever // Each engine on its own scale (its authors'): not a person's Elo, said under it.
// is chosen; the thumb stops at the top of Rodent's style. let (min, max) = range(self.prefs.rival);
let (rodent_min, rodent_max) = rodent_range(style(&self.prefs.style));
let top = if rodent_ok { RODENT_TOP } else { STRENGTH_MAX };
let before = self.prefs.strength;
ui.horizontal(|ui| { ui.horizontal(|ui| {
let end = |ui: &mut egui::Ui, v: u32| { let end = |ui: &mut egui::Ui, v: u32| {
ui.add_sized([34.0, 18.0], egui::Label::new(RichText::new(v.to_string()).weak())) ui.add_sized([34.0, 18.0], egui::Label::new(RichText::new(v.to_string()).weak()))
}; };
end(ui, STRENGTH_MIN); end(ui, min);
ui.spacing_mut().slider_width = W - 2.0 * 34.0 - 2.0 * GAP; ui.spacing_mut().slider_width = W - 2.0 * 34.0 - 2.0 * GAP;
let resp = ui.add( ui.add(
egui::Slider::new(&mut self.prefs.strength, STRENGTH_MIN..=top) egui::Slider::new(&mut self.prefs.strength, min..=max)
.step_by(50.0) .step_by(50.0)
.show_value(false), .show_value(false),
); );
// Where each plays, under the track: Maia's zone, then Rodent's with the end(ui, max);
// style chosen; the chosen one's lit.
if rodent_ok {
let rect = resp.rect;
let pad = rect.height() / 2.0;
let x = |v: u32| {
rect.left() + pad + (v - STRENGTH_MIN) as f32 / (top - STRENGTH_MIN) as f32 * (rect.width() - 2.0 * pad)
};
let lit = ui.visuals().selection.bg_fill.gamma_multiply(0.6);
let dim = ui.visuals().weak_text_color().gamma_multiply(0.4);
let maia = self.prefs.rival == Rival::Maia;
for (from, to, y, on) in
[(STRENGTH_MIN, STRENGTH_MAX, 1.0, maia), (rodent_min, rodent_max, 5.0, !maia)]
{
let band = egui::Rect::from_min_max(
egui::pos2(x(from), rect.bottom() + y),
egui::pos2(x(to), rect.bottom() + y + 3.0),
);
ui.painter().rect_filled(band, 1.0, if on { lit } else { dim });
}
}
end(ui, top);
}); });
ui.add_space(8.0); ui.add_space(4.0);
if self.prefs.strength != before { let note = if self.prefs.rival == Rival::Rodent {
// A word stays only while it is about the strength shown. tr("Rodent V's own rating (UCI_Elo): it does not match a person's Elo.")
self.event = None; } else {
// Past Maia's top: Rodent at once (the owner's rule); below Rodent's tr("Maia's own rating: it does not match a person's Elo.")
// bottom: Maia. Moving back keeps the choice, with a word about it. };
if self.prefs.rival == Rival::Maia && self.prefs.strength > STRENGTH_MAX { ui.add(egui::Label::new(RichText::new(note).weak().size(11.5)).wrap());
self.prefs.rival = Rival::Rodent;
self.prefs.strength = self.prefs.strength.clamp(rodent_min, rodent_max);
self.auto_switched = true;
self.event = Some(if rodent_min > STRENGTH_MAX {
crate::i18n::trf(
"Stronger than {elo} plays Rodent V, from {min} on: Maia does not play that strong.",
&[("elo", &STRENGTH_MAX), ("min", &rodent_min)],
)
} else {
crate::i18n::trf(
"Stronger than {elo} plays Rodent V: Maia does not play that strong.",
&[("elo", &STRENGTH_MAX)],
)
});
} else if self.prefs.rival == Rival::Rodent
&& self.prefs.strength < rodent_min
&& self.prefs.strength > STRENGTH_MAX
{
// In the gap nobody plays: Rodent stays, at his lowest (a drag through
// it does not flip between the two every frame).
self.prefs.strength = rodent_min;
} else if self.prefs.rival == Rival::Rodent && self.prefs.strength > rodent_max {
self.prefs.strength = rodent_max;
} else if self.prefs.rival == Rival::Rodent && self.prefs.strength < rodent_min {
self.prefs.rival = Rival::Maia;
self.auto_switched = false;
self.event = Some(crate::i18n::trf("Weaker than {elo} plays Maia.", &[("elo", &rodent_min)]));
} else if self.auto_switched && self.prefs.strength <= STRENGTH_MAX {
self.event = Some(tr("Maia can play here too: choose her if you want human mistakes.").to_owned());
}
}
let rodent = self.prefs.rival == Rival::Rodent;
let note = self.event.clone().unwrap_or_else(|| match (rodent, rodent_ok) {
(true, _) => tr("Measured strength, on the Lichess blitz scale.").to_owned(),
(false, true) => crate::i18n::trf(
"Her measured strength, on the Lichess blitz scale. Stronger than {elo}: Rodent V.",
&[("elo", &STRENGTH_MAX)],
),
(false, false) => tr("Her measured strength, on the Lichess blitz scale.").to_owned(),
});
ui.add(egui::Label::new(RichText::new(note).weak().size(11.5)).truncate());
// Rodent's style: always in its place (greyed for Maia), so nothing jumps. // Rodent's style: always in its place (greyed for Maia), so nothing jumps.
ui.add_space(4.0); ui.add_space(4.0);
let style_before = self.prefs.style.clone();
ui.add_enabled_ui(rodent, |ui| { ui.add_enabled_ui(rodent, |ui| {
// As tall as the buttons around it. // As tall as the buttons around it.
ui.spacing_mut().interact_size.y = 32.0; ui.spacing_mut().interact_size.y = 32.0;
@ -1542,18 +1316,7 @@ impl Dialog {
for (head, player) in [(tr("Style"), false), (tr("As a player"), true)] { for (head, player) in [(tr("Style"), false), (tr("As a player"), true)] {
ui.label(RichText::new(head).weak().size(11.5)); ui.label(RichText::new(head).weak().size(11.5));
for st in STYLES.iter().filter(|st| st.player == player) { for st in STYLES.iter().filter(|st| st.player == player) {
// Each style's strengths at the right: who plays weaker or stronger. ui.selectable_value(&mut self.prefs.style, st.id.to_owned(), style_label(st))
let (min, max) = rodent_range(st);
let mut job = egui::text::LayoutJob::default();
let font = egui::TextStyle::Button.resolve(ui.style());
let text_color = ui.visuals().text_color();
job.append(&style_label(st), 0.0, egui::TextFormat::simple(font.clone(), text_color));
job.append(
&format!("{min}–{max}"),
12.0,
egui::TextFormat::simple(font, ui.visuals().weak_text_color()),
);
ui.selectable_value(&mut self.prefs.style, st.id.to_owned(), job)
.on_hover_text(tr(st.about)); .on_hover_text(tr(st.about));
} }
if !player { if !player {
@ -1564,25 +1327,8 @@ impl Dialog {
.response .response
.on_disabled_hover_text(tr("The style is chosen for Rodent V")); .on_disabled_hover_text(tr("The style is chosen for Rodent V"));
}); });
// Another style plays at other strengths: the strength is kept inside them.
if self.prefs.style != style_before {
self.event = None;
}
if rodent {
let (min, max) = rodent_range(style(&self.prefs.style));
let kept = self.prefs.strength.clamp(min, max);
if kept != self.prefs.strength {
self.prefs.strength = kept;
self.event = Some(crate::i18n::trf(
"In this style Rodent V plays from {min} to {max}: the strength is set to {elo}.",
&[("min", &min), ("max", &max), ("elo", &kept)],
));
}
}
let about = if rodent { let about = if rodent {
let st = style(&self.prefs.style); tr(style(&self.prefs.style).about).to_owned()
let (min, max) = rodent_range(st);
format!("{} · {min}–{max}", tr(st.about))
} else { } else {
tr("Maia does not pick a style: she plays like people of her rating.").to_owned() tr("Maia does not pick a style: she plays like people of her rating.").to_owned()
}; };
@ -1956,19 +1702,11 @@ fn start_failure(detail: &str) -> String {
/// What the download button brings: Maia herself, or (the small one being there) the /// What the download button brings: Maia herself, or (the small one being there) the
/// large one for the strength chosen. /// large one for the strength chosen.
fn download_note(model: Option<Model>) -> String { fn download_note(model: Option<Model>) -> String {
let model = model.unwrap_or(Model::Large); let mb = model.unwrap_or(Model::Large).size().div_ceil(1_000_000);
let mb = model.size().div_ceil(1_000_000); crate::i18n::trf(
if crate::maia_download::installed(Model::Small).is_some() { "Maia is downloaded once ({mb} MB, from huggingface.co, the authors' own file).",
crate::i18n::trf( &[("mb", &mb)],
"Stronger than {elo} plays the large Maia: {mb} MB, downloaded once.", )
&[("elo", &SMALL_MAX), ("mb", &mb)],
)
} else {
crate::i18n::trf(
"Maia is downloaded once ({mb} MB, from huggingface.co, the authors' own file).",
&[("mb", &mb)],
)
}
} }
/// A game just played: what the result strip says. /// A game just played: what the result strip says.

View file

@ -371,6 +371,30 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir); let _ = std::fs::remove_dir_all(&dir);
} }
/// Recovery until only the journals of games being played are left. Another test
/// starting a process holds a copy of a lock for a moment (the child gets the parent's
/// files until it runs its program); recovery then leaves that journal for later.
fn recover_until(dir: &Path, live: usize) -> Vec<Recovered> {
let locks = || {
std::fs::read_dir(dir)
.map(|r| {
r.flatten()
.filter(|e| e.path().extension().is_some_and(|x| x == "lock"))
.count()
})
.unwrap_or(0)
};
let mut out = Vec::new();
for _ in 0..200 {
out.extend(recover_in(dir));
if locks() <= live {
break;
}
std::thread::sleep(std::time::Duration::from_millis(10));
}
out
}
#[test] #[test]
fn a_game_left_by_a_crash_is_written_once() { fn a_game_left_by_a_crash_is_written_once() {
let dir = std::env::temp_dir().join(format!("cp-journal-{}", std::process::id())); let dir = std::env::temp_dir().join(format!("cp-journal-{}", std::process::id()));
@ -387,7 +411,7 @@ mod tests {
// A game being played now (its lock held) is left alone. // A game being played now (its lock held) is left alone.
let live = Journal::in_dir(Some(journals.clone()), dir.join("live.pgn"), ""); let live = Journal::in_dir(Some(journals.clone()), dir.join("live.pgn"), "");
live.save(game); live.save(game);
let got = recover_in(&journals); let got = recover_until(&journals, 1);
assert_eq!(got.len(), 1); assert_eq!(got.len(), 1);
assert_eq!(got[0].player, "Роман"); assert_eq!(got[0].player, "Роман");
assert_eq!(got[0].written.as_ref().map(|w| w.index), Ok(0)); assert_eq!(got[0].written.as_ref().map(|w| w.index), Ok(0));
@ -400,7 +424,7 @@ mod tests {
let mut j = j; let mut j = j;
drop(j.lock.take()); drop(j.lock.take());
drop(j); drop(j);
assert!(recover_in(&journals).is_empty()); assert!(recover_until(&journals, 1).is_empty());
let n = chess_core::PgnDatabase::open(&db, &mut |_| {}, &AtomicBool::new(false)) let n = chess_core::PgnDatabase::open(&db, &mut |_| {}, &AtomicBool::new(false))
.unwrap() .unwrap()
.len(); .len();

View file

@ -117,6 +117,10 @@
- **Только на компьютере**; на телефоне остаётся Maia. - **Только на компьютере**; на телефоне остаётся Maia.
- Перед реализацией — замер силы Rodent V по шкале Lichess (как у Maia) и проверка сборки на Linux, Windows, macOS. - Перед реализацией — замер силы Rodent V по шкале Lichess (как у Maia) и проверка сборки на Linux, Windows, macOS.
## Сила соперника — по шкале самого движка (2026-10-26)
Владелец: «запарился с калибровкой движков» — в диалоге игры два движка, Maia и Rodent V, у каждого **своя шкала, как её заявляют авторы**: Maia 600–2600 (рейтинг, на котором обучена сеть; ходы — выбором по её вероятностям, температура 1), Rodent V 800–3000 (UCI_Elo; у Rodent по-прежнему выбирается стиль). Под ползунком сказано, что это рейтинги самих движков и Эло человека они не соответствуют. Автопереключения Maia → Rodent за 2100 больше нет; при смене движка сила приводится в его диапазон. Пересчёт по замерам (`research/maia-strength.md`, `research/rodent.md`) остаётся исследованием и в программе не используется (на телефоне пока прежняя шкала Maia).
## Партии игрока записываются сами (2026-10-26) ## Партии игрока записываются сами (2026-10-26)
Владелец: игроку, вписавшему имя, программа сама заводит базу его партий, и все партии с компьютером пишутся туда без отдельного действия — на компьютере и на телефоне (сначала компьютер). Это отменяет прежнее «автосохранения нет» (`own-databases.md` §1 п.4, `play-mode.md` §5.2, `android-play.md`) — только для сыгранных партий. Согласовано по `research/player-games-db.md` и `design/player-games.md`: Владелец: игроку, вписавшему имя, программа сама заводит базу его партий, и все партии с компьютером пишутся туда без отдельного действия — на компьютере и на телефоне (сначала компьютер). Это отменяет прежнее «автосохранения нет» (`own-databases.md` §1 п.4, `play-mode.md` §5.2, `android-play.md`) — только для сыгранных партий. Согласовано по `research/player-games-db.md` и `design/player-games.md`: