The product 4 x 4 x 6 x 10 gives you 960, the total number of starting positions. The first 4 stands for the number of
possible squares for the light-square Bishop (b, d, f & h), and the second 4 for the dark-square Bishop (a, c, e &
g). The 6 stands for the number of squares available for the Queen, and the 10 for the number of KeRN codes (legal Fischer
combinations of Knights, Rooks and the King). See the KeRN table below.

KeRN Codes:

0 N N R K R (Knight, Knight, Rook, King, Rook)

1 N R N K R (Knight, Rook, Knight, King, Rook)

2
N R K N R (and so on...)

3 N R K R N

4 R N N K R

5 R N K N R

6 R N K R N

7 R K N N R

8
R K N R N

9 R K R N N

To create a starting position given the id, first divide the id by 4, giving you a quotient and a remainder. The
remainder locates the light-square Bishop: 0 means file b, 1 means file d, 2 means file f, and 3 means file h.

Second, take the quotient from the first division and divide it by 4, producing a new quotient and remainder.
The new remainder locates the dark-square Bishop: 0 means file a, 1 means file c, 2 means file e, and 3 means file g.

Third, take the quotient from the second division and divide by 6, producing the last quotient and remainder.
The last remainder locates the queen, and identifies the number of the vacant square it occupies (counting from the left,
where 0 is the leftmost square and 5 is the rightmost square).

The last quotient will be a number between 0 to 9 inclusive. This is the KeRN code, and from the KeRN codes
table above, you will get the location of the King, Rooks and Knights among the remaining 5 squares.

Alternately, given a board position, it's id can be computed as follows:

id = 1 * light-square Bishop location (counting leftmost as 0) +

4 * dark-square Bishop location (counting leftmost as 0) +

16 * Queen location (leftmost is 0 and skipping Bishops) +

96 * (KRN code)

Example 1: Find starting position 451 (above right on this webpage)

1) 451 / 4 = quotient 112 remainder 3

2) 112 / 4 = quotient 28 remainder 0

3) 28 / 6 = quotient 4 remainder 4

The first remainder, 3, places the light-square Bishop in the h-file (note that for Bishops, 0 stands for the first
available square, 1 for the second, 2 for the third, and 3 for the last). The second remainder, 0, places the dark-square
Bishop on the a-file. The third remainder, 4, places the Queen on the 5th available square, the f-file (for the Queen, 0 stands
for the first available square, skiping the Bishops, and 5 for the last). The KeRN code, the quotient from the last division,
also a 4 in our example, from the KeRN table above (for 4 we get R N N K R) gives us the location of the the remaining pieces
among the squares left. In this case Rook on first available square, then Knight, then Knight again, then the King, and
finally the other Rook on the last available square.

Example 2: Find id for position in the diagram above (BRNNKQRB)

id = 1 * 3 (light-square Bishop is on the last available square, remember 0 is the first) + 4 *
0 (dark-square Bishop is on it's first available square) + 16 * 4 (Queen is on it's fifth available square minus
1 is 4, remember 0 stands for the first available square) + 96 * 4 (KeRN code for RNNKR)

id = 1*3 + 4*0 + 16*4 + 96*4

id = 3 + 0 + 64 + 384

id = 451