From d8a5c8f4c7fcbaf1847467bd717384329d397c57 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 30 Oct 2026 01:43:43 +0300 Subject: [PATCH] Review: a check that wins a piece whatever the reply is not great 90.Ra4+ of the owner's son's game, a skewer, is a textbook blow - the owner calls it plain. The checks of a mating attack stay (22.Bf5+, 23.Bd7+ of the Evergreen game). ChessCom rules only; the son's game now lists Ra4+ among the owner's plain moves. Co-Authored-By: Claude Opus 5.5 --- .../chesscom/owner-matovalov-2.pgn | 2 +- crates/game-review/src/features.rs | 29 +++++++++++++++++++ crates/game-review/src/report.rs | 9 +++++- docs/decisions.md | 1 + 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/crates/game-review/chesscom/owner-matovalov-2.pgn b/crates/game-review/chesscom/owner-matovalov-2.pgn index 59214f5..41a6cea 100644 --- a/crates/game-review/chesscom/owner-matovalov-2.pgn +++ b/crates/game-review/chesscom/owner-matovalov-2.pgn @@ -4,7 +4,7 @@ [White "Matovalov"] [Black "Karataschessnew"] [Result "1-0"] -[OwnerPlain "Ra7 Ra7+"] +[OwnerPlain "Ra7 Ra7+ Ra4+"] [Annotator "The owner: Ra7 is no ! (2026-10-29)"] 1. e4 e5 2. Nf3 Nc6 3. d4 exd4 4. Bc4 Nf6 5. e5 Ne4 6. O-O d5 7. exd6 Nxd6 8. diff --git a/crates/game-review/src/features.rs b/crates/game-review/src/features.rs index 2de9eb2..1d9989f 100644 --- a/crates/game-review/src/features.rs +++ b/crates/game-review/src/features.rs @@ -43,6 +43,9 @@ pub struct MoveFeatures { pub gives_check: bool, /// The king moves. pub king_move: bool, + /// A check after which every reply loses a piece at once (a skewer or a fork with + /// check): a textbook blow. + pub check_wins_piece: bool, } /// Which rules decide !! and !. Both stay, to compare them and to go back. @@ -128,6 +131,7 @@ impl MoveFeatures { book: chess_openings::in_book(chess_openings::key(&after)), gives_check: after.is_check(), king_move: m.role() == Role::King, + check_wins_piece: check_wins_piece(&after), } } @@ -278,6 +282,21 @@ fn taking_loses(before: &Board, pos: &Chess, sq: Square, threat: i32) -> bool { }) } +/// `pos` (after the mover's move) is check, and after every legal reply the mover can win +/// a piece (a knight or more, three points or more by exchange) at once. +fn check_wins_piece(pos: &Chess) -> bool { + if !pos.is_check() { + return false; + } + let replies = pos.legal_moves(); + !replies.is_empty() + && replies.iter().all(|r| { + let mut after = pos.clone(); + after.play_unchecked(*r); + threats(&after).iter().any(|t| t.0 >= 3) + }) +} + /// What `by` would win taking on `sq`, whoever is to move (a piece already hanging). fn pseudo_threat(board: &Board, sq: Square, by: Color) -> i32 { let first = board @@ -503,6 +522,16 @@ mod tests { ); } + #[test] + fn a_check_that_wins_a_piece_is_plain() { + // A skewer: the rook checks the king and wins the rook behind it. + let f = features("8/8/8/8/2k2r2/8/R7/4K3 w - - 0 1", "Ra4+"); + assert!(f.check_wins_piece, "{f:?}"); + // A plain check that wins nothing. + let f = features("8/8/8/8/2k5/8/R7/4K3 w - - 0 1", "Ra4+"); + assert!(!f.check_wins_piece, "{f:?}"); + } + #[test] fn a_piece_no_one_can_legally_take_is_not_offered() { // The rook on d7 is pinned by the bishop: the knight on d5 is no offer to it. diff --git a/crates/game-review/src/report.rs b/crates/game-review/src/report.rs index 543aa8b..f200d3b 100644 --- a/crates/game-review/src/report.rs +++ b/crates/game-review/src/report.rs @@ -323,11 +323,18 @@ fn note(before: Eval, after: Eval, ply: &Ply, rules: Rules, hard: Hardness) -> O if rules == Rules::Strict { return only_move(good::GAP).then_some(Judgement::Great); } + // A check that wins a piece whatever the reply is a textbook blow, plain (90.Ra4+ of the + // owner's son's game, a skewer: «канеш это очевидный ход») — unless it mates: the checks + // of a mating attack stay (22.Bf5+! 23.Bd7+! of the Evergreen game, chess.com's). + let blow = bans && f.check_wins_piece && after.mate_for(ply.mover) != Some(true); // How hard the move was to find: unknown (no shallow search) is not hard. let at_least = |t: Option| t.is_some_and(|t| ply.difficulty.is_some_and(|d| d >= t)); if at_least(hard.brilliant) && only_move(hard.brilliant_gap) { Some(Judgement::Brilliant) - } else if only_move(hard.gap) && (hard.great.is_none() || at_least(hard.great)) { + } else if only_move(hard.gap) + && !blow + && (hard.great.is_none() || at_least(hard.great)) + { Some(Judgement::Great) } else { None diff --git a/docs/decisions.md b/docs/decisions.md index 3f90bac..a3919ae 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -184,6 +184,7 @@ - **Тихое отступление — не «!» (2026-10-29, владелец о 10.Be2 своей онлайн-партии: «ну какой же это !»):** правило ChessCom — атакованная фигура, уходящая на своё единственное хорошее поле без шаха, «!» не получает; уход с шахом — может (19…Ne2+, 23.Bd7+ у chess.com «!»). Теряем 13.Qa4! «Вечнозелёной» (chess.com) — осознанно: владельцу важнее, чтобы «!» не было лишних. Набор: «!» найдено 20 из 40, наших верных 80 %; «!!» без изменений. Ra7! из второй партии владельца был в 2.0.0, в 2.1.0 его уже нет. - **Трудный ход — «!!» и без жертвы (2026-10-29, идея владельца «двумя движками»):** для кандидатов в !!/! — ещё неглубокий поиск (5 000 узлов, тот же детерминированный режим). Если ход — единственный хороший (разрыв ≥ 10 %), а неглубокий поиск выбирает другой ход и ставит этот на ≥ 30 % ниже — «!!». Опора — статья Zaidi & Guerzhoy 2024 (arXiv 2406.11895: блестящим считают ход, который слабый движок оценивает ниже, а сильный — лучшим). Набор: !! найдено 35 из 39 (было 32), верных 95 %; ложных не прибавилось; одинаково на 2 000–5 000 узлов и порогах 20–40 %. Для «!» трудность не включена: при «неглубокий выбрал тот же ход» «!» исчезает почти весь (5 000 узлов уже находят 127 из 141), при «неглубокий оценил ниже» уходят и матовые шахи, которые chess.com отмечает. Разбор длиннее на 1–2 %. Прежние правила — ветка Forgejo `marks-before-shallow`. В набор добавлены партии владельца с его вердиктом «это не !» (`owner-*.pgn`, тег `OwnerPlain`): 10.Be2 и Ra7 — сейчас без отметок. - **Уход короля из-под шаха — не «!» (2026-10-29, владелец: «будем считать очевидным»):** правило ChessCom. Убрало три наших лишних «!» (23.Kd3, 20…Ka7, 32.Kd2) и три совпадения с chess.com (22.Ke3, 25…Kb6, 20.Ke2 — chess.com здесь непоследователен; к тому же на новой учётке он щедрее, сам писал об этом в 2023). Набор: наших «!» верны 27 из 28 (96 %), найдено 27 из 82 отметок chess.com; «!!» без изменений (35 из 39, 95 %). +- **Шах, выигрывающий фигуру, — не «!» (2026-10-29, владелец о 90.Ra4+ партии сына: «канеш это очевидный ход»):** правило ChessCom — шах, после которого при любом ответе тут же выигрывается фигура (связка, вилка с шахом), — готовый приём; кроме шахов матовой атаки (после хода — форсированный мат: 22.Bf5+, 23.Bd7+ «Вечнозелёной» остаются). Пробовали «неглубокий поиск уже видит силу хода» — убирало почти все «!» и добавляло ложные «!!», отброшено. Набор: наших «!» верны 25 из 26 (96 %), найдено 25 из 82; ушёл 19…Ne2+ Бирн — Фишер (тот же приём; посчитан дважды); «!!» без изменений. - Второй поиск движка (лучший ход, кроме сыгранного) — **всегда**, только для подходящих ходов: разбор примерно на треть дольше. Старые разборы дозаполняются кнопкой «Обновить» без пересчёта оценок. - Для оценок из PGN (`[%eval]`) !! и ! нет: в отчёте прочерк и пояснение. - В PGN — `$3`/`$1` с комментарием, только если у хода нет оценки автора. Русское имя `$3` — «Блестящий ход» (было «Отличный ход»); «Отличный ход» стал !, затем переименован в «Замечательный ход» (владелец, 2026-10-28).