Home * Chess * Files

For disambiguation see also Computer file

Files are the eight vertical lines or columns of a Chessboard, labeled from 'A' to 'H', or 'a' to 'h'. Each file contains eight vertically arranged Squares of alternating white and black, or light and dark Color. In a descriptive notation, files are also nominated by the Pieces from their initial position (similar to Pawns), like Rook-Files (A- and H-File), Knight-Files (B- and G-File), Bishop-Files (C- and F-File), and Queen-File (D-File) and King-File (E-File), also called Center Files.

Square Mapping Notes

Whether the square difference of neighbored squares on a rank or file is either 1 or 8, depends on the square mapping. We further rely on little-endian rank-file mapping, which keeps consecutive squares of a rank as neighbored elements in Memory (or register).

Square Difference

Within a 0..63 square index range and the mentioned square mapping (a1 = 0), the difference of two neighbored squares on a File is eight.

Enumeration

As mentioned, on a Chessboard the eight files are labeled from 'A' to 'H'. To make them zero based indices as appropriate for C like programming languages, we enumerate files from 0 to 7. Little-endian file-mapping (as used here) assigns the A-File to index zero. Three bits are required to enumerate from 0 to 7.

A little-endian file-mapping enumeration in C++ might look like this:
enum enumFile {
  efAFile = 0,
  efBFile = 1,
  efCFile = 2,
  efDFile = 3,
  efEFile = 4,
  efFFile = 5,
  efGFile = 6,
  efHFile = 7,
};

File from Square

Rank-File mapping of squares keeps the file as the three lower bits of a Square index.
file = square & 7; // modulo 8

File-Distance

The file-distance is the absolute difference between two files (their 0-7 indices). The maximum file-distance is 7.
fileDistance = abs (file1 - file2);
fileDistance = abs (file2 - file1);

See also


What links here?


Up one Level