Offer Maia a draw (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

The shared rule (play::accepts_draw): she accepts when clearly worse or mated,
or when about level (at most +0.2 for her) and her last three scores agree
within 0.3; after a refusal, again two of her moves later. Her judge keeps the
scores of her turns. Desktop: «½ Offer a draw» beside «Resign»; Android: a
«Draw» button in the game's bar (labels may take two lines).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-26 02:44:05 +03:00
parent 0d7c0923fa
commit b90bcdf3a3
18 changed files with 297 additions and 4 deletions

View file

@ -2691,6 +2691,7 @@ impl GameView {
s.hopeless = 0;
if let Some(j) = s.judge.as_mut() {
j.forget();
j.forget_scores();
}
s.opponent.forget();
let user = s.user;
@ -3105,6 +3106,36 @@ impl GameView {
{
s.resign_asked = true;
}
// A draw offered: Maia answers by the judge's scores of her last turns (no
// judge, no answer: the button says why).
if self.play_started() {
let judge = self.play.as_ref().and_then(|s| s.judge.as_ref());
let may = judge.is_some_and(|j| j.may_offer_draw());
let hint = match judge {
None => {
tr("Maia answers a draw offer with Stockfish's help: none is installed")
}
Some(_) if !may => tr("Maia declined; offer again after two of her moves"),
Some(_) => tr("Maia accepts when her position is no better and has settled"),
};
if ui
.add_enabled(may, word(tr("½ Offer a draw")))
.on_hover_text(hint)
.on_disabled_hover_text(hint)
.clicked()
{
let yes = self
.play
.as_mut()
.and_then(|s| s.judge.as_mut())
.is_some_and(|j| j.offer_draw());
if yes {
self.finish_play(crate::play::Ending::DrawAgreed, actions);
} else {
actions.push(GameAction::Toast(tr("Maia declines the draw").into()));
}
}
}
});
ui.add_space(4.0);
}

View file

@ -10891,6 +10891,72 @@ const ROWS: &[[&str; 9]] = &[
"{elo} dan kuchliroq katta Maia o‘ynaydi: {mb} MB, bir marta yuklab olinadi.",
"{elo}-ден күштірек үлкен Maia ойнайды: {mb} МБ, бір рет жүктеледі.",
],
[
"by agreement",
"по соглашению",
"par accord mutuel",
"durch Einigung",
"por acuerdo",
"per accordo",
"por acordo",
"kelishuv bo‘yicha",
"келісім бойынша",
],
[
"½ Offer a draw",
"½ Предложить ничью",
"½ Proposer nulle",
"½ Remis anbieten",
"½ Ofrecer tablas",
"½ Proponi patta",
"½ Propor empate",
"½ Durang taklif qilish",
"½ Тең ойын ұсыну",
],
[
"Maia answers a draw offer with Stockfish's help: none is installed",
"Maia отвечает на предложение ничьей с помощью Stockfish, а он не установлен",
"Maia répond à une proposition de nulle avec l’aide de Stockfish, qui n’est pas installé",
"Maia beantwortet Remisangebote mit Hilfe von Stockfish, der nicht installiert ist",
"Maia responde a las tablas con ayuda de Stockfish, que no está instalado",
"Maia risponde alla patta con l’aiuto di Stockfish, che non è installato",
"A Maia responde ao empate com a ajuda do Stockfish, que não está instalado",
"Maia durang taklifiga Stockfish yordamida javob beradi, u o‘rnatilmagan",
"Maia тең ойын ұсынысына Stockfish көмегімен жауап береді, ол орнатылмаған",
],
[
"Maia declined; offer again after two of her moves",
"Maia отказалась; снова можно предложить через два её хода",
"Maia a refusé ; reproposez après deux de ses coups",
"Maia hat abgelehnt; nach zwei ihrer Züge wieder anbieten",
"Maia lo rechazó; ofrece de nuevo tras dos de sus jugadas",
"Maia ha rifiutato; riproponi dopo due sue mosse",
"A Maia recusou; ofereça de novo após dois lances dela",
"Maia rad etdi; uning ikki yurishidan keyin yana taklif qiling",
"Maia бас тартты; оның екі жүрісінен кейін қайта ұсыныңыз",
],
[
"Maia accepts when her position is no better and has settled",
"Maia соглашается, когда её позиция не лучше и уже не меняется",
"Maia accepte quand sa position n’est pas meilleure et s’est stabilisée",
"Maia nimmt an, wenn ihre Stellung nicht besser ist und sich beruhigt hat",
"Maia acepta cuando su posición no es mejor y se ha estabilizado",
"Maia accetta quando la sua posizione non è migliore e si è stabilizzata",
"A Maia aceita quando a posição dela não é melhor e se estabilizou",
"Maia pozitsiyasi yaxshi bo‘lmasa va o‘zgarmay qolsa, rozi bo‘ladi",
"Maia позициясы жақсы болмаса және өзгермей қалса, келіседі",
],
[
"Maia declines the draw",
"Maia отказывается от ничьей",
"Maia refuse la nulle",
"Maia lehnt das Remis ab",
"Maia rechaza las tablas",
"Maia rifiuta la patta",
"A Maia recusa o empate",
"Maia durangdan bosh tortadi",
"Maia тең ойыннан бас тартады",
],
[
"Maia resigned",
"Maia сдалась",

View file

@ -1165,6 +1165,7 @@ impl End {
Ending::Time { .. } => tr("time is up"),
Ending::Resigned { loser } if loser == self.user => "",
Ending::Resigned { .. } => tr("Maia resigned"),
Ending::DrawAgreed => tr("by agreement"),
}
}
}