From dbcfe818565be1afa91f04fa89cfbaf3af607508 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Mon, 26 Oct 2026 00:11:02 +0300 Subject: [PATCH] Play: Maia up to 2100 (surer choices above a model's top), measured with random openings Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 +-- apps/desktop/src/game_view.rs | 10 +++++-- apps/desktop/src/play.rs | 49 +++++++++++++++++++++++++++++++--- docs/research/maia-strength.md | 16 +++++++++++ 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c09930..ef941cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,8 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https - Play against Maia: the large model (79M parameters, 316 MB, downloaded once from the authors' page) plays every strength; it is stronger and closer to how people play. - The slider shows her measured strength on the Lichess blitz scale (1100–2000). The - small model, when it is there, still plays up to 1800. Maia thinks on half the cores; + The slider shows her measured strength on the Lichess blitz scale (1100–2100; at the + top she chooses her moves more surely). The small model, when it is there, still plays up to 1800. Maia thinks on half the cores; her clock counts the computing when it takes longer than her pause. - Game analysis: «Analyse» starts at once with the options chosen the last time; the options dialog comes the first time and with «Analyse again…». diff --git a/apps/desktop/src/game_view.rs b/apps/desktop/src/game_view.rs index fed560d..7ca1b5d 100644 --- a/apps/desktop/src/game_view.rs +++ b/apps/desktop/src/game_view.rs @@ -2344,7 +2344,10 @@ impl GameView { let elo = s.user_elo.unwrap_or(s.strength); s.opponent.ask( positions, - crate::play::rating_input(s.model, elo), + ( + crate::play::rating_input(s.model, elo), + crate::play::temperature(s.model, elo), + ), s.strength, std::time::Duration::from_millis(30), ); @@ -2364,7 +2367,10 @@ impl GameView { }; // Her rating input is what makes her play at her strength; the user's is as is. let oppo = s.user_elo.unwrap_or(s.strength); - let own = crate::play::rating_input(s.model, s.strength); + let own = ( + crate::play::rating_input(s.model, s.strength), + crate::play::temperature(s.model, s.strength), + ); s.opponent.ask(positions, own, oppo, pause); // Is her position lost? (Unless the user wants to play to the end.) if !s.play_on diff --git a/apps/desktop/src/play.rs b/apps/desktop/src/play.rs index 5f4675a..3a0ea42 100644 --- a/apps/desktop/src/play.rs +++ b/apps/desktop/src/play.rs @@ -153,7 +153,7 @@ impl Default for PlayPrefs { } pub const STRENGTH_MIN: u32 = 1100; -pub const STRENGTH_MAX: u32 = 2000; +pub const STRENGTH_MAX: u32 = 2100; // ----- Maia's strength ---------------------------------------------------------------- @@ -172,7 +172,7 @@ const SMALL: &[(u32, u32)] = &[ (1900, 1632), (2100, 1683), (2300, 1737), - (2600, 1800), + (2600, 1767), ]; const LARGE: &[(u32, u32)] = &[ (600, 1078), @@ -183,6 +183,34 @@ const LARGE: &[(u32, u32)] = &[ (2600, 2000), ]; +/// Above what a model plays choosing among the likely moves (temperature 1), it is made +/// stronger by choosing more surely: measured strength at its top rating input → the +/// temperature (0: always the most likely move). +const SMALL_SURE: &[(u32, f32)] = &[(1767, 1.0), (1854, 0.5)]; +const LARGE_SURE: &[(u32, f32)] = &[(1976, 1.0), (2053, 0.5), (2126, 0.0)]; + +/// How surely `model` chooses its move to play at `strength` (1 below its top). +pub fn temperature(model: Model, strength: u32) -> f32 { + let table = match model { + Model::Small => SMALL_SURE, + Model::Large => LARGE_SURE, + }; + let (first, last) = (table[0], table[table.len() - 1]); + if strength <= first.0 { + return first.1; + } + if strength >= last.0 { + return last.1; + } + let i = table + .iter() + .position(|p| p.0 >= strength) + .unwrap_or(table.len() - 1); + let ((a_s, a_t), (b_s, b_t)) = (table[i - 1], table[i]); + let k = (strength - a_s) as f32 / (b_s - a_s) as f32; + a_t + k * (b_t - a_t) +} + /// The rating to give `model` for it to play at `strength` (between the measured /// points, in proportion; outside them, the nearest). pub fn rating_input(model: Model, strength: u32) -> u32 { @@ -424,6 +452,7 @@ struct Request { positions: Vec, self_elo: u32, oppo_elo: u32, + temperature: f32, pause: Duration, } @@ -470,7 +499,7 @@ impl Opponent { // one time in five thousand). let top = p.moves.first().map_or(0.0, |(_, pr)| *pr); p.moves.retain(|(_, pr)| *pr >= 0.1 * top); - let m = maia::pick(&p, 1.0, random_unit()); + let m = maia::pick(&p, r.temperature, random_unit()); let rest = r.pause.saturating_sub(started.elapsed()); std::thread::sleep(rest); // Her clock: the pause, or the computing when it took longer (a slow @@ -492,7 +521,13 @@ impl Opponent { } /// Asks for a move in the last of `positions`. - pub fn ask(&mut self, positions: Vec, self_elo: u32, oppo_elo: u32, pause: Duration) { + pub fn ask( + &mut self, + positions: Vec, + (self_elo, temperature): (u32, f32), + oppo_elo: u32, + pause: Duration, + ) { self.generation += 1; self.thinking = true; let _ = self.tx.send(Request { @@ -500,6 +535,7 @@ impl Opponent { positions, self_elo, oppo_elo, + temperature, pause, }); } @@ -574,6 +610,11 @@ mod tests { // 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); diff --git a/docs/research/maia-strength.md b/docs/research/maia-strength.md index bca707c..44e293f 100644 --- a/docs/research/maia-strength.md +++ b/docs/research/maia-strength.md @@ -248,3 +248,19 @@ С дебютами и без них совпадает в пределах ошибки (5M 1100: 1314 и 1352; 79M 1500: 1615 и 1594). **Вывод для программы** (`apps/desktop/src/play.rs`, таблицы `SMALL`/`LARGE`): ползунок 1100–2000 настоящей силы. Большая модель покрывает его весь (внизу — номинал ≈ 640), малая — 1100–1800. Выше ≈ 2000 при T=1 не растёт ни одна модель; что дают T<1 для 79M — по ночному прогону. + +## Ночной прогон со случайными дебютами, 2026-10-26 (факт) + +2800 партий на второй машине (`CALIB_OPENING=8`), подогнаны вместе с замером нижних уровней (4000 партий; якоря — боты Maia-1, шкала блица Lichess, ± 1 с.о.): + +| Номинал | 5M, T=1 | 5M, T=0,5 | 5M, T=0 | 79M, T=0,5 | 79M, T=0 | +|---|---|---|---|---|---| +| 1100 | 1338 ± 17 | | | | | +| 1500 | 1501 ± 21 | | | | | +| 1900 | 1625 ± 23 | 1673 ± 27 | 1738 ± 29 | | | +| 2300 | 1690 ± 27 | | | | | +| 2600 | 1767 ± 24 | 1854 ± 35 | 1909 ± 18 | 2053 ± 24 | 2126 ± 23 | + +- Режим «лучший ход» малой модели — ≈1910, а не ≈2000 (прежняя цифра — следствие повторяющихся партий). +- **Потолок Maia-3 без поиска — ≈2125** (79M, всегда самый вероятный ход): сильный I разряд; КМС и выше недостижимы. +- В программе (`play.rs`, `temperature`): выше потолка модели при T=1 (5M ≈1767, 79M ≈1976) температура снижается по таблице до нужной силы; ползунок 1100–2100.