Chess960 is a variant of chess in which the arrangement of pieces on the first rank is randomly generated. There are 960 possible starting positions, hence the name. The starting position can be generated before the game either by a computer program or using dice, coin, cards etc.
The starting position for Chess960 must meet the following rules:
Note that the king never starts on file a or h, because there would be no room for a rook.
There are many procedures for creating the starting position for a game of Chess960. The methods that are presented below fall into two general categories:
Hans L. Bodlaender has proposed the following procedure using one sixsided die to create an initial position:
This procedure generates any of the 960 possible initial positions with an equal chance; on average, this particular procedure uses 6.7 die rolls  an optimal procedure would use on average somewhere between 4 and 4.45 die rolls. Note that one of these initial positions is the standard chess position, at which point a standard chess game begins.
It is also possible to use this procedure to see why there are exactly 960 possible initial positions. Each bishop can take one of four positions, the queen one of six, and the two knights can have five or four possible positions, respectively. (That leaves three open squares and the king must occupy the middle of those three squares, with rooks taking the last two squares, with no choice.) This means that there are 4×4×6×5×4 = 1920 possible positions if the two knights were different in some way. However, the two knights are indistinguishable during play; if they were swapped, there would be no difference. This means that the number of distinguishable positions is half of 1920, or 1920/2 = 960 possible distinguishable positions.
This method does not give equal probabilities to the starting positions. For example, there are 108 starting positions with the king on b1, so the totality of these positions should have probability 108/960 = 9/80. This method, however, gives probability 1/6 to the totality of these positions.
Roberto Rovida's method is more complicated than Bodlaender's, but uses fewer die rolls (56). When each piece is placed, there will be one, two, three, or six possible spaces for it. If one, there is no need to roll a die; if two, assign them the ranges 13 and 46; if three, assign them the ranges 12, 34, and 56.
The two coins method does not produce all legal starting positions with equal probability. The positions that arise when the king occupies the center two of the four possibilities are two thirds as likely as the others.
Edward Northam has developed the following approach for creating initial positions using only two distinguishable coins.
First, two coins (small and large) are used to randomly generate numbers with equal probability. He suggests doing this by declaring that tails on the smaller coin counts as 0, tails on the larger coin counts as 1, and heads on either coin counts as 2. To create numbers in the range 1 through 4, toss both coins and add their values together. To create numbers in the range 1 through 3, do the same but retoss whenever 4 is the result. To create numbers in the range 1 through 2, just toss the larger coin (tails is 1, heads is 2).
Any other technique that randomly generates numbers from 1 to 4 (or at least 12) will work as well, such as the selection of a closed hand that may hold a white or black Pawn.
As with a die, the coin tosses can build a starting position one piece at a time. Before each toss there will be at most four vacant squares available to the piece at hand, and they can be numbered counting from the aside (as with the die procedure described above). Place the white pieces on white's back rank as follows:
The average number of tosses needed to complete the process is 6.
There is a way of using coins and making all starting positions equally likely. It uses a third coin for which tails counts for 0, and heads counts for 4. Tossing all three coins makes the numbers 1 through 8 equally likely. The method follows the piece placements used for a die. Two coins are used for the bishops as before. Then six squares are available for the queen. All three coins are tossed and retossed until a number in the range 1...6 comes up. Then five squares are available for the first knight. Now the three coins should be tossed and retossed until a number in the range 1...5 shows up. For the second knight, only a four way choice is needed, so a single toss of two coins will do the job. The average number of tosses needed for this method is 5 + 14/15.
The Coffin and Scharnagl methods below do not give equal probabilities to all 960 starting positions.
David J. Coffin suggests the following procedure, which has the advantage of not requiring computers, dice, or lookup tables:
However, while all positions can be generated this way, not all positions have the same probability to be generated. Mathematical analysis shows that positions with the bishops on a pair a1b1, c1d1, e1f1, or g1h1 actually have half the probability to be generated of the other positions.
R. Scharnagl also has a method for correcting same color bishop positions when the pieces are drawn from a bag. He acknowledges that it does not produce all positions with equal probability, but makes the point that this is not necessary to achieve the main objective of Chess960. See the external reference.
In order to move a randomly selected bishop to a randomly selected square of the opposite color, as suggested in the Introduction, a choice involving a white Pawn and a black Pawn could be used to select the aside or hside bishop, which would be removed from the board. Then the black pieces could be put in the bag and mixed up. One would be drawn out, and the numbering of the square of opposite color could, for example, be given by R=1, N=2, B=3, K, Q=4.
A much quicker method is to simply gather the eight pieces into a circle on the table, then squash the circle flat into a line. If the bishops would be on the same colour, gather the pieces and try again. Once the bishops are right, swap the king and rook (as above), and start the game.
This method produces all legal starting positions with equal probability.
This method makes use of eight cards marked with the numbers 1 through 8. These numbers are associated with piece names according to the starting position in standard chess, ie. 1,8=R, 2,7=N, 3,6=B, 4=Q, 5=K. After the cards are shuffled and dealt in a row, the white pieces should be placed on the back rank as designated by the piece labels. If the bishops are on squares of the same color, the Coffin or Scharnagl bishop adjustments of the previous section could correct this immediately, but there is a very easy way to move a randomly selected bishop to a randomly selected square of the opposite color. The cards should be put face down, mixed up, and one selected at random. A number in the range 1...4 indicates that the aside bishop should move to the indicated square of the opposite color. A number in the range 5...8 should be diminished by 4 and the hside bishop should be moved to the indicated square of the opposite color.
After the bishops are on squares of different colors, attention is given to the king and rooks. If the king is not between the rooks, it must trade places with the nearest rook.
OR
This method does not produce all legal starting positions with equal probabilities. The problem is discussed in the Introduction.
Using a deck of playing cards, the king, queen, two jacks, two aces, and two tens can be selected. It is decided which pieces are represented by which cards (as the king and queen are obvious.) The deck is shuffled, cut, and dealt. Care must be taken as to keep the bishops on opposite colors, and the king between the rooks. To deal with a card that would be illegal, just hold that piece to the side until it is legal to place. When a legal square opens, place the held piece. Sometimes, two pieces are held but it is not confusing and quite a speedy and random method.
If one has polyhedral dice shaped like each of the Platonic solids, one never needs to reroll any dice.
There is a special chess timer on the market that can determine a random Chess960 starting position, with, it is claimed, an equal probability of each position, by the push of a button.
See also: Chess960 Enumbering Scheme
For years, Reinhard Scharnagl has championed the desirability of giving each of the Chess960 starting positions (SP) a unique identification number (idn) in the range 0959 or, perhaps, 1960. He has presented his methods on the internet and in books. See the external references. As an application, a random number generator could make one probe into the range at hand for a random number, and produce a random SP. Late in 2005, the program Fritz9 became available. It has a Chess960 option, but, for some unexplained reason, it assigns idns to SPs in a different way. Rather than requiring a giant table with 960 entries, both methods can use some smaller tables and some arithmetic.
Both methods take account of the positions of the bishops first, and ignore the distinction between the king and rooks. Once the positions of the bishops, knights and queen are known, there is only one possibility for the remaining three squares. In the places where division of whole numbers is done, it is always done giving a quotient (designated q1,q2,..) and a remainder (designated r1,r2 ..).
There are 16 ways to put two bishops on opposite colored squares. These are shown and numbered in the small table below. The entries actually can be calculated using simple arithmetic, but the table method seems less error prone. For the standard SP the bishop's code is 6.
Scharnagl's Bishop's Table

0 BB 4 BB 8 BB 12 BB
1 BB 5 BB 9 BB 13 BB
2 BB 6 BB 10 BB 14 BB
3 BB 7 BB 11 BB 15 BB
In any SP, when looking at the arrangement of the other pieces around the bishops, it is helpful to write down the NQskeleton for that SP. This is done by ignoring the bishops and replacing the "K" and "R" by a common symbol, say "". The NQskeleton for the standard SP is NQN. The sections below showing Scharnagl's Methods and the Fritz9 Methods are independent, and may be read in any order.
The methods described below are appropriate for the idn range 0959. For the idn range 1960, he recommends conversion by dividing by 960 and working with the remainder. This has the effect of assigning to idn 0 the SP that was at idn 960, and leaving the other idn SP matchups unchanged. If this calculation is applied in the idn range 0959, nothing is changed.
For any SP, after skipping over the bishop's, the queen may occupy any one of six possible squares, and they are numbered from left to right (from White's perspective) 0,1,2,3,4,5. The two knights, then, can appear in any of the remaining five squares (skipping over bishops and queen) in 10 ways. These are shown and numbered in the N5N table below.
Scharnagl's N5N Table

0 NN 2 NN 4 NN 6 NN 8 NN
1 NN 3 NN 5 NN 7 NN 9 NN
For any SP, both the queens position and the N5N configuration are immediately available from the NQskeleton. The queen's position is the number of characters to the left of the "Q" , giving 2 for the standard SP. The N5N configuration is obtained by omitting the "Q", giving NN for the standard SP, so its N5N code is 5. In general
idn = (bishop's code) + 16* (queen's position) + 96* (N5N code)
For the standard SP, idn = 6 + 16*2 + 96*5 = 518
Going the other way, starting with an idn, divide it by 16 and get
idn = q1*16 + r1. r1 gives the bishop's code, so put the bishops on the board. Then divide q1 by 6.
q1 = q2*6 + r2. r2 gives the queen's position, so put it on the board.
q2 gives the N5N code, so put the knights on the board (of course skipping over the bishops and queen).
Starting with idn = 518, we get 518 = 32*16 + 6, and 32 = 5*6 + 2 so the bishop's code is 6, the queen's position is 2 and the N5N code is 5 with configuration NN. If asterisks denote blank squares, the first rank fills up as: **B**B** **BQ*B** *NBQ*BN*
All of the multiplication and division can be eliminated by using the NQskeleton table below. It contains all of the 60 possible NQskeletons, and directly refers to all of the SPs with bishop's code 0, ie. with bishops on a1 and b1.
Scharnagl's NQskeleton Table

0 QNN 192 QNN 384 QNN 576 QNN 768 QNN
16 NQN 208 NQN 400 QNN 592 QNN 784 QNN
32 NNQ 224 NQN 416 NQN 608 NQN 800 QNN
48 NNQ 240 NQN 432 NNQ 624 NQN 816 NQN
64 NNQ 256 NNQ 448 NNQ 640 NQN 832 NQN
80 NNQ 272 NNQ 464 NNQ 656 NNQ 848 NNQ

96 QNN 286 QNN 480 QNN 672 QNN 864 QNN
112 NQN 304 NQN 496 QNN 688 QNN 880 QNN
128 NQN 320 NQN 512 NQN 704 QNN 896 QNN
144 NNQ 336 NQN 528 NQN 720 NQN 912 QNN
160 NNQ 352 NQN 544 NNQ 736 NNQ 928 NQN
176 NNQ 368 NNQ 560 NNQ 752 NNQ 944 NNQ
Given an SP, extract the bishop's code, the NQskeleton and its N5N configuration. The six skeletons in each of the 10 blocks in the table all have the same N5N configuration, and the blocks are arranged according to the N5N table above. It is easy, then, to find the appropriate block, and look inside for the entry with the "Q" in the desired place, say at No. M. Then idn = (bishop's code) + M. For the standard SP, we extract 6 NQN and NN. The desired block is the middle one in the second row, and the desired skeleton is at No. 512. We get idn = 6 + 512 = 518.
Going the other way, given an idn, locate, in the table, the largest number, say M, that is less than or equal to idn. Then idn  M gives the bishop's code, and the skeleton at M shows how to fill in the rest of the pieces. Given idn = 518 we locate 512, with NQskeleton NQN, in the table, and get bishops code = 518  512 = 6.
Upon entry to Chess960, Fritz9 prompts the user to enter a position idn or to "Draw Lots". If the user wishes to choose the first rank configuration of pieces, he/she must know how to get at the idn, but, unfortunately, Fritz9 does not use the standard method described above. The table below shows a quick way to get the Fritz9 idn for any SP.
For any SP, after ignoring the bishops, attention is given first to the knights (rather than to the queen). After taking account of the arrangement of the two knights in six squares (skipping over bishops), the queen is left with four possibilities: 0,1,2,3 (counting from the aside of the board and skipping over bishops and knights). The queen's position is the number of hyphens to the left of the "Q" in the NQskeleton for the SP.
In the table below, the columns correspond to the queen's position, and, in each column, the ordering is alphabetic with "" last.
Given an SP, extract the bishop's code, the NQskeleton and its queen's position. Then, locate, in the appropriate column, the NQskeleton at hand, say at No. M. The Fritz9 idn = (bishop's code) + M. For the standard SP, we extract 6 NQN and 1 and get Fritz9 idn = 6 + 353 = 359.
Fritz9 NQskeleton Table

1 NNQ 241 NNQ 481 NNQ 721 NNQ
17 NQN 257 NNQ 497 NNQ 737 NNQ
33 NQN 273 NQN 513 NNQ 753 NNQ
49 NQN 289 NQN 529 NQN 769 NNQ
65 NQN 305 NQN 545 NQN 785 NQN
81 QNN 321 NNQ 561 NNQ 801 NNQ
97 QNN 337 NQN 577 NNQ 817 NNQ
113 QNN 353 NQN 593 NQN 833 NNQ
129 QNN 369 NQN 609 NQN 849 NQN
145 QNN 385 QNN 625 NNQ 865 NNQ
161 QNN 401 QNN 641 NQN 881 NNQ
177 QNN 417 QNN 657 NQN 897 NQN
193 QNN 433 QNN 673 QNN 913 NNQ
209 QNN 449 QNN 689 QNN 929 NQN
225 QNN 465 QNN 705 QNN 945 QNN
Anyone with Fritz9 can verify this table by entering in the idns. It directly refers to just those SPs with bishop's code 0 ie. with the bishops on a1 and b1.