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

@ -48,7 +48,9 @@ impl GameSession {
::play::Ending::Threefold => GameEnding::Threefold,
::play::Ending::FiftyMoves => GameEnding::FiftyMoves,
// No clocks and no resignations here: the app knows those itself.
::play::Ending::Time { .. } | ::play::Ending::Resigned { .. } => return None,
::play::Ending::Time { .. }
| ::play::Ending::Resigned { .. }
| ::play::Ending::DrawAgreed => return None,
})
}
}
@ -143,6 +145,30 @@ impl ResignJudge {
.unwrap_or_else(|e| e.into_inner())
.forget();
}
/// Moves were taken back: the scores of Maia's turns gone are forgotten.
pub fn forget_scores(&self) {
self.judge
.lock()
.unwrap_or_else(|e| e.into_inner())
.forget_scores();
}
/// A draw may be offered now (not right after a refusal).
pub fn may_offer_draw(&self) -> bool {
self.judge
.lock()
.unwrap_or_else(|e| e.into_inner())
.may_offer_draw()
}
/// The user offers a draw: whether Maia accepts (the shared rule, `play::accepts_draw`).
pub fn offer_draw(&self) -> bool {
self.judge
.lock()
.unwrap_or_else(|e| e.into_inner())
.offer_draw()
}
}
/// The weakest and strongest Maia on the phone (the small model's measured range).