Fischer random chess numbering scheme
This article needs additional citations for verification. (August 2012) (Learn how and when to remove this template message)
The game Fischer random chess, played with conventional chess pieces and rules, starts with a random selection of one of 960 positions for the pieces. Arrangements of the pieces are restricted so that the king is between the rooks and the bishops are on different colored squares. In order to both select a valid arrangement and to then concisely discuss which randomly selected arrangement a particular game used, the Fischer random chess numbering scheme is used: a number between 0 and 959 indicates a valid arrangement and given an arrangement the number can be determined.
The Fischer random chess numbering scheme can be shown in the form of a simple two-tables representation. Also a direct derivation of starting arrays exists for any given number from 0 to 959. This mapping of starting arrays and numbers stems from Reinhard Scharnagl and is now used worldwide for Fischer random chess. The enumeration has been published first in the internet and then 2004 in his (German language) book "Fischer-Random-Schach (FRC / Chess960) - Die revolutionäre Zukunft des Schachspiels (inkl. Computerschach)", ISBN 3-8334-1322-0.
These two tables will serve for a quick mapping of an arbitrary Fischer random chess starting position (short: SP) at White's base row to a random number between 0 and 959. First search for the same or the nearest smaller number from the King's Table. Then determine the difference (0 to 15) to the drawn number and select that matching bishops' positioning from the Bishop's Table. According to this first place both bishops at the first base row, then the six pieces in the sequence of the found row of the King's Table upon the six free places left over. Finally the black pieces will be placed symmetrically to White's base row.
This is the SP-518 arrangement. In the King's table we will find No. 512 "RNQKNR". For the remainder 6 we will find "--B--B--" in the Bishop's table at No. 6. Altogether by that for the SP-518 = 512+6 this will result in the well known white starting array "RNBQKBNR" from traditional chess.
|Max.||Positioning Sequence of the other Pieces|
White's starting array can be derived from its number N (0 ... 959) as follows:
a) Divide N by 4, yielding quotient N2 and remainder B1. Place a Bishop upon the bright square corresponding to B1 (0=b, 1=d, 2=f, 3=h).
b) Divide N2 by 4 again, yielding quotient N3 and remainder B2. Place a second Bishop upon the dark square corresponding to B2 (0=a, 1=c, 2=e, 3=g).
c) Divide N3 by 6, yielding quotient N4 and remainder Q. Place the Queen according to Q, where 0 is the first free square starting from a, 1 is the second, etc.
d) N4 will be a single digit, 0 ... 9. Place the Knights according to its value by consulting the following table:
e) There are three blank squares remaining; place a Rook in each of the outer two and the King in the middle one.
Starting position IDs in Fischer random chess
For years, Reinhard Scharnagl has championed the desirability of giving each of the starting positions (SP) a unique identification number (idn) in the range 0-959 or, perhaps, 1-960. 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 Fischer random chess 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 -B--B--- 12 -B----B- 1 B--B---- 5 --BB---- 9 ---BB--- 13 ---B--B- 2 B----B-- 6 --B--B-- 10 ----BB-- 14 -----BB- 3 B------B 7 --B----B 11 ----B--B 15 ------BB
In any SP, when looking at the arrangement of the other pieces around the bishops, it is helpful to write down the NQ-skeleton for that SP. This is done by ignoring the bishops and replacing the "K" and "R" by a common symbol, say "-". The NQ-skeleton for the standard SP is -NQ-N-. 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 0-959. For the idn range 1-960, 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 0-959, 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.
For any SP, both the queens position and the N5N configuration are immediately available from the NQ-skeleton. 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 -N-N- 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 -N-N-. 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 NQ-skeleton table below. It contains all of the 60 possible NQ-skeletons, and directly refers to all of the SPs with bishop's code 0, i.e. with bishops on a1 and b1.
Given an SP, extract the bishop's code, the NQ-skeleton 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 -NQ-N- and -N-N-. 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 NQ-skeleton -NQ-N-, in the table, and get bishops code = 518 - 512 = 6.
Upon entry to Fischer random chess, 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 a-side 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 NQ-skeleton 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 NQ-skeleton and its queen's position. Then, locate, in the appropriate column, the NQ-skeleton at hand, say at No. M. The Fritz9 idn = (bishop's code) + M. For the standard SP, we extract 6 -NQ-N- and 1 and get Fritz9 idn = 6 + 353 = 359.
Fritz9 NQ-skeleton Table - 1 NNQ--- 241 NN-Q-- 481 NN—Q- 721 NN---Q 17 NQN--- 257 N-NQ—497 N-N-Q- 737 N-N--Q 33 NQ-N-- 273 N-QN—513 N--NQ- 753 N--N-Q 49 NQ—N- 289 N-Q-N- 529 N--QN- 769 N---NQ 65 NQ---N 305 N-Q--N 545 N--Q-N 785 N---QN 81 QNN--- 321 -NNQ—561 -NN-Q- 801 -NN—Q 97 QN-N-- 337 -NQN—577 -N-NQ- 817 -N-N-Q 113 QN—N- 353 -NQ-N- 593 -N-QN- 833 -N--NQ 129 QN---N 369 -NQ—N 609 -N-Q-N 849 -N--QN 145 Q-NN—385 -QNN—625—NNQ- 865—NN-Q 161 Q-N-N- 401 -QN-N- 641—NQN- 881—N-NQ 177 Q-N--N 417 -QN—N 657—NQ-N 897—N-QN 193 Q--NN- 433 -Q-NN- 673—QNN- 913 ---NNQ 209 Q--N-N 449 -Q-N-N 689—QN-N 929 ---NQN 225 Q---NN 465 -Q--NN 705—Q-NN 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 i.e. with the bishops on a1 and b1.