How Koga decides

Definition Answer a threat with a bigger threat
  • The opponent is threatening to win one of our pieces. Instead of defending it or moving it to safety, we play a move so forcing that the opponent must deal with our threat first — and our piece survives because they never get time to take it.
  • We only look at our own pieces worth a knight or more (knight, bishop, rook, queen). A threat against a mere pawn is not worth a counter.
Condition 1 There really is a threat to one of our pieces
  • We scan our pieces (knight value or higher) and check whether an enemy piece is attacking one in a way that actually wins material — judged by a full capture-and-recapture count, not just a bare attack, so a piece that is adequately defended does not count as threatened.
  • We ignore the piece that is moving: simply moving a threatened piece away resolves the threat by itself, which is not a counter-threat.
  • If our move is a capture, the piece it captures can no longer threaten anything, so it is removed from the list of attackers.
  • If we have the engine's line and every threatened piece simply steps away on our next move, the threat was solved by tempo, not by a counter-threat, and we do not flag it.
Condition 2 Our move is forcing enough to ignore their threat
  • The move gives check; or
  • the moved piece attacks an enemy piece worth a knight or more that is either undefended or more valuable than our attacker (so they must save it); or
  • the line that follows forces checkmate.
  • If at least one of these holds while one of our pieces is left hanging, it is a counter threat.

Test positions (the examples that guard against regressions)

Hang the rook, give check instead

A constructed position. Black's rook on a8 is attacking our undefended rook on a1. Rather than defend it, we play Qd8+ — a check the opponent must answer immediately. The check is so forcing that our a1 rook is never actually taken, so the move counts as a counter threat.

✓ detectedForcing checktest_detects_counter_threat_check_while_hanging
r . . Q k . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . K . . .
Attacking piece
Targeted / won piece
Piece that moves
King

Hit the very piece that was threatening us

Lichess 0Ivll. Here Black's bishop on d5 is threatening to win our bishop on g2. The best move e2-e4 attacks that same d5 bishop: a pawn worth far less than the bishop, so Black must save it and never gets to take on g2. Our counter-threat hits the threatener itself.

✓ detectedAttack a heavier piece♟ Lichess 0Ivlltest_detects_short_pv_trapped_piece_when_only_counter_threat_exists
. . r . . . k .
p . . . . . p p
. . q . p r . .
. . . b . . . .
. . p . P . . P
. . . . . . P .
P . Q . . P B .
. . R R . . K .
Attacking piece
Targeted / won piece
Piece that moves

The only threatened piece is the one that moves

The white knight on b5 attacks Black's rook (it started on c7), so Black answers with Rxc2, grabbing the white queen — the rook is shown here on c2 after the capture. This is NOT a counter threat: the only Black piece worth a knight or more that White attacked was that very rook, and it simply moved away as it captured. Nothing of Black's is left hanging, so there is no threat to counter.

✗ not detectedNot a counter threattest_counter_threat_excludes_captured_piece_as_attacker
. . . . . . . .
. . . . . . k .
. . . . . . . .
. N . . . . . .
. . . . . . . .
. . . . . . . .
. . r . . . p p
. . . . . . K .
Targeted / won piece
Attacking piece