# Maximum number of ways to get out of check

What is the maximum number of legal moves in a legal position, given that the player is in check?

It's easy to see that 43 is an upper bound. Let's suppose the white K is in check along a diagonal by a Q or B (other cases are similar or easier). Then White has at most 7 legal K moves; a white Q has at most 3 moves (interposition or capture); a white B of the right color has at most one move; and a white R, N, or P has at most 2 moves. Even if White has lost no pieces and has promoted all his pawns to queens, he has no more than 1*7 + 9*3 + 1*1 + 4*2 = 43 legal moves.

In fact it's easy to see that 43 cannot be attained. If White has 7 legal K moves, then one of them must be to capture the checking piece. But in that case no interposition is possible, the only legal non-K moves are captures, so White has at most 21 moves total.

Of course we can do better. We can always do better. 42 legal responses with a little trick.

``````[FEN "3rB2k/2P1P3/1NQ1QN2/2Q1QN2/2Q1Q3/1R3R2/3K1B2/8 w - - 0 1"]
``````

My previous attempt, 40 legal responses:

``````[FEN "8/4N2R/3QQQQ1/1K5r/3QQQQ1/BB1NN2R/8/1k6 w - - 0 1"]
``````

And 39 legal responses with a bishop check (and the position is legal, black's last move was ...h2-h1=B+):

``````[FEN "7k/1K6/4RN2/5QN1/B1R3QN/3Q3Q/3NQ3/4NQ1b w - - 0 1"]
``````
• Just a minor comment from a purely aesthetical point of view. In the last position, Black's last move could also have been 0...gxh1=B+. If you place a black pawn (it can't be white) on h2 then that move is unique. Commented May 3, 2021 at 17:05
• No, it can't be gxh1B. White's pawns all promoted and the only missing piece is a dark squared bishop. Commented May 4, 2021 at 2:13
• I stand corrected. Commented May 4, 2021 at 6:22

Since several lower bounds have already been posted, I would like to elaborate a bit more on the possible upper bounds, since the estimate in the question is a bit oversimplified in my opinion (although the conclusion is still correct).

First, let us have a look at naive upper bounds, not considering interference between piece types, for each possible checking piece. The number of moves per piece type in the respective scenario (with the optimal number of pieces given in brackets) are given below:

``````    R       B       N       P
---------------------------------
K   7 (1)   7 (1)   8 (1)   8 (1)
Q   3 (7)   3 (8)   1 (1)   1 (3)
R   1 (2)   2 (2)   1 (2)   1 (2)
B   2 (2)   1 (1)   1 (1)   1 (1)
N   2 (2)   2 (2)   1 (8)   1 (8)
P   4 (2)   4 (1)   4 (2)   1 (0)
---------------------------------
46      44      28      22
``````

It is quite obvious that checks of non-sliding piece (N/P) do not need to be considered, since they can not be blocked. The case of a bishop is only slightly worse than a rook, but it is relatively obvious that it can not be better (because of opposite colored bishops, and pawns can not be effectively used against bishops), so we can focus on the scenario of a rook check.

The naive/conservative upper bound is 46 as given above. However, there are several interferences that make it impossible to achieve this:

• The slider blocking moves only work if the king is not next to the piece giving check, therefore, the king effectively can only have 6 moves, i.e., one less than the maximum.
• The 8x8 board is too small to fit all possible interposing pieces into their optimal positions:
• When the king is not at the edge of the board, we only have 8 squares available for the 2 pawns, 7 queens, and 2 bishops. Therefore, 3 of these pieces need to be put on suboptimal squares or need to be replaced by a different piece, which will lose at least 3x1 move.
• When the king is at the edge of the board, we still have only 10 squares for the 11 P/Q/B, so we lose one move. Furthermore, the king of course has two moves less compared to when it is not at the edge of the board.

For those reasons, the theoretical maximum needs to be lowered by 4, arriving at 42. Since we already know the lower bound 42 from Remellion's answer, we can conclude that 42 is both the lower and the upper bound, so it has to be the optimum.

The number of 42 can be achieved with different scenarios, just using different ways to concede the 4 moves that we have to lose compared to the naive upper bound, but all of them are similar to the position from Remellion's answer:

• King at the edge, one queen replaced by a knight
``````3r3k/2P1P3/1NQ1QN2/2Q1QN2/2Q1B3/2Q1B3/1R3R2/3K4 w - - 0 1
``````
• King at the edge, one bishop at a suboptimal square
``````3rB2k/2P1P3/1NQ1QN2/2Q1Q3/2Q1Q3/2Q1B3/1R3R2/3K4 w - - 0 1
``````
• Three queens replaced by knights.
``````3r3k/2P1P3/1NQ1QN2/1NQ1BN2/2Q1BN2/1R3R2/3K4/8 w - - 0 1
``````
• etc.

Building on @Remellion's matrix for 42 in a legal position, here is 68 in an illegal position.

``````[Title "mec chess.stackexchange.com 9/22/2019, 68 Check Blocks"]
[FEN "1NQrQN2/1NP1PN2/1NQ1QN2/1NQ1QN2/1NQ1QN2/1NQ1QN2/1NQ1QN2/1N1K1N2 w - - 0 1"]
``````

Needed this for a test case. (engine check extension heuristics)

42, like already proven in other answers, but with no underpromoted pieces and no block resulting in a stalemate or lost position

``````[Title "chess.stackexchange.com 2022-07-19, 42 Check Blocks"]
[FEN "R3q2R/2NP1PN1/3Q1Q2/3Q1Q2/pn1Q1Q2/1p1B1Q2/k7/4K1B1 w - - 0 1"]
``````
• nb: White has two bishops on dark squares, with all pawns still on the board as either pawns or queens, so the position is not attainable. Move the bottom bishop over one square toward the king to fix this. Commented Jul 19, 2022 at 17:38