Android: fixes from the tester's report
- An old evaluation never shows for a new position, not even for a frame:
every snapshot carries its position and the screen compares it with the
board; the engine handle is held for 40 ms at most.
- Turning the engine off while it starts no longer leaves a Stockfish process
behind (generations in EngineSession).
- Landscape: the board on the left, the notation, engine and buttons beside it.
- "Undo" after removing a database keeps the access to its file; picking a
file again restores the access.
- After Android restarts the app the same game comes back (the search is kept).
- Mate and stalemate are named instead of waiting for the engine.
- The download sheet shows progress and "Cancel" at once; a cancelled download
stops reading and never writes the file together with the next one.
- Plain error texts with "Remove from list"; evaluations rounded ("+0.5",
"0.0", "#−2"); search results start at the top; tag names translated;
"PGN copied" / "FEN copied".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
305fff20b6
commit
7eac8db29a
13 changed files with 416 additions and 181 deletions
|
|
@ -36,7 +36,7 @@ pub enum EngineFailure {
|
|||
pub struct EngineLine {
|
||||
/// 1 for the best line.
|
||||
pub multipv: u32,
|
||||
/// "+0.45", "−1.20", "0.00", "#3" (White mates), "−#2" (Black mates).
|
||||
/// "+0.45", "−1.20", "0.00", "#3" (White mates), "#−2" (Black mates).
|
||||
pub eval: String,
|
||||
/// Centipawns for White, when the score is not a mate.
|
||||
pub cp: Option<i32>,
|
||||
|
|
@ -288,7 +288,7 @@ fn engine_line(root: &Chess, multipv: u32, score: Score, pv: &[String]) -> Engin
|
|||
if winner == Side::White {
|
||||
(format!("#{n}"), None, Some(n))
|
||||
} else {
|
||||
(format!("\u{2212}#{n}"), None, Some(-n))
|
||||
(format!("#\u{2212}{n}"), None, Some(-n))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -366,7 +366,7 @@ mod tests {
|
|||
(Some("e7"), Some("e5"))
|
||||
);
|
||||
let m = engine_line(&black_to_move, 1, Score::Mate(2), &[]);
|
||||
assert_eq!((m.eval.as_str(), m.mate), ("\u{2212}#2", Some(-2)));
|
||||
assert_eq!((m.eval.as_str(), m.mate), ("#\u{2212}2", Some(-2)));
|
||||
assert_eq!(pawns(0), "0.00");
|
||||
assert_eq!(pawns(-120), "\u{2212}1.20");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use std::sync::Arc;
|
|||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use chess_core::{Game, MoveKind, NodeId};
|
||||
use shakmaty::Position;
|
||||
|
||||
mod engine;
|
||||
|
||||
|
|
@ -118,6 +119,8 @@ pub struct MoveNode {
|
|||
pub uci: String,
|
||||
/// Arrows (`[%cal]`) and marked squares (`[%csl]`) of the comments after the move.
|
||||
pub marks: Vec<Mark>,
|
||||
/// "checkmate" or "stalemate" when the game cannot go on from here; "" otherwise.
|
||||
pub end: String,
|
||||
/// On the main line of the game (not inside a variation).
|
||||
pub main_line: bool,
|
||||
}
|
||||
|
|
@ -442,6 +445,19 @@ fn game_data(game: &Game, diagnostics: &[chess_core::Diagnostic]) -> GameData {
|
|||
null_move: mv.is_some_and(|m| matches!(m.kind, MoveKind::Null)),
|
||||
uci: uci.clone().unwrap_or_default(),
|
||||
marks: node.map(|n| marks(n.comments_after())).unwrap_or_default(),
|
||||
end: game
|
||||
.position(id)
|
||||
.map(|p| {
|
||||
if p.is_checkmate() {
|
||||
"checkmate"
|
||||
} else if p.is_stalemate() {
|
||||
"stalemate"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
})
|
||||
.unwrap_or("")
|
||||
.to_owned(),
|
||||
main_line: id == NodeId::ROOT || main.contains(&id),
|
||||
}
|
||||
})
|
||||
|
|
@ -504,6 +520,10 @@ mod tests {
|
|||
]
|
||||
);
|
||||
assert!(g.nodes[0].uci.is_empty());
|
||||
assert!(g.nodes.iter().all(|n| n.end.is_empty()));
|
||||
let mate = open_bytes("m.pgn".into(), b"1. f3 e5 2. g4 Qh4# 0-1\n".to_vec()).unwrap();
|
||||
let g = mate.game(0).unwrap();
|
||||
assert_eq!(g.nodes.last().unwrap().end, "checkmate");
|
||||
assert!(db.pgn(0).unwrap().contains("[%cal Ge2e4,Rd7d5]"));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue