Review: a piece moved into a new attack is offered; a pawn for a quicker mate; taking back a trade
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

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 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-28 18:46:50 +03:00
parent 9f46fb1d71
commit 1be3f84802
7 changed files with 128 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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::<San>().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.

View file

@ -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())

View file

@ -204,6 +204,9 @@ fn note(before: Eval, after: Eval, ply: &Ply, rules: Rules) -> Option<Judgement>
{
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