Diagonals

Home * Chess * Diagonals



Diagonals go from south-west to north-east on a chess board, the main diagonal is a1/h8. There are 15 diagonals, with line-length from 1 to 8. A Diagonal is monochrome, all their squares are either white or black.

=Main Diagonal= .......(+)/......(+)./.....(+)../....(+).../...(+)..../..(+)...../.(+)....../(+).......

=Square Mapping Notes= A 90 degree rotation of the Chessboard, as well as flipping vertically (reversed ranks) or (exclusive) mirroring horizontally (reversed files), change the roles of diagonals and anti-diagonals. However, we define the main diagonal on the chess board from a1/h8 and the main anti-diagonal from h1\a8. Whether the square difference of neighbored squares on a diagonal or anti-diagonal is either 7 or 9, depends on the square mapping. We further rely on little-endian rank-file mapping.

=Square Difference= Within a 0..63 square index range and the mentioned square mapping (a1 = 0), the difference of two neighbored squares (if any) on a diagonal is nine.

=Enumeration= If we follow a diagonal from south-west (a1) to north-east (h8) step by step, we increment the rank, and increment the file, which yields in same difference. Thus, subtracting rank from file indices (or vice versa) enumerates all Diagonals, unfortunately with negative numbers involved, which can easily adjusted by adding seven.
 * The main diagonal a1/h8 with index 0 and length 8.
 * The diagonals a8/ and h1/ with length 1, are index 7 and -7 respectively.
 * All even indices are the diagonals with dark squares

rank - file

7 + rank - file

=Alternative Enumeration= Some alternative enumeration of diagonals to keep the main-diagonal index 0, by anding the difference with 15. This yields in a 0..15 range with 8 as gap or Nexus in the center of the range:

(rank - file) & 15

=See also=
 * Anti-Diagonals
 * Ranks
 * Files
 * Squares
 * Intersection Squares
 * Nexus the chess program

=References=

Up one Level