Find a chess position that can occur twice but not thrice in a single game

For purposes of this puzzle, a chess position consists of an arrangement of pieces on the board, as well as the side to move. No other information about the game state is included.

The objective of this puzzle is to identify a position that can occur twice in a single game but cannot occur three times.

More generally, what numbers $$n$$ are such that some position can occur $$n$$ times but not $$n+1$$ times?

Note that we're using the FIDE ruleset, so 3-fold repetition and 50 move rules are optional for the players to call and basically irrelevant to this puzzle (but the 5-fold and 75 move rules are mandatory and may or may not be useful to a solution).

• I presume you aren't working with the FIDE ruleset when it comes to positions? FIDE rules says positions are equal if 1) the pieces are on the same squares, 2) it's the same player to move 3) the same en passant moves are possible, and 4) the castling rights are the same. So, after, 1 h4 h5, 2 Rh2 Rh7, 3 Rh1 Rh8, under FIDE rules, no position has appeared twice on the board, as after the first move, players have the right to castle short, while they have lost that right after the third move. Commented Feb 12 at 20:21
• @Abigail My use of the term "position" is ad hoc for this puzzle (though if there's some standard terminology for this, I would be happy to use that). Commented Feb 12 at 20:41
• FIDE Law 9.2.3 Positions are considered the same if and only if the same player has the move, pieces of the same kind and colour occupy the same squares and the possible moves of all the pieces of both players are the same. Thus positions are not the same if: 9.2.3.1 at the start of the sequence a pawn could have been captured en passant. 9.2.3.2 a king had castling rights with a rook that has not been moved, but forfeited these after moving. The castling rights are lost only after the king or rook is moved Commented Feb 28 at 6:57
• So the notion here is diagram + whose move: that's fine. But note that the answer given by the questioner (reaching up to n=22) assumes just diagram without the move Commented Feb 28 at 7:23

Here's my go. The final key idea is lifted from loopy walt's solution, but the rest of the setup feels different enough to warrant posting separately:

White to play:

Here, the first time around, white can castle, which is the only non-checkmate move that avoids both a stalemate and a capture. To get back to the same position later, white can bring a rook to e4, which makes the king position safe again, so white has time to get all their ducks in a row while black wiggles the knight around elsewhere.

White will then play the discovered check by moving the rook from e4 to e8, and after the black knight blocks, the same situation is reached again. This time castling is not allowed anymore, so either a checkmate, a stalemate, or a capture (Qg2+ Kxg2) is unavoidable.

For double checking purposes, here's a sample game that reaches the position after moves 28 and 38, and then never again:

1. e4 d5
2. exd5 Qxd5
3. Qh5 Qxa2
4. Qxh7 Qxb1
5. Qxh8 Qxb2
6. Qxg8 Qxc2
7. Qxf7+ Kd7
8. Qxf8 Ke6
9. Qxe7+ Kf5
10. Qxc7 Nc6
11. Qxb7 Ne5
12. Bb2 Qxb2
13. Qxc8+ Kf4
14. Nf3 g5
15. g3+ Kxf3
16. Qxa8+ Kg4
17. Qxa7 Qb6
18. Bc4 Qh6
19. Bd5 Qxh2
20. Rxh2 Nc4
21. Rh8 Nxd2
22. Re8 Nc4
23. Re4+ Kf3
24. Ba8 g4
25. Qh7 Nd6
26. Qh2 Nf7
27. Qg1 Ng5
28. Re8+ Ne4
29. O-O-O Ke2
30. Bb7 Kf3
31. Ba6 Nf6
32. Re4 Nh5
33. Bb7 Nf6
34. Kd2 Nh5
35. Ke1 Nf6
36. Ra1 Nh5
37. Ba8 Nf6
38. Re8+ Ne4


EDIT: In the comments below, @Retudin proposes an outrageously beautiful modification that not only does away with an unnecessary pawn, but two of them!

• Wow, very efficient solution! Commented Feb 13 at 1:52
• Indeed, but still 2 unneeded pawns (unless I miss something). fen: B7/8/8/6Q1/4n1R1/5k2/5P2/R3K3 w Q - 0 1 Commented Feb 13 at 16:25
• @Retudin That's outright gorgeous.
– Bass
Commented Feb 13 at 22:33
• Accepting this answer for having what seems to be a pretty optimal solution. I appreciate that you, loopy walt, and Retudin all contributed to the creation of this position! Commented Feb 13 at 22:49

White to move:

Accounting only for non-pawn non-capturing moves no matter what white does black will have to move the Bg1 either checkmating or forcing white to capture on f2 unless white's move was

0-0-0

which is available only once.

Proof game:

1. h4 h5 2. Rh3 Nf6 3. Rg3 Ne4 4. Rg6 Ng3 5. Rh6 Nxf1 6. Rxh8 d5 7. Nf3 Bf5 8. Ng5 Bh7 9. f4 Bg8 10. Nh7 e6 11. f5 Bc5 12. f6 Bg1 13. c4 a5 14. cxd5 Kd7 15. d6 Kc6 16. d7 Kd5 17. Qb3+ Ke4 18. Qc3 Kf5 19. Qf3+ Kg6 20. Qxf1 Kh6 21. Qf5 g5 22. Qf4 a4 23. Qe4 a3 24. Qe5 axb2 25. Na3 Rxa3 26. Qxc7 Rh3 27. Qxd8 Rh1 28. Qc7 b1=B 29. Bb2 g4 30. Be5 b5 31. Bh2 g3 32. Qxb8 gxh2 33. Qxb5 Bxa2 34. Qb1 Bxb1 35. Nf8+ Bbh7 36. O-O-O Bf2 37. Ng6 Be3 38. Nf4 Bd4 39. Nd5 Bc5 40. Kb2 Kg6 41. Ra1 Bg1 42. Kc1 Kf5 43. Nf4 Ke5 44. Nh3 Bb1 45. Kd1 Ke4 46. Ng5+ Kf5 47. Nh7 Kg6 48. Ke1 Kh6 49. Nf8+ Bbh7

The shown position occurs after 35 and 49 moves.

• Similar to my own solution! Do you believe it's possible to achieve $n=3$ with a position involving castles from both players? Commented Feb 12 at 21:11
• Ah yes, the discovered check from a paralysed piece does it! I was having a really hard time getting back to the repeated position with a legal game, while not adding an extra move option for white.
– Bass
Commented Feb 12 at 21:58
• I don't think you need to paralyse the knight by the way; it's white's hurry to create a non-irrevocable move for black that makes the position work in the first place, so the pawns at d7 and e6 aren't really necessary.
– Bass
Commented Feb 12 at 22:09
• @Bass If the knight moves, then the black king is no longer trapped. Commented Feb 12 at 22:38
• @ElliotGlazer Re n=3 I really have no idea. It might be but I don't see an obvious strategy. Commented Feb 12 at 22:43

Here's a full solution. The set of possible $$n$$ is

$$n \le 22.$$

We first note that $$n \le 22$$ is ensured by the 5-fold repetition rule. A position can occur once with an en passant right, then 4 more times each with 4, then 3, then 2, then 1 castle right, and then 5 times with 0 castle rights. A draw will necessarily occur before any position reaches a 23rd occurrence.

Now we will verify every $$n \le 22$$ is achieved by some position. We will avoid positions constrained by the 75 move rule when possible.

First some remarks about the $$n=0$$ case. Of course, any position where the number of kings is not 2 is impossible, but also these are arguably not chess positions at all. If we demand that a chess position be reachable in game, then trivially $$n=0$$ is impossible. If we merely demand that a chess position be reachable by some legal sequence of moves, the following arrangement has this property yet cannot be achieved in a game (with either to move), since the previous position is necessarily dead:

Next, we quickly list the easy cases. We have $$n=1$$ for any position in a checkmate (or a stalemate, or a king in check to a pawn, etc.). The starting position has $$n=21,$$ and after a few pawn moves, we can reach a position with $$n=22$$ involving an en passant right. We can get $$n=20$$ with a position where the last move is uniquely determined, e.g.:

Any value of $$n \in [4, 22]$$ which is not congruent to 3 mod 4 can be achieved by moving/removing rooks from the positions mentioned in the preceding paragraph.

Other answers have provided solutions for $$n=2.$$ Here is the one I originally found.

White to move:

White must immediately castle to avoid an irrevocable move occurring in the next couple turns. The mutually pinned bishops make entrance into the position "one-way."

Next we handle the cases $$n=7$$ and $$n=11.$$ For $$n=11,$$ here's a white-to-move position that can occur once with three castling rights, once with two castling rights, 4 times with 1 castling right, and 5 times with 0 castling rights:

Then $$n=7$$ is achieved by removing a black rook from this position.

The remaining cases are $$n=3,15,19,$$ for which we will use positions constrained by the 75 move rule, which I suspect is necessary. First, our example for $$n=3:$$

It takes 26 turns to return to this position, with one white knight having to reach g2 to unpin the other white knight. This sequence of moves can only occur twice before running afoul of the 75 move rule.

For $$n=15,$$ we make a position which requires 5 turns to cycle, in addition to 2 extra turns each cycle in which a white rook moves back and forth to spend a castling right (the black rook can spend its castling right without lengthening the cycle). This position can occur 4 times with 3 castling rights, 4 times with 2 rights, 4 times with 1 right, and 3 times with 0 rights, requiring $$3*5+2+4*5+2+4*5+3*5=74$$ turns.

Finally, here's our example for $$n=19.$$ This one takes 7 turns to cycle if the white king does not move, but there's a 2 turn cycle with movement of the white king. This position can occur 4 times with 4 castling rights, 3 times with 3 castling rights, 4 times with 2 rights, 4 times with 1 right, and 4 times with 0 rights (it can't appear a 5th time with 0 rights, due to the previous position being determined). Including 2*3 turns spent on using castling rights (the kingside white rook never needs to move, since the white king moving spends that castling right), this takes $$3*7 + 2*3 + 3*7+ 4*2 + 4*2 + 4*2 = 72$$ turns. It would be impossible to achieve this position with 3 or more castling rights any more times, for that would require 79 turns.

• What a beautiful investigation. If you add a bounty, I suspect you'll get more clarity on the remaining 3 cases. Commented Feb 14 at 13:41
• Thank you! I have fully solved the problem. Commented Feb 14 at 16:24
• I hate to ask this but won't your 15 and 19 approaches be cut short by 5fold repetition? Commented Feb 15 at 0:43
• @loopywalt I forgot to take that into consideration! I have revised those positions. Commented Feb 15 at 6:02
• This is great work! Couple of nits however. (1) If the position has check or parity applies, then it can only be achieved with one player on the move. For example, the initial game array can only be achieved 11 times. (2) Your question says that you are counting repetitions of diagram+whose move, but this answer is just counting repetitions of diagram. See also puzzling.stackexchange.com/questions/125524/… Commented Feb 28 at 7:53

I think with retudin's answer we are near the economy minimum. But there's a small improvement possible, to the challenge of finding a minimal diagram+move that can be achieved twice but not thrice.

White to play:

I used Popeye with the option "half-duplex" to find all "h~1" from this position. This asks, with White to move, for all the ways that White then Black can move. There are 24 sequences possible, but in 23 of them, Black must capture. The only exception is

1. 0-0-0 Ke2. Following this the position can be reset with e.g. 2. Kc2 Sf6 3. Re4+ Kf3 4. Rb1 Sg8 5. Ra1 Sf6 6. Kd2 Sg8 7. Ke1 Sf6 8. Rg4+ Se4.

There's a broader question of what are valid n for how many times can a diagram+move be repeated. This is discussed thoroughly in another response, but I agree that the maximum is 22, see: https://chess.stackexchange.com/questions/33707/extended-new-years-math-riddle-5-fold-repetition-75-move-rules/34091#34091.

EDIT: Pulled out from loopy walt's comment, even better!

Again, Popeye proves this is sound.

• Would B7/8/8/8/4r3/4NkP1/5P2/R3K3 w Q - 0 1 count as even more economical? Commented Feb 28 at 13:20
• @loopywalt That is really good, and definitely sound! Commented Feb 29 at 0:34

Minimalistic approach for n=2: (which incorrectly ends with the other color to move)

White to move must 0-0-0 to prevent a pawn move, capture or mate.
It can then give the black King some space with a3b3 and eventually get into the same position with e.g. Rba1 Kb8 Rba3. (and then 0-0-0 is not available anymore)
[FEN "1k6/1ppP4/8/8/8/R4p2/2PPPrp1/R3K3 w Q - 0 1"]
1. O-O-O Rf1 2. Rb3 Ka7 3. Kb2 Rf2 4. Rb1 Kb8 5. Kc1 Ka7 6. Kd1 Ka8 7. Ke1 Ka7 8. Ra1+ Kb8 9. Rba3

• Ah, position includes whose turn it is?! Then you are right that my solution is incorrect. Commented Feb 12 at 18:35
• Maybe I'm just failing to parse SAN (Super Ambiguous Notation) but your move list at the bottom doesn't make sense. If white castles then it would be black's turn which can't move a3b3 or b1a1 (since those are white rooks). I don't know what "space" you refer to since the black king still can't move (did you mean for black to f2f1?) which in turn makes "Kb8" impossible since he's already there. And I don't see how the image's board would happen again (but not a 3rd time) Commented Feb 12 at 22:44
• How do you intend to get back to this position again? On the first go, the previous black move can have been a pawn push, but the second time around black has no possible previous move, no matter whose turn it is.
– Bass
Commented Feb 13 at 1:15
• @Bass the last black move can be with the king (I added notation to clarify things). Commented Feb 13 at 16:03
• Ah, sure. My bad. So the problem is only that you can't reach this position again with white to play.
– Bass
Commented Feb 13 at 22:29

$$n=0$$:

$$n=1$$:

$$n=2$$:

I don't really know, the best I have come up with is

setting the 50-move counter to 18, although for this puzzle 47 is required.

$$n=3$$:

• 3-fold repetition and 50 move rules aren't directly relevant to this problem, since players can simply choose not to call a draw. Of course, the 5-fold and 75 move rules are mandatory. Commented Feb 12 at 3:52
• any explanation on n=2 and n=3 parts? Commented Feb 12 at 4:05
• @ElliotGlazer I think you should state that in the problem, since afaik some sites like chess.com force three-fold repetition to be a draw, which is what I am familiar with
– Sny
Commented Feb 12 at 5:01
• I've added clarification to the problem. Commented Feb 12 at 5:20