# Minimal number of moves before castling in 960 chess

As you know, in chess 960, in the initial position, the king lies between the two rooks. Here are also the rules for castling. The question is:

For a starting position position P, let n(P) be the minimal number of moves the Whites need to legally castle in the King wing. How many position are there such that n(P)=1? n(P)=2? And so one.

There are cases where we can castle at the first move (when the King is in f1 and the rook in g1).

There are other extreme case: King in b1, rook in c1; then we have to make space.

Maybe some engines can solve the question.

• If you can count you can work out the answer yourself. There are only 960 positions to consider. The clue is in the name. – Brian Towers Aug 29 '19 at 17:39
• Yes, but 1. I am mathematician, so I can count :). 2. Since I am a mathematician, I am lazy so I would like to know whether there are general principles which would avoid to count. And how n(P) is distributed. – Davide Giraudo Aug 29 '19 at 20:17
• @DavideGiraudo : 1.I am mathematician, so I can count (...) 2. Since I am a mathematician, I am lazy : I could name several counterexamples for both claims ! – Evargalo Aug 30 '19 at 10:17
• Is n(P) the minimal number of moves before White can castle if he plays alone, or in any possible game (I.e. Black can help)? – Evargalo Aug 31 '19 at 6:32
• Ah I missed this aspect. I am interested in the minimum in any possible game so like the example of your answer shows, black can help to make space by taking a pawn in the second row. In this way, they do not have to spend a time. – Davide Giraudo Aug 31 '19 at 8:17

The three first steps:

There are 90 positions where n(P)=1

For White to be able to castle short at once, he needs to have Kf1, Rg1 in the initial position. Then there are 5 possible spots from the second rook, 3 for one bishop and 2 for the other one, and finally 3 remaining spots for the queen. The knights go to the last two spots.

There are 64 positions where n(P)=2

36 of them with Kf1, Ng1, Rh1: White can play 1.Nf3 or 1.Nh3 and 2.0-0

28 of them with Rg1, Nf1, Ke1: White can play 1.Ng3 or 1.Ne3 and 2.0-0

There are 242 positions where n(P)=3 please double-check this part

Here are the different configurations and the number of relevant positions:

xxxxxQKR 18
xxxxxBKR 36
xxxxxRKR 18
xxxxxKQR 18
xxxxxKBR 24
xxxxKNNR 8
xxxKNNRx 6
xxxKNRNx 6
xxxKRNNx 6
xxKRxNNx 4
RKRxBNNx 2
xxxxKBRx 24
xxxxKQRx 18
xxxxKRBx 36
xxxxKRQx 18

Total:242

Once we reach n(P)=4, we cannot ignore Black's play anymore: for instance, QNRNKBBR looks like it should have n=5, but actually it has n=4 because of the sequence 1.f4 b5 2.Bxa7 Qxg2 3.Bxg2 Nc6 4.0-0. Counting by hand becomes too fastidious and hazardous: a software program is needed.

On the other hand, after clarification by the OP, I believe 7 to be the maximum value of the function P->n(P).

If Black wasn't allowed to "help" we could build only 2 positions with n(P)=9; Here is one, the other is similar with RKBBNNQR on the first rank.

In a series problem where White plays alone he would need 9 moves in order to castle. But since Black moves are taken into account, White actually can castle on move 7 from that diagram if the game goes something like 1.b3 d5 2.Qa3 Qe6 3.Nb2 Qxe2 4.Nd3 Qxf2 5.Bxf2 Nc6 6.Be2 0-0-0 7.0-0.