How Koga decides

Definition Unmasking a check
  • A piece of ours moves off a line (rank, file, or diagonal) that one of our own long-range pieces — a rook, bishop, or queen — was sitting behind.
  • As the front piece steps away, the long-range piece behind it is unmasked and its line now runs straight into the enemy king. That newly revealed check is the discovered check.
  • The check comes from a piece that did not move, which is what makes it so dangerous: the moving piece is free to do something else entirely while the king must respond to the check.
Relationship Always paired with a discovered attack
  • We look at every rook, bishop, and queen that lined up with the square the moving piece left from, then check what each one attacks once the line is clear.
  • If the unmasked line hits the enemy king, Koga reports a discovered check AND a discovered attack together — a check is simply the sharpest kind of discovered attack, so both labels apply.
Filters No defender check needed
  • For a discovered attack on an ordinary piece we make sure the target isn't safely defended before trusting it. A king is different: it can never be defended, so once the revealed line reaches the king the check is accepted at once.
  • A discovered check also outranks a couple of simpler readings of the same move — when it fires, Koga suppresses Double Attack and Insufficiently Defended, since the check is the real point.

Test positions (the examples that guard against regressions)

Knight unmasks a rook (also a double check)

A constructed position. The knight stands on e4, directly in front of our rook on e1, and the black king is on e8. When the knight moves to d6 the e-file opens and the rook on e1 checks the king — a discovered check, reported together with a discovered attack. Note that the knight's landing square d6 ALSO attacks e8, so the king faces two checkers at once: this is simultaneously a double check.

✓ detectedDiscovered + double check · motiftest_discovered_check_includes_both
. . . . k . . .
. . . . . . . .
. . . N . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . R . K .
Piece giving check
Piece that moves
King

Golden puzzles — every real Lichess puzzle Koga is tested against for this tactic (10)

Lichess 01SBn

Lichess 01SBn (rating 2068). Solution: Nc5+ Ra6 Qxa6+ Qxa6 Nxa6.

✓ detectedrating 2068♟ Lichess 01SBn
k r . . . . . .
. . . . . . . .
. . r . . . . .
. q . p . . . P
N . . P . . . .
Q . P . . . . .
P P . . . . P .
. K . . . . . .

Lichess 01kSp

Lichess 01kSp (rating 1063). Solution: e4+ f4 exd3.

✓ detectedrating 1063♟ Lichess 01kSp
. . . . . . . .
. . . . . . k .
. . b b . . p p
. . . . p P . .
. . . . . . P .
. . . B B P K P
. . . . . . . .
. . . . . . . .

Lichess 03Rmn

Lichess 03Rmn (rating 1925). Solution: Bxe6+ Kd8 Rc8#.

✓ detectedrating 1925♟ Lichess 03Rmn
. . k . . . . r
p p . . b p p .
. q . . p n . .
. b . . . . . p
. . B . . B . .
. N . . . P . P
P P . r . P . .
. . R . . R K .

Lichess 00GBX

Lichess 00GBX (rating 892). Solution: Nf7+ Kg8 Nxg5+.

Koga flags discovered check as a follow-up here — it fires later in the line, on Nxg5+, not on the move shown above.

✓ detectedrating 892♟ Lichess 00GBX
r . . . . . k .
p p . . n N p p
. . n . . . . .
. . . . p . r .
. P B . . . . .
. . P . . . . b
P . . . N b . P
R . . R . . . K

Lichess 01KFo

Lichess 01KFo (rating 1338). Solution: Bh2+ Kh1 Ng3+ Kxh2 Nxe2+.

Koga flags discovered check as a follow-up here — it fires later in the line, on Nxe2+, not on the move shown above.

✓ detectedrating 1338♟ Lichess 01KFo
. . . . . r k .
p p q . . p p p
. . . . p . . .
. . . p . . P P
. . . P . . . .
. . P . B . n .
P P . . Q . P K
R . . . . R . .

Lichess 04Qx2

Lichess 04Qx2 (rating 2031). Solution: Be8+ Qg7 Qxg7+ Kxg7 Rxc8.

✓ detectedrating 2031♟ Lichess 04Qx2
. . r . . r k .
. . . p q . . p
p b . . p . B .
. p . . P . . .
. . . . . . Q .
P . . . . . P .
. n . . . P P .
. . R . . R K .

Lichess 01utE

Lichess 01utE (rating 1400). Solution: Bh7+ Kh8 Bg8+ Qh4 Rxh4+ gxh4 Qh7#.

Koga flags discovered check as a follow-up here — it fires later in the line, on Bg8+, not on the move shown above.

✓ detectedrating 1400♟ Lichess 01utE
r . b . . r . k
. . . . . p p B
p . . . p . . .
. p . p . . p .
. . . q . . . .
P . . . . . . .
. P Q . . P K .
. . . . . . . R

Lichess 027Ar

Lichess 027Ar (rating 1177). Solution: exd5+ e4 Bxe4+.

✓ detectedrating 1177♟ Lichess 027Ar
. . q . . r . .
. p p . . r p k
p . n p . n . p
. . . b p . . .
. . . . P . . N
P . . Q P . P P
. P P . . . B K
. . . R . R . .

Lichess 01TmZ

Lichess 01TmZ (rating 1398). Solution: Nh3+ Kh1 Qg1+ Rxg1 Nf2#.

✓ detectedrating 1398♟ Lichess 01TmZ
r . b . . r k .
. p . . b p p p
p q n p . . . .
. . . N p . . .
. . B . P P . .
P N . . . . . .
. P P . . n P P
R . B Q . R K .

Lichess 011u9

Lichess 011u9 (rating 2183). Solution: Be4 Rxe4 Kf3+.

Koga flags discovered check as a follow-up here — it fires later in the line, on Kf3+, not on the move shown above.

✓ detectedrating 2183♟ Lichess 011u9
. . . . . . . .
p p . . . . . p
. . . . . . . .
. . . N . . . .
. . P . R . . .
. P . . . . . P
P . . r . k . K
. . . . . . . .