From 1be3f84802fd4f2b283494ea2b96e8c32b6eaac0 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Wed, 28 Oct 2026 18:46:50 +0300 Subject: [PATCH] Review: a piece moved into a new attack is offered; a pawn for a quicker mate; taking back a trade Calibrated on three more games marked by chess.com (Pillsbury - Lasker, Rotlewi - Rubinstein, Reti - Tartakower), ChessCom rules only: - an attacked piece moved quietly onto another attacked square could have stepped away: offered (18...Ra3!!, 20...Ng4!!); only a desperado capture is a piece lost anyway; - a capture winning back what the opponent has just taken elsewhere is no winning capture and can be great (18.fxe6!), unless the opponent took a piece the mover had just offered (24...Bxe4+); - a pawn offered for a quicker mate is brilliant (29...b5+!!). Check set: 7 games, 38 agree, 6 differ (was 34/10). Co-Authored-By: Claude Opus 5.5 --- .../game-review/chesscom/pillsbury-lasker.pgn | 15 +++ .../game-review/chesscom/reti-tartakower.pgn | 11 +++ .../chesscom/rotlewi-rubinstein.pgn | 13 +++ crates/game-review/src/features.rs | 92 +++++++++++++++++-- crates/game-review/src/lib.rs | 3 +- crates/game-review/src/report.rs | 3 + docs/decisions.md | 1 + 7 files changed, 128 insertions(+), 10 deletions(-) create mode 100644 crates/game-review/chesscom/pillsbury-lasker.pgn create mode 100644 crates/game-review/chesscom/reti-tartakower.pgn create mode 100644 crates/game-review/chesscom/rotlewi-rubinstein.pgn diff --git a/crates/game-review/chesscom/pillsbury-lasker.pgn b/crates/game-review/chesscom/pillsbury-lasker.pgn new file mode 100644 index 0000000..3262a1f --- /dev/null +++ b/crates/game-review/chesscom/pillsbury-lasker.pgn @@ -0,0 +1,15 @@ +[Event "St. Petersburg"] +[Site "St. Petersburg RUE"] +[Date "1896.01.04"] +[White "Pillsbury, Harry Nelson"] +[Black "Lasker, Emanuel"] +[Result "0-1"] +[ChessComMarks "!! !"] +[Annotator "chess.com Game Review (owner's screenshot, 2026-10-28)"] + +1. d4 d5 2. c4 e6 3. Nc3 Nf6 4. Nf3 c5 5. Bg5 cxd4 6. Qxd4 Nc6 7. Qh4 Be7 8. +O-O-O Qa5 9. e3 Bd7 10. Kb1 h6 11. cxd5 exd5 12. Nd4 O-O 13. Bxf6 Bxf6 14. Qh5 +Nxd4 15. exd4 Be6 16. f4 Rac8 17. f5 Rxc3 18. fxe6 $1 Ra3 $3 19. exf7+ Rxf7 20. +bxa3 Qb6+ $1 21. Bb5 Qxb5+ 22. Ka1 Rc7 23. Rd2 $1 Rc4 24. Rhd1 Rc3 25. Qf5 Qc4 +26. Kb2 Rxa3 $3 27. Qe6+ Kh7 28. Kxa3 Qc3+ $1 29. Ka4 b5+ $3 30. Kxb5 Qc4+ $1 31. +Ka5 Bd8+ $1 32. Qb6 Bxb6# 0-1 diff --git a/crates/game-review/chesscom/reti-tartakower.pgn b/crates/game-review/chesscom/reti-tartakower.pgn new file mode 100644 index 0000000..dc995b4 --- /dev/null +++ b/crates/game-review/chesscom/reti-tartakower.pgn @@ -0,0 +1,11 @@ +[Event "Vienna"] +[Site "Vienna AUT"] +[Date "1910.??.??"] +[White "Reti, Richard"] +[Black "Tartakower, Saviely"] +[Result "1-0"] +[ChessComMarks "!! !"] +[Annotator "chess.com Game Review (owner's screenshot, 2026-10-28)"] + +1. e4 c6 2. d4 d5 3. Nc3 dxe4 4. Nxe4 Nf6 5. Qd3 e5 6. dxe5 Qa5+ 7. Bd2 $1 Qxe5 +8. O-O-O $1 Nxe4 9. Qd8+ $3 Kxd8 10. Bg5+ $1 Kc7 11. Bd8# 1-0 diff --git a/crates/game-review/chesscom/rotlewi-rubinstein.pgn b/crates/game-review/chesscom/rotlewi-rubinstein.pgn new file mode 100644 index 0000000..d8d5734 --- /dev/null +++ b/crates/game-review/chesscom/rotlewi-rubinstein.pgn @@ -0,0 +1,13 @@ +[Event "Lodz"] +[Site "Lodz POL"] +[Date "1907.12.26"] +[White "Rotlewi, Georg A"] +[Black "Rubinstein, Akiba"] +[Result "0-1"] +[ChessComMarks "!! !"] +[Annotator "chess.com Game Review (owner's screenshot, 2026-10-28)"] + +1. d4 d5 2. Nf3 e6 3. e3 c5 4. c4 Nc6 5. Nc3 Nf6 6. dxc5 Bxc5 7. a3 a6 8. b4 Bd6 +9. Bb2 O-O 10. Qd2 Qe7 11. Bd3 dxc4 12. Bxc4 b5 13. Bd3 Rd8 14. Qe2 Bb7 15. O-O +Ne5 16. Nxe5 Bxe5 17. f4 Bc7 18. e4 Rac8 19. e5 Bb6+ 20. Kh1 Ng4 $3 21. Be4 Qh4 +22. g3 Rxc3 $3 23. gxh4 Rd2 $3 24. Qxd2 Bxe4+ 25. Qg2 Rh3 0-1 diff --git a/crates/game-review/src/features.rs b/crates/game-review/src/features.rs index a981260..0d3a1e7 100644 --- a/crates/game-review/src/features.rs +++ b/crates/game-review/src/features.rs @@ -17,12 +17,20 @@ pub struct MoveFeatures { /// Takes back on the square where the opponent has just taken. pub recapture: bool, /// After the move the opponent can win a piece (a knight or more) for at least two - /// points more than the move took; a piece that was lost anyway does not count, nor - /// one whose capture loses as much back at once (the move uncovered an attack on a - /// bigger piece: taking is no answer to it). + /// points more than the move took; not a piece selling itself (an attacked piece + /// taking something on its way, a desperado), nor one whose capture loses as much + /// back at once (the move uncovered an attack on a bigger piece: taking is no answer + /// to it). An attacked piece moved quietly to another square where it is lost is + /// offered: it could have stepped away (18…Ra3!! of Pillsbury — Lasker). pub sacrifice: bool, + /// A pawn moved (not taking) to a square where the opponent wins it: offered, but + /// brilliant only for a quicker mate (29…b5+!! of Pillsbury — Lasker). + pub pawn_offered: bool, /// A capture that wins two points or more. pub winning_capture: bool, + /// The capture only wins back what the opponent has just taken, elsewhere (18.fxe6! + /// of Pillsbury — Lasker after 17…Rxc3): no gain, so it can be great. + pub takes_back: bool, /// The first rules' sacrifice ([`Rules::Strict`]): any piece the opponent can win /// after the move, also one that hung before it. pub sacrifice_any: bool, @@ -46,8 +54,9 @@ pub enum Rules { } impl MoveFeatures { - /// `prev`: the opponent's move just before (for a recapture). - pub fn of(before: &Chess, m: &Move, prev: Option<&Move>) -> MoveFeatures { + /// `prev`: the opponent's move just before (for a recapture); `own`: the mover's move + /// before that. + pub fn of(before: &Chess, m: &Move, prev: Option<&Move>, own: Option<&Move>) -> MoveFeatures { let mover = before.turn(); let mut after = before.clone(); after.play_unchecked(*m); @@ -86,6 +95,7 @@ impl MoveFeatures { .from() .map_or(0, |f| pseudo_threat(before.board(), f, mover.other())); let lost_anyway = from_threat >= 2; + let desperado = lost_anyway && m.is_capture(); let on_target = threats.iter().find(|t| t.2 == m.to()).map_or(0, |t| t.0); let gain = taken - on_target; MoveFeatures { @@ -94,8 +104,19 @@ impl MoveFeatures { promotion: m.is_promotion(), mates: after.is_checkmate(), recapture: m.is_capture() && prev.is_some_and(|p| p.is_capture() && p.to() == m.to()), - sacrifice: offered >= 3 && taken - threat <= -2 && !lost_anyway && !taking_loses, + sacrifice: offered >= 3 && taken - threat <= -2 && !desperado && !taking_loses, + pawn_offered: m.role() == Role::Pawn + && !m.is_capture() + && pseudo_threat(after.board(), m.to(), mover.other()) > 0, winning_capture: m.is_capture() && gain >= 2, + takes_back: m.is_capture() + && prev.is_some_and(|p| { + // Not the piece the mover had just put there: taking it accepted an + // offer, and winning something now goes on with the combination + // (24…Bxe4+ of Rotlewi — Rubinstein after 23…Rd2 24.Qxd2). + p.capture().is_some_and(|r| gain - value(r) < 2) + && own.is_none_or(|o| o.to() != p.to()) + }), sacrifice_any: offered_any >= 3 && taken - threat_any <= -2 && !lost_anyway, escape: lost_anyway && from_threat < 900 && gain >= 0, book: chess_openings::in_book(chess_openings::key(&after)), @@ -123,7 +144,7 @@ impl MoveFeatures { && !(rules == Rules::ChessCom && self.book) && !self.mates && !self.recapture - && !self.winning_capture + && !(self.winning_capture && !(rules == Rules::ChessCom && self.takes_back)) && !(rules == Rules::Strict && self.escape) } @@ -132,7 +153,17 @@ impl MoveFeatures { pub fn candidate(&self) -> bool { [Rules::Strict, Rules::ChessCom] .into_iter() - .any(|r| self.brilliant_shape(r) || self.great_shape(r)) + .any(|r| self.brilliant_shape(r) || self.pawn_shape(r) || self.great_shape(r)) + } + + /// Could be brilliant for a quicker mate only: a pawn offered ([`Rules::ChessCom`]). + pub fn pawn_shape(&self, rules: Rules) -> bool { + rules == Rules::ChessCom + && self.pawn_offered + && self.legal > 1 + && !self.check + && !self.promotion + && !self.book } } @@ -252,6 +283,7 @@ mod tests { fn last(start: Chess, moves: &str) -> MoveFeatures { let mut pos = start; let mut prev = None; + let mut own = None; let sans: Vec<&str> = moves .split_whitespace() .filter(|t| !t.ends_with('.')) @@ -259,9 +291,10 @@ mod tests { for (i, san) in sans.iter().enumerate() { let m = san.parse::().unwrap().to_move(&pos).unwrap(); if i + 1 == sans.len() { - return MoveFeatures::of(&pos, &m, prev.as_ref()); + return MoveFeatures::of(&pos, &m, prev.as_ref(), own.as_ref()); } pos.play_unchecked(m); + own = prev; prev = Some(m); } unreachable!() @@ -349,6 +382,47 @@ mod tests { assert!(f.sacrifice && f.brilliant_shape(Rules::ChessCom), "{f:?}"); } + const PILLSBURY: &str = "1. d4 d5 2. c4 e6 3. Nc3 Nf6 4. Nf3 c5 5. Bg5 cxd4 6. Qxd4 Nc6 \ + 7. Qh4 Be7 8. O-O-O Qa5 9. e3 Bd7 10. Kb1 h6 11. cxd5 exd5 12. Nd4 O-O 13. Bxf6 Bxf6 \ + 14. Qh5 Nxd4 15. exd4 Be6 16. f4 Rac8 17. f5 Rxc3 18. fxe6 Ra3"; + + #[test] + fn an_attacked_piece_moved_into_another_attack_is_offered() { + // 18…Ra3!! (Pillsbury — Lasker): the rook on c3 under the pawn could step away. + let f = last(Chess::default(), PILLSBURY); + assert!(f.sacrifice && f.brilliant_shape(Rules::ChessCom), "{f:?}"); + // 18.fxe6! just before: takes back the knight taken on c3, no gain. + let f = last(Chess::default(), &PILLSBURY[..PILLSBURY.rfind(" Ra3").unwrap()]); + assert!(f.winning_capture && f.takes_back && f.great_shape(Rules::ChessCom), "{f:?}"); + assert!(!f.great_shape(Rules::Strict), "the first rules stay: {f:?}"); + } + + #[test] + fn taking_back_an_offered_piece_is_no_trade() { + // 24…Bxe4+ (Rotlewi — Rubinstein) after 23…Rd2 24.Qxd2: the combination goes on. + let f = last( + Chess::default(), + "1. d4 d5 2. Nf3 e6 3. e3 c5 4. c4 Nc6 5. Nc3 Nf6 6. dxc5 Bxc5 7. a3 a6 8. b4 Bd6 \ + 9. Bb2 O-O 10. Qd2 Qe7 11. Bd3 dxc4 12. Bxc4 b5 13. Bd3 Rd8 14. Qe2 Bb7 \ + 15. O-O Ne5 16. Nxe5 Bxe5 17. f4 Bc7 18. e4 Rac8 19. e5 Bb6+ 20. Kh1 Ng4 \ + 21. Be4 Qh4 22. g3 Rxc3 23. gxh4 Rd2 24. Qxd2 Bxe4+", + ); + assert!(f.winning_capture && !f.takes_back && !f.great_shape(Rules::ChessCom), "{f:?}"); + } + + #[test] + fn a_pawn_offered_is_only_for_a_quicker_mate() { + // 29…b5+!! (Pillsbury — Lasker): the pawn under the king. + let line = format!( + "{PILLSBURY} 19. exf7+ Rxf7 20. bxa3 Qb6+ 21. Bb5 Qxb5+ 22. Ka1 Rc7 23. Rd2 Rc4 \ + 24. Rhd1 Rc3 25. Qf5 Qc4 26. Kb2 Rxa3 27. Qe6+ Kh7 28. Kxa3 Qc3+ 29. Ka4 b5+" + ); + let f = last(Chess::default(), &line); + assert!(f.pawn_offered && f.pawn_shape(Rules::ChessCom), "{f:?}"); + assert!(!f.sacrifice && !f.brilliant_shape(Rules::ChessCom), "{f:?}"); + assert!(!f.pawn_shape(Rules::Strict)); + } + #[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/lib.rs b/crates/game-review/src/lib.rs index ad7a293..36af3e1 100644 --- a/crates/game-review/src/lib.rs +++ b/crates/game-review/src/lib.rs @@ -333,7 +333,8 @@ impl GameAnalysis { .map(|i| { let (m, before) = (moves[i].as_ref()?, positions.get(i)?); let prev = i.checked_sub(1).and_then(|p| moves[p].as_ref()); - Some(MoveFeatures::of(before, m, prev)) + let own = i.checked_sub(2).and_then(|p| moves[p].as_ref()); + Some(MoveFeatures::of(before, m, prev, own)) }) .collect(); self.played = (1..self.line.len()) diff --git a/crates/game-review/src/report.rs b/crates/game-review/src/report.rs index 8a9ea15..babc384 100644 --- a/crates/game-review/src/report.rs +++ b/crates/game-review/src/report.rs @@ -204,6 +204,9 @@ fn note(before: Eval, after: Eval, ply: &Ply, rules: Rules) -> Option { return Some(Judgement::Brilliant); } + if f.pawn_shape(rules) && mates_sooner { + return Some(Judgement::Brilliant); + } let w2 = second?; // The engine's own best move loses nothing: a drop to the next position is the noise // of two searches (9.Nf5! of the Immortal game, −0.51 then −0.82 at 3M nodes); the diff --git a/docs/decisions.md b/docs/decisions.md index b94447b..c16b335 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -177,6 +177,7 @@ - **Калибровка 3 (2026-10-28, «Бессмертная» по chess.com):** (а) жертва, которая матует быстрее любого другого хода, — не «и так выиграно»: 22.Qf6+!! (мат в 2), хотя 22.Qf7 тоже матует (в 4) — win % этого не различает (`mates_sooner` в `report.rs`); (б) для «!» лучшего хода движка падение оценки к следующей позиции не учитывается — это шум двух поисков (9.Nf5! и 12.h4! пропадали на оценках владельца: −0,51 → −0,82). Обе правки — только правило ChessCom. Набор: 17 из 17 на наших оценках; на оценках из кэша владельца 16 из 17 — 10…Nge7 «Вечнозелёной» (разрыв 9 % при пороге 10, пограничный случай с первой калибровки; порог под одну партию не двигаем). - **Калибровка 4 (2026-10-28, Стейниц — фон Барделебен по chess.com):** правило калибровки 2 оказалось слишком широким — оно сняло 22.Rxe7+!! и 24.Rg7+!!: после 22…Qxe7 белые отыгрываются 23.Rxc8+, но эту угрозу открыло само взятие (ферзь ушёл с d7). Уточнено: фигура не отдана, только если угроза, отыгрывающая её, стояла уже сразу после хода (18.Bxa7: ферзь d8 под ладьёй до взятия). Оба !! совпали, 18.Bxa7 по-прежнему без !!. Расхождения по «!» в этой партии (у нас лишние 6…Bb4+, 8.exd5, 13.Bxe7, 17.d5, 18.Nd4, 19.Ne6, 23.Rf7+, 25.Rxh7+; нет 18…Kf7) — открыты, см. разбор владельцу. - **Калибровка 5 (2026-10-28, по предложению, владелец согласился «посмотрим»):** правило ChessCom — (а) книжный ход (позиция после хода лежит на линии таблицы дебютов `chess-openings`, крейт `crates/openings`) не получает ни !, ни !!; (б) ! нет, если лучший другой ход оставляет ≥ 60 % (было 75; у всех ! chess.com в наборе — не больше 59 %, запас мал). Убрало 6…Bb4+, 18.Nd4, 23.Rf7+, 25.Rxh7+. Набор: 23 совпадения, 5 расхождений (8.exd5, 13.Bxe7, 17.d5, 19.Ne6 у нас лишние; 18…Kf7 нет — у чёрных 17 %, ! там не ставим); на оценках владельца ещё 10…Nge7. +- **Калибровка 6 (2026-10-28, ещё три партии: Пиллсбери — Ласкер, Ротлеви — Рубинштейн, Рети — Тартаковер):** правило ChessCom — (а) атакованная фигура, тихо переставленная под новый бой, — жертва (могла уйти): 18…Ra3!!, 20…Ng4!!; «всё равно потерянной» остаётся только фигура, которая напоследок бьёт (десперадо); (б) взятие, лишь отыгрывающее только что взятое соперником (не на том же поле), — не «выгодное взятие» и может быть «!»: 18.fxe6!; но не когда соперник взял фигуру, которую мы только что отдали (24…Bxe4+ после 23…Rd2 24.Qxd2 — продолжение комбинации); (в) пешка, отданная ради более быстрого мата, — «!!»: 29…b5+ (мат в 4 против 6 у 29…Qc4+). Набор: 7 партий, 38 совпадений, 6 расхождений (23.Rd2 у Пиллсбери: наш движок предпочитает 23.Qh3; остальные 5 — прежние в партии Стейница); на оценках из кэша владельца 35/9 — разброс движка (лучший ход другой, нет второго поиска). - Второй поиск движка (лучший ход, кроме сыгранного) — **всегда**, только для подходящих ходов: разбор примерно на треть дольше. Старые разборы дозаполняются кнопкой «Обновить» без пересчёта оценок. - Для оценок из PGN (`[%eval]`) !! и ! нет: в отчёте прочерк и пояснение. - В PGN — `$3`/`$1` с комментарием, только если у хода нет оценки автора. Русское имя `$3` — «Блестящий ход» (было «Отличный ход»); «Отличный ход» стал !, затем переименован в «Замечательный ход» (владелец, 2026-10-28).