How Koga decides

Absolute Pin to the king
  • An enemy piece is pinned to its king when it sits on a line (rank, file, or diagonal) directly between its own king and one of our long-range pieces — a rook, bishop, or queen.
  • Because moving it would expose the king to check, the piece may not legally leave that line. It is effectively frozen.
  • A pinned pawn is only flagged when one of our pieces is already attacking it — a pawn merely standing in front of its king is not worth calling out.
Relative Pin to a more valuable piece
  • We look along every line of each of our rooks, bishops, and queens.
  • The first enemy piece on that line is the candidate pinned piece.
  • If a MORE valuable enemy piece stands directly behind it on the same line, the front piece is pinned: moving it would hand us the bigger piece behind.
  • If taking the rear piece would only be an even trade (it is defended and our piece is worth at least as much), we don't count it — there is nothing to actually win.
  • Same pawn rule as the absolute pin: a pinned pawn counts only when we already attack it.
Filters When we do NOT call it a pin
  • Checker bypass — if the very piece that would do the pinning is also giving check right now, we ignore that pin. While the king is in check the defender's choices are dictated by the check, not the pin, and once the check is met the pin often vanishes.
  • Quiet pawns — a pinned pawn is ignored unless it is already under attack.
  • When we look — a pin is judged on the position AFTER the candidate move, and we also scan a few moves ahead in the engine's main line, so a pin that only appears later in a forcing sequence is still caught.
Roles How the pin relates to the move
  • New pin (motif) — the pin did not exist before the move; the move creates it.
  • Pre-existing pin (enabling) — the pin was already on the board; the move makes use of the freeze it provides.
  • Found deeper in the line (follow-up) — the pin appears a few moves into the engine's main line rather than immediately.

Test positions (the examples that guard against regressions)

Basic absolute pin

Our rook on e1 pins the black knight on e5 to the black king on e8. The knight cannot legally leave the e-file.

✓ detectedAbsolutetest_detects_pin
. . . . k . . .
. . . . . . . .
. . . . . . . .
. . . . n . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . R . K .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Relative pin while a different piece checks

The rook on a8 gives check to the king on e8. A SEPARATE piece — the bishop on c4 — pins the knight on d5 to the queen on e6. Because the pinner is not the checker, the pin is real.

✓ detectedRelativetest_pin_detected_when_checking_piece_is_different
R . . . k . . .
. . . . . . . .
. . . . q . . .
. . . n . . . .
. . B . . . . .
. . . . . . . .
. . . . . . . .
. . . . . K . .
Piece giving check
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Checker bypass — same piece checks and pins

The queen on e4 checks the king on h7 along one diagonal, and on the other diagonal it would line up d5 behind c6 (a relative pin). Because the checking piece IS the would-be pinner, the pin is bypassed and not reported.

✗ not detectedRelative · bypassedtest_pin_checker_bypass_same_piece_checks_and_pins
. . . . . . . .
. . . . . . . k
. . r . . . . .
. . . n . . . .
. . . . Q . . .
. . . . . . . .
. . . . . . . .
K . . . . . . .
Checker = would-be pinner (bypassed)
Pinned piece (frozen)
Piece behind (king or valuable piece)
Piece giving check

Pin created by the move (motif)

A constructed counterpart to the enabling case. The rook starts on a1 with no pin; after Ra1–e1 a fresh absolute pin appears on the e5 knight against the e8 king. Since it did not exist before the move, it is tagged a motif.

✓ detectedAbsolute · motiftest_role_motif_for_new_pin
. . . . k . . .
. . . . . . . .
. . . . . . . .
. . . . n . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . R . K .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Pre-existing pin (enabling)

A constructed position for role-tagging (White is up a rook, so this is not real best play). The e1–e5–e8 pin is already on the board, and the move we classify — the deliberately quiet, pin-irrelevant Kg1–f2 — has nothing to do with it. Because the pin existed before that move, Koga tags it enabling rather than motif.

✓ detectedAbsolute · enablingtest_role_enabling_for_preexisting_pin
. . . . k . . .
. . . . . . . .
. . . . . . . .
. . . . n . . .
. . . . . . . .
. . . . . . . .
. . . . . K . .
. . . . R . . .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Pin two moves deep in the line

Lichess 00yP0. After Qf6, the main line continues Qg7, Rg5 — and the rook on g5 pins the queen on g7 to the king on g8. The pin is not visible right after the first move; it emerges deeper in the forcing line.

✓ detectedAbsolute · in line♟ Lichess 00yP0test_pin_in_pv_where_pinned_piece_is_later_recaptured
. . r . r . k .
. . . . . . q p
. . . . p Q . .
p . . p . . R .
. . . P . . . .
. . P . . . . P
P . . . . P P .
. . . . . . K .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Pin as the final point of the line

After Rxe6 dxe6 Bd4, the bishop on d4 pins the queen on f2 to the king on g1 along the long diagonal. The pin is the very last move of the line — the point of the whole sequence.

✓ detectedAbsolute · in linetest_pin_at_end_of_pv_is_accepted
. . . . r . k .
p . . . . . . p
. q . . P . p .
. . p . . p . .
. p P b . . . .
. . . . . . P P
P . . . . Q B .
. R . . . R K .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Pin prevents a mating defence

Lichess 00KhM. After Qxf7+ Rxf7, the bishop on c4 pins the rook on f7 to the king on g8. The rook can no longer step to f8 to block, so Rd8 is mate.

✓ detectedAbsolute · in line♟ Lichess 00KhMtest_pin_counts_blocked_interposition_in_mate_for_00khm
. . . R . . k .
. . . . . r p p
. r . . . . . .
. . . . p . . .
. . B . P . . .
. . q . . . P .
. . . . . P K P
. . . . . . . .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

Pin on the opponent's defender

Lichess 00kDo. After Qb1+ Bf1, the queen on b1 pins the bishop on f1 to the king on g1 along the first rank. The pinned bishop is the only guard of a6, so it cannot stop Bxa6.

✓ detectedAbsolute · in line♟ Lichess 00kDotest_flipped_pin_bad_defender_00kDo
. . . . . . . .
. . . . . p p k
P . . . . . . p
. . p . p . . .
. . . . . . . Q
. P . . P . P .
. . . . b P . P
. q . . . B K .
Pinner (our long-range piece)
Pinned piece (frozen)
Piece behind (king or valuable piece)

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

Lichess 00WG3

Lichess 00WG3 (rating 1044). Solution: Rxd1 Rxf7 Nd6+ Kc7 Nxf7. Koga intentionally does not flag Pin here — Koga reports the more specific pinned-defender motif, which subsumes the plain pin.

✗ not detectedKnown boundary♟ Lichess 00WG3
. . . . . . . .
p k . r . R p .
. p . . p . . p
. . . . P . b P
. . . . N . . .
. . . . . . . .
P P . . . . . .
. K . r . R . .

Lichess 00eWz

Lichess 00eWz (rating 1674). Solution: R5xe6 dxe6 Bd4.

Koga flags pin as a follow-up here — it fires later in the line, on Bd4, not on the move shown above.

✓ detectedrating 1674♟ Lichess 00eWz
. . . . r . k .
p . . . . . b p
. q . . P . p .
. . p . . p . .
. p P . . . . .
. . . . . . P P
P . . . . Q B .
. R . . . R K .

Lichess 008LT

Lichess 008LT (rating 2066). Solution: Nf7+ Rxf7 Bxe6.

Koga flags pin as a follow-up here — it fires later in the line, on Bxe6, not on the move shown above.

✓ detectedrating 2066♟ Lichess 008LT
r . . . . . . k
. . . . . r p .
b . . . p . n .
p . p p . . . .
. p . . . P . q
. . . P . Q . B
P P P . . P K .
R . . . . . . R

Lichess 00RtC

Lichess 00RtC (rating 1948). Solution: Ne2+ Kh1 Qxf2 Qxg7+ Kxg7.

✓ detectedrating 1948♟ Lichess 00RtC
r . . . . k . .
p p p . . . p .
. . . p . . . r
. . q . . . . .
. P N n P . . .
. . Q . . P B p
P . . . . R . P
. . . . . R K .

Lichess 01CvZ

Lichess 01CvZ (rating 1232). Solution: Ba6 Kd2 Bxb5.

✓ detectedrating 1232♟ Lichess 01CvZ
. . b . . . . .
. . . . . . . .
. . . . . . p .
. R . . . . . .
. . . k P . . .
. . . . . P P n
. . . . K . . .
. . . . . . . .

Lichess 00cy1

Lichess 00cy1 (rating 1188). Solution: Qb6+ Nc7 dxc7+.

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

✓ detectedrating 1188♟ Lichess 00cy1
. . r k . b . .
. . n q . p p .
p Q p P . . . r
. p . . P . . .
. . . . . P . p
. P . . . . P .
P B . . . . K .
. . . R . . . .

Lichess 013Kj

Lichess 013Kj (rating 1920). Solution: Kh1 Qg6 Rg1 Kg7 Rxg6+.

Koga flags pin as a follow-up here — it fires later in the line, on Rg1, not on the move shown above.

✓ detectedrating 1920♟ Lichess 013Kj
. . r . . r k .
p p . . . p . .
. . . . p . q .
. . . p . . . .
. . . P . . . .
P . N . . . . Q
. P P . . . . .
. R . . . . . K

Lichess 045gE

Lichess 045gE (rating 1449). Solution: Rxd5+ Qxd5 Rb5 Qxb5 axb5.

Koga flags pin as a follow-up here — it fires later in the line, on Rb5, not on the move shown above.

✓ detectedrating 1449♟ Lichess 045gE
. . . . . . . .
. . . . . p k .
p r . . . . . .
. . . Q . K P .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .