31 March 2009

Introduction to Chess960 Geometry

One of the curiosities of chess960, at least in comparing it to traditional chess (SP518), is that there are many positions where the players can castle on the first move. One such position is shown in the following diagram.


Start Position 119

Wondering how many similar chess960 positions exist, I queried my
Database of Chess960 Start Positions and discovered that there are 90 start positions where the players can castle O-O on the first move. A similar query on O-O-O determined that there are 72 positions where the players can castle O-O-O on the first move, i.e. the Rook and King start the game on the c- and d-files.

I'm the type of person who likes to know where numbers come from, and I started to wonder if the numbers 90 and 72 can be derived by logic. It turns out they can and the reasoning is not too difficult.

The first step is to notice that for any given start position of the King and two Rooks, there are five empty squares. The other pieces can only be distributed in a fixed number of ways on those five squares: one Bishop must be on a light colored square, one Bishop must be on a dark square, and the Queen and two Knights are on the other three squares. Of the five empty squares there are three squares of one color and two squares of the other, so the Bishops can be placed six different ways (3 x 2) on the five squares. After the Bishops are placed, the Queen can be placed on any one of the three remaining squares, and since it doesn't matter which of the Knights takes the last two squares, there are 18 different ways (3 x 2 x 3) to place two Bishops, one Queen, and two Knights on five empty squares.

The second step is to notice that when the King and Rook start in a position to castle O-O on the first move (King on f-file, Rook on g-file), the other Rook has five possible squares on which it can start (a-, b-, c-, d-, and e-files). When the King and Rook start in a position to castle O-O-O on the first move (Rook on c-file, King on d-file), the other Rook has four possible squares on which it can start (e-, f-, g-, and h-files).

The third step is to combine the results of the first two steps. When castling O-O on the first move, there are five ways to place the free Rook and 18 ways to place the other pieces, so there are a total of 90 possible setups (5 x 18). Similarly, when castling O-O-O on the first move, there are 72 possible setups (4 x 18). The numbers 90 and 72 match the number of positions calculated from the database.

***

After I worked out the preceding, I started to wonder how many different castling positions, i.e. unique initial positions of the King and Rooks, there are across the 960 start positions. To start thinking about this, I first worked out the following table with the help of my database. For each of the five pieces, it shows the number of positions where a particular piece starts the game on a particular file.

Table 1: Chess960 Start Positions per Piece per File

 ABCDEFGHTot
Q120120120120120120120120960
B2402402402402402402402401920
N2402402402402402402402401920
K 108168204204168108 960
R3602521921561561922523601920

For example, since the Queen can start a game with equal probability on any one of the eight files, it stands to reason that there are 120 positions (1/8 x 960) where Her Majesty starts on the a-file, on the b-file, or on any one of the other six files. Similarly, since there are two each of the Bishops and Knights, there are 240 positions where one of the Bishops (or one of the Knights) starts on the a-file, on the b-file, on the c-file, etc.

The counts are more interesting for the King and Rooks. Since the King can't start in a corner square, you might suppose that it has an equal chance of starting on the other six files (b-file, c-file, etc.). The table, however, shows otherwise. The King has the highest probability of starting the game on a center file (d- & e-files), and the least probability of starting on the b- & g-files.

The Rooks' probabilities complement the King's. The Rooks have the highest probabilty of starting on a corner square and the least probability of starting on a center file. Note that the sum of the number of start positions having a King or a Rook on a particular file is 360 for each square.

The probabilities of King and Rook starting on a particular square have some impact on chess960 opening theory. Since positions with a King starting in the center are more likely, they will arise more frequently in practical play, making them more attractive for preparatory study..

***

Getting back to my obsession with the origin of numbers, I wondered how the King and Rook probabilities might be derived. It can be no accident that there are exactly 108 positions where the King starts on the b-file.

I started by counting the number of unique King and Rook setups. My first step was to consider only the positions where the King starts on the 'Kingside' (as it's called in traditional chess), the right side of the board from White's point of view (called the 'h-side' in chess960). With the White King on e1, there are four different squares where a Rook can be placed to its left, and three different squares for a Rook to its right. This means that there are 12 different start positions (4 x 3) for a King and two Rooks when the King starts on the e-file.

The corresponding numbers for the three Kingside start squares are shown in the following table.

  • Ke1 : 4 x 3 = 12
  • Kf1 : 5 x 2 = 10
  • Kg1 : 6 x 1 = 6

This means that there are 28 (12 + 10 + 6) different placements for a King and two Rooks when the King starts on the Kingside. Since the Queenside (aka 'left side' or 'a-side') is a mirror image of the Kingside, there are 56 unique start positions (28 x 2) for the King and its castling partners.

As I already calculated that there are 18 different ways to place the other five pieces (Q/Bs/Ns), there must be 56 times 18 different start positions. Unfortunately, 56 x 18 = 1008, not 960, which is the well-known, exact number of chess960 start positions. There must be an error in the calculations.

Indeed there is an error, and it arises when the King and Rooks all start on the same color. In my earlier example, using positions where castling could happen on the first move, the King and Rook were always on adjacent squares, meaning always on different colors. In other start positions, that assumption is not necessarily true. When, for example, one Rook starts on the b-file, the King starts on the d-file, and the other Rook starts on the f-file (or h-file), the five empty squares have one square of the same color as the King/Rooks and four of the opposite color. This has an impact on how the Bishops can be placed.

One Bishop must be placed on the last square corresponding to the color of the King/Rooks, while the other Bishop has a choice of four squares. After placing the Bishops, the Queen still has a choice of three squares. This gives 12 different ways (4 x 3) to place two Bishops, one Queen, and two Knights on the five empty squares.

Of the 56 unique start positions for the King and Rooks, it's easy to determine that eight positions have those pieces 'all on the same color'. Now we have (48 x 18) + (8 x 12) ways to place the pieces, which reduces to (864 + 96) ways, which in turn reduces to 960.

***

That last quirk also explains the distribution of the Kings and Rooks in Table 1. If the King starts on the g-file, a Rook must be on the h-file. This means that the other Rook has six possible start files. Since the g-file King and h-file Rook are necessarily on different colors, there are 18 different Q/B/N setups per position of the other Rook. It follows that there are 6 x 18 = 108 different positions with King on the g-file.

Similar logic holds if the King starts on the f-file. One Rook must be on the g- or h-file, meaning the other Rook has five possible start squares. If the Rook is on the g-file, it is on a square of opposite color to the King, and we have 5 x 18 (=90) possible start positions. If the Rook is on the h-file, a square of the same color as the King, then we have 3 x 18 (=54) plus 2 x 12 (=24) possible start positions. The sum of 90 + 54 + 24 is 168, the number shown in Table 1. Ditto for the King starting on the e-file, where one Rook is on the f-, g-, or h-file, and in each case the other Rook has four possible squares.

I'm always happy when the math works!

No comments: