Can someone derive how do we get the total number of 960 possible positions for Chess960?
You're counting the same position a couple of times and not including the rule that the bishops have to be on opposite colors. (And possible that the king must be between the rooks.)
The actual number is 4 x 4 x (6 x 5) / 2 x 4
4 for the LSB
4 for the DSB
(6 x 5) / 2 for the two knights (halved due to account for the same type of piece being placed)
4 for the queen
1 due to the king must be between the rooks (Without this rule, it would be (3 x 2) / 2 or 1440.)
The bishops must be on opposite colors and the king must be between the rooks for Chess960. Each bishop can go on one of four squares, so there are 4x4 ways.
Now the queen can go on one of the six remaining squares, so the total combinations = 4x4x6.
Now there are five squares for the knights, but the knights are interchangeable, so there are 5C3 = 5!/(3!*2!) = 10 ways. So that makes the total combinations = 4x4x6x10 = 960.
Now there are three squares for the king and rooks, but since the king must go between the rooks, and the rooks are interchangeable, there is only one distinct way for the rooks and king, so the total number of combinations = 960.
We can permute 8 pieces in 8! =40320 ways. But we have some conditions:
- Two knights are identical.
- There must be opposite colour bishops.
- Rooks are identical.
- King must be between the rooks.
Now in 8 boxes there are 4 black boxes and 4 white boxes.
We can place the black bishop in one of the 4 black boxes which can be done in 4 ways. Similarly the position of white bishop can be chosen in 4 ways. So there are 4×4=16 ways to choose bishop position.
Now we have 6 more positions to fill.
We have to fix the sequence Rook-King-Rook
To do so we only have to chose three boxes out of 6 which can be done in 6C3 =20 ways.
The other three boxes have to be filled by queen, and two knights. This can be done in 3 ways since knights are identical.
Thus we have 16×20×3=960 positions.
This number is derived by using permutations (an arrangement of objects where the order they're arranged in matters). We have a few variables:
n = how many objects there are. r = how many objects we are taking to arrange.
Both n and r equal 8 (since there are eight pieces, and we will be arranging all of them).
n = 8 r = 8
The formula for Permutations:
n! / (n - r)!
However, we have a certain number of duplicate objects (such as 2 Knights, 2 Bishops, and 2 Rooks):
# Permutations = n! / ( (n - r)!(2!)(2!)(2!) ) = 8! / ( (8 - 8)!(2!)(2!)(2!) ) = 8! / ( (0!)(2!)(2!)(2!) ) = 8! / ( (2!)(2!)(2!) ) = 40320 / 8 = 5040
This shows that there are actually 5040 possible "Chess 960" positions.
However, in the game "Chess 960" there are limitations for which squares certain pieces can go on. For example, a Bishop can only go on one of four squares. This causes the number to go down to 960 (decreasing by a factor of exactly 42).