Files

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.

=File Names= 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, see diagram), 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); =Two Squares on a File= Two Squares are on the same File, if their file distance is zero. The masking of the file bits can be done after the subtraction. bool squaresOnSameFile(int sq1, int sq2) { return ((sq2 - sq1) & 7) == 0; } The Symmetric difference aka xor is sufficent for the test as well bool squaresOnSameFile(int sq1, int sq2) { return ((sq1 ^ sq2) & 7) == 0; } =Pawns and Files=
 * Half-open File
 * Open File
 * Pawns and Files (Bitboards)

=See also=
 * Ranks
 * Diagonals
 * Anti-Diagonals
 * Squares
 * Intersection Squares

=References= Up one Level